mirror of
https://github.com/mytechnotalent/Embedded-Hacking.git
synced 2026-07-25 13:20:56 +02:00
Fixed improper _
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
* @brief Heartbeat callback invoked by TIMER0 alarm 0 IRQ.
|
||||
* @retval None
|
||||
*/
|
||||
static void _heartbeat(void)
|
||||
static void heartbeat(void)
|
||||
{
|
||||
uart_puts("Timer heartbeat\r\n");
|
||||
}
|
||||
@@ -41,7 +41,7 @@ static void _heartbeat(void)
|
||||
int main(void)
|
||||
{
|
||||
uart_puts("Timer alarm demo initialized\r\n");
|
||||
timer_alarm_start(1000, _heartbeat);
|
||||
timer_alarm_start(1000, heartbeat);
|
||||
while (1)
|
||||
__asm__ volatile ("wfi");
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ static uint32_t _alarm_period_us;
|
||||
* @brief Clear the TIMER0 reset bit in the reset controller.
|
||||
* @retval None
|
||||
*/
|
||||
static void _timer_clear_reset_bit(void)
|
||||
static void timer_clear_reset_bit(void)
|
||||
{
|
||||
uint32_t value;
|
||||
value = RESETS->RESET;
|
||||
@@ -49,7 +49,7 @@ static void _timer_clear_reset_bit(void)
|
||||
* @brief Wait until the TIMER0 block is out of reset.
|
||||
* @retval None
|
||||
*/
|
||||
static void _timer_wait_reset_done(void)
|
||||
static void timer_wait_reset_done(void)
|
||||
{
|
||||
while ((RESETS->RESET_DONE & (1U << RESETS_RESET_TIMER0_SHIFT)) == 0) {}
|
||||
}
|
||||
@@ -58,7 +58,7 @@ static void _timer_wait_reset_done(void)
|
||||
* @brief Set the TIMER0 tick generator cycle count to 12.
|
||||
* @retval None
|
||||
*/
|
||||
static void _timer_set_tick_cycles(void)
|
||||
static void timer_set_tick_cycles(void)
|
||||
{
|
||||
TICKS_TIMER0->CYCLES = TICKS_TIMER0_CYCLES_12MHZ;
|
||||
}
|
||||
@@ -67,7 +67,7 @@ static void _timer_set_tick_cycles(void)
|
||||
* @brief Enable the TIMER0 tick generator.
|
||||
* @retval None
|
||||
*/
|
||||
static void _timer_enable_tick(void)
|
||||
static void timer_enable_tick(void)
|
||||
{
|
||||
TICKS_TIMER0->CTRL = (1U << TICKS_CTRL_ENABLE_SHIFT);
|
||||
}
|
||||
@@ -76,7 +76,7 @@ static void _timer_enable_tick(void)
|
||||
* @brief Enable the alarm 0 interrupt in TIMER0 INTE register.
|
||||
* @retval None
|
||||
*/
|
||||
static void _timer_enable_alarm_irq(void)
|
||||
static void timer_enable_alarm_irq(void)
|
||||
{
|
||||
TIMER0->INTE = (1U << TIMER_INTE_ALARM0_SHIFT);
|
||||
}
|
||||
@@ -85,7 +85,7 @@ static void _timer_enable_alarm_irq(void)
|
||||
* @brief Enable TIMER0_IRQ_0 in the NVIC.
|
||||
* @retval None
|
||||
*/
|
||||
static void _timer_enable_nvic(void)
|
||||
static void timer_enable_nvic(void)
|
||||
{
|
||||
*NVIC_ISER0 = (1U << TIMER0_ALARM0_IRQ);
|
||||
}
|
||||
@@ -94,7 +94,7 @@ static void _timer_enable_nvic(void)
|
||||
* @brief Arm alarm 0 with the next target time.
|
||||
* @retval None
|
||||
*/
|
||||
static void _timer_arm_alarm(void)
|
||||
static void timer_arm_alarm(void)
|
||||
{
|
||||
uint32_t target;
|
||||
target = TIMER0->TIMERAWL + _alarm_period_us;
|
||||
@@ -103,29 +103,29 @@ static void _timer_arm_alarm(void)
|
||||
|
||||
void timer_release_reset(void)
|
||||
{
|
||||
_timer_clear_reset_bit();
|
||||
_timer_wait_reset_done();
|
||||
timer_clear_reset_bit();
|
||||
timer_wait_reset_done();
|
||||
}
|
||||
|
||||
void timer_tick_init(void)
|
||||
{
|
||||
_timer_set_tick_cycles();
|
||||
_timer_enable_tick();
|
||||
timer_set_tick_cycles();
|
||||
timer_enable_tick();
|
||||
}
|
||||
|
||||
void timer_alarm_start(uint32_t period_ms, timer_callback_t cb)
|
||||
{
|
||||
_user_callback = cb;
|
||||
_alarm_period_us = period_ms * 1000U;
|
||||
_timer_enable_alarm_irq();
|
||||
_timer_enable_nvic();
|
||||
_timer_arm_alarm();
|
||||
timer_enable_alarm_irq();
|
||||
timer_enable_nvic();
|
||||
timer_arm_alarm();
|
||||
}
|
||||
|
||||
void TIMER0_IRQ_0_Handler(void)
|
||||
{
|
||||
TIMER0->INTR = TIMER_INTR_ALARM0_MASK;
|
||||
_timer_arm_alarm();
|
||||
timer_arm_alarm();
|
||||
if (_user_callback)
|
||||
_user_callback();
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
* @brief Clear the UART0 reset bit in the reset controller.
|
||||
* @retval None
|
||||
*/
|
||||
static void _uart_clear_reset_bit(void)
|
||||
static void uart_clear_reset_bit(void)
|
||||
{
|
||||
uint32_t value;
|
||||
value = RESETS->RESET;
|
||||
@@ -40,7 +40,7 @@ static void _uart_clear_reset_bit(void)
|
||||
* @brief Wait until the UART0 block is out of reset.
|
||||
* @retval None
|
||||
*/
|
||||
static void _uart_wait_reset_done(void)
|
||||
static void uart_wait_reset_done(void)
|
||||
{
|
||||
while ((RESETS->RESET_DONE & (1U << RESETS_RESET_UART0_SHIFT)) == 0) {}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ static void _uart_wait_reset_done(void)
|
||||
* @brief Configure GPIO pins 0 (TX) and 1 (RX) for UART function.
|
||||
* @retval None
|
||||
*/
|
||||
static void _uart_configure_pins(void)
|
||||
static void uart_configure_pins(void)
|
||||
{
|
||||
IO_BANK0->GPIO[0].CTRL = IO_BANK0_CTRL_FUNCSEL_UART;
|
||||
IO_BANK0->GPIO[1].CTRL = IO_BANK0_CTRL_FUNCSEL_UART;
|
||||
@@ -61,7 +61,7 @@ static void _uart_configure_pins(void)
|
||||
* @brief Set UART0 baud rate divisors for 115200 at 12 MHz.
|
||||
* @retval None
|
||||
*/
|
||||
static void _uart_set_baud(void)
|
||||
static void uart_set_baud(void)
|
||||
{
|
||||
UART_BASE[UART_CR_OFFSET] = 0;
|
||||
UART_BASE[UART_IBRD_OFFSET] = 6;
|
||||
@@ -72,7 +72,7 @@ static void _uart_set_baud(void)
|
||||
* @brief Configure line control and enable UART0.
|
||||
* @retval None
|
||||
*/
|
||||
static void _uart_enable(void)
|
||||
static void uart_enable(void)
|
||||
{
|
||||
UART_BASE[UART_LCR_H_OFFSET] = UART_LCR_H_8N1_FIFO;
|
||||
UART_BASE[UART_CR_OFFSET] = UART_CR_ENABLE;
|
||||
@@ -80,15 +80,15 @@ static void _uart_enable(void)
|
||||
|
||||
void uart_release_reset(void)
|
||||
{
|
||||
_uart_clear_reset_bit();
|
||||
_uart_wait_reset_done();
|
||||
uart_clear_reset_bit();
|
||||
uart_wait_reset_done();
|
||||
}
|
||||
|
||||
void uart_init(void)
|
||||
{
|
||||
_uart_configure_pins();
|
||||
_uart_set_baud();
|
||||
_uart_enable();
|
||||
uart_configure_pins();
|
||||
uart_set_baud();
|
||||
uart_enable();
|
||||
}
|
||||
|
||||
bool uart_is_readable(void)
|
||||
|
||||
@@ -32,7 +32,7 @@ extern void TIMER0_IRQ_0_Handler(void);
|
||||
* @brief Default handler for unused exceptions (infinite loop).
|
||||
* @retval None
|
||||
*/
|
||||
static void _default_handler(void)
|
||||
static void default_handler(void)
|
||||
{
|
||||
while (1) {}
|
||||
}
|
||||
@@ -43,19 +43,19 @@ __attribute__((section(".vectors"), used))
|
||||
const void *_vectors[17] = {
|
||||
&_stack_top, // 0: Initial stack pointer
|
||||
Reset_Handler, // 1: Reset
|
||||
_default_handler, // 2: NMI
|
||||
_default_handler, // 3: HardFault
|
||||
_default_handler, // 4: MemManage
|
||||
_default_handler, // 5: BusFault
|
||||
_default_handler, // 6: UsageFault
|
||||
_default_handler, // 7: SecureFault
|
||||
default_handler, // 2: NMI
|
||||
default_handler, // 3: HardFault
|
||||
default_handler, // 4: MemManage
|
||||
default_handler, // 5: BusFault
|
||||
default_handler, // 6: UsageFault
|
||||
default_handler, // 7: SecureFault
|
||||
0, // 8: Reserved
|
||||
0, // 9: Reserved
|
||||
0, // 10: Reserved
|
||||
_default_handler, // 11: SVCall
|
||||
_default_handler, // 12: DebugMon
|
||||
default_handler, // 11: SVCall
|
||||
default_handler, // 12: DebugMon
|
||||
0, // 13: Reserved
|
||||
_default_handler, // 14: PendSV
|
||||
_default_handler, // 15: SysTick
|
||||
default_handler, // 14: PendSV
|
||||
default_handler, // 15: SysTick
|
||||
TIMER0_IRQ_0_Handler, // 16: IRQ 0 — TIMER0_IRQ_0
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user