2025-09-23 00:27:51 +08:00
|
|
|
#include "initial.h"
|
2025-11-01 20:29:11 +08:00
|
|
|
#include <stdint.h>
|
2025-09-23 00:27:51 +08:00
|
|
|
|
2025-11-22 23:59:43 +08:00
|
|
|
|
2025-09-23 00:27:51 +08:00
|
|
|
|
|
|
|
|
/* retarget the C library printf function to the USART */
|
|
|
|
|
u8 USART0_init() {
|
|
|
|
|
gd_eval_com_init(EVAL_COM0);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-02 23:50:12 +08:00
|
|
|
/*!
|
|
|
|
|
\brief configure the watchdog peripheral
|
|
|
|
|
\param[in] none
|
|
|
|
|
\param[out] none
|
|
|
|
|
\retval none
|
|
|
|
|
*/
|
|
|
|
|
u8 watchdog_init(u32 time) {
|
|
|
|
|
u8 status = 0;
|
|
|
|
|
/* configure FWDGT counter clock: 40KHz(IRC40K) / 64 = 0.625 KHz */
|
|
|
|
|
/* time = reload_value / clock_frequency */
|
|
|
|
|
status = fwdgt_config(time * 0.625, FWDGT_PSC_DIV64);
|
|
|
|
|
fwdgt_enable();
|
|
|
|
|
return status;
|
|
|
|
|
}
|
2025-11-02 01:54:01 +08:00
|
|
|
|
2025-11-22 23:59:43 +08:00
|
|
|
|
2025-09-23 00:27:51 +08:00
|
|
|
int fputc(int ch, FILE *f) throw() {
|
|
|
|
|
usart_data_transmit(EVAL_COM0, (uint8_t)ch);
|
|
|
|
|
while (RESET == usart_flag_get(EVAL_COM0, USART_FLAG_TBE))
|
|
|
|
|
;
|
|
|
|
|
return ch;
|
|
|
|
|
}
|