Skip to content

Commit

Permalink
Sync latest firmware
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgerhardt committed Jan 6, 2024
1 parent 285be0b commit 354b90d
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
#include "uart.h"
#include "swio.h"

#define TARGET_NRESET_PORT PORTB
#define TARGET_NRESET_DDR DDRB
#define TARGET_NRESET_BIT 1
#define TARGET_POWER_PORT PORTB
#define TARGET_POWER_DDR DDRB
#define TARGET_POWER_BIT 1

void target_reset(int x) {
void target_power(int x) {
if (x)
TARGET_NRESET_PORT &= ~_BV(TARGET_NRESET_BIT);
TARGET_POWER_PORT |= _BV(TARGET_POWER_BIT);
else
TARGET_NRESET_PORT |= _BV(TARGET_NRESET_BIT);
TARGET_POWER_PORT &= ~_BV(TARGET_POWER_BIT);
}

#define PROTOCOL_START '!'
#define PROTOCOL_ACK '+'
#define PROTOCOL_TEST '?'
#define PROTOCOL_RESET 'a'
#define PROTOCOL_NORES 'A'
#define PROTOCOL_POWER_ON 'p'
#define PROTOCOL_POWER_OFF 'P'
#define PROTOCOL_WRITE_REG 'w'
#define PROTOCOL_READ_REG 'r'

Expand All @@ -28,7 +28,7 @@ int main() {
uint32_t val;

// Make the target reset pin an output.
TARGET_NRESET_DDR |= _BV(TARGET_NRESET_BIT);
TARGET_POWER_DDR |= _BV(TARGET_POWER_BIT);

uart_init();
swio_init();
Expand All @@ -39,12 +39,12 @@ int main() {
case PROTOCOL_TEST:
fputc(PROTOCOL_ACK, uart);
break;
case PROTOCOL_RESET:
target_reset(1);
case PROTOCOL_POWER_ON:
target_power(1);
fputc(PROTOCOL_ACK, uart);
break;
case PROTOCOL_NORES:
target_reset(0);
case PROTOCOL_POWER_OFF:
target_power(0);
fputc(PROTOCOL_ACK, uart);
break;
case PROTOCOL_WRITE_REG:
Expand Down

0 comments on commit 354b90d

Please sign in to comment.