Replace tabs with spaces.
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
/* bits for enabledPeripherals */
|
/* bits for enabledPeripherals */
|
||||||
#define ENABLE_PERIPHERAL_UART (1<<0)
|
#define ENABLE_PERIPHERAL_UART (1<<0)
|
||||||
#define ENABLE_PERIPHERAL_I2C (1<<1)
|
#define ENABLE_PERIPHERAL_I2C (1<<1)
|
||||||
#define ENABLE_PERIPHERAL_SPI (1<<2)
|
#define ENABLE_PERIPHERAL_SPI (1<<2)
|
||||||
#define ENABLE_PERIPHERAL_CAN (1<<3)
|
#define ENABLE_PERIPHERAL_CAN (1<<3)
|
||||||
#define ENABLE_PERIPHERAL_USB_HID (1<<4)
|
#define ENABLE_PERIPHERAL_USB_HID (1<<4)
|
||||||
#define ENABLE_PERIPHERAL_USB_MSC (1<<7)
|
#define ENABLE_PERIPHERAL_USB_MSC (1<<7)
|
||||||
@@ -18,13 +18,13 @@ __attribute__((used, section(".BootloaderConfig"))) const bootloader_config_t Bo
|
|||||||
};
|
};
|
||||||
|
|
||||||
void JumpToBootloader(void) {
|
void JumpToBootloader(void) {
|
||||||
uint32_t runBootloaderAddress;
|
uint32_t runBootloaderAddress;
|
||||||
void (*runBootloader)(void *arg);
|
void (*runBootloader)(void *arg);
|
||||||
|
|
||||||
/* Read the function address from the ROM API tree. */
|
/* Read the function address from the ROM API tree. */
|
||||||
runBootloaderAddress = **(uint32_t **)(0x1c00001c);
|
runBootloaderAddress = **(uint32_t **)(0x1c00001c);
|
||||||
runBootloader = (void (*)(void * arg))runBootloaderAddress;
|
runBootloader = (void (*)(void * arg))runBootloaderAddress;
|
||||||
|
|
||||||
/* Start the bootloader. */
|
/* Start the bootloader. */
|
||||||
runBootloader(NULL);
|
runBootloader(NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,14 +37,14 @@ static int WaitForStartByte(uint8_t *buf, size_t *nofRead)
|
|||||||
uint8_t tmp;
|
uint8_t tmp;
|
||||||
int cntr = 128; /* max retries */
|
int cntr = 128; /* max retries */
|
||||||
|
|
||||||
microseconds_delay(1000); /* initial delay of 1 ms, see errata of KL03Z ROM Bootloader */
|
microseconds_delay(1000); /* initial delay of 1 ms, see errata of KL03Z ROM Bootloader */
|
||||||
while(cntr>0)
|
while(cntr>0)
|
||||||
{
|
{
|
||||||
peripheral_read(&tmp, 1); /* read one byte */
|
peripheral_read(&tmp, 1); /* read one byte */
|
||||||
if (tmp==kFramingPacketStartByte)
|
if (tmp==kFramingPacketStartByte)
|
||||||
{ /* start of frame? */
|
{ /* start of frame? */
|
||||||
*buf = tmp; /* store byte read */
|
*buf = tmp; /* store byte read */
|
||||||
*nofRead = 1; /* return number of bytes read */
|
*nofRead = 1; /* return number of bytes read */
|
||||||
return 1; /* ok */
|
return 1; /* ok */
|
||||||
}
|
}
|
||||||
microseconds_delay(500); /* just wait for some time until the next retry */
|
microseconds_delay(500); /* just wait for some time until the next retry */
|
||||||
@@ -164,20 +164,20 @@ static void finalize_data_phase(status_t status)
|
|||||||
if (status == kStatus_Success)
|
if (status == kStatus_Success)
|
||||||
{
|
{
|
||||||
#if FIXED_BUSPAL_BOOTLOADER
|
#if FIXED_BUSPAL_BOOTLOADER
|
||||||
int res;
|
int res;
|
||||||
size_t offset;
|
size_t offset;
|
||||||
|
|
||||||
status = kStatus_Success; /* default */
|
status = kStatus_Success; /* default */
|
||||||
res = WaitForStartByte(rxBuf, &offset);
|
res = WaitForStartByte(rxBuf, &offset);
|
||||||
if (res==1 && offset==1)
|
if (res==1 && offset==1)
|
||||||
{
|
{
|
||||||
/* read remaining bytes */
|
/* read remaining bytes */
|
||||||
if (peripheral_read(rxBuf+offset, sizeof(framing_data_packet_t)-offset) != kStatus_Success)
|
if (peripheral_read(rxBuf+offset, sizeof(framing_data_packet_t)-offset) != kStatus_Success)
|
||||||
{
|
{
|
||||||
status = kStatus_Fail;
|
status = kStatus_Fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (kStatus_Success!=kStatus_Success)
|
if (kStatus_Success!=kStatus_Success)
|
||||||
#else
|
#else
|
||||||
// receiving framing packet header
|
// receiving framing packet header
|
||||||
if (peripheral_read(rxBuf, sizeof(framing_data_packet_t)) != kStatus_Success)
|
if (peripheral_read(rxBuf, sizeof(framing_data_packet_t)) != kStatus_Success)
|
||||||
@@ -205,9 +205,9 @@ static void finalize_data_phase(status_t status)
|
|||||||
sync.header.packetType = kFramingPacketType_Ack;
|
sync.header.packetType = kFramingPacketType_Ack;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if FIXED_BUSPAL_BOOTLOADER
|
#if FIXED_BUSPAL_BOOTLOADER
|
||||||
microseconds_delay(1000);
|
microseconds_delay(1000);
|
||||||
#endif
|
#endif
|
||||||
// send Ack/Nak back to peripheral
|
// send Ack/Nak back to peripheral
|
||||||
peripheral_write((uint8_t *)&sync, sizeof(framing_sync_packet_t));
|
peripheral_write((uint8_t *)&sync, sizeof(framing_sync_packet_t));
|
||||||
}
|
}
|
||||||
@@ -376,23 +376,23 @@ static status_t handle_data_write(bool *hasMoreData)
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
#if FIXED_BUSPAL_BOOTLOADER
|
#if FIXED_BUSPAL_BOOTLOADER
|
||||||
int res;
|
int res;
|
||||||
size_t offset;
|
size_t offset;
|
||||||
|
|
||||||
status = kStatus_Success; /* default */
|
status = kStatus_Success; /* default */
|
||||||
res = WaitForStartByte((uint8_t *)&sync.header, &offset);
|
res = WaitForStartByte((uint8_t *)&sync.header, &offset);
|
||||||
if (res==1 && offset==1)
|
if (res==1 && offset==1)
|
||||||
{ /* success! read remaining byte */
|
{ /* success! read remaining byte */
|
||||||
if (peripheral_read((uint8_t *)&sync.header+offset, 2-offset) != kStatus_Success)
|
if (peripheral_read((uint8_t *)&sync.header+offset, 2-offset) != kStatus_Success)
|
||||||
{
|
{
|
||||||
status = kStatus_Fail;
|
status = kStatus_Fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
status = kStatus_Fail;
|
status = kStatus_Fail;
|
||||||
}
|
}
|
||||||
if (status != kStatus_Success)
|
if (status != kStatus_Success)
|
||||||
#else
|
#else
|
||||||
if (peripheral_read((uint8_t *)&sync.header, 2) != kStatus_Success)
|
if (peripheral_read((uint8_t *)&sync.header, 2) != kStatus_Success)
|
||||||
#endif
|
#endif
|
||||||
@@ -563,11 +563,11 @@ static status_t handle_command_internal(uint8_t *packet, uint32_t packetLength)
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
#if FIXED_BUSPAL_BOOTLOADER
|
#if FIXED_BUSPAL_BOOTLOADER
|
||||||
size_t offset;
|
size_t offset;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
res = WaitForStartByte(&sync.header.startByte, &offset);
|
res = WaitForStartByte(&sync.header.startByte, &offset);
|
||||||
if (res!=1 || offset!=1)
|
if (res!=1 || offset!=1)
|
||||||
#else
|
#else
|
||||||
if (peripheral_read((uint8_t *)&sync.header.startByte, 1) != kStatus_Success)
|
if (peripheral_read((uint8_t *)&sync.header.startByte, 1) != kStatus_Success)
|
||||||
#endif
|
#endif
|
||||||
@@ -590,24 +590,24 @@ static status_t handle_command_internal(uint8_t *packet, uint32_t packetLength)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if FIXED_BUSPAL_BOOTLOADER
|
#if FIXED_BUSPAL_BOOTLOADER
|
||||||
size_t offset;
|
size_t offset;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
status = kStatus_Success; /* set default */
|
status = kStatus_Success; /* set default */
|
||||||
res = WaitForStartByte(rxBuf, &offset);
|
res = WaitForStartByte(rxBuf, &offset);
|
||||||
if (res==1 && offset==1)
|
if (res==1 && offset==1)
|
||||||
{
|
{
|
||||||
/* read remaining bytes */
|
/* read remaining bytes */
|
||||||
if (peripheral_read(rxBuf+offset, sizeof(framing_data_packet_t)-offset) != kStatus_Success)
|
if (peripheral_read(rxBuf+offset, sizeof(framing_data_packet_t)-offset) != kStatus_Success)
|
||||||
{
|
{
|
||||||
status = kStatus_Fail;
|
status = kStatus_Fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
status = kStatus_Fail;
|
status = kStatus_Fail;
|
||||||
}
|
}
|
||||||
if (status!=kStatus_Success)
|
if (status!=kStatus_Success)
|
||||||
#else
|
#else
|
||||||
// receiving framing packet header
|
// receiving framing packet header
|
||||||
if (peripheral_read(rxBuf, sizeof(framing_data_packet_t)) != kStatus_Success)
|
if (peripheral_read(rxBuf, sizeof(framing_data_packet_t)) != kStatus_Success)
|
||||||
@@ -629,9 +629,9 @@ static status_t handle_command_internal(uint8_t *packet, uint32_t packetLength)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// send Ack/Nak back to peripheral
|
// send Ack/Nak back to peripheral
|
||||||
#if FIXED_BUSPAL_BOOTLOADER
|
#if FIXED_BUSPAL_BOOTLOADER
|
||||||
microseconds_delay(1000);
|
microseconds_delay(1000);
|
||||||
#endif
|
#endif
|
||||||
peripheral_write((uint8_t *)&sync, sizeof(framing_sync_packet_t));
|
peripheral_write((uint8_t *)&sync, sizeof(framing_sync_packet_t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user