Skip to content

Commit 08de8a1

Browse files
committed
save some more flash space
1 parent e96c644 commit 08de8a1

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

bootloader/main.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -197,17 +197,14 @@ typedef void (*pFunction)(void);
197197
#define CMD_SET_ADDRESS 0xFF
198198
#define CMD_SET_BUFFER 0xFE
199199

200-
static uint16_t low_pin_count;
201200
static char receiveByte;
202-
static int count;
203-
static char messagereceived;
204-
static uint16_t address_expected_increment;
201+
static bool messagereceived;
205202
static int cmd;
206203
static int received;
207204

208205
static uint8_t rxBuffer[258];
209206
static uint8_t payLoadBuffer[256];
210-
static char rxbyte;
207+
static uint8_t rxbyte;
211208
static uint32_t address;
212209
static uint32_t continue_address;
213210

@@ -527,7 +524,6 @@ static void decodeInput()
527524
payload_buffer_size = rxBuffer[3];
528525
}
529526
incoming_payload_no_command = 1;
530-
address_expected_increment = 256;
531527
setReceive();
532528

533529
return;
@@ -581,12 +577,10 @@ static void decodeInput()
581577
return;
582578
}
583579

584-
count++;
585580
uint16_t out_buffer_size = rxBuffer[1];//
586581
if (out_buffer_size == 0) {
587582
out_buffer_size = 256;
588583
}
589-
address_expected_increment = 128;
590584

591585
uint8_t read_data[out_buffer_size + 3]; // make buffer 3 larger to fit CRC and ACK
592586
memset(read_data, 0, sizeof(read_data));
@@ -702,7 +696,7 @@ static bool serialreadChar()
702696
}
703697

704698
// we got a good byte
705-
messagereceived = 1;
699+
messagereceived = true;
706700
receiveByte = rxbyte;
707701
#ifdef SERIAL_STATS
708702
stats.good++;
@@ -756,8 +750,8 @@ static void sendString(const uint8_t *data, int len)
756750

757751
static void receiveBuffer()
758752
{
759-
count = 0;
760-
messagereceived = 0;
753+
uint16_t count = 0;
754+
messagereceived = false;
761755
memset(rxBuffer, 0, sizeof(rxBuffer));
762756

763757
setReceive();
@@ -768,7 +762,7 @@ static void receiveBuffer()
768762
}
769763

770764
if (incoming_payload_no_command) {
771-
if (count == payload_buffer_size+2) {
765+
if (count == payload_buffer_size+2U) {
772766
break;
773767
}
774768
rxBuffer[i] = rxbyte;
@@ -832,6 +826,8 @@ static void update_EEPROM()
832826
#define pull_down_pin_count_interations 4000 // greater interations extend grace period for input devices booting with signal pin high
833827
static void checkForSignal()
834828
{
829+
uint16_t low_pin_count = 0;
830+
835831
gpio_mode_set_input(input_pin, GPIO_PULL_DOWN);
836832

837833
delayMicroseconds(500);

0 commit comments

Comments
 (0)