63 lines
1.8 KiB
C
63 lines
1.8 KiB
C
|
/*
|
||
|
* Author: klaute -Kai Lauterbach - @kailauterbach - me@klaute.de
|
||
|
* Date: 08/2016
|
||
|
* License: GPLv3
|
||
|
*/
|
||
|
|
||
|
/*****************************************************************************/
|
||
|
|
||
|
extern void USB_serialStreamWriteC(char*, uint16_t);
|
||
|
|
||
|
extern uint32_t eep_baudrate;
|
||
|
extern uint32_t baudrate;
|
||
|
|
||
|
/*****************************************************************************/
|
||
|
|
||
|
void cc_setBaudrate()
|
||
|
{
|
||
|
baudrate = (uint32_t)cc_read_data[0] << 24;
|
||
|
baudrate += (uint32_t)cc_read_data[1] << 16;
|
||
|
baudrate += (uint32_t)cc_read_data[2] << 8;
|
||
|
baudrate += (uint32_t)cc_read_data[3];
|
||
|
|
||
|
eeprom_busy_wait();
|
||
|
|
||
|
eeprom_write_dword(&eep_baudrate, baudrate);
|
||
|
|
||
|
eeprom_busy_wait();
|
||
|
|
||
|
uart_init( UART_BAUD_SELECT(baudrate, F_CPU) );
|
||
|
|
||
|
char* sBody = " ";
|
||
|
sprintf(sBody, "%c%c%c%c%c", MSG_SOM1, MSG_SOM2, MSG_TYPE_ANSWER_OK, MSG_EOM1, MSG_EOM2);
|
||
|
USB_serialStreamWriteC(sBody, strlen(sBody));
|
||
|
}
|
||
|
|
||
|
/*****************************************************************************/
|
||
|
|
||
|
void cc_getBaudrate()
|
||
|
{
|
||
|
char* sBody = " ";
|
||
|
sprintf(sBody, "%c%c%c%c%c%c%c%c%c", MSG_SOM1, MSG_SOM2, MSG_TYPE_BAUDRATE,
|
||
|
(uint8_t)((baudrate & 0xff000000) >> 24),
|
||
|
(uint8_t)((baudrate & 0xff0000) >> 16),
|
||
|
(uint8_t)((baudrate & 0xff00) >> 8),
|
||
|
(uint8_t) (baudrate & 0xff),
|
||
|
MSG_EOM1, MSG_EOM2);
|
||
|
USB_serialStreamWriteC(sBody, strlen(sBody));
|
||
|
}
|
||
|
|
||
|
/*****************************************************************************/
|
||
|
|
||
|
void cc_startBootloader()
|
||
|
{
|
||
|
// enable the watchdog without a time interval to use
|
||
|
wdt_enable(0);
|
||
|
|
||
|
// trigger watchdog
|
||
|
while(1) {};
|
||
|
}
|
||
|
|
||
|
/*****************************************************************************/
|
||
|
|