comparison hw.c @ 30:435c6330896c

Set tv_usec in gettimeofday() by using the prescaler counter.
author Daniel O'Connor <darius@dons.net.au>
date Tue, 27 Nov 2012 13:19:11 +1030
parents 5c9d2e3d6591
children 03592ca4d37e
comparison
equal deleted inserted replaced
29:077cdff4662a 30:435c6330896c
2 #include <stdio.h> 2 #include <stdio.h>
3 #include "stm32f10x.h" 3 #include "stm32f10x.h"
4 4
5 #include "1wire.h" 5 #include "1wire.h"
6 #include "lcd.h" 6 #include "lcd.h"
7 #include "rtc.h"
7 8
8 #define I2C_TIMEOUT 10000 9 #define I2C_TIMEOUT 10000
9
10 static void hw_port_cfg(void); 10 static void hw_port_cfg(void);
11 11
12 /* Wait for cnt microseconds */ 12 /* Wait for cnt microseconds */
13 void 13 void
14 _usleep16(uint16_t cnt) { 14 _usleep16(uint16_t cnt) {
75 75
76 /* Wait until last write operation on RTC registers has finished */ 76 /* Wait until last write operation on RTC registers has finished */
77 RTC_WaitForLastTask(); 77 RTC_WaitForLastTask();
78 78
79 /* Set RTC prescaler: set RTC period to 1sec */ 79 /* Set RTC prescaler: set RTC period to 1sec */
80 RTC_SetPrescaler(32767); /* RTC period = RTCCLK/RTC_PR = (32.768 KHz)/(32767+1) */ 80 RTC_SetPrescaler(RTC_PRESCALE);
81 81
82 /* Wait until last write operation on RTC registers has finished */ 82 /* Wait until last write operation on RTC registers has finished */
83 RTC_WaitForLastTask(); 83 RTC_WaitForLastTask();
84 84
85 /* Port configuration */ 85 /* Port configuration */