diff options
| author | Gabriel Hart | 2021-02-01 10:33:43 -0600 |
|---|---|---|
| committer | Gabriel Hart | 2021-02-01 10:33:43 -0600 |
| commit | 4dfe5e628823c478124a03e381ee6bcdcb9ca314 (patch) | |
| tree | f572286b9751123b8d2c60cf4acfc1cf6e5fbf1c | |
| parent | Updated the Sofirn SP10S Anduril board (diff) | |
| download | anduril-4dfe5e628823c478124a03e381ee6bcdcb9ca314.tar.gz anduril-4dfe5e628823c478124a03e381ee6bcdcb9ca314.tar.bz2 anduril-4dfe5e628823c478124a03e381ee6bcdcb9ca314.zip | |
Add RGB Aux functionality for 1-Series
Diffstat (limited to '')
| -rw-r--r-- | hwdef-BLF_Q8-T1616.h | 5 | ||||
| -rw-r--r-- | hwdef-gchart-fet1-t16.h | 6 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/version.h | 2 | ||||
| -rw-r--r-- | spaghetti-monster/fsm-misc.c | 63 |
4 files changed, 47 insertions, 29 deletions
diff --git a/hwdef-BLF_Q8-T1616.h b/hwdef-BLF_Q8-T1616.h index a838655..6dfb4ab 100644 --- a/hwdef-BLF_Q8-T1616.h +++ b/hwdef-BLF_Q8-T1616.h @@ -24,7 +24,7 @@ Driver pinout: #define PWM_CHANNELS 2 #ifndef SWITCH_PIN -#define SWITCH_PIN 5 +#define SWITCH_PIN PIN5_bp #define SWITCH_PORT VPORTA.IN #define SWITCH_ISC_REG PORTA.PIN2CTRL #define SWITCH_VECT PORTA_PORT_vect @@ -52,9 +52,8 @@ Driver pinout: // lighted button #ifndef AUXLED_PIN -#define AUXLED_PIN PIN5_bm +#define AUXLED_PIN PIN5_bp #define AUXLED_PORT PORTB -#define AUXLED_CTRL PIN5CTRL #endif diff --git a/hwdef-gchart-fet1-t16.h b/hwdef-gchart-fet1-t16.h index 3a79586..e8fd11c 100644 --- a/hwdef-gchart-fet1-t16.h +++ b/hwdef-gchart-fet1-t16.h @@ -23,12 +23,11 @@ Read voltage from VCC pin, has diode with ~0.4v drop #define PWM_CHANNELS 2 #ifndef SWITCH_PIN -#define SWITCH_PIN 2 +#define SWITCH_PIN PIN2_bp #define SWITCH_PORT VPORTB.IN #define SWITCH_ISC_REG PORTB.PIN2CTRL #define SWITCH_VECT PORTB_PORT_vect #define SWITCH_INTFLG VPORTB.INTFLAGS -//#define SWITCH_ISC_REG _SFR_MEM8(&PORTB + 0x10 + SWITCH_PIN) #endif @@ -52,9 +51,8 @@ Read voltage from VCC pin, has diode with ~0.4v drop // lighted button #ifndef AUXLED_PIN -#define AUXLED_PIN PIN3_bm +#define AUXLED_PIN PIN3_bp #define AUXLED_PORT PORTB -#define AUXLED_CTRL PIN3CTRL #endif diff --git a/spaghetti-monster/anduril/version.h b/spaghetti-monster/anduril/version.h index e896823..14502aa 100644 --- a/spaghetti-monster/anduril/version.h +++ b/spaghetti-monster/anduril/version.h @@ -1 +1 @@ -#define VERSION_NUMBER "20210117" +#define VERSION_NUMBER "20210201" diff --git a/spaghetti-monster/fsm-misc.c b/spaghetti-monster/fsm-misc.c index 7ba9b45..edd982a 100644 --- a/spaghetti-monster/fsm-misc.c +++ b/spaghetti-monster/fsm-misc.c @@ -112,27 +112,29 @@ void indicator_led(uint8_t lvl) { switch (lvl) { #ifdef AVRXMEGA3 // ATTINY816, 817, etc case 0: // indicator off - AUXLED_PORT.DIRSET = AUXLED_PIN; // set as output - AUXLED_PORT.OUTCLR = AUXLED_PIN; // set output low + AUXLED_PORT.DIRSET = (1 << AUXLED_PIN); // set as output + AUXLED_PORT.OUTCLR = (1 << AUXLED_PIN); // set output low #ifdef AUXLED2_PIN // second LED mirrors the first - AUXLED2_PORT.DIRSET = AUXLED2_PIN; // set as output - AUXLED2_PORT.OUTCLR = AUXLED2_PIN; // set output low + AUXLED2_PORT.DIRSET = (1 << AUXLED2_PIN); // set as output + AUXLED2_PORT.OUTCLR = (1 << AUXLED2_PIN); // set output low #endif break; case 1: // indicator low - AUXLED_PORT.DIRCLR = AUXLED_PIN; // set as input - AUXLED_PORT.AUXLED_CTRL = PORT_PULLUPEN_bm; // enable internal pull-up + AUXLED_PORT.DIRCLR = (1 << AUXLED_PIN); // set as input + // this resolves to PORTx.PINxCTRL = PORT_PULLUPEN_bm; + *((uint8_t *)&AUXLED_PORT + 0x10 + AUXLED_PIN) = PORT_PULLUPEN_bm; // enable internal pull-up #ifdef AUXLED2_PIN // second LED mirrors the first - AUXLED2_PORT.DIRCLR = AUXLE2D_PIN; // set as input - AUXLED2_PORT.AUXLED2_CTRL = PORT_PULLUPEN_bm; // enable internal pull-up + AUXLED2_PORT.DIRCLR = (1 << AUXLED2_PIN); // set as input + // this resolves to PORTx.PINxCTRL = PORT_PULLUPEN_bm; + *((uint8_t *)&AUXLED2_PORT + 0x10 + AUXLED2_PIN) = PORT_PULLUPEN_bm; // enable internal pull-up #endif break; default: // indicator high - AUXLED_PORT.DIRSET = AUXLED_PIN; // set as output - AUXLED_PORT.OUTSET = AUXLED_PIN; // set as high + AUXLED_PORT.DIRSET = (1 << AUXLED_PIN); // set as output + AUXLED_PORT.OUTSET = (1 << AUXLED_PIN); // set as high #ifdef AUXLED2_PIN // second LED mirrors the first - AUXLED2_PORT.DIRSET = AUXLED2_PIN; // set as output - AUXLED2_PORT.OUTSET = AUXLED2_PIN; // set as high + AUXLED2_PORT.DIRSET = (1 << AUXLED2_PIN); // set as output + AUXLED2_PORT.OUTSET = (1 << AUXLED2_PIN); // set as high #endif break; @@ -182,16 +184,17 @@ void button_led_set(uint8_t lvl) { #ifdef AVRXMEGA3 // ATTINY816, 817, etc case 0: // LED off - BUTTON_LED_PORT.DIRSET = BUTTON_LED_PIN; // set as output - BUTTON_LED_PORT.OUTCLR = BUTTON_LED_PIN; // set output low + BUTTON_LED_PORT.DIRSET = (1 << BUTTON_LED_PIN); // set as output + BUTTON_LED_PORT.OUTCLR = (1 << BUTTON_LED_PIN); // set output low break; case 1: // LED low - BUTTON_LED_PORT.DIRCLR = BUTTON_LED_PIN; // set as input - BUTTON_LED_PORT.BUTTON_LED_CTRL = PORT_PULLUPEN_bm; // enable internal pull-up + BUTTON_LED_PORT.DIRCLR = (1 << BUTTON_LED_PIN); // set as input + // this resolves to PORTx.PINxCTRL = PORT_PULLUPEN_bm; + *((uint8_t *)&BUTTON_LED_PORT + 0x10 + BUTTON_LED_PIN) = PORT_PULLUPEN_bm; // enable internal pull-up break; default: // LED high - BUTTON_LED_PORT.DIRSET = BUTTON_LED_PIN; // set as output - BUTTON_LED_PORT.OUTSET = BUTTON_LED_PIN; // set as high + BUTTON_LED_PORT.DIRSET = (1 << BUTTON_LED_PIN); // set as output + BUTTON_LED_PORT.OUTSET = (1 << BUTTON_LED_PIN); // set as high break; #else @@ -218,9 +221,6 @@ void button_led_set(uint8_t lvl) { #endif #ifdef USE_AUX_RGB_LEDS -#ifdef AVRXMEGA3 // ATTINY816, 817, etc -#error Function rgb_led_set in fsm-misc is currently not set up for the AVR 1-Series -#endif void rgb_led_set(uint8_t value) { // value: 0b00BBGGRR uint8_t pins[] = { AUXLED_R_PIN, AUXLED_G_PIN, AUXLED_B_PIN }; @@ -228,6 +228,24 @@ void rgb_led_set(uint8_t value) { uint8_t lvl = (value >> (i<<1)) & 0x03; uint8_t pin = pins[i]; switch (lvl) { + + #ifdef AVRXMEGA3 // ATTINY816, 817, etc + case 0: // LED off + AUXLED_RGB_PORT.DIRSET = (1 << pin); // set as output + AUXLED_RGB_PORT.OUTCLR = (1 << pin); // set output low + break; + case 1: // LED low + AUXLED_RGB_PORT.DIRCLR = (1 << pin); // set as input + // this resolves to PORTx.PINxCTRL = PORT_PULLUPEN_bm; + *((uint8_t *)&AUXLED_RGB_PORT + 0x10 + pin) = PORT_PULLUPEN_bm; // enable internal pull-up + break; + default: // LED high + AUXLED_RGB_PORT.DIRSET = (1 << pin); // set as output + AUXLED_RGB_PORT.OUTSET = (1 << pin); // set as high + break; + + #else + case 0: // LED off AUXLED_RGB_DDR &= 0xff ^ (1 << pin); AUXLED_RGB_PUE &= 0xff ^ (1 << pin); @@ -243,6 +261,9 @@ void rgb_led_set(uint8_t value) { AUXLED_RGB_PUE |= (1 << pin); AUXLED_RGB_PORT |= (1 << pin); break; + + #endif + } } } |
