neopixel pmos control, power hold implemented

master
Ondřej Hruška 7 years ago
parent 0d5288a4f3
commit 2d58ca3e1f
  1. 4
      lib/iopins.h
  2. 15
      main.c
  3. 3
      pinout.h

@ -108,12 +108,12 @@ bool pin_read_n(uint8_t pin);
/** CHeck if pin is low */
#define pin_is_low(pin) (get_pin(pin) == 0)
#define pin_is_low(pin) (pin_read(pin) == 0)
bool pin_is_low_n(uint8_t pin);
/** CHeck if pin is high */
#define pin_is_high(pin) (get_pin(pin) != 0)
#define pin_is_high(pin) (pin_read(pin) != 0)
bool pin_is_high_n(uint8_t pin);

@ -33,6 +33,8 @@ void setup_io(void)
as_input(PIN_PWR_KEY);
as_output(PIN_PWR_HOLD);
as_output(PIN_NEOPIXEL_PWRN);
pin_up(PIN_NEOPIXEL_PWRN); // turn neopixels OFF
// PIN_LIGHT_SENSE is ADC exclusive, needs no config
}
@ -74,13 +76,22 @@ void main()
usart_init(BAUD_115200);
//usart_isr_rx_enable(true); // enable RX interrupt handler
adc_init(ADC_PRESC_128);
setup_io();
setup_pwm();
// Stay on
pin_up(D13); // the on-board LED (also SPI clk)
pin_up(PIN_PWR_HOLD);
// Wait for user to release the power key
while (pin_is_high(PIN_PWR_KEY));
// SPI conf
// TODO verify the cpha and cpol. those seem to work, but it's a guess
spi_init_master(SPI_LSB_FIRST, CPOL_1, CPHA_0, SPI_DIV_2);
adc_init(ADC_PRESC_128);
setup_pwm();
// Turn neopixels ON
pin_down(PIN_NEOPIXEL_PWRN);
// globally enable interrupts
sei();

@ -12,7 +12,7 @@
#define PIN_DISP_D D11 // MOSI
#define PIN_DISP_CP D13 // SCK
#define PIN_DISP_STR D10 // NSS, unused for SPI
#define PIN_DISP_OE D3 // SCK
#define PIN_DISP_OE D3 // OE (PWM)
// Touch keys
#define PIN_KEY_1 A0
@ -25,6 +25,7 @@
// NeoPixel data
#define PIN_NEOPIXEL D2
#define PIN_NEOPIXEL_PWRN D4 // PMOS gate
// Power
#define PIN_PWR_KEY A4 // Direct input from the power key, used for power-off

Loading…
Cancel
Save