Skip to content

Commit

Permalink
sn32: splittest: add uart configs
Browse files Browse the repository at this point in the history
  • Loading branch information
dexter93 committed Jun 7, 2024
1 parent 14b84ee commit f5652ab
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 0 deletions.
10 changes: 10 additions & 0 deletions keyboards/handwired/splittest/sn32f240b/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright 2024 Dimitris Mantzouranis (@dexter93)
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#define SPLIT_HAND_PIN A7

#if !(defined(USE_SDI0) || defined(USE_SDI1) || defined(USE_SDI2))
#define USE_SDI0
#endif
12 changes: 12 additions & 0 deletions keyboards/handwired/splittest/sn32f240b/halconf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 2024 Dimitris Mantzouranis (@dexter93)
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

/* Needed for serial bitbang, half-duplex and full-duplex */
#define HAL_USE_PAL TRUE
#define PAL_USE_WAIT TRUE
#define PAL_USE_CALLBACKS TRUE
#include_next <halconf.h>
#undef HAL_USE_PWM
#define HAL_USE_PWM FALSE
15 changes: 15 additions & 0 deletions keyboards/handwired/splittest/sn32f240b/keyboard.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"matrix_pins": {
"cols": ["B1"],
"rows": ["B10"]
},
"diode_direction": "COL2ROW",
"processor": "SN32F248BF",
"bootloader": "sn32-dfu",
"features": {
"bootmagic": false,
"mousekey": false,
"extrakey": false,
"console": true
}
}
18 changes: 18 additions & 0 deletions keyboards/handwired/splittest/sn32f240b/mcuconf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2024 Dimitris Mantzouranis (@dexter93)
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include_next <mcuconf.h>

// These are needed if the communication is on the SD0 UART, either with standard or alternate pins
#undef SN32_SERIAL_USE_UART0
#define SN32_SERIAL_USE_UART0 TRUE

// These are needed if the communication is on the SD1 UART, either with standard or alternate pins
#undef SN32_SERIAL_USE_UART1
#define SN32_SERIAL_USE_UART1 TRUE

// These are needed if the communication is on the SD2 UART, either with standard or alternate pins
#undef SN32_SERIAL_USE_UART2
#define SN32_SERIAL_USE_UART2 TRUE
26 changes: 26 additions & 0 deletions keyboards/handwired/splittest/sn32f240b/post_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2024 Dimitris Mantzouranis (@dexter93)
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#if defined(SPLIT_SERIAL_FULLDUPLEX)
# define SERIAL_USART_FULL_DUPLEX // Enable full duplex operation mode.
#endif
#if defined(SPLIT_SERIAL_HALFDUPLEX) || defined(SPLIT_SERIAL_FULLDUPLEX)
# if defined(USE_SDI0)
# define SOFT_SERIAL_PIN A10
# define SERIAL_USART_RX_PIN A11 // USART RX pin
# define SERIAL_USART_DRIVER SD0
# elif defined(USE_SDI1)
# define SOFT_SERIAL_PIN B9
# define SERIAL_USART_RX_PIN B8 // USART RX pin
# elif defined(USE_SDI2)
# define SOFT_SERIAL_PIN A1
# define SERIAL_USART_RX_PIN A0 // USART RX pin
# define SERIAL_USART_DRIVER SD2 // USART driver of TX and RX pin. default: SD1
# else
# error "splittest serial keymap is missing a configuration"
# endif
#else // defined(SPLIT_BITBANG)
# define SOFT_SERIAL_PIN B8
#endif
66 changes: 66 additions & 0 deletions keyboards/handwired/splittest/sn32f240b/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# sn32f240b splittest

This is the splittest example for the sn32f240b MCU.
To trigger keypress, short together pins _B10_ and _B1_.

## Keyboard Configuration

The type of communication (bitbang, serial (half/full duplex)) is set by the keymap `config.h` file with variables with `SPLIT_` prefix.
So this example uses:

- `config.h` to set which SDI to use for serial. Either define `USE_SDI0`, `USE_SDI1` or `USE_SDI2` before the `#ifdef` that configures the default case when none of these variable is defined.
- `post_config.h` for defining the communication pins between the halves once the keymap is configured.

On your keyboard, you most likely will only use `config.h` because you'd have already chosen your communication scheme: serial type, SDI, pins.

## Wiring

### Switches

- Add switches to both sn32f240b across B10 and B1 pins

### Handedness

Have a look at the [handedness documentation](https://docs.qmk.fm/#/feature_split_keyboard?id=setting-handedness)

- Add pull-up resistor to left side between VCC and A7
- Add pull-down resistors to right side between GND and A7

### Send power to the other half

- Connect the following pins on both sides together: GND, VCC

### Halves data connection

Choose one of the connection type

#### serial - bitbang

- Connect the B8 pins on both sides together
- Note that bitbang functionality requires strict timings. Currently not supported.

#### serial - usart half duplex

Check the [documentation](https://docs.qmk.fm/#/serial_driver?id=usart-half-duplex) to determine the pull-up resistor.

- To use the default usart (UART0),
- Connect the A10, A11 pins on both sides together and to add a pull-up resistor on one of these pins
- Define USE_SDI0 in config.h
- To use the second usart (UART1),
- Connect the B8, B9 pins on both sides together and to add a pull-up resistor on one of these pins
- Define USE_SDI1 in config.h
- To use the third usart (UART2),
- Connect the A0, A1 pins on both sides together and to add a pull-up resistor on one of these pins
- Define USE_SDI1 in config.h

#### serial - usart full duplex

- To use the default usart (UART0),
- Connect the pins on A10, A11 one to the other on each side
- Define USE_SDI0 in config.h
- To use the second usart (UART1),
- Connect the pins B8, B9 one to the other on each side
- Define USE_SDI1 in config.h
- To use the third usart2 (UART2) pins,
- Connect the pins A0, A1 one to the other on each side
- Define USE_SDI2 in config.h

0 comments on commit f5652ab

Please sign in to comment.