Create mostly working delayms()

This commit is contained in:
Stefan `Sec` Zehl
2015-08-07 21:04:28 +02:00
parent 04e9d599c5
commit f092321907
6 changed files with 13 additions and 15 deletions

View File

@@ -3,6 +3,7 @@
#include <rad1olib/pins.h>
#include <r0ketlib/display.h>
#include <r0ketlib/print.h>
#include <r0ketlib/idle.h>
#include <libopencm3/lpc43xx/ssp.h>
#include <libopencm3/lpc43xx/gpio.h>
#include <libopencm3/lpc43xx/scu.h>
@@ -14,16 +15,6 @@
uint8_t lcdBuffer[RESX*RESY];
uint8_t displayType;
void delayms(uint32_t duration){ /* XXX: do me correctly */
uint32_t i;
duration*=10000;
for (i = 0; i < duration; i++)
__asm__("nop");
}
void lcd_select() {
/* the LCD requires 9-Bit frames */
// Freq = PCLK / (CPSDVSR * [SCR+1])

View File

@@ -5,7 +5,6 @@
/**************************************************************************/
void work_queue(void){
__WFI();
return;
}
@@ -33,3 +32,10 @@ void delayms_power(uint32_t ms){
__WFI();
} while (ms >_timectr);
}
void delayms(uint32_t duration){
int end=_timectr+duration/SYSTICKSPEED;
do {
__WFI();
} while (end >_timectr);
}

View File

@@ -5,5 +5,6 @@ void work_queue(void);
uint8_t delayms_queue_plus(uint32_t ms, uint8_t final);
void delayms_queue(uint32_t ms);
void delayms_power(uint32_t ms);
void delayms(uint32_t duration);
#endif /* _IDLE_H */

View File

@@ -106,7 +106,7 @@ uint8_t getInputWaitRepeat(void) {
else
dtime=20;
repeatctr++;
int end=_timectr+(dtime*1000/SYSTICKSPEED);
int end=_timectr+(dtime/SYSTICKSPEED);
while(_timectr<end && key==getInputRaw())
work_queue();
key=getInputRaw();

View File

@@ -8,13 +8,13 @@ volatile uint32_t _timectr=0;
void systickInit(){
systick_set_clocksource(0);
systick_set_reload(12e6/SYSTICKSPEED);
systick_set_reload(12e6/SYSTICKSPEED/1000);
systick_interrupt_enable();
systick_counter_enable();
};
void systickAdjustFreq(uint32_t hz){
systick_set_reload(hz/SYSTICKSPEED);
systick_set_reload(hz/SYSTICKSPEED/1000);
};
void systickDisable(){

View File

@@ -5,7 +5,7 @@
// Our time implementation will fail after 497 days of continous uptime.
// ( 2^32 / 1000 * SYSTICKSPEED ) seconds
#define SYSTICKSPEED 1000
#define SYSTICKSPEED 1
#ifndef LOCAL
extern volatile uint32_t _timectr;
#endif