Bugfix in clock_wait() declaration. Various style fixes.

This commit is contained in:
Adam Dunkels 2012-04-22 20:54:29 +02:00
parent b4e7468b12
commit b85bc3379c

View file

@ -55,17 +55,17 @@
#define DEBUG DEBUG_NONE #define DEBUG DEBUG_NONE
#include "net/uip-debug.h" #include "net/uip-debug.h"
// The value that will be load in the SysTick value register. /* The value that will be load in the SysTick value register. */
#define RELOAD_VALUE 24000-1 // 1 ms with a 24 MHz clock #define RELOAD_VALUE 24000-1 /* 1 ms with a 24 MHz clock */
static volatile clock_time_t count; static volatile clock_time_t count;
static volatile unsigned long current_seconds = 0; static volatile unsigned long current_seconds = 0;
static unsigned int second_countdown = CLOCK_SECOND; static unsigned int second_countdown = CLOCK_SECOND;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void SysTick_Handler(void) void
SysTick_Handler(void)
{ {
count++; count++;
if(etimer_pending()) { if(etimer_pending()) {
@ -78,10 +78,9 @@ void SysTick_Handler(void)
} }
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void
void clock_init(void) clock_init(void)
{ {
ATOMIC( ATOMIC(
@ -97,19 +96,18 @@ void clock_init(void)
) )
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
clock_time_t
clock_time_t clock_time(void) clock_time(void)
{ {
return count; return count;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/** /**
* Delay the CPU for a multiple of TODO * Delay the CPU for a multiple of TODO
*/ */
void clock_delay(unsigned int i) void
clock_delay(unsigned int i)
{ {
for (; i > 0; i--) { /* Needs fixing XXX */ for (; i > 0; i--) { /* Needs fixing XXX */
unsigned j; unsigned j;
@ -117,13 +115,13 @@ void clock_delay(unsigned int i)
asm ("nop"); asm ("nop");
} }
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/** /**
* Wait for a multiple of 1 ms. * Wait for a multiple of 1 ms.
* *
*/ */
void clock_wait(clock_timt_t i) void
clock_wait(clock_time_t i)
{ {
clock_time_t start; clock_time_t start;
@ -131,20 +129,20 @@ void clock_wait(clock_timt_t i)
while(clock_time() - start < (clock_time_t)i); while(clock_time() - start < (clock_time_t)i);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
unsigned long
unsigned long clock_seconds(void) clock_seconds(void)
{ {
return current_seconds; return current_seconds;
} }
#include <stdio.h> #include <stdio.h>
void sleep_seconds(int seconds) void
sleep_seconds(int seconds)
{ {
int32u quarter_seconds = seconds * 4; int32u quarter_seconds = seconds * 4;
uint8_t radio_on; uint8_t radio_on;
halPowerDown(); halPowerDown();
radio_on = stm32w_radio_is_on(); radio_on = stm32w_radio_is_on();
stm32w_radio_driver.off(); stm32w_radio_driver.off();
@ -156,8 +154,8 @@ void sleep_seconds(int seconds)
halPowerUp(); halPowerUp();
// Update OS system ticks. /* Update OS system ticks. */
current_seconds += seconds - quarter_seconds / 4 ; // Passed seconds current_seconds += seconds - quarter_seconds / 4 ; /* Passed seconds */
count += seconds * CLOCK_SECOND - quarter_seconds * CLOCK_SECOND / 4 ; count += seconds * CLOCK_SECOND - quarter_seconds * CLOCK_SECOND / 4 ;
if(etimer_pending()) { if(etimer_pending()) {
@ -168,12 +166,11 @@ void sleep_seconds(int seconds)
SysTick_SetReload(RELOAD_VALUE); SysTick_SetReload(RELOAD_VALUE);
SysTick_ITConfig(ENABLE); SysTick_ITConfig(ENABLE);
SysTick_CounterCmd(SysTick_Counter_Enable); SysTick_CounterCmd(SysTick_Counter_Enable);
) )
stm32w_radio_driver.init(); stm32w_radio_driver.init();
if(radio_on){ if(radio_on) {
stm32w_radio_driver.on(); stm32w_radio_driver.on();
} }
uart1_init(115200); uart1_init(115200);
@ -182,5 +179,4 @@ void sleep_seconds(int seconds)
PRINTF("WakeInfo: %04x\r\n", halGetWakeInfo()); PRINTF("WakeInfo: %04x\r\n", halGetWakeInfo());
} }