allow correct building/syntax highlighting on desktop
This commit is contained in:
parent
4ed3d1654e
commit
d1ec11cad8
@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "decn/decn.h"
|
#include "decn/decn.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
#define STACK_SIZE 4 //must be a power of 2
|
#define STACK_SIZE 4 //must be a power of 2
|
||||||
|
|
||||||
@ -52,6 +53,8 @@ static void do_binary_op(void (*f_ptr)(dec80*, const dec80*)){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void process_cmd(char cmd){
|
void process_cmd(char cmd){
|
||||||
|
//turn off backlight before start of processing
|
||||||
|
backlight_off();
|
||||||
//process cmd
|
//process cmd
|
||||||
switch(cmd){
|
switch(cmd){
|
||||||
//////////
|
//////////
|
||||||
|
23
src/main.c
23
src/main.c
@ -29,8 +29,8 @@ volatile uint8_t NewKeyEmpty;
|
|||||||
#define INCR_NEW_KEY_I(i) i = (i + 1) & 3
|
#define INCR_NEW_KEY_I(i) i = (i + 1) & 3
|
||||||
|
|
||||||
volatile uint8_t SecCount;
|
volatile uint8_t SecCount;
|
||||||
void timer0_isr() __interrupt 1 __using 1
|
|
||||||
//#define TRACK_TIME
|
//#define TRACK_TIME
|
||||||
|
void timer0_isr() SDCC_ISR(1,1)
|
||||||
{
|
{
|
||||||
#ifdef TRACK_TIME
|
#ifdef TRACK_TIME
|
||||||
static uint8_t count = 0;
|
static uint8_t count = 0;
|
||||||
@ -71,6 +71,10 @@ void timer0_isr() __interrupt 1 __using 1
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef DESKTOP
|
||||||
|
void Timer0Init(void) { }
|
||||||
|
static void latch_on(void){ }
|
||||||
|
#else
|
||||||
// Call timer0_isr() 200/sec: 5 ms period
|
// Call timer0_isr() 200/sec: 5 ms period
|
||||||
// Initialize the timer count so that it overflows after 0.01 sec
|
// Initialize the timer count so that it overflows after 0.01 sec
|
||||||
// THTL = 0x10000 - FOSC / 200 = 0x10000 - 115830 = 7621 = 0x1DC5
|
// THTL = 0x10000 - FOSC / 200 = 0x10000 - 115830 = 7621 = 0x1DC5
|
||||||
@ -87,6 +91,7 @@ void Timer0Init(void)
|
|||||||
EA = 1; // Enable global interrupt
|
EA = 1; // Enable global interrupt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif //!DESKTOP
|
||||||
|
|
||||||
|
|
||||||
char Buf[DECN_BUF_SIZE];
|
char Buf[DECN_BUF_SIZE];
|
||||||
@ -118,6 +123,8 @@ int main()
|
|||||||
#ifdef DEBUG_UPTIME
|
#ifdef DEBUG_UPTIME
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
latch_on();
|
||||||
Timer0Init(); // display refresh & switch read
|
Timer0Init(); // display refresh & switch read
|
||||||
LCD_Open();
|
LCD_Open();
|
||||||
KeyInit();
|
KeyInit();
|
||||||
@ -127,6 +134,7 @@ int main()
|
|||||||
P3_2 = 1; //latch on
|
P3_2 = 1; //latch on
|
||||||
P3M1 &= ~(0x4);
|
P3M1 &= ~(0x4);
|
||||||
P3M0 |= (0x4);
|
P3M0 |= (0x4);
|
||||||
|
BACKLIGHT_ON(); //turn on led backlight
|
||||||
|
|
||||||
#ifdef DEBUG_UPTIME
|
#ifdef DEBUG_UPTIME
|
||||||
i = 0;
|
i = 0;
|
||||||
@ -134,6 +142,11 @@ int main()
|
|||||||
// LOOP
|
// LOOP
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
//turn off?
|
||||||
|
if (Keys[0] == 8 && Keys[4] == 8){
|
||||||
|
TURN_OFF();
|
||||||
|
}
|
||||||
|
|
||||||
LCD_GoTo(0,0);
|
LCD_GoTo(0,0);
|
||||||
#ifdef DEBUG_UPTIME
|
#ifdef DEBUG_UPTIME
|
||||||
u32str(i++, Buf, 10);
|
u32str(i++, Buf, 10);
|
||||||
@ -155,11 +168,6 @@ int main()
|
|||||||
for (key_i = 0; key_i < 5; key_i++){
|
for (key_i = 0; key_i < 5; key_i++){
|
||||||
LCD_OutNibble(keys[key_i]);
|
LCD_OutNibble(keys[key_i]);
|
||||||
}
|
}
|
||||||
//turn off?
|
|
||||||
if (keys[0] == 8 && keys[4] == 8){
|
|
||||||
P3_2 = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
TERMIO_PutChar(',');
|
TERMIO_PutChar(',');
|
||||||
//counter
|
//counter
|
||||||
if (SecCount == 0){
|
if (SecCount == 0){
|
||||||
@ -181,7 +189,6 @@ int main()
|
|||||||
if (new_key_read_i == new_key_write_i){
|
if (new_key_read_i == new_key_write_i){
|
||||||
NewKeyEmpty = 1;
|
NewKeyEmpty = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_KEYS
|
#ifdef DEBUG_KEYS
|
||||||
LCD_GoTo(1,j);
|
LCD_GoTo(1,j);
|
||||||
#endif
|
#endif
|
||||||
@ -374,6 +381,8 @@ int main()
|
|||||||
TERMIO_PutChar(ExpBuf[0] + '0');
|
TERMIO_PutChar(ExpBuf[0] + '0');
|
||||||
}
|
}
|
||||||
LCD_ClearToEnd(1);
|
LCD_ClearToEnd(1);
|
||||||
|
//turn backlight back on
|
||||||
|
BACKLIGHT_ON();
|
||||||
} //while (1)
|
} //while (1)
|
||||||
}
|
}
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include "stc15.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#ifdef DESKTOP
|
#ifdef DESKTOP
|
||||||
@ -11,6 +12,8 @@ void _delay_us(uint8_t us)
|
|||||||
//TODO:
|
//TODO:
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
void backlight_off(void){ }
|
||||||
|
#else //!DESKTOP
|
||||||
void _delay_ms(uint8_t ms)
|
void _delay_ms(uint8_t ms)
|
||||||
{
|
{
|
||||||
// delay function, tuned for 11.583 MHz clock
|
// delay function, tuned for 11.583 MHz clock
|
||||||
@ -49,6 +52,12 @@ void _delay_us(uint8_t us)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void backlight_off(void){
|
||||||
|
P3_4 = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //ifdef desktop
|
||||||
|
|
||||||
char* u32str(uint32_t x, char* buf, uint8_t base)
|
char* u32str(uint32_t x, char* buf, uint8_t base)
|
||||||
{
|
{
|
||||||
int i = 0, j;
|
int i = 0, j;
|
||||||
|
14
src/utils.h
14
src/utils.h
@ -18,6 +18,7 @@ void _delay_us(uint8_t us);
|
|||||||
#define _delay_us(x) _delay_ms(1)
|
#define _delay_us(x) _delay_ms(1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void backlight_off(void);
|
||||||
|
|
||||||
char* u32str(uint32_t x, char* buf, uint8_t base);
|
char* u32str(uint32_t x, char* buf, uint8_t base);
|
||||||
|
|
||||||
@ -30,5 +31,18 @@ char* u32str(uint32_t x, char* buf, uint8_t base);
|
|||||||
#define DESKTOP
|
#define DESKTOP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(DESKTOP) || defined(IS_ECLIPSE)
|
||||||
|
#define __xdata
|
||||||
|
#define __sfr
|
||||||
|
#define __at uint8_t*
|
||||||
|
#define SDCC_ISR(isr, reg)
|
||||||
|
#define BACKLIGHT_ON()
|
||||||
|
#define TURN_OFF()
|
||||||
|
#else
|
||||||
|
#define SDCC_ISR(isr, reg) __interrupt (isr) __using (reg)
|
||||||
|
#define BACKLIGHT_ON() P3_4 = 0
|
||||||
|
#define TURN_OFF() P3_2 = 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* SRC_UTILS_H_ */
|
#endif /* SRC_UTILS_H_ */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user