fixed BusPal Bootloader (https://github.com/UltimateHackingKeyboard/firmware/issues/44)
This commit is contained in:
@@ -1,20 +1,30 @@
|
||||
#include "bootloader.h"
|
||||
|
||||
/* bits for enabledPeripherals */
|
||||
#define ENABLE_PERIPHERAL_UART (1<<0)
|
||||
#define ENABLE_PERIPHERAL_I2C (1<<1)
|
||||
#define ENABLE_PERIPHERAL_SPI (1<<2)
|
||||
#define ENABLE_PERIPHERAL_CAN (1<<3)
|
||||
#define ENABLE_PERIPHERAL_USB_HID (1<<4)
|
||||
#define ENABLE_PERIPHERAL_USB_MSC (1<<7)
|
||||
|
||||
__attribute__((used, section(".BootloaderConfig"))) const bootloader_config_t BootloaderConfig = {
|
||||
.tag = 0x6766636B, // Magic Number
|
||||
.enabledPeripherals = 0xE2, // Enabled Peripheral: I2C
|
||||
.enabledPeripherals = ENABLE_PERIPHERAL_I2C /*0xE2*/, // Enabled Peripheral: I2C
|
||||
.i2cSlaveAddress = 0x10, // Use user-defined I2C address
|
||||
.peripheralDetectionTimeoutMs = 300, // Use user-defined timeout (ms)
|
||||
.peripheralDetectionTimeoutMs = 3000, // Use user-defined timeout (ms)
|
||||
.clockFlags = 0xFF, // Disable High speed mode
|
||||
.clockDivider = 0xFF, // Use clock divider (0)
|
||||
};
|
||||
|
||||
void JumpToBootloader(void) {
|
||||
uint32_t runBootloaderAddress;
|
||||
void (*runBootloader)(void * arg);
|
||||
// Read the function address from the ROM API tree.
|
||||
runBootloaderAddress = **(uint32_t **)(0x1c00001c);
|
||||
runBootloader = (void (*)(void * arg))runBootloaderAddress;
|
||||
// Start the bootloader.
|
||||
runBootloader(NULL);
|
||||
uint32_t runBootloaderAddress;
|
||||
void (*runBootloader)(void *arg);
|
||||
|
||||
/* Read the function address from the ROM API tree. */
|
||||
runBootloaderAddress = **(uint32_t **)(0x1c00001c);
|
||||
runBootloader = (void (*)(void * arg))runBootloaderAddress;
|
||||
|
||||
/* Start the bootloader. */
|
||||
runBootloader(NULL);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "main.h"
|
||||
#include "init_clock.h"
|
||||
#include "init_peripherals.h"
|
||||
#include "bootloader.h"
|
||||
|
||||
key_matrix_t keyMatrix = {
|
||||
.colNum = KEYBOARD_MATRIX_COLS_NUM,
|
||||
@@ -25,12 +26,18 @@ key_matrix_t keyMatrix = {
|
||||
|
||||
volatile bool DisableKeyMatrixScanState;
|
||||
|
||||
#define ALWAYS_ENTER_BOOTLOADER (0)
|
||||
/*! set to 1 for easier bootloader debugging. With this, the KL03 always enters bootloader mode after reset */
|
||||
|
||||
int main(void)
|
||||
{
|
||||
InitClock();
|
||||
InitPeripherals();
|
||||
KeyMatrix_Init(&keyMatrix);
|
||||
|
||||
#if ALWAYS_ENTER_BOOTLOADER
|
||||
JumpToBootloader(); /* << EST: \todo Temporary only */
|
||||
#endif
|
||||
while (1) {
|
||||
if (!DisableKeyMatrixScanState) {
|
||||
KeyMatrix_Scan(&keyMatrix);
|
||||
|
||||
Reference in New Issue
Block a user