Skip to content

Commit

Permalink
fix: Fix spare parts Buzzer crash on board reset.
Browse files Browse the repository at this point in the history
  • Loading branch information
lcgamboa committed Jun 15, 2024
1 parent efe3883 commit 3337f96
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/devices/rtc_ds1307.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
} else \
printf

enum { DS_SECONDS = 0, DS_MINUTES, DS_HOURS, DS_DAY, DS_DATE, DS_MONTH, DS_YEAR, DS_CONTROL };
enum { DS_SECONDS = 0, DS_MINUTES, DS_HOURS, DS_DAY, DS_DATE, DS_MONTH, DS_YEAR, DS_CTRL };

#ifdef _DEBUG
static char buff[30];
Expand Down Expand Up @@ -69,7 +69,7 @@ const char* get_addr_str(const unsigned char addr, const unsigned char data) {
case DS_YEAR:
sprintf(buff, "YEAR [%02X] = %02X", addr, data);
break;
case DS_CONTROL:
case DS_CTRL:
sprintf(buff, "CONTROL [%02X] = %02X", addr, data);
break;
default:
Expand Down Expand Up @@ -265,7 +265,7 @@ void rtc_ds1307_init(rtc_ds1307_t* rtc, board* pboard_) {

memset(rtc->data, 0xFF, 8);
rtc->data[DS_HOURS] &= 0x3F; // 24h mode
rtc->data[DS_CONTROL] = 0;
rtc->data[DS_CTRL] = 0;
rtc_ds1307_rst(rtc);

utime = time(NULL);
Expand Down Expand Up @@ -404,4 +404,4 @@ unsigned char rtc_ds1307_I2C_io(rtc_ds1307_t* rtc, unsigned char scl, unsigned c
return ret;
}

// TODO int output
// TODO int output
18 changes: 10 additions & 8 deletions src/parts/output_Buzzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,16 @@ void cpart_Buzzer::PostProcess(void) {
}
}
} else if (btype == PASSIVE) {
buffer[buffercount - 1] = 0;
short* ptr[2];
ptr[0] = (short int*)&buffercount;
ptr[1] = buffer;
/*int ret =*/PICSimLab.SystemCmd(PSC_AUDIOCHSOUNDPLAY, (const char*)&buzzerId, ptr);
// printf("ret=%i buffercount=%i sample=%i time=%f timer=%i\n", ret, buffercount, samplerate,
// ((float)(buffercount)) / samplerate, timer->GetTime());
buffercount = 0;
if (buffercount) {
buffer[buffercount - 1] = 0;
short* ptr[2];
ptr[0] = (short int*)&buffercount;
ptr[1] = buffer;
/*int ret =*/PICSimLab.SystemCmd(PSC_AUDIOCHSOUNDPLAY, (const char*)&buzzerId, ptr);
// printf("ret=%i buffercount=%i sample=%i time=%f timer=%i\n", ret, buffercount, samplerate,
// ((float)(buffercount)) / samplerate, timer->GetTime());
buffercount = 0;
}
} else // TONE
{
float freq;
Expand Down

0 comments on commit 3337f96

Please sign in to comment.