[Stylecheck] F0, F1, F4
There are remaining C99 comments.
This commit is contained in:
@@ -38,7 +38,7 @@ static volatile struct state_t state;
|
||||
|
||||
int _write(int file, char *ptr, int len);
|
||||
|
||||
__attribute__((always_inline)) static inline void __WFI(void)
|
||||
static inline __attribute__((always_inline)) void __WFI(void)
|
||||
{
|
||||
__asm volatile ("wfi");
|
||||
}
|
||||
@@ -46,8 +46,11 @@ __attribute__((always_inline)) static inline void __WFI(void)
|
||||
static void gpio_setup(void)
|
||||
{
|
||||
/* green led for ticking, blue for button feedback */
|
||||
gpio_mode_setup(LED_DISCO_GREEN_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LED_DISCO_GREEN_PIN);
|
||||
gpio_mode_setup(LED_DISCO_BLUE_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LED_DISCO_BLUE_PIN);
|
||||
gpio_mode_setup(LED_DISCO_GREEN_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE,
|
||||
LED_DISCO_GREEN_PIN);
|
||||
|
||||
gpio_mode_setup(LED_DISCO_BLUE_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE,
|
||||
LED_DISCO_BLUE_PIN);
|
||||
|
||||
/* Setup GPIO pins for USART2 transmit. */
|
||||
gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO2);
|
||||
@@ -76,7 +79,8 @@ static void setup_buttons(void)
|
||||
/* Enable EXTI0 interrupt. */
|
||||
nvic_enable_irq(BUTTON_DISCO_USER_NVIC);
|
||||
|
||||
gpio_mode_setup(BUTTON_DISCO_USER_PORT, GPIO_MODE_INPUT, GPIO_PUPD_NONE, BUTTON_DISCO_USER_PIN);
|
||||
gpio_mode_setup(BUTTON_DISCO_USER_PORT, GPIO_MODE_INPUT, GPIO_PUPD_NONE,
|
||||
BUTTON_DISCO_USER_PIN);
|
||||
|
||||
/* Configure the EXTI subsystem. */
|
||||
exti_select_source(BUTTON_DISCO_USER_EXTI, BUTTON_DISCO_USER_PORT);
|
||||
@@ -128,7 +132,7 @@ int _write(int file, char *ptr, int len)
|
||||
static void setup_button_press_timer(void)
|
||||
{
|
||||
timer_reset(TIMER_BUTTON_PRESS);
|
||||
timer_set_prescaler(TIMER_BUTTON_PRESS, 3999); // 4Mhz/1000hz - 1
|
||||
timer_set_prescaler(TIMER_BUTTON_PRESS, 3999); /* 4Mhz/1000hz - 1 */
|
||||
timer_set_period(TIMER_BUTTON_PRESS, 0xffff);
|
||||
timer_enable_counter(TIMER_BUTTON_PRESS);
|
||||
}
|
||||
@@ -151,15 +155,15 @@ static int setup_rtc(void)
|
||||
rcc_rtc_select_clock(RCC_CSR_RTCSEL_LSE);
|
||||
|
||||
/* ?! Stdperiph examples don't turn this on until _afterwards_ which
|
||||
* simply doesn't work. It must be on at least to be able to configure it */
|
||||
* simply doesn't work. It must be on at least to be able to
|
||||
* configure it */
|
||||
RCC_CSR |= RCC_CSR_RTCEN;
|
||||
|
||||
rtc_unlock();
|
||||
|
||||
/* enter init mode */
|
||||
RTC_ISR |= RTC_ISR_INIT;
|
||||
while ((RTC_ISR & RTC_ISR_INITF) == 0)
|
||||
;
|
||||
while ((RTC_ISR & RTC_ISR_INITF) == 0);
|
||||
|
||||
/* set synch prescaler, using defaults for 1Hz out */
|
||||
uint32_t sync = 255;
|
||||
@@ -190,8 +194,7 @@ static int setup_rtc_wakeup(int period)
|
||||
RTC_CR &= ~RTC_CR_WUTE;
|
||||
|
||||
/* Wait until we can write */
|
||||
while ((RTC_ISR & RTC_ISR_WUTWF) == 0)
|
||||
;
|
||||
while ((RTC_ISR & RTC_ISR_WUTWF) == 0);
|
||||
|
||||
RTC_WUTR = period - 1;
|
||||
|
||||
@@ -210,12 +213,13 @@ static int setup_rtc_wakeup(int period)
|
||||
/* done with rtc registers, lock them again */
|
||||
rtc_lock();
|
||||
|
||||
|
||||
nvic_enable_irq(NVIC_RTC_WKUP_IRQ);
|
||||
|
||||
// EXTI configuration
|
||||
/* EXTI configuration */
|
||||
/* Configure the EXTI subsystem. */
|
||||
// not needed, this chooses ports exti_select_source(EXTI20, BUTTON_DISCO_USER_PORT);
|
||||
/* not needed, this chooses ports
|
||||
exti_select_source(EXTI20, BUTTON_DISCO_USER_PORT);
|
||||
*/
|
||||
exti_set_trigger(EXTI20, EXTI_TRIGGER_RISING);
|
||||
exti_enable_request(EXTI20);
|
||||
return 0;
|
||||
|
||||
@@ -46,14 +46,16 @@ static void clock_setup(void)
|
||||
/* And timers. */
|
||||
rcc_periph_clock_enable(RCC_TIM6);
|
||||
rcc_periph_clock_enable(RCC_TIM7);
|
||||
|
||||
}
|
||||
|
||||
static void gpio_setup(void)
|
||||
{
|
||||
/* green led for ticking, blue for button feedback */
|
||||
gpio_mode_setup(LED_DISCO_GREEN_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LED_DISCO_GREEN_PIN);
|
||||
gpio_mode_setup(LED_DISCO_BLUE_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LED_DISCO_BLUE_PIN);
|
||||
gpio_mode_setup(LED_DISCO_GREEN_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE,
|
||||
LED_DISCO_GREEN_PIN);
|
||||
|
||||
gpio_mode_setup(LED_DISCO_BLUE_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE,
|
||||
LED_DISCO_BLUE_PIN);
|
||||
|
||||
/* Setup GPIO pins for USART2 transmit. */
|
||||
gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO2);
|
||||
@@ -117,7 +119,7 @@ void BUTTON_DISCO_USER_isr(void)
|
||||
}
|
||||
}
|
||||
|
||||
static volatile int t6ovf = 0;
|
||||
static volatile int t6ovf;
|
||||
|
||||
void tim6_isr(void)
|
||||
{
|
||||
@@ -136,13 +138,13 @@ void tim6_isr(void)
|
||||
static void setup_tim6(void)
|
||||
{
|
||||
timer_reset(TIM6);
|
||||
// 24Mhz / 10khz -1.
|
||||
timer_set_prescaler(TIM6, 2399); // 24Mhz/10000hz - 1
|
||||
// 10khz for 10 ticks = 1 khz overflow = 1ms overflow interrupts
|
||||
/* 24Mhz / 10khz -1. */
|
||||
timer_set_prescaler(TIM6, 2399); /* 24Mhz/10000hz - 1 */
|
||||
/* 10khz for 10 ticks = 1 khz overflow = 1ms overflow interrupts */
|
||||
timer_set_period(TIM6, 10);
|
||||
|
||||
nvic_enable_irq(NVIC_TIM6_IRQ);
|
||||
timer_enable_update_event(TIM6); // default at reset!
|
||||
timer_enable_update_event(TIM6); /* default at reset! */
|
||||
timer_enable_irq(TIM6, TIM_DIER_UIE);
|
||||
timer_enable_counter(TIM6);
|
||||
}
|
||||
@@ -153,7 +155,7 @@ static void setup_tim6(void)
|
||||
static void setup_tim7(void)
|
||||
{
|
||||
timer_reset(TIM7);
|
||||
timer_set_prescaler(TIM7, 23999); // 24Mhz/1000hz - 1
|
||||
timer_set_prescaler(TIM7, 23999); /* 24Mhz/1000hz - 1 */
|
||||
timer_set_period(TIM7, 0xffff);
|
||||
timer_enable_counter(TIM7);
|
||||
}
|
||||
@@ -163,7 +165,8 @@ static void setup_buttons(void)
|
||||
/* Enable EXTI0 interrupt. */
|
||||
nvic_enable_irq(BUTTON_DISCO_USER_NVIC);
|
||||
|
||||
gpio_mode_setup(BUTTON_DISCO_USER_PORT, GPIO_MODE_INPUT, GPIO_PUPD_NONE, BUTTON_DISCO_USER_PIN);
|
||||
gpio_mode_setup(BUTTON_DISCO_USER_PORT, GPIO_MODE_INPUT, GPIO_PUPD_NONE,
|
||||
BUTTON_DISCO_USER_PIN);
|
||||
|
||||
/* Configure the EXTI subsystem. */
|
||||
exti_select_source(BUTTON_DISCO_USER_EXTI, BUTTON_DISCO_USER_PORT);
|
||||
|
||||
@@ -46,23 +46,24 @@ int main(void)
|
||||
/* Manually: */
|
||||
// GPIOD_BSRR = GPIO6; /* LED off */
|
||||
// for (i = 0; i < 1000000; i++) /* Wait a bit. */
|
||||
// __asm__("nop");
|
||||
// __asm__("nop");
|
||||
// GPIOD_BRR = GPIO6; /* LED on */
|
||||
// for (i = 0; i < 1000000; i++) /* Wait a bit. */
|
||||
// __asm__("nop");
|
||||
// __asm__("nop");
|
||||
|
||||
/* Using API functions gpio_set()/gpio_clear(): */
|
||||
// gpio_set(GPIOD, GPIO6); /* LED off */
|
||||
// for (i = 0; i < 1000000; i++) /* Wait a bit. */
|
||||
// __asm__("nop");
|
||||
// __asm__("nop");
|
||||
// gpio_clear(GPIOD, GPIO6); /* LED on */
|
||||
// for (i = 0; i < 1000000; i++) /* Wait a bit. */
|
||||
// __asm__("nop");
|
||||
// __asm__("nop");
|
||||
|
||||
/* Using API function gpio_toggle(): */
|
||||
gpio_toggle(GPIOB, GPIO6); /* LED on/off */
|
||||
for (i = 0; i < 1000000; i++) /* Wait a bit. */
|
||||
for (i = 0; i < 1000000; i++) { /* Wait a bit. */
|
||||
__asm__("nop");
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -84,8 +84,9 @@ int main(void)
|
||||
usart_send_blocking(USART2, '\r');
|
||||
usart_send_blocking(USART2, '\n');
|
||||
}
|
||||
for (i = 0; i < 100000; i++) /* Wait a bit. */
|
||||
for (i = 0; i < 100000; i++) { /* Wait a bit. */
|
||||
__asm__("NOP");
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -76,8 +76,9 @@ int main(void)
|
||||
usart_send_blocking(USART2, '\r');
|
||||
usart_send_blocking(USART2, '\n');
|
||||
}
|
||||
for (i = 0; i < 100000; i++) /* Wait a bit. */
|
||||
for (i = 0; i < 100000; i++) { /* Wait a bit. */
|
||||
__asm__("NOP");
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user