Skip to content

Commit

Permalink
Added direct pin support and jumploader for DareU EM908
Browse files Browse the repository at this point in the history
  • Loading branch information
HorrorTroll authored and dexter93 committed Jul 24, 2023
1 parent c3e3573 commit cbcfcc7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ add_bootloader(keychron_k12_white)
add_bootloader(keychron_k7_rgb_optical)
add_bootloader(keychron_k7_white_optical)
add_bootloader(sharkoon_sgk50s4)
add_bootloader(dareu_em908)
8 changes: 8 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,14 @@
#define BLKEY_INPUT_PIN 1
#define BLKEY_OUTPUT_GPIO SN_GPIO3
#define BLKEY_OUTPUT_PIN 2
#elif defined(TARGET_DAREU_EM908) // SN32F260
#include "SN32F260.h"
#define SN32_BOOTLOADER_ADDRESS 0x1FFF0009
#define BOOT0_GPIO SN_GPIO3
#define BOOT0_PIN 5
/* Side Button 2 */
#define BLKEY_INPUT_GPIO SN_GPIO2
#define BLKEY_INPUT_PIN 7
#else
#error Not configured for this target.
#endif
7 changes: 4 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,21 @@ static int boot0_low(void) {

/* Check if a keyboard key is held (specified in config.h) */
static int key_held(void) {
#ifdef BLKEY_OUTPUT_GPIO
#ifdef BLKEY_INPUT_GPIO
int res;

/* Enable pull-up for the input pin */
BLKEY_INPUT_GPIO->CFG &= ~(3 << (BLKEY_INPUT_PIN * 2));

#ifdef BLKEY_OUTPUT_GPIO
/* Set up the output pin as output */
BLKEY_OUTPUT_GPIO->MODE |= (1 << BLKEY_OUTPUT_PIN);

delay();

/* Send on the output */
BLKEY_OUTPUT_GPIO->BCLR = (1 << BLKEY_OUTPUT_PIN);

#endif // BLKEY_OUTPUT_GPIO
delay();

/* Read the input */
Expand All @@ -88,7 +89,7 @@ static int key_held(void) {
#endif
#else
return 0;
#endif
#endif // BLKEY_INPUT_GPIO
}

void _start(void) {
Expand Down

0 comments on commit cbcfcc7

Please sign in to comment.