Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
fix issues with newer sdcc (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
zerog2k authored Oct 21, 2018
1 parent c51e454 commit 1b48d85
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/ds1302.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ void ds_ram_config_init() {
// using a second variable instead of DS_CMD_RAM>>1 | (i+2) generates less code
j = DS_CMD_RAM >> 1 | 2;
for (i = 0; i != 4; i++) {
cfg_table[i] = ds_readbyte(j++);
cfg_table[i] = ds_readbyte(j);
j++;
}
}

void ds_ram_config_write() {
uint8_t i, j;
j = DS_CMD_RAM >> 1 | 2;
for (i=0; i!=4; i++) {
ds_writebyte( j++, cfg_table[i]);
ds_writebyte( j, cfg_table[i]);
j++;
}
}

Expand Down
12 changes: 8 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void _delay_ms(uint8_t ms)
*/

uint8_t count; // main loop counter
uint16_t temp; // temperature sensor value
uint8_t temp; // temperature sensor value
uint8_t lightval; // light sensor value

volatile uint8_t displaycounter;
Expand Down Expand Up @@ -157,10 +157,11 @@ volatile enum Event event;

void timer0_isr() __interrupt 1 __using 1
{
uint8_t tmp;
enum Event ev = EV_NONE;
// display refresh ISR
// cycle thru digits one at a time
uint8_t digit = displaycounter % 4;
uint8_t digit = displaycounter % (uint8_t) 4;

// turn off all digits, set high
LED_DIGITS_OFF();
Expand All @@ -170,7 +171,10 @@ void timer0_isr() __interrupt 1 __using 1
// fill digits
LED_SEGMENT_PORT = dbuf[digit];
// turn on selected digit, set low
LED_DIGIT_ON(digit);
//LED_DIGIT_ON(digit);
// issue #32, fix for newer sdcc versions which are using non-atomic port access
tmp = ~((1<<LED_DIGITS_PORT_BASE) << digit);
LED_DIGITS_PORT &= tmp;
}
displaycounter++;

Expand Down Expand Up @@ -375,7 +379,7 @@ int main()
event = EV_NONE;

// sample adc, run frequently
if (count % 4 == 0) {
if (count % (uint8_t) 4 == 0) {
temp = gettemp(getADCResult(ADC_TEMP));
// auto-dimming, by dividing adc range into 8 steps
lightval = getADCResult8(ADC_LIGHT) >> 3;
Expand Down

0 comments on commit 1b48d85

Please sign in to comment.