Skip to content

Commit

Permalink
chips/avr: Clear DDR and PORT registers during 'reset' operation
Browse files Browse the repository at this point in the history
This chip doesn't reboot at reset time so that USB stays active, this
means we need to carefully reset all of the GPIO registers. We
probably need to do more careful resetting of the timer registers too,
but there isn't ROM space available today.

Signed-off-by: Keith Packard <keithp@keithp.com>
  • Loading branch information
keith-packard committed Jun 1, 2019
1 parent 319cae7 commit 7c80abc
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions chips/avr/ao-snek-avr.c
Expand Up @@ -78,6 +78,9 @@ static uint8_t timer0_fract = 0;
#define FIRST_ADC 14

static uint8_t power[NUM_PIN];
static uint8_t power_pin;
static uint8_t dir_pin;
static uint8_t on_pins[NUM_PIN];

ISR(TIMER0_OVF_vect)
{
Expand Down Expand Up @@ -159,6 +162,16 @@ port_init(void)
OCR4C = 0xff;

memset(power, 0xff, NUM_PIN);
DDRB = 0;
DDRC = 0;
DDRD = 0;
DDRE = 0;
DDRF = 0;
PORTB = 0;
PORTC = 0;
PORTD = 0;
PORTE = 0;
PORTF = 0;
}

#include <avr/wdt.h>
Expand All @@ -181,10 +194,6 @@ main (void)
snek_parse();
}

static uint8_t power_pin;
static uint8_t dir_pin;
static uint8_t on_pins[NUM_PIN];

static const PROGMEM uint8_t _pin_map[NUM_PIN] = PIN_MAP;
static const PROGMEM uint8_t _adc_map[NUM_ADC] = ADC_MAP;
static uint8_t const PROGMEM ocr_reg_addrs[NUM_PIN] = OCR_REG_ADDRS;
Expand Down

0 comments on commit 7c80abc

Please sign in to comment.