Skip to content

Commit b83877d

Browse files
authored
Minor fixes from code review. (#25)
1 parent 18a8f65 commit b83877d

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/main/application/intf_port.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,11 @@ void intf_port_tick( tick_t tick )
132132

133133
void intf_port_usart_rx( void )
134134
{
135+
s_rx_tick = sys_get_tick();
136+
135137
while( rx_buf_avail() != 0 &&
136138
usart_rx( INTF_PORT_USART, s_rx_buf + s_rx_count, 1 ) )
137139
{
138-
s_rx_tick = sys_get_tick();
139140
s_rx_count++;
140141
evaluate_rx_buf();
141142
}
@@ -190,6 +191,13 @@ static void evaluate_rx_buf( void )
190191
return;
191192
}
192193
}
194+
else if( header->crc != 0 )
195+
{
196+
// Enforce a CRC of zero for zero-sized packets
197+
send_empty_packet( INTF_MESSAGE_REPLY_INVALID_CRC );
198+
s_rx_count = 0;
199+
return;
200+
}
193201

194202
// CRC check passed - process the packet then reset the buffer
195203
process_message( header, s_rx_buf + sizeof( intf_header_t ) );

src/main/drivers/eeprom.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,11 @@ static void strobe_write_enable( void )
301301
{
302302
// The write to EEPE must happen within 4 clock cycles of the write to EEMPE.
303303
// Clear interrupt flag while writing bits to prevent this from being interrupted.
304+
bool intrpt_en = sys_intrpt_enabled();
304305
sys_cli();
305306
set_bit( EECR, EEMPE ); // enable writes
306307
set_bit( EECR, EEPE ); // command write
307-
sys_sei();
308+
sys_set_intrpt_enabled( intrpt_en );
308309

309310
} /* strobe_write_enable() */
310311

0 commit comments

Comments
 (0)