diff options
Diffstat (limited to 'drivers')
57 files changed, 4882 insertions, 7001 deletions
diff --git a/drivers/arm/i2c_master.c b/drivers/arm/i2c_master.c index cba5a1c67..18068d3a6 100644 --- a/drivers/arm/i2c_master.c +++ b/drivers/arm/i2c_master.c | |||
| @@ -34,98 +34,83 @@ static uint8_t i2c_address; | |||
| 34 | 34 | ||
| 35 | static const I2CConfig i2cconfig = { | 35 | static const I2CConfig i2cconfig = { |
| 36 | #ifdef USE_I2CV1 | 36 | #ifdef USE_I2CV1 |
| 37 | I2C1_OPMODE, | 37 | I2C1_OPMODE, |
| 38 | I2C1_CLOCK_SPEED, | 38 | I2C1_CLOCK_SPEED, |
| 39 | I2C1_DUTY_CYCLE, | 39 | I2C1_DUTY_CYCLE, |
| 40 | #else | 40 | #else |
| 41 | STM32_TIMINGR_PRESC(I2C1_TIMINGR_PRESC) | | 41 | STM32_TIMINGR_PRESC(I2C1_TIMINGR_PRESC) | STM32_TIMINGR_SCLDEL(I2C1_TIMINGR_SCLDEL) | STM32_TIMINGR_SDADEL(I2C1_TIMINGR_SDADEL) | STM32_TIMINGR_SCLH(I2C1_TIMINGR_SCLH) | STM32_TIMINGR_SCLL(I2C1_TIMINGR_SCLL), 0, 0 |
| 42 | STM32_TIMINGR_SCLDEL(I2C1_TIMINGR_SCLDEL) | STM32_TIMINGR_SDADEL(I2C1_TIMINGR_SDADEL) | | ||
| 43 | STM32_TIMINGR_SCLH(I2C1_TIMINGR_SCLH) | STM32_TIMINGR_SCLL(I2C1_TIMINGR_SCLL), | ||
| 44 | 0, | ||
| 45 | 0 | ||
| 46 | #endif | 42 | #endif |
| 47 | }; | 43 | }; |
| 48 | 44 | ||
| 49 | static i2c_status_t chibios_to_qmk(const msg_t* status) { | 45 | static i2c_status_t chibios_to_qmk(const msg_t* status) { |
| 50 | switch (*status) { | 46 | switch (*status) { |
| 51 | case I2C_NO_ERROR: | 47 | case I2C_NO_ERROR: |
| 52 | return I2C_STATUS_SUCCESS; | 48 | return I2C_STATUS_SUCCESS; |
| 53 | case I2C_TIMEOUT: | 49 | case I2C_TIMEOUT: |
| 54 | return I2C_STATUS_TIMEOUT; | 50 | return I2C_STATUS_TIMEOUT; |
| 55 | // I2C_BUS_ERROR, I2C_ARBITRATION_LOST, I2C_ACK_FAILURE, I2C_OVERRUN, I2C_PEC_ERROR, I2C_SMB_ALERT | 51 | // I2C_BUS_ERROR, I2C_ARBITRATION_LOST, I2C_ACK_FAILURE, I2C_OVERRUN, I2C_PEC_ERROR, I2C_SMB_ALERT |
| 56 | default: | 52 | default: |
| 57 | return I2C_STATUS_ERROR; | 53 | return I2C_STATUS_ERROR; |
| 58 | } | 54 | } |
| 59 | } | 55 | } |
| 60 | 56 | ||
| 61 | __attribute__ ((weak)) | 57 | __attribute__((weak)) void i2c_init(void) { |
| 62 | void i2c_init(void) | 58 | // Try releasing special pins for a short time |
| 63 | { | 59 | palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_INPUT); |
| 64 | // Try releasing special pins for a short time | 60 | palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_INPUT); |
| 65 | palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_INPUT); | ||
| 66 | palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_INPUT); | ||
| 67 | 61 | ||
| 68 | chThdSleepMilliseconds(10); | 62 | chThdSleepMilliseconds(10); |
| 69 | 63 | ||
| 70 | #ifdef USE_I2CV1 | 64 | #ifdef USE_I2CV1 |
| 71 | palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_STM32_ALTERNATE_OPENDRAIN); | 65 | palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_STM32_ALTERNATE_OPENDRAIN); |
| 72 | palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_STM32_ALTERNATE_OPENDRAIN); | 66 | palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_STM32_ALTERNATE_OPENDRAIN); |
| 73 | #else | 67 | #else |
| 74 | palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_ALTERNATE(I2C1_SCL_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN); | 68 | palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_ALTERNATE(I2C1_SCL_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN); |
| 75 | palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_ALTERNATE(I2C1_SDA_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN); | 69 | palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_ALTERNATE(I2C1_SDA_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN); |
| 76 | #endif | 70 | #endif |
| 77 | 71 | ||
| 78 | //i2cInit(); //This is invoked by halInit() so no need to redo it. | 72 | // i2cInit(); //This is invoked by halInit() so no need to redo it. |
| 79 | } | 73 | } |
| 80 | 74 | ||
| 81 | i2c_status_t i2c_start(uint8_t address) | 75 | i2c_status_t i2c_start(uint8_t address) { |
| 82 | { | 76 | i2c_address = address; |
| 83 | i2c_address = address; | 77 | i2cStart(&I2C_DRIVER, &i2cconfig); |
| 84 | i2cStart(&I2C_DRIVER, &i2cconfig); | 78 | return I2C_STATUS_SUCCESS; |
| 85 | return I2C_STATUS_SUCCESS; | ||
| 86 | } | 79 | } |
| 87 | 80 | ||
| 88 | i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout) | 81 | i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout) { |
| 89 | { | 82 | i2c_address = address; |
| 90 | i2c_address = address; | 83 | i2cStart(&I2C_DRIVER, &i2cconfig); |
| 91 | i2cStart(&I2C_DRIVER, &i2cconfig); | 84 | msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, 0, 0, MS2ST(timeout)); |
| 92 | msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, 0, 0, MS2ST(timeout)); | 85 | return chibios_to_qmk(&status); |
| 93 | return chibios_to_qmk(&status); | ||
| 94 | } | 86 | } |
| 95 | 87 | ||
| 96 | i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout) | 88 | i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout) { |
| 97 | { | 89 | i2c_address = address; |
| 98 | i2c_address = address; | 90 | i2cStart(&I2C_DRIVER, &i2cconfig); |
| 99 | i2cStart(&I2C_DRIVER, &i2cconfig); | 91 | msg_t status = i2cMasterReceiveTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, MS2ST(timeout)); |
| 100 | msg_t status = i2cMasterReceiveTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, MS2ST(timeout)); | 92 | return chibios_to_qmk(&status); |
| 101 | return chibios_to_qmk(&status); | ||
| 102 | } | 93 | } |
| 103 | 94 | ||
| 104 | i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout) | 95 | i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout) { |
| 105 | { | 96 | i2c_address = devaddr; |
| 106 | i2c_address = devaddr; | 97 | i2cStart(&I2C_DRIVER, &i2cconfig); |
| 107 | i2cStart(&I2C_DRIVER, &i2cconfig); | ||
| 108 | 98 | ||
| 109 | uint8_t complete_packet[length + 1]; | 99 | uint8_t complete_packet[length + 1]; |
| 110 | for(uint8_t i = 0; i < length; i++) | 100 | for (uint8_t i = 0; i < length; i++) { |
| 111 | { | 101 | complete_packet[i + 1] = data[i]; |
| 112 | complete_packet[i+1] = data[i]; | 102 | } |
| 113 | } | 103 | complete_packet[0] = regaddr; |
| 114 | complete_packet[0] = regaddr; | ||
| 115 | 104 | ||
| 116 | msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), complete_packet, length + 1, 0, 0, MS2ST(timeout)); | 105 | msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), complete_packet, length + 1, 0, 0, MS2ST(timeout)); |
| 117 | return chibios_to_qmk(&status); | 106 | return chibios_to_qmk(&status); |
| 118 | } | 107 | } |
| 119 | 108 | ||
| 120 | i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout) | 109 | i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout) { |
| 121 | { | 110 | i2c_address = devaddr; |
| 122 | i2c_address = devaddr; | 111 | i2cStart(&I2C_DRIVER, &i2cconfig); |
| 123 | i2cStart(&I2C_DRIVER, &i2cconfig); | 112 | msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), ®addr, 1, data, length, MS2ST(timeout)); |
| 124 | msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), ®addr, 1, data, length, MS2ST(timeout)); | 113 | return chibios_to_qmk(&status); |
| 125 | return chibios_to_qmk(&status); | ||
| 126 | } | 114 | } |
| 127 | 115 | ||
| 128 | void i2c_stop(void) | 116 | void i2c_stop(void) { i2cStop(&I2C_DRIVER); } |
| 129 | { | ||
| 130 | i2cStop(&I2C_DRIVER); | ||
| 131 | } | ||
diff --git a/drivers/arm/i2c_master.h b/drivers/arm/i2c_master.h index c8afa31e2..b40fa0a91 100644 --- a/drivers/arm/i2c_master.h +++ b/drivers/arm/i2c_master.h | |||
| @@ -27,84 +27,83 @@ | |||
| 27 | #include "ch.h" | 27 | #include "ch.h" |
| 28 | #include <hal.h> | 28 | #include <hal.h> |
| 29 | 29 | ||
| 30 | |||
| 31 | #if defined(STM32F1XX) || defined(STM32F1xx) || defined(STM32F2xx) || defined(STM32F4xx) || defined(STM32L0xx) || defined(STM32L1xx) | 30 | #if defined(STM32F1XX) || defined(STM32F1xx) || defined(STM32F2xx) || defined(STM32F4xx) || defined(STM32L0xx) || defined(STM32L1xx) |
| 32 | #define USE_I2CV1 | 31 | # define USE_I2CV1 |
| 33 | #endif | 32 | #endif |
| 34 | 33 | ||
| 35 | #ifdef I2C1_BANK | 34 | #ifdef I2C1_BANK |
| 36 | #define I2C1_SCL_BANK I2C1_BANK | 35 | # define I2C1_SCL_BANK I2C1_BANK |
| 37 | #define I2C1_SDA_BANK I2C1_BANK | 36 | # define I2C1_SDA_BANK I2C1_BANK |
| 38 | #endif | 37 | #endif |
| 39 | 38 | ||
| 40 | #ifndef I2C1_SCL_BANK | 39 | #ifndef I2C1_SCL_BANK |
| 41 | #define I2C1_SCL_BANK GPIOB | 40 | # define I2C1_SCL_BANK GPIOB |
| 42 | #endif | 41 | #endif |
| 43 | 42 | ||
| 44 | #ifndef I2C1_SDA_BANK | 43 | #ifndef I2C1_SDA_BANK |
| 45 | #define I2C1_SDA_BANK GPIOB | 44 | # define I2C1_SDA_BANK GPIOB |
| 46 | #endif | 45 | #endif |
| 47 | 46 | ||
| 48 | #ifndef I2C1_SCL | 47 | #ifndef I2C1_SCL |
| 49 | #define I2C1_SCL 6 | 48 | # define I2C1_SCL 6 |
| 50 | #endif | 49 | #endif |
| 51 | #ifndef I2C1_SDA | 50 | #ifndef I2C1_SDA |
| 52 | #define I2C1_SDA 7 | 51 | # define I2C1_SDA 7 |
| 53 | #endif | 52 | #endif |
| 54 | 53 | ||
| 55 | #ifdef USE_I2CV1 | 54 | #ifdef USE_I2CV1 |
| 56 | #ifndef I2C1_OPMODE | 55 | # ifndef I2C1_OPMODE |
| 57 | #define I2C1_OPMODE OPMODE_I2C | 56 | # define I2C1_OPMODE OPMODE_I2C |
| 58 | #endif | 57 | # endif |
| 59 | #ifndef I2C1_CLOCK_SPEED | 58 | # ifndef I2C1_CLOCK_SPEED |
| 60 | #define I2C1_CLOCK_SPEED 100000 /* 400000 */ | 59 | # define I2C1_CLOCK_SPEED 100000 /* 400000 */ |
| 61 | #endif | 60 | # endif |
| 62 | #ifndef I2C1_DUTY_CYCLE | 61 | # ifndef I2C1_DUTY_CYCLE |
| 63 | #define I2C1_DUTY_CYCLE STD_DUTY_CYCLE /* FAST_DUTY_CYCLE_2 */ | 62 | # define I2C1_DUTY_CYCLE STD_DUTY_CYCLE /* FAST_DUTY_CYCLE_2 */ |
| 64 | #endif | 63 | # endif |
| 65 | #else | 64 | #else |
| 66 | // The default PAL alternate modes are used to signal that the pins are used for I2C | 65 | // The default PAL alternate modes are used to signal that the pins are used for I2C |
| 67 | #ifndef I2C1_SCL_PAL_MODE | 66 | # ifndef I2C1_SCL_PAL_MODE |
| 68 | #define I2C1_SCL_PAL_MODE 4 | 67 | # define I2C1_SCL_PAL_MODE 4 |
| 69 | #endif | 68 | # endif |
| 70 | #ifndef I2C1_SDA_PAL_MODE | 69 | # ifndef I2C1_SDA_PAL_MODE |
| 71 | #define I2C1_SDA_PAL_MODE 4 | 70 | # define I2C1_SDA_PAL_MODE 4 |
| 72 | #endif | 71 | # endif |
| 73 | 72 | ||
| 74 | // The default timing values below configures the I2C clock to 400khz assuming a 72Mhz clock | 73 | // The default timing values below configures the I2C clock to 400khz assuming a 72Mhz clock |
| 75 | // For more info : https://www.st.com/en/embedded-software/stsw-stm32126.html | 74 | // For more info : https://www.st.com/en/embedded-software/stsw-stm32126.html |
| 76 | #ifndef I2C1_TIMINGR_PRESC | 75 | # ifndef I2C1_TIMINGR_PRESC |
| 77 | #define I2C1_TIMINGR_PRESC 15U | 76 | # define I2C1_TIMINGR_PRESC 15U |
| 78 | #endif | 77 | # endif |
| 79 | #ifndef I2C1_TIMINGR_SCLDEL | 78 | # ifndef I2C1_TIMINGR_SCLDEL |
| 80 | #define I2C1_TIMINGR_SCLDEL 4U | 79 | # define I2C1_TIMINGR_SCLDEL 4U |
| 81 | #endif | 80 | # endif |
| 82 | #ifndef I2C1_TIMINGR_SDADEL | 81 | # ifndef I2C1_TIMINGR_SDADEL |
| 83 | #define I2C1_TIMINGR_SDADEL 2U | 82 | # define I2C1_TIMINGR_SDADEL 2U |
| 84 | #endif | 83 | # endif |
| 85 | #ifndef I2C1_TIMINGR_SCLH | 84 | # ifndef I2C1_TIMINGR_SCLH |
| 86 | #define I2C1_TIMINGR_SCLH 15U | 85 | # define I2C1_TIMINGR_SCLH 15U |
| 87 | #endif | 86 | # endif |
| 88 | #ifndef I2C1_TIMINGR_SCLL | 87 | # ifndef I2C1_TIMINGR_SCLL |
| 89 | #define I2C1_TIMINGR_SCLL 21U | 88 | # define I2C1_TIMINGR_SCLL 21U |
| 90 | #endif | 89 | # endif |
| 91 | #endif | 90 | #endif |
| 92 | 91 | ||
| 93 | #ifndef I2C_DRIVER | 92 | #ifndef I2C_DRIVER |
| 94 | #define I2C_DRIVER I2CD1 | 93 | # define I2C_DRIVER I2CD1 |
| 95 | #endif | 94 | #endif |
| 96 | 95 | ||
| 97 | typedef int16_t i2c_status_t; | 96 | typedef int16_t i2c_status_t; |
| 98 | 97 | ||
| 99 | #define I2C_STATUS_SUCCESS (0) | 98 | #define I2C_STATUS_SUCCESS (0) |
| 100 | #define I2C_STATUS_ERROR (-1) | 99 | #define I2C_STATUS_ERROR (-1) |
| 101 | #define I2C_STATUS_TIMEOUT (-2) | 100 | #define I2C_STATUS_TIMEOUT (-2) |
| 102 | 101 | ||
| 103 | void i2c_init(void); | 102 | void i2c_init(void); |
| 104 | i2c_status_t i2c_start(uint8_t address); | 103 | i2c_status_t i2c_start(uint8_t address); |
| 105 | i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout); | 104 | i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout); |
| 106 | i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout); | 105 | i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout); |
| 107 | i2c_status_t i2c_transmit_receive(uint8_t address, uint8_t * tx_body, uint16_t tx_length, uint8_t * rx_body, uint16_t rx_length); | 106 | i2c_status_t i2c_transmit_receive(uint8_t address, uint8_t* tx_body, uint16_t tx_length, uint8_t* rx_body, uint16_t rx_length); |
| 108 | i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout); | 107 | i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout); |
| 109 | i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout); | 108 | i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout); |
| 110 | void i2c_stop(void); | 109 | void i2c_stop(void); |
diff --git a/drivers/avr/analog.c b/drivers/avr/analog.c index 1ec38df75..1a8da4261 100644 --- a/drivers/avr/analog.c +++ b/drivers/avr/analog.c | |||
| @@ -21,49 +21,38 @@ | |||
| 21 | #include <stdint.h> | 21 | #include <stdint.h> |
| 22 | #include "analog.h" | 22 | #include "analog.h" |
| 23 | 23 | ||
| 24 | static uint8_t aref = (1 << REFS0); // default to AREF = Vcc | ||
| 24 | 25 | ||
| 25 | static uint8_t aref = (1<<REFS0); // default to AREF = Vcc | 26 | void analogReference(uint8_t mode) { aref = mode & 0xC0; } |
| 26 | |||
| 27 | |||
| 28 | void analogReference(uint8_t mode) | ||
| 29 | { | ||
| 30 | aref = mode & 0xC0; | ||
| 31 | } | ||
| 32 | |||
| 33 | 27 | ||
| 34 | // Arduino compatible pin input | 28 | // Arduino compatible pin input |
| 35 | int16_t analogRead(uint8_t pin) | 29 | int16_t analogRead(uint8_t pin) { |
| 36 | { | ||
| 37 | #if defined(__AVR_ATmega32U4__) | 30 | #if defined(__AVR_ATmega32U4__) |
| 38 | static const uint8_t PROGMEM pin_to_mux[] = { | 31 | static const uint8_t PROGMEM pin_to_mux[] = {0x00, 0x01, 0x04, 0x05, 0x06, 0x07, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20}; |
| 39 | 0x00, 0x01, 0x04, 0x05, 0x06, 0x07, | 32 | if (pin >= 12) return 0; |
| 40 | 0x25, 0x24, 0x23, 0x22, 0x21, 0x20}; | 33 | return adc_read(pgm_read_byte(pin_to_mux + pin)); |
| 41 | if (pin >= 12) return 0; | ||
| 42 | return adc_read(pgm_read_byte(pin_to_mux + pin)); | ||
| 43 | #elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) | 34 | #elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) |
| 44 | if (pin >= 8) return 0; | 35 | if (pin >= 8) return 0; |
| 45 | return adc_read(pin); | 36 | return adc_read(pin); |
| 46 | #else | 37 | #else |
| 47 | return 0; | 38 | return 0; |
| 48 | #endif | 39 | #endif |
| 49 | } | 40 | } |
| 50 | 41 | ||
| 51 | // Mux input | 42 | // Mux input |
| 52 | int16_t adc_read(uint8_t mux) | 43 | int16_t adc_read(uint8_t mux) { |
| 53 | { | ||
| 54 | #if defined(__AVR_AT90USB162__) | 44 | #if defined(__AVR_AT90USB162__) |
| 55 | return 0; | 45 | return 0; |
| 56 | #else | 46 | #else |
| 57 | uint8_t low; | 47 | uint8_t low; |
| 58 | 48 | ||
| 59 | ADCSRA = (1<<ADEN) | ADC_PRESCALER; // enable ADC | 49 | ADCSRA = (1 << ADEN) | ADC_PRESCALER; // enable ADC |
| 60 | ADCSRB = (1<<ADHSM) | (mux & 0x20); // high speed mode | 50 | ADCSRB = (1 << ADHSM) | (mux & 0x20); // high speed mode |
| 61 | ADMUX = aref | (mux & 0x1F); // configure mux input | 51 | ADMUX = aref | (mux & 0x1F); // configure mux input |
| 62 | ADCSRA = (1<<ADEN) | ADC_PRESCALER | (1<<ADSC); // start the conversion | 52 | ADCSRA = (1 << ADEN) | ADC_PRESCALER | (1 << ADSC); // start the conversion |
| 63 | while (ADCSRA & (1<<ADSC)) ; // wait for result | 53 | while (ADCSRA & (1 << ADSC)) |
| 64 | low = ADCL; // must read LSB first | 54 | ; // wait for result |
| 65 | return (ADCH << 8) | low; // must read MSB only once! | 55 | low = ADCL; // must read LSB first |
| 56 | return (ADCH << 8) | low; // must read MSB only once! | ||
| 66 | #endif | 57 | #endif |
| 67 | } | 58 | } |
| 68 | |||
| 69 | |||
diff --git a/drivers/avr/analog.h b/drivers/avr/analog.h index 8d93de7dc..32452a1ec 100644 --- a/drivers/avr/analog.h +++ b/drivers/avr/analog.h | |||
| @@ -19,34 +19,34 @@ | |||
| 19 | 19 | ||
| 20 | #include <stdint.h> | 20 | #include <stdint.h> |
| 21 | 21 | ||
| 22 | void analogReference(uint8_t mode); | 22 | void analogReference(uint8_t mode); |
| 23 | int16_t analogRead(uint8_t pin); | 23 | int16_t analogRead(uint8_t pin); |
| 24 | int16_t adc_read(uint8_t mux); | 24 | int16_t adc_read(uint8_t mux); |
| 25 | 25 | ||
| 26 | #define ADC_REF_POWER (1<<REFS0) | 26 | #define ADC_REF_POWER (1 << REFS0) |
| 27 | #define ADC_REF_INTERNAL ((1<<REFS1) | (1<<REFS0)) | 27 | #define ADC_REF_INTERNAL ((1 << REFS1) | (1 << REFS0)) |
| 28 | #define ADC_REF_EXTERNAL (0) | 28 | #define ADC_REF_EXTERNAL (0) |
| 29 | 29 | ||
| 30 | // These prescaler values are for high speed mode, ADHSM = 1 | 30 | // These prescaler values are for high speed mode, ADHSM = 1 |
| 31 | #if F_CPU == 16000000L | 31 | #if F_CPU == 16000000L |
| 32 | #define ADC_PRESCALER ((1<<ADPS2) | (1<<ADPS1)) | 32 | # define ADC_PRESCALER ((1 << ADPS2) | (1 << ADPS1)) |
| 33 | #elif F_CPU == 8000000L | 33 | #elif F_CPU == 8000000L |
| 34 | #define ADC_PRESCALER ((1<<ADPS2) | (1<<ADPS0)) | 34 | # define ADC_PRESCALER ((1 << ADPS2) | (1 << ADPS0)) |
| 35 | #elif F_CPU == 4000000L | 35 | #elif F_CPU == 4000000L |
| 36 | #define ADC_PRESCALER ((1<<ADPS2)) | 36 | # define ADC_PRESCALER ((1 << ADPS2)) |
| 37 | #elif F_CPU == 2000000L | 37 | #elif F_CPU == 2000000L |
| 38 | #define ADC_PRESCALER ((1<<ADPS1) | (1<<ADPS0)) | 38 | # define ADC_PRESCALER ((1 << ADPS1) | (1 << ADPS0)) |
| 39 | #elif F_CPU == 1000000L | 39 | #elif F_CPU == 1000000L |
| 40 | #define ADC_PRESCALER ((1<<ADPS1)) | 40 | # define ADC_PRESCALER ((1 << ADPS1)) |
| 41 | #else | 41 | #else |
| 42 | #define ADC_PRESCALER ((1<<ADPS0)) | 42 | # define ADC_PRESCALER ((1 << ADPS0)) |
| 43 | #endif | 43 | #endif |
| 44 | 44 | ||
| 45 | // some avr-libc versions do not properly define ADHSM | 45 | // some avr-libc versions do not properly define ADHSM |
| 46 | #if defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) | 46 | #if defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) |
| 47 | #if !defined(ADHSM) | 47 | # if !defined(ADHSM) |
| 48 | #define ADHSM (7) | 48 | # define ADHSM (7) |
| 49 | #endif | 49 | # endif |
| 50 | #endif | 50 | #endif |
| 51 | 51 | ||
| 52 | #endif | 52 | #endif |
diff --git a/drivers/avr/apa102.c b/drivers/avr/apa102.c index 55a0d5777..f4d97a158 100755..100644 --- a/drivers/avr/apa102.c +++ b/drivers/avr/apa102.c | |||
| @@ -1,24 +1,24 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * APA102 lib V1.0a | 2 | * APA102 lib V1.0a |
| 3 | * | 3 | * |
| 4 | * Controls APA102 RGB-LEDs | 4 | * Controls APA102 RGB-LEDs |
| 5 | * Author: Mikkel (Duckle29 on github) | 5 | * Author: Mikkel (Duckle29 on github) |
| 6 | * | 6 | * |
| 7 | * Dec 22th, 2017 v1.0a Initial Version | 7 | * Dec 22th, 2017 v1.0a Initial Version |
| 8 | * | 8 | * |
| 9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation, either version 2 of the License, or | 11 | * the Free Software Foundation, either version 2 of the License, or |
| 12 | * (at your option) any later version. | 12 | * (at your option) any later version. |
| 13 | * | 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, | 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. | 17 | * GNU General Public License for more details. |
| 18 | * | 18 | * |
| 19 | * You should have received a copy of the GNU General Public License | 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | #include "apa102.h" | 23 | #include "apa102.h" |
| 24 | #include <avr/interrupt.h> | 24 | #include <avr/interrupt.h> |
| @@ -27,75 +27,70 @@ | |||
| 27 | #include "debug.h" | 27 | #include "debug.h" |
| 28 | 28 | ||
| 29 | // Setleds for standard RGB | 29 | // Setleds for standard RGB |
| 30 | void inline apa102_setleds(LED_TYPE *ledarray, uint16_t leds){ | 30 | void inline apa102_setleds(LED_TYPE *ledarray, uint16_t leds) { apa102_setleds_pin(ledarray, leds, _BV(RGB_DI_PIN & 0xF), _BV(RGB_CLK_PIN & 0xF)); } |
| 31 | apa102_setleds_pin(ledarray,leds, _BV(RGB_DI_PIN & 0xF), _BV(RGB_CLK_PIN & 0xF)); | ||
| 32 | } | ||
| 33 | 31 | ||
| 34 | void static inline apa102_setleds_pin(LED_TYPE *ledarray, uint16_t leds, uint8_t pinmask_DI, uint8_t pinmask_CLK){ | 32 | void static inline apa102_setleds_pin(LED_TYPE *ledarray, uint16_t leds, uint8_t pinmask_DI, uint8_t pinmask_CLK) { |
| 35 | pinMode(RGB_DI_PIN, PinDirectionOutput); | 33 | pinMode(RGB_DI_PIN, PinDirectionOutput); |
| 36 | pinMode(RGB_CLK_PIN, PinDirectionOutput); | 34 | pinMode(RGB_CLK_PIN, PinDirectionOutput); |
| 37 | 35 | ||
| 38 | apa102_send_array((uint8_t*)ledarray,leds) | 36 | apa102_send_array((uint8_t *)ledarray, leds) |
| 39 | } | 37 | } |
| 40 | 38 | ||
| 41 | void apa102_send_array(uint8_t *data, uint16_t leds){ // Data is struct of 3 bytes. RGB - leds is number of leds in data | 39 | void apa102_send_array(uint8_t *data, uint16_t leds) { // Data is struct of 3 bytes. RGB - leds is number of leds in data |
| 42 | apa102_start_frame(); | 40 | apa102_start_frame(); |
| 43 | while(leds--){ | 41 | while (leds--) { |
| 44 | apa102_send_frame(0xFF000000 | (data->b << 16) | (data->g << 8) | data->r); | 42 | apa102_send_frame(0xFF000000 | (data->b << 16) | (data->g << 8) | data->r); |
| 45 | data++; | 43 | data++; |
| 46 | } | 44 | } |
| 47 | apa102_end_frame(leds); | 45 | apa102_end_frame(leds); |
| 48 | } | 46 | } |
| 49 | 47 | ||
| 50 | void apa102_send_frame(uint32_t frame){ | 48 | void apa102_send_frame(uint32_t frame) { |
| 51 | for(uint32_t i=0xFF; i>0;){ | 49 | for (uint32_t i = 0xFF; i > 0;) { |
| 52 | apa102_send_byte(frame & i); | 50 | apa102_send_byte(frame & i); |
| 53 | i = i << 8; | 51 | i = i << 8; |
| 54 | } | 52 | } |
| 55 | } | 53 | } |
| 56 | 54 | ||
| 57 | void apa102_start_frame(){ | 55 | void apa102_start_frame() { apa102_send_frame(0); } |
| 58 | apa102_send_frame(0); | ||
| 59 | } | ||
| 60 | 56 | ||
| 61 | void apa102_end_frame(uint16_t leds) | 57 | void apa102_end_frame(uint16_t leds) { |
| 62 | { | 58 | // This function has been taken from: https://github.com/pololu/apa102-arduino/blob/master/APA102.h |
| 63 | // This function has been taken from: https://github.com/pololu/apa102-arduino/blob/master/APA102.h | 59 | // and adapted. The code is MIT licensed. I think thats compatible? |
| 64 | // and adapted. The code is MIT licensed. I think thats compatible? | ||
| 65 | 60 | ||
| 66 | // We need to send some more bytes to ensure that all the LEDs in the | 61 | // We need to send some more bytes to ensure that all the LEDs in the |
| 67 | // chain see their new color and start displaying it. | 62 | // chain see their new color and start displaying it. |
| 68 | // | 63 | // |
| 69 | // The data stream seen by the last LED in the chain will be delayed by | 64 | // The data stream seen by the last LED in the chain will be delayed by |
| 70 | // (count - 1) clock edges, because each LED before it inverts the clock | 65 | // (count - 1) clock edges, because each LED before it inverts the clock |
| 71 | // line and delays the data by one clock edge. Therefore, to make sure | 66 | // line and delays the data by one clock edge. Therefore, to make sure |
| 72 | // the last LED actually receives the data we wrote, the number of extra | 67 | // the last LED actually receives the data we wrote, the number of extra |
| 73 | // edges we send at the end of the frame must be at least (count - 1). | 68 | // edges we send at the end of the frame must be at least (count - 1). |
| 74 | // For the APA102C, that is sufficient. | 69 | // For the APA102C, that is sufficient. |
| 75 | // | 70 | // |
| 76 | // The SK9822 only updates after it sees 32 zero bits followed by one more | 71 | // The SK9822 only updates after it sees 32 zero bits followed by one more |
| 77 | // rising edge. To avoid having the update time depend on the color of | 72 | // rising edge. To avoid having the update time depend on the color of |
| 78 | // the last LED, we send a dummy 0xFF byte. (Unfortunately, this means | 73 | // the last LED, we send a dummy 0xFF byte. (Unfortunately, this means |
| 79 | // that partial updates of the beginning of an LED strip are not possible; | 74 | // that partial updates of the beginning of an LED strip are not possible; |
| 80 | // the LED after the last one you are trying to update will be black.) | 75 | // the LED after the last one you are trying to update will be black.) |
| 81 | // After that, to ensure that the last LED in the chain sees 32 zero bits | 76 | // After that, to ensure that the last LED in the chain sees 32 zero bits |
| 82 | // and a rising edge, we need to send at least 65 + (count - 1) edges. It | 77 | // and a rising edge, we need to send at least 65 + (count - 1) edges. It |
| 83 | // is sufficent and simpler to just send (5 + count/16) bytes of zeros. | 78 | // is sufficent and simpler to just send (5 + count/16) bytes of zeros. |
| 84 | // | 79 | // |
| 85 | // We are ignoring the specification for the end frame in the APA102/SK9822 | 80 | // We are ignoring the specification for the end frame in the APA102/SK9822 |
| 86 | // datasheets because it does not actually ensure that all the LEDs will | 81 | // datasheets because it does not actually ensure that all the LEDs will |
| 87 | // start displaying their new colors right away. | 82 | // start displaying their new colors right away. |
| 88 | 83 | ||
| 89 | apa102_send_byte(0xFF); | 84 | apa102_send_byte(0xFF); |
| 90 | for (uint16_t i = 0; i < 5 + leds / 16; i++){ | 85 | for (uint16_t i = 0; i < 5 + leds / 16; i++) { |
| 91 | apa102_send_byte(0); | 86 | apa102_send_byte(0); |
| 92 | } | 87 | } |
| 93 | } | 88 | } |
| 94 | 89 | ||
| 95 | void apa102_send_byte(uint8_t byte){ | 90 | void apa102_send_byte(uint8_t byte) { |
| 96 | uint8_t i; | 91 | uint8_t i; |
| 97 | for (i = 0; i < 8; i++){ | 92 | for (i = 0; i < 8; i++) { |
| 98 | digitalWrite(RGB_DI_PIN, !!(byte & (1 << (7-i))); | 93 | digitalWrite(RGB_DI_PIN, !!(byte & (1 << (7-i))); |
| 99 | digitalWrite(RGB_CLK_PIN, PinLevelHigh); | 94 | digitalWrite(RGB_CLK_PIN, PinLevelHigh); |
| 100 | } | 95 | } |
| 101 | } | 96 | } |
diff --git a/drivers/avr/apa102.h b/drivers/avr/apa102.h index 5d852e067..d4c1e18ee 100755..100644 --- a/drivers/avr/apa102.h +++ b/drivers/avr/apa102.h | |||
| @@ -27,7 +27,6 @@ | |||
| 27 | 27 | ||
| 28 | #include "color.h" | 28 | #include "color.h" |
| 29 | 29 | ||
| 30 | |||
| 31 | /* User Interface | 30 | /* User Interface |
| 32 | * | 31 | * |
| 33 | * Input: | 32 | * Input: |
| @@ -41,6 +40,6 @@ | |||
| 41 | * - Wait 50�s to reset the LEDs | 40 | * - Wait 50�s to reset the LEDs |
| 42 | */ | 41 | */ |
| 43 | 42 | ||
| 44 | void apa102_setleds (LED_TYPE *ledarray, uint16_t number_of_leds); | 43 | void apa102_setleds(LED_TYPE *ledarray, uint16_t number_of_leds); |
| 45 | void apa102_setleds_pin (LED_TYPE *ledarray, uint16_t number_of_leds,uint8_t pinmask); | 44 | void apa102_setleds_pin(LED_TYPE *ledarray, uint16_t number_of_leds, uint8_t pinmask); |
| 46 | void apa102_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds); | 45 | void apa102_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds); |
diff --git a/drivers/avr/glcdfont.c b/drivers/avr/glcdfont.c index 6f88bd23a..2c332ea6d 100644 --- a/drivers/avr/glcdfont.c +++ b/drivers/avr/glcdfont.c | |||
| @@ -5,272 +5,30 @@ | |||
| 5 | #define FONT5X7_H | 5 | #define FONT5X7_H |
| 6 | 6 | ||
| 7 | #ifdef __AVR__ | 7 | #ifdef __AVR__ |
| 8 | #include <avr/io.h> | 8 | # include <avr/io.h> |
| 9 | #include <avr/pgmspace.h> | 9 | # include <avr/pgmspace.h> |
| 10 | #elif defined(ESP8266) | 10 | #elif defined(ESP8266) |
| 11 | #include <pgmspace.h> | 11 | # include <pgmspace.h> |
| 12 | #else | 12 | #else |
| 13 | #define PROGMEM | 13 | # define PROGMEM |
| 14 | #endif | 14 | #endif |
| 15 | 15 | ||
| 16 | // Standard ASCII 5x7 font | 16 | // Standard ASCII 5x7 font |
| 17 | 17 | ||
| 18 | static const unsigned char font[] PROGMEM = { | 18 | static const unsigned char font[] PROGMEM = { |
| 19 | 0x00, 0x00, 0x00, 0x00, 0x00, | 19 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00, 0x18, 0x3C, 0x18, 0x00, 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, 0x18, 0x24, 0x18, 0x00, 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x26, 0x29, 0x79, 0x29, 0x26, 0x40, 0x7F, 0x05, 0x05, 0x07, 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x14, 0x22, 0x7F, 0x22, 0x14, 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, 0x66, 0x89, 0x95, 0x6A, 0x60, 0x60, 0x60, 0x60, 0x60, 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x08, 0x04, 0x7E, 0x04, 0x08, 0x10, 0x20, 0x7E, 0x20, 0x10, 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x1E, 0x10, 0x10, 0x10, 0x10, 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, |
| 20 | 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, | 20 | 0x30, 0x38, 0x3E, 0x38, 0x30, 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x23, 0x13, 0x08, 0x64, 0x62, 0x36, 0x49, 0x56, 0x20, 0x50, 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, 0x41, 0x22, 0x1C, 0x00, 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, 0x80, 0x70, 0x30, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x60, 0x60, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x72, 0x49, 0x49, 0x49, 0x46, 0x21, 0x41, 0x49, 0x4D, 0x33, 0x18, 0x14, 0x12, 0x7F, 0x10, 0x27, 0x45, 0x45, 0x45, 0x39, 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x41, 0x21, 0x11, 0x09, 0x07, 0x36, 0x49, 0x49, 0x49, 0x36, 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x40, 0x34, 0x00, 0x00, |
| 21 | 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, | 21 | 0x00, 0x08, 0x14, 0x22, 0x41, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, 0x41, 0x22, 0x14, 0x08, 0x02, 0x01, 0x59, 0x09, 0x06, 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x7F, 0x49, 0x49, 0x49, 0x36, 0x3E, 0x41, 0x41, 0x41, 0x22, 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x7F, 0x49, 0x49, 0x49, 0x41, 0x7F, 0x09, 0x09, 0x09, 0x01, 0x3E, 0x41, 0x41, 0x51, 0x73, 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, 0x41, 0x7F, 0x41, 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, 0x7F, 0x08, 0x14, 0x22, 0x41, 0x7F, 0x40, 0x40, 0x40, 0x40, 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x7F, 0x09, 0x09, 0x09, 0x06, 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x7F, 0x09, 0x19, 0x29, 0x46, 0x26, 0x49, 0x49, 0x49, 0x32, 0x03, 0x01, 0x7F, 0x01, 0x03, 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x63, 0x14, 0x08, 0x14, 0x63, 0x03, 0x04, 0x78, 0x04, 0x03, |
| 22 | 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, | 22 | 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, 0x41, 0x41, 0x41, 0x7F, 0x04, 0x02, 0x01, 0x02, 0x04, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x03, 0x07, 0x08, 0x00, 0x20, 0x54, 0x54, 0x78, 0x40, 0x7F, 0x28, 0x44, 0x44, 0x38, 0x38, 0x44, 0x44, 0x44, 0x28, 0x38, 0x44, 0x44, 0x28, 0x7F, 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, 0x08, 0x7E, 0x09, 0x02, 0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, 0x44, 0x7D, 0x40, 0x00, 0x20, 0x40, 0x40, 0x3D, 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00, 0x7C, 0x04, 0x78, 0x04, 0x78, 0x7C, 0x08, 0x04, 0x04, 0x78, 0x38, 0x44, 0x44, 0x44, 0x38, 0xFC, 0x18, 0x24, 0x24, 0x18, 0x18, 0x24, 0x24, 0x18, 0xFC, 0x7C, 0x08, 0x04, 0x04, 0x08, 0x48, 0x54, 0x54, 0x54, 0x24, 0x04, 0x04, 0x3F, 0x44, 0x24, 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x3C, 0x40, 0x30, 0x40, 0x3C, |
| 23 | 0x18, 0x3C, 0x7E, 0x3C, 0x18, | 23 | 0x44, 0x28, 0x10, 0x28, 0x44, 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x41, 0x36, 0x08, 0x00, 0x02, 0x01, 0x02, 0x04, 0x02, 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x1E, 0xA1, 0xA1, 0x61, 0x12, 0x3A, 0x40, 0x40, 0x20, 0x7A, 0x38, 0x54, 0x54, 0x55, 0x59, 0x21, 0x55, 0x55, 0x79, 0x41, 0x22, 0x54, 0x54, 0x78, 0x42, // a-umlaut |
| 24 | 0x1C, 0x57, 0x7D, 0x57, 0x1C, | 24 | 0x21, 0x55, 0x54, 0x78, 0x40, 0x20, 0x54, 0x55, 0x79, 0x40, 0x0C, 0x1E, 0x52, 0x72, 0x12, 0x39, 0x55, 0x55, 0x55, 0x59, 0x39, 0x54, 0x54, 0x54, 0x59, 0x39, 0x55, 0x54, 0x54, 0x58, 0x00, 0x00, 0x45, 0x7C, 0x41, 0x00, 0x02, 0x45, 0x7D, 0x42, 0x00, 0x01, 0x45, 0x7C, 0x40, 0x7D, 0x12, 0x11, 0x12, 0x7D, // A-umlaut |
| 25 | 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, | 25 | 0xF0, 0x28, 0x25, 0x28, 0xF0, 0x7C, 0x54, 0x55, 0x45, 0x00, 0x20, 0x54, 0x54, 0x7C, 0x54, 0x7C, 0x0A, 0x09, 0x7F, 0x49, 0x32, 0x49, 0x49, 0x49, 0x32, 0x3A, 0x44, 0x44, 0x44, 0x3A, // o-umlaut |
| 26 | 0x00, 0x18, 0x3C, 0x18, 0x00, | 26 | 0x32, 0x4A, 0x48, 0x48, 0x30, 0x3A, 0x41, 0x41, 0x21, 0x7A, 0x3A, 0x42, 0x40, 0x20, 0x78, 0x00, 0x9D, 0xA0, 0xA0, 0x7D, 0x3D, 0x42, 0x42, 0x42, 0x3D, // O-umlaut |
| 27 | 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, | 27 | 0x3D, 0x40, 0x40, 0x40, 0x3D, 0x3C, 0x24, 0xFF, 0x24, 0x24, 0x48, 0x7E, 0x49, 0x43, 0x66, 0x2B, 0x2F, 0xFC, 0x2F, 0x2B, 0xFF, 0x09, 0x29, 0xF6, 0x20, 0xC0, 0x88, 0x7E, 0x09, 0x03, 0x20, 0x54, 0x54, 0x79, 0x41, 0x00, 0x00, 0x44, 0x7D, 0x41, 0x30, 0x48, 0x48, 0x4A, 0x32, 0x38, 0x40, 0x40, 0x22, 0x7A, 0x00, 0x7A, 0x0A, 0x0A, 0x72, 0x7D, 0x0D, 0x19, 0x31, 0x7D, 0x26, 0x29, 0x29, 0x2F, 0x28, 0x26, 0x29, 0x29, 0x29, 0x26, 0x30, 0x48, 0x4D, 0x40, 0x20, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x2F, 0x10, 0xC8, 0xAC, 0xBA, 0x2F, 0x10, 0x28, 0x34, 0xFA, 0x00, 0x00, 0x7B, 0x00, 0x00, 0x08, 0x14, 0x2A, 0x14, 0x22, 0x22, 0x14, 0x2A, 0x14, 0x08, 0x55, 0x00, 0x55, 0x00, 0x55, // #176 (25% block) missing in old code |
| 28 | 0x00, 0x18, 0x24, 0x18, 0x00, | 28 | 0xAA, 0x55, 0xAA, 0x55, 0xAA, // 50% block |
| 29 | 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, | 29 | 0xFF, 0x55, 0xFF, 0x55, 0xFF, // 75% block |
| 30 | 0x30, 0x48, 0x3A, 0x06, 0x0E, | 30 | 0x00, 0x00, 0x00, 0xFF, 0x00, 0x10, 0x10, 0x10, 0xFF, 0x00, 0x14, 0x14, 0x14, 0xFF, 0x00, 0x10, 0x10, 0xFF, 0x00, 0xFF, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x14, 0x14, 0x14, 0xFC, 0x00, 0x14, 0x14, 0xF7, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x14, 0x14, 0xF4, 0x04, 0xFC, 0x14, 0x14, 0x17, 0x10, 0x1F, 0x10, 0x10, 0x1F, 0x10, 0x1F, 0x14, 0x14, 0x14, 0x1F, 0x00, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x10, 0x10, 0x10, 0x10, 0xF0, 0x10, 0x00, 0x00, 0x00, 0xFF, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xFF, 0x10, 0x00, 0x00, 0x00, 0xFF, 0x14, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x1F, 0x10, 0x17, 0x00, 0x00, 0xFC, 0x04, 0xF4, 0x14, 0x14, 0x17, 0x10, 0x17, 0x14, 0x14, 0xF4, 0x04, 0xF4, 0x00, 0x00, 0xFF, 0x00, 0xF7, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0xF7, 0x00, 0xF7, 0x14, 0x14, 0x14, 0x17, 0x14, 0x10, 0x10, 0x1F, 0x10, 0x1F, |
| 31 | 0x26, 0x29, 0x79, 0x29, 0x26, | 31 | 0x14, 0x14, 0x14, 0xF4, 0x14, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x00, 0x00, 0x1F, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x1F, 0x14, 0x00, 0x00, 0x00, 0xFC, 0x14, 0x00, 0x00, 0xF0, 0x10, 0xF0, 0x10, 0x10, 0xFF, 0x10, 0xFF, 0x14, 0x14, 0x14, 0xFF, 0x14, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x38, 0x44, 0x44, 0x38, 0x44, 0xFC, 0x4A, 0x4A, 0x4A, 0x34, // sharp-s or beta |
| 32 | 0x40, 0x7F, 0x05, 0x05, 0x07, | 32 | 0x7E, 0x02, 0x02, 0x06, 0x06, 0x02, 0x7E, 0x02, 0x7E, 0x02, 0x63, 0x55, 0x49, 0x41, 0x63, 0x38, 0x44, 0x44, 0x3C, 0x04, 0x40, 0x7E, 0x20, 0x1E, 0x20, 0x06, 0x02, 0x7E, 0x02, 0x02, 0x99, 0xA5, 0xE7, 0xA5, 0x99, 0x1C, 0x2A, 0x49, 0x2A, 0x1C, 0x4C, 0x72, 0x01, 0x72, 0x4C, 0x30, 0x4A, 0x4D, 0x4D, 0x30, 0x30, 0x48, 0x78, 0x48, 0x30, 0xBC, 0x62, 0x5A, 0x46, 0x3D, 0x3E, 0x49, 0x49, 0x49, 0x00, 0x7E, 0x01, 0x01, 0x01, 0x7E, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x44, 0x44, 0x5F, 0x44, 0x44, 0x40, 0x51, 0x4A, 0x44, 0x40, 0x40, 0x44, 0x4A, 0x51, 0x40, 0x00, 0x00, 0xFF, 0x01, 0x03, 0xE0, 0x80, 0xFF, 0x00, 0x00, 0x08, 0x08, 0x6B, 0x6B, 0x08, 0x36, 0x12, 0x36, 0x24, 0x36, 0x06, 0x0F, 0x09, 0x0F, 0x06, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x30, 0x40, 0xFF, 0x01, 0x01, 0x00, 0x1F, 0x01, 0x01, 0x1E, 0x00, 0x19, 0x1D, 0x17, 0x12, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00 // #255 NBSP |
| 33 | 0x40, 0x7F, 0x05, 0x25, 0x3F, | ||
| 34 | 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, | ||
| 35 | 0x7F, 0x3E, 0x1C, 0x1C, 0x08, | ||
| 36 | 0x08, 0x1C, 0x1C, 0x3E, 0x7F, | ||
| 37 | 0x14, 0x22, 0x7F, 0x22, 0x14, | ||
| 38 | 0x5F, 0x5F, 0x00, 0x5F, 0x5F, | ||
| 39 | 0x06, 0x09, 0x7F, 0x01, 0x7F, | ||
| 40 | 0x00, 0x66, 0x89, 0x95, 0x6A, | ||
| 41 | 0x60, 0x60, 0x60, 0x60, 0x60, | ||
| 42 | 0x94, 0xA2, 0xFF, 0xA2, 0x94, | ||
| 43 | 0x08, 0x04, 0x7E, 0x04, 0x08, | ||
| 44 | 0x10, 0x20, 0x7E, 0x20, 0x10, | ||
| 45 | 0x08, 0x08, 0x2A, 0x1C, 0x08, | ||
| 46 | 0x08, 0x1C, 0x2A, 0x08, 0x08, | ||
| 47 | 0x1E, 0x10, 0x10, 0x10, 0x10, | ||
| 48 | 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, | ||
| 49 | 0x30, 0x38, 0x3E, 0x38, 0x30, | ||
| 50 | 0x06, 0x0E, 0x3E, 0x0E, 0x06, | ||
| 51 | 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 52 | 0x00, 0x00, 0x5F, 0x00, 0x00, | ||
| 53 | 0x00, 0x07, 0x00, 0x07, 0x00, | ||
| 54 | 0x14, 0x7F, 0x14, 0x7F, 0x14, | ||
| 55 | 0x24, 0x2A, 0x7F, 0x2A, 0x12, | ||
| 56 | 0x23, 0x13, 0x08, 0x64, 0x62, | ||
| 57 | 0x36, 0x49, 0x56, 0x20, 0x50, | ||
| 58 | 0x00, 0x08, 0x07, 0x03, 0x00, | ||
| 59 | 0x00, 0x1C, 0x22, 0x41, 0x00, | ||
| 60 | 0x00, 0x41, 0x22, 0x1C, 0x00, | ||
| 61 | 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, | ||
| 62 | 0x08, 0x08, 0x3E, 0x08, 0x08, | ||
| 63 | 0x00, 0x80, 0x70, 0x30, 0x00, | ||
| 64 | 0x08, 0x08, 0x08, 0x08, 0x08, | ||
| 65 | 0x00, 0x00, 0x60, 0x60, 0x00, | ||
| 66 | 0x20, 0x10, 0x08, 0x04, 0x02, | ||
| 67 | 0x3E, 0x51, 0x49, 0x45, 0x3E, | ||
| 68 | 0x00, 0x42, 0x7F, 0x40, 0x00, | ||
| 69 | 0x72, 0x49, 0x49, 0x49, 0x46, | ||
| 70 | 0x21, 0x41, 0x49, 0x4D, 0x33, | ||
| 71 | 0x18, 0x14, 0x12, 0x7F, 0x10, | ||
| 72 | 0x27, 0x45, 0x45, 0x45, 0x39, | ||
| 73 | 0x3C, 0x4A, 0x49, 0x49, 0x31, | ||
| 74 | 0x41, 0x21, 0x11, 0x09, 0x07, | ||
| 75 | 0x36, 0x49, 0x49, 0x49, 0x36, | ||
| 76 | 0x46, 0x49, 0x49, 0x29, 0x1E, | ||
| 77 | 0x00, 0x00, 0x14, 0x00, 0x00, | ||
| 78 | 0x00, 0x40, 0x34, 0x00, 0x00, | ||
| 79 | 0x00, 0x08, 0x14, 0x22, 0x41, | ||
| 80 | 0x14, 0x14, 0x14, 0x14, 0x14, | ||
| 81 | 0x00, 0x41, 0x22, 0x14, 0x08, | ||
| 82 | 0x02, 0x01, 0x59, 0x09, 0x06, | ||
| 83 | 0x3E, 0x41, 0x5D, 0x59, 0x4E, | ||
| 84 | 0x7C, 0x12, 0x11, 0x12, 0x7C, | ||
| 85 | 0x7F, 0x49, 0x49, 0x49, 0x36, | ||
| 86 | 0x3E, 0x41, 0x41, 0x41, 0x22, | ||
| 87 | 0x7F, 0x41, 0x41, 0x41, 0x3E, | ||
| 88 | 0x7F, 0x49, 0x49, 0x49, 0x41, | ||
| 89 | 0x7F, 0x09, 0x09, 0x09, 0x01, | ||
| 90 | 0x3E, 0x41, 0x41, 0x51, 0x73, | ||
| 91 | 0x7F, 0x08, 0x08, 0x08, 0x7F, | ||
| 92 | 0x00, 0x41, 0x7F, 0x41, 0x00, | ||
| 93 | 0x20, 0x40, 0x41, 0x3F, 0x01, | ||
| 94 | 0x7F, 0x08, 0x14, 0x22, 0x41, | ||
| 95 | 0x7F, 0x40, 0x40, 0x40, 0x40, | ||
| 96 | 0x7F, 0x02, 0x1C, 0x02, 0x7F, | ||
| 97 | 0x7F, 0x04, 0x08, 0x10, 0x7F, | ||
| 98 | 0x3E, 0x41, 0x41, 0x41, 0x3E, | ||
| 99 | 0x7F, 0x09, 0x09, 0x09, 0x06, | ||
| 100 | 0x3E, 0x41, 0x51, 0x21, 0x5E, | ||
| 101 | 0x7F, 0x09, 0x19, 0x29, 0x46, | ||
| 102 | 0x26, 0x49, 0x49, 0x49, 0x32, | ||
| 103 | 0x03, 0x01, 0x7F, 0x01, 0x03, | ||
| 104 | 0x3F, 0x40, 0x40, 0x40, 0x3F, | ||
| 105 | 0x1F, 0x20, 0x40, 0x20, 0x1F, | ||
| 106 | 0x3F, 0x40, 0x38, 0x40, 0x3F, | ||
| 107 | 0x63, 0x14, 0x08, 0x14, 0x63, | ||
| 108 | 0x03, 0x04, 0x78, 0x04, 0x03, | ||
| 109 | 0x61, 0x59, 0x49, 0x4D, 0x43, | ||
| 110 | 0x00, 0x7F, 0x41, 0x41, 0x41, | ||
| 111 | 0x02, 0x04, 0x08, 0x10, 0x20, | ||
| 112 | 0x00, 0x41, 0x41, 0x41, 0x7F, | ||
| 113 | 0x04, 0x02, 0x01, 0x02, 0x04, | ||
| 114 | 0x40, 0x40, 0x40, 0x40, 0x40, | ||
| 115 | 0x00, 0x03, 0x07, 0x08, 0x00, | ||
| 116 | 0x20, 0x54, 0x54, 0x78, 0x40, | ||
| 117 | 0x7F, 0x28, 0x44, 0x44, 0x38, | ||
| 118 | 0x38, 0x44, 0x44, 0x44, 0x28, | ||
| 119 | 0x38, 0x44, 0x44, 0x28, 0x7F, | ||
| 120 | 0x38, 0x54, 0x54, 0x54, 0x18, | ||
| 121 | 0x00, 0x08, 0x7E, 0x09, 0x02, | ||
| 122 | 0x18, 0xA4, 0xA4, 0x9C, 0x78, | ||
| 123 | 0x7F, 0x08, 0x04, 0x04, 0x78, | ||
| 124 | 0x00, 0x44, 0x7D, 0x40, 0x00, | ||
| 125 | 0x20, 0x40, 0x40, 0x3D, 0x00, | ||
| 126 | 0x7F, 0x10, 0x28, 0x44, 0x00, | ||
| 127 | 0x00, 0x41, 0x7F, 0x40, 0x00, | ||
| 128 | 0x7C, 0x04, 0x78, 0x04, 0x78, | ||
| 129 | 0x7C, 0x08, 0x04, 0x04, 0x78, | ||
| 130 | 0x38, 0x44, 0x44, 0x44, 0x38, | ||
| 131 | 0xFC, 0x18, 0x24, 0x24, 0x18, | ||
| 132 | 0x18, 0x24, 0x24, 0x18, 0xFC, | ||
| 133 | 0x7C, 0x08, 0x04, 0x04, 0x08, | ||
| 134 | 0x48, 0x54, 0x54, 0x54, 0x24, | ||
| 135 | 0x04, 0x04, 0x3F, 0x44, 0x24, | ||
| 136 | 0x3C, 0x40, 0x40, 0x20, 0x7C, | ||
| 137 | 0x1C, 0x20, 0x40, 0x20, 0x1C, | ||
| 138 | 0x3C, 0x40, 0x30, 0x40, 0x3C, | ||
| 139 | 0x44, 0x28, 0x10, 0x28, 0x44, | ||
| 140 | 0x4C, 0x90, 0x90, 0x90, 0x7C, | ||
| 141 | 0x44, 0x64, 0x54, 0x4C, 0x44, | ||
| 142 | 0x00, 0x08, 0x36, 0x41, 0x00, | ||
| 143 | 0x00, 0x00, 0x77, 0x00, 0x00, | ||
| 144 | 0x00, 0x41, 0x36, 0x08, 0x00, | ||
| 145 | 0x02, 0x01, 0x02, 0x04, 0x02, | ||
| 146 | 0x3C, 0x26, 0x23, 0x26, 0x3C, | ||
| 147 | 0x1E, 0xA1, 0xA1, 0x61, 0x12, | ||
| 148 | 0x3A, 0x40, 0x40, 0x20, 0x7A, | ||
| 149 | 0x38, 0x54, 0x54, 0x55, 0x59, | ||
| 150 | 0x21, 0x55, 0x55, 0x79, 0x41, | ||
| 151 | 0x22, 0x54, 0x54, 0x78, 0x42, // a-umlaut | ||
| 152 | 0x21, 0x55, 0x54, 0x78, 0x40, | ||
| 153 | 0x20, 0x54, 0x55, 0x79, 0x40, | ||
| 154 | 0x0C, 0x1E, 0x52, 0x72, 0x12, | ||
| 155 | 0x39, 0x55, 0x55, 0x55, 0x59, | ||
| 156 | 0x39, 0x54, 0x54, 0x54, 0x59, | ||
| 157 | 0x39, 0x55, 0x54, 0x54, 0x58, | ||
| 158 | 0x00, 0x00, 0x45, 0x7C, 0x41, | ||
| 159 | 0x00, 0x02, 0x45, 0x7D, 0x42, | ||
| 160 | 0x00, 0x01, 0x45, 0x7C, 0x40, | ||
| 161 | 0x7D, 0x12, 0x11, 0x12, 0x7D, // A-umlaut | ||
| 162 | 0xF0, 0x28, 0x25, 0x28, 0xF0, | ||
| 163 | 0x7C, 0x54, 0x55, 0x45, 0x00, | ||
| 164 | 0x20, 0x54, 0x54, 0x7C, 0x54, | ||
| 165 | 0x7C, 0x0A, 0x09, 0x7F, 0x49, | ||
| 166 | 0x32, 0x49, 0x49, 0x49, 0x32, | ||
| 167 | 0x3A, 0x44, 0x44, 0x44, 0x3A, // o-umlaut | ||
| 168 | 0x32, 0x4A, 0x48, 0x48, 0x30, | ||
| 169 | 0x3A, 0x41, 0x41, 0x21, 0x7A, | ||
| 170 | 0x3A, 0x42, 0x40, 0x20, 0x78, | ||
| 171 | 0x00, 0x9D, 0xA0, 0xA0, 0x7D, | ||
| 172 | 0x3D, 0x42, 0x42, 0x42, 0x3D, // O-umlaut | ||
| 173 | 0x3D, 0x40, 0x40, 0x40, 0x3D, | ||
| 174 | 0x3C, 0x24, 0xFF, 0x24, 0x24, | ||
| 175 | 0x48, 0x7E, 0x49, 0x43, 0x66, | ||
| 176 | 0x2B, 0x2F, 0xFC, 0x2F, 0x2B, | ||
| 177 | 0xFF, 0x09, 0x29, 0xF6, 0x20, | ||
| 178 | 0xC0, 0x88, 0x7E, 0x09, 0x03, | ||
| 179 | 0x20, 0x54, 0x54, 0x79, 0x41, | ||
| 180 | 0x00, 0x00, 0x44, 0x7D, 0x41, | ||
| 181 | 0x30, 0x48, 0x48, 0x4A, 0x32, | ||
| 182 | 0x38, 0x40, 0x40, 0x22, 0x7A, | ||
| 183 | 0x00, 0x7A, 0x0A, 0x0A, 0x72, | ||
| 184 | 0x7D, 0x0D, 0x19, 0x31, 0x7D, | ||
| 185 | 0x26, 0x29, 0x29, 0x2F, 0x28, | ||
| 186 | 0x26, 0x29, 0x29, 0x29, 0x26, | ||
| 187 | 0x30, 0x48, 0x4D, 0x40, 0x20, | ||
| 188 | 0x38, 0x08, 0x08, 0x08, 0x08, | ||
| 189 | 0x08, 0x08, 0x08, 0x08, 0x38, | ||
| 190 | 0x2F, 0x10, 0xC8, 0xAC, 0xBA, | ||
| 191 | 0x2F, 0x10, 0x28, 0x34, 0xFA, | ||
| 192 | 0x00, 0x00, 0x7B, 0x00, 0x00, | ||
| 193 | 0x08, 0x14, 0x2A, 0x14, 0x22, | ||
| 194 | 0x22, 0x14, 0x2A, 0x14, 0x08, | ||
| 195 | 0x55, 0x00, 0x55, 0x00, 0x55, // #176 (25% block) missing in old code | ||
| 196 | 0xAA, 0x55, 0xAA, 0x55, 0xAA, // 50% block | ||
| 197 | 0xFF, 0x55, 0xFF, 0x55, 0xFF, // 75% block | ||
| 198 | 0x00, 0x00, 0x00, 0xFF, 0x00, | ||
| 199 | 0x10, 0x10, 0x10, 0xFF, 0x00, | ||
| 200 | 0x14, 0x14, 0x14, 0xFF, 0x00, | ||
| 201 | 0x10, 0x10, 0xFF, 0x00, 0xFF, | ||
| 202 | 0x10, 0x10, 0xF0, 0x10, 0xF0, | ||
| 203 | 0x14, 0x14, 0x14, 0xFC, 0x00, | ||
| 204 | 0x14, 0x14, 0xF7, 0x00, 0xFF, | ||
| 205 | 0x00, 0x00, 0xFF, 0x00, 0xFF, | ||
| 206 | 0x14, 0x14, 0xF4, 0x04, 0xFC, | ||
| 207 | 0x14, 0x14, 0x17, 0x10, 0x1F, | ||
| 208 | 0x10, 0x10, 0x1F, 0x10, 0x1F, | ||
| 209 | 0x14, 0x14, 0x14, 0x1F, 0x00, | ||
| 210 | 0x10, 0x10, 0x10, 0xF0, 0x00, | ||
| 211 | 0x00, 0x00, 0x00, 0x1F, 0x10, | ||
| 212 | 0x10, 0x10, 0x10, 0x1F, 0x10, | ||
| 213 | 0x10, 0x10, 0x10, 0xF0, 0x10, | ||
| 214 | 0x00, 0x00, 0x00, 0xFF, 0x10, | ||
| 215 | 0x10, 0x10, 0x10, 0x10, 0x10, | ||
| 216 | 0x10, 0x10, 0x10, 0xFF, 0x10, | ||
| 217 | 0x00, 0x00, 0x00, 0xFF, 0x14, | ||
| 218 | 0x00, 0x00, 0xFF, 0x00, 0xFF, | ||
| 219 | 0x00, 0x00, 0x1F, 0x10, 0x17, | ||
| 220 | 0x00, 0x00, 0xFC, 0x04, 0xF4, | ||
| 221 | 0x14, 0x14, 0x17, 0x10, 0x17, | ||
| 222 | 0x14, 0x14, 0xF4, 0x04, 0xF4, | ||
| 223 | 0x00, 0x00, 0xFF, 0x00, 0xF7, | ||
| 224 | 0x14, 0x14, 0x14, 0x14, 0x14, | ||
| 225 | 0x14, 0x14, 0xF7, 0x00, 0xF7, | ||
| 226 | 0x14, 0x14, 0x14, 0x17, 0x14, | ||
| 227 | 0x10, 0x10, 0x1F, 0x10, 0x1F, | ||
| 228 | 0x14, 0x14, 0x14, 0xF4, 0x14, | ||
| 229 | 0x10, 0x10, 0xF0, 0x10, 0xF0, | ||
| 230 | 0x00, 0x00, 0x1F, 0x10, 0x1F, | ||
| 231 | 0x00, 0x00, 0x00, 0x1F, 0x14, | ||
| 232 | 0x00, 0x00, 0x00, 0xFC, 0x14, | ||
| 233 | 0x00, 0x00, 0xF0, 0x10, 0xF0, | ||
| 234 | 0x10, 0x10, 0xFF, 0x10, 0xFF, | ||
| 235 | 0x14, 0x14, 0x14, 0xFF, 0x14, | ||
| 236 | 0x10, 0x10, 0x10, 0x1F, 0x00, | ||
| 237 | 0x00, 0x00, 0x00, 0xF0, 0x10, | ||
| 238 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | ||
| 239 | 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, | ||
| 240 | 0xFF, 0xFF, 0xFF, 0x00, 0x00, | ||
| 241 | 0x00, 0x00, 0x00, 0xFF, 0xFF, | ||
| 242 | 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, | ||
| 243 | 0x38, 0x44, 0x44, 0x38, 0x44, | ||
| 244 | 0xFC, 0x4A, 0x4A, 0x4A, 0x34, // sharp-s or beta | ||
| 245 | 0x7E, 0x02, 0x02, 0x06, 0x06, | ||
| 246 | 0x02, 0x7E, 0x02, 0x7E, 0x02, | ||
| 247 | 0x63, 0x55, 0x49, 0x41, 0x63, | ||
| 248 | 0x38, 0x44, 0x44, 0x3C, 0x04, | ||
| 249 | 0x40, 0x7E, 0x20, 0x1E, 0x20, | ||
| 250 | 0x06, 0x02, 0x7E, 0x02, 0x02, | ||
| 251 | 0x99, 0xA5, 0xE7, 0xA5, 0x99, | ||
| 252 | 0x1C, 0x2A, 0x49, 0x2A, 0x1C, | ||
| 253 | 0x4C, 0x72, 0x01, 0x72, 0x4C, | ||
| 254 | 0x30, 0x4A, 0x4D, 0x4D, 0x30, | ||
| 255 | 0x30, 0x48, 0x78, 0x48, 0x30, | ||
| 256 | 0xBC, 0x62, 0x5A, 0x46, 0x3D, | ||
| 257 | 0x3E, 0x49, 0x49, 0x49, 0x00, | ||
| 258 | 0x7E, 0x01, 0x01, 0x01, 0x7E, | ||
| 259 | 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, | ||
| 260 | 0x44, 0x44, 0x5F, 0x44, 0x44, | ||
| 261 | 0x40, 0x51, 0x4A, 0x44, 0x40, | ||
| 262 | 0x40, 0x44, 0x4A, 0x51, 0x40, | ||
| 263 | 0x00, 0x00, 0xFF, 0x01, 0x03, | ||
| 264 | 0xE0, 0x80, 0xFF, 0x00, 0x00, | ||
| 265 | 0x08, 0x08, 0x6B, 0x6B, 0x08, | ||
| 266 | 0x36, 0x12, 0x36, 0x24, 0x36, | ||
| 267 | 0x06, 0x0F, 0x09, 0x0F, 0x06, | ||
| 268 | 0x00, 0x00, 0x18, 0x18, 0x00, | ||
| 269 | 0x00, 0x00, 0x10, 0x10, 0x00, | ||
| 270 | 0x30, 0x40, 0xFF, 0x01, 0x01, | ||
| 271 | 0x00, 0x1F, 0x01, 0x01, 0x1E, | ||
| 272 | 0x00, 0x19, 0x1D, 0x17, 0x12, | ||
| 273 | 0x00, 0x3C, 0x3C, 0x3C, 0x3C, | ||
| 274 | 0x00, 0x00, 0x00, 0x00, 0x00 // #255 NBSP | ||
| 275 | }; | 33 | }; |
| 276 | #endif // FONT5X7_H | 34 | #endif // FONT5X7_H |
diff --git a/drivers/avr/hd44780.c b/drivers/avr/hd44780.c index 51414d8f9..f71069dec 100644 --- a/drivers/avr/hd44780.c +++ b/drivers/avr/hd44780.c | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | Author: Peter Fleury <pfleury@gmx.ch> http://tinyurl.com/peterfleury | 3 | Author: Peter Fleury <pfleury@gmx.ch> http://tinyurl.com/peterfleury |
| 4 | License: GNU General Public License Version 3 | 4 | License: GNU General Public License Version 3 |
| 5 | File: $Id: lcd.c,v 1.15.2.2 2015/01/17 12:16:05 peter Exp $ | 5 | File: $Id: lcd.c,v 1.15.2.2 2015/01/17 12:16:05 peter Exp $ |
| 6 | Software: AVR-GCC 3.3 | 6 | Software: AVR-GCC 3.3 |
| 7 | Target: any AVR device, memory mapped mode only for AT90S4414/8515/Mega | 7 | Target: any AVR device, memory mapped mode only for AT90S4414/8515/Mega |
| 8 | 8 | ||
| 9 | DESCRIPTION | 9 | DESCRIPTION |
| @@ -13,15 +13,15 @@ | |||
| 13 | changed lcd_init(), added additional constants for lcd_command(), | 13 | changed lcd_init(), added additional constants for lcd_command(), |
| 14 | added 4-bit I/O mode, improved and optimized code. | 14 | added 4-bit I/O mode, improved and optimized code. |
| 15 | 15 | ||
| 16 | Library can be operated in memory mapped mode (LCD_IO_MODE=0) or in | 16 | Library can be operated in memory mapped mode (LCD_IO_MODE=0) or in |
| 17 | 4-bit IO port mode (LCD_IO_MODE=1). 8-bit IO port mode not supported. | 17 | 4-bit IO port mode (LCD_IO_MODE=1). 8-bit IO port mode not supported. |
| 18 | 18 | ||
| 19 | Memory mapped mode compatible with Kanda STK200, but supports also | 19 | Memory mapped mode compatible with Kanda STK200, but supports also |
| 20 | generation of R/W signal through A8 address line. | 20 | generation of R/W signal through A8 address line. |
| 21 | 21 | ||
| 22 | USAGE | 22 | USAGE |
| 23 | See the C include lcd.h file for a description of each function | 23 | See the C include lcd.h file for a description of each function |
| 24 | 24 | ||
| 25 | *****************************************************************************/ | 25 | *****************************************************************************/ |
| 26 | #include <inttypes.h> | 26 | #include <inttypes.h> |
| 27 | #include <avr/io.h> | 27 | #include <avr/io.h> |
| @@ -29,55 +29,54 @@ | |||
| 29 | #include <util/delay.h> | 29 | #include <util/delay.h> |
| 30 | #include "hd44780.h" | 30 | #include "hd44780.h" |
| 31 | 31 | ||
| 32 | /* | 32 | /* |
| 33 | ** constants/macros | 33 | ** constants/macros |
| 34 | */ | 34 | */ |
| 35 | #define DDR(x) (*(&x - 1)) /* address of data direction register of port x */ | 35 | #define DDR(x) (*(&x - 1)) /* address of data direction register of port x */ |
| 36 | #if defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) | 36 | #if defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) |
| 37 | /* on ATmega64/128 PINF is on port 0x00 and not 0x60 */ | 37 | /* on ATmega64/128 PINF is on port 0x00 and not 0x60 */ |
| 38 | #define PIN(x) ( &PORTF==&(x) ? _SFR_IO8(0x00) : (*(&x - 2)) ) | 38 | # define PIN(x) (&PORTF == &(x) ? _SFR_IO8(0x00) : (*(&x - 2))) |
| 39 | #else | 39 | #else |
| 40 | #define PIN(x) (*(&x - 2)) /* address of input register of port x */ | 40 | # define PIN(x) (*(&x - 2)) /* address of input register of port x */ |
| 41 | #endif | 41 | #endif |
| 42 | 42 | ||
| 43 | |||
| 44 | #if LCD_IO_MODE | 43 | #if LCD_IO_MODE |
| 45 | #define lcd_e_delay() _delay_us(LCD_DELAY_ENABLE_PULSE) | 44 | # define lcd_e_delay() _delay_us(LCD_DELAY_ENABLE_PULSE) |
| 46 | #define lcd_e_high() LCD_E_PORT |= _BV(LCD_E_PIN); | 45 | # define lcd_e_high() LCD_E_PORT |= _BV(LCD_E_PIN); |
| 47 | #define lcd_e_low() LCD_E_PORT &= ~_BV(LCD_E_PIN); | 46 | # define lcd_e_low() LCD_E_PORT &= ~_BV(LCD_E_PIN); |
| 48 | #define lcd_e_toggle() toggle_e() | 47 | # define lcd_e_toggle() toggle_e() |
| 49 | #define lcd_rw_high() LCD_RW_PORT |= _BV(LCD_RW_PIN) | 48 | # define lcd_rw_high() LCD_RW_PORT |= _BV(LCD_RW_PIN) |
| 50 | #define lcd_rw_low() LCD_RW_PORT &= ~_BV(LCD_RW_PIN) | 49 | # define lcd_rw_low() LCD_RW_PORT &= ~_BV(LCD_RW_PIN) |
| 51 | #define lcd_rs_high() LCD_RS_PORT |= _BV(LCD_RS_PIN) | 50 | # define lcd_rs_high() LCD_RS_PORT |= _BV(LCD_RS_PIN) |
| 52 | #define lcd_rs_low() LCD_RS_PORT &= ~_BV(LCD_RS_PIN) | 51 | # define lcd_rs_low() LCD_RS_PORT &= ~_BV(LCD_RS_PIN) |
| 53 | #endif | 52 | #endif |
| 54 | 53 | ||
| 55 | #if LCD_IO_MODE | 54 | #if LCD_IO_MODE |
| 56 | #if LCD_LINES==1 | 55 | # if LCD_LINES == 1 |
| 57 | #define LCD_FUNCTION_DEFAULT LCD_FUNCTION_4BIT_1LINE | 56 | # define LCD_FUNCTION_DEFAULT LCD_FUNCTION_4BIT_1LINE |
| 57 | # else | ||
| 58 | # define LCD_FUNCTION_DEFAULT LCD_FUNCTION_4BIT_2LINES | ||
| 59 | # endif | ||
| 58 | #else | 60 | #else |
| 59 | #define LCD_FUNCTION_DEFAULT LCD_FUNCTION_4BIT_2LINES | 61 | # if LCD_LINES == 1 |
| 60 | #endif | 62 | # define LCD_FUNCTION_DEFAULT LCD_FUNCTION_8BIT_1LINE |
| 61 | #else | 63 | # else |
| 62 | #if LCD_LINES==1 | 64 | # define LCD_FUNCTION_DEFAULT LCD_FUNCTION_8BIT_2LINES |
| 63 | #define LCD_FUNCTION_DEFAULT LCD_FUNCTION_8BIT_1LINE | 65 | # endif |
| 64 | #else | ||
| 65 | #define LCD_FUNCTION_DEFAULT LCD_FUNCTION_8BIT_2LINES | ||
| 66 | #endif | ||
| 67 | #endif | 66 | #endif |
| 68 | 67 | ||
| 69 | #if LCD_CONTROLLER_KS0073 | 68 | #if LCD_CONTROLLER_KS0073 |
| 70 | #if LCD_LINES==4 | 69 | # if LCD_LINES == 4 |
| 71 | 70 | ||
| 72 | #define KS0073_EXTENDED_FUNCTION_REGISTER_ON 0x2C /* |0|010|1100 4-bit mode, extension-bit RE = 1 */ | 71 | # define KS0073_EXTENDED_FUNCTION_REGISTER_ON 0x2C /* |0|010|1100 4-bit mode, extension-bit RE = 1 */ |
| 73 | #define KS0073_EXTENDED_FUNCTION_REGISTER_OFF 0x28 /* |0|010|1000 4-bit mode, extension-bit RE = 0 */ | 72 | # define KS0073_EXTENDED_FUNCTION_REGISTER_OFF 0x28 /* |0|010|1000 4-bit mode, extension-bit RE = 0 */ |
| 74 | #define KS0073_4LINES_MODE 0x09 /* |0|000|1001 4 lines mode */ | 73 | # define KS0073_4LINES_MODE 0x09 /* |0|000|1001 4 lines mode */ |
| 75 | 74 | ||
| 76 | #endif | 75 | # endif |
| 77 | #endif | 76 | #endif |
| 78 | 77 | ||
| 79 | /* | 78 | /* |
| 80 | ** function prototypes | 79 | ** function prototypes |
| 81 | */ | 80 | */ |
| 82 | #if LCD_IO_MODE | 81 | #if LCD_IO_MODE |
| 83 | static void toggle_e(void); | 82 | static void toggle_e(void); |
| @@ -87,93 +86,83 @@ static void toggle_e(void); | |||
| 87 | ** local functions | 86 | ** local functions |
| 88 | */ | 87 | */ |
| 89 | 88 | ||
| 90 | 89 | /************************************************************************* | |
| 91 | /************************************************************************* | ||
| 92 | delay for a minimum of <us> microseconds | 90 | delay for a minimum of <us> microseconds |
| 93 | the number of loops is calculated at compile-time from MCU clock frequency | 91 | the number of loops is calculated at compile-time from MCU clock frequency |
| 94 | *************************************************************************/ | 92 | *************************************************************************/ |
| 95 | #define delay(us) _delay_us(us) | 93 | #define delay(us) _delay_us(us) |
| 96 | |||
| 97 | 94 | ||
| 98 | #if LCD_IO_MODE | 95 | #if LCD_IO_MODE |
| 99 | /* toggle Enable Pin to initiate write */ | 96 | /* toggle Enable Pin to initiate write */ |
| 100 | static void toggle_e(void) | 97 | static void toggle_e(void) { |
| 101 | { | ||
| 102 | lcd_e_high(); | 98 | lcd_e_high(); |
| 103 | lcd_e_delay(); | 99 | lcd_e_delay(); |
| 104 | lcd_e_low(); | 100 | lcd_e_low(); |
| 105 | } | 101 | } |
| 106 | #endif | 102 | #endif |
| 107 | 103 | ||
| 108 | |||
| 109 | /************************************************************************* | 104 | /************************************************************************* |
| 110 | Low-level function to write byte to LCD controller | 105 | Low-level function to write byte to LCD controller |
| 111 | Input: data byte to write to LCD | 106 | Input: data byte to write to LCD |
| 112 | rs 1: write data | 107 | rs 1: write data |
| 113 | 0: write instruction | 108 | 0: write instruction |
| 114 | Returns: none | 109 | Returns: none |
| 115 | *************************************************************************/ | 110 | *************************************************************************/ |
| 116 | #if LCD_IO_MODE | 111 | #if LCD_IO_MODE |
| 117 | static void lcd_write(uint8_t data,uint8_t rs) | 112 | static void lcd_write(uint8_t data, uint8_t rs) { |
| 118 | { | 113 | unsigned char dataBits; |
| 119 | unsigned char dataBits ; | ||
| 120 | |||
| 121 | 114 | ||
| 122 | if (rs) { /* write data (RS=1, RW=0) */ | 115 | if (rs) { /* write data (RS=1, RW=0) */ |
| 123 | lcd_rs_high(); | 116 | lcd_rs_high(); |
| 124 | } else { /* write instruction (RS=0, RW=0) */ | 117 | } else { /* write instruction (RS=0, RW=0) */ |
| 125 | lcd_rs_low(); | 118 | lcd_rs_low(); |
| 126 | } | 119 | } |
| 127 | lcd_rw_low(); /* RW=0 write mode */ | 120 | lcd_rw_low(); /* RW=0 write mode */ |
| 128 | 121 | ||
| 129 | if ( ( &LCD_DATA0_PORT == &LCD_DATA1_PORT) && ( &LCD_DATA1_PORT == &LCD_DATA2_PORT ) && ( &LCD_DATA2_PORT == &LCD_DATA3_PORT ) | 122 | if ((&LCD_DATA0_PORT == &LCD_DATA1_PORT) && (&LCD_DATA1_PORT == &LCD_DATA2_PORT) && (&LCD_DATA2_PORT == &LCD_DATA3_PORT) && (LCD_DATA0_PIN == 0) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3)) { |
| 130 | && (LCD_DATA0_PIN == 0) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3) ) | ||
| 131 | { | ||
| 132 | /* configure data pins as output */ | 123 | /* configure data pins as output */ |
| 133 | DDR(LCD_DATA0_PORT) |= 0x0F; | 124 | DDR(LCD_DATA0_PORT) |= 0x0F; |
| 134 | 125 | ||
| 135 | /* output high nibble first */ | 126 | /* output high nibble first */ |
| 136 | dataBits = LCD_DATA0_PORT & 0xF0; | 127 | dataBits = LCD_DATA0_PORT & 0xF0; |
| 137 | LCD_DATA0_PORT = dataBits |((data>>4)&0x0F); | 128 | LCD_DATA0_PORT = dataBits | ((data >> 4) & 0x0F); |
| 138 | lcd_e_toggle(); | 129 | lcd_e_toggle(); |
| 139 | 130 | ||
| 140 | /* output low nibble */ | 131 | /* output low nibble */ |
| 141 | LCD_DATA0_PORT = dataBits | (data&0x0F); | 132 | LCD_DATA0_PORT = dataBits | (data & 0x0F); |
| 142 | lcd_e_toggle(); | 133 | lcd_e_toggle(); |
| 143 | 134 | ||
| 144 | /* all data pins high (inactive) */ | 135 | /* all data pins high (inactive) */ |
| 145 | LCD_DATA0_PORT = dataBits | 0x0F; | 136 | LCD_DATA0_PORT = dataBits | 0x0F; |
| 146 | } | 137 | } else { |
| 147 | else | ||
| 148 | { | ||
| 149 | /* configure data pins as output */ | 138 | /* configure data pins as output */ |
| 150 | DDR(LCD_DATA0_PORT) |= _BV(LCD_DATA0_PIN); | 139 | DDR(LCD_DATA0_PORT) |= _BV(LCD_DATA0_PIN); |
| 151 | DDR(LCD_DATA1_PORT) |= _BV(LCD_DATA1_PIN); | 140 | DDR(LCD_DATA1_PORT) |= _BV(LCD_DATA1_PIN); |
| 152 | DDR(LCD_DATA2_PORT) |= _BV(LCD_DATA2_PIN); | 141 | DDR(LCD_DATA2_PORT) |= _BV(LCD_DATA2_PIN); |
| 153 | DDR(LCD_DATA3_PORT) |= _BV(LCD_DATA3_PIN); | 142 | DDR(LCD_DATA3_PORT) |= _BV(LCD_DATA3_PIN); |
| 154 | 143 | ||
| 155 | /* output high nibble first */ | 144 | /* output high nibble first */ |
| 156 | LCD_DATA3_PORT &= ~_BV(LCD_DATA3_PIN); | 145 | LCD_DATA3_PORT &= ~_BV(LCD_DATA3_PIN); |
| 157 | LCD_DATA2_PORT &= ~_BV(LCD_DATA2_PIN); | 146 | LCD_DATA2_PORT &= ~_BV(LCD_DATA2_PIN); |
| 158 | LCD_DATA1_PORT &= ~_BV(LCD_DATA1_PIN); | 147 | LCD_DATA1_PORT &= ~_BV(LCD_DATA1_PIN); |
| 159 | LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN); | 148 | LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN); |
| 160 | if(data & 0x80) LCD_DATA3_PORT |= _BV(LCD_DATA3_PIN); | 149 | if (data & 0x80) LCD_DATA3_PORT |= _BV(LCD_DATA3_PIN); |
| 161 | if(data & 0x40) LCD_DATA2_PORT |= _BV(LCD_DATA2_PIN); | 150 | if (data & 0x40) LCD_DATA2_PORT |= _BV(LCD_DATA2_PIN); |
| 162 | if(data & 0x20) LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN); | 151 | if (data & 0x20) LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN); |
| 163 | if(data & 0x10) LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN); | 152 | if (data & 0x10) LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN); |
| 164 | lcd_e_toggle(); | 153 | lcd_e_toggle(); |
| 165 | 154 | ||
| 166 | /* output low nibble */ | 155 | /* output low nibble */ |
| 167 | LCD_DATA3_PORT &= ~_BV(LCD_DATA3_PIN); | 156 | LCD_DATA3_PORT &= ~_BV(LCD_DATA3_PIN); |
| 168 | LCD_DATA2_PORT &= ~_BV(LCD_DATA2_PIN); | 157 | LCD_DATA2_PORT &= ~_BV(LCD_DATA2_PIN); |
| 169 | LCD_DATA1_PORT &= ~_BV(LCD_DATA1_PIN); | 158 | LCD_DATA1_PORT &= ~_BV(LCD_DATA1_PIN); |
| 170 | LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN); | 159 | LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN); |
| 171 | if(data & 0x08) LCD_DATA3_PORT |= _BV(LCD_DATA3_PIN); | 160 | if (data & 0x08) LCD_DATA3_PORT |= _BV(LCD_DATA3_PIN); |
| 172 | if(data & 0x04) LCD_DATA2_PORT |= _BV(LCD_DATA2_PIN); | 161 | if (data & 0x04) LCD_DATA2_PORT |= _BV(LCD_DATA2_PIN); |
| 173 | if(data & 0x02) LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN); | 162 | if (data & 0x02) LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN); |
| 174 | if(data & 0x01) LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN); | 163 | if (data & 0x01) LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN); |
| 175 | lcd_e_toggle(); | 164 | lcd_e_toggle(); |
| 176 | 165 | ||
| 177 | /* all data pins high (inactive) */ | 166 | /* all data pins high (inactive) */ |
| 178 | LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN); | 167 | LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN); |
| 179 | LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN); | 168 | LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN); |
| @@ -182,85 +171,81 @@ static void lcd_write(uint8_t data,uint8_t rs) | |||
| 182 | } | 171 | } |
| 183 | } | 172 | } |
| 184 | #else | 173 | #else |
| 185 | #define lcd_write(d,rs) if (rs) *(volatile uint8_t*)(LCD_IO_DATA) = d; else *(volatile uint8_t*)(LCD_IO_FUNCTION) = d; | 174 | # define lcd_write(d, rs) \ |
| 175 | if (rs) \ | ||
| 176 | *(volatile uint8_t *)(LCD_IO_DATA) = d; \ | ||
| 177 | else \ | ||
| 178 | *(volatile uint8_t *)(LCD_IO_FUNCTION) = d; | ||
| 186 | /* rs==0 -> write instruction to LCD_IO_FUNCTION */ | 179 | /* rs==0 -> write instruction to LCD_IO_FUNCTION */ |
| 187 | /* rs==1 -> write data to LCD_IO_DATA */ | 180 | /* rs==1 -> write data to LCD_IO_DATA */ |
| 188 | #endif | 181 | #endif |
| 189 | 182 | ||
| 190 | |||
| 191 | /************************************************************************* | 183 | /************************************************************************* |
| 192 | Low-level function to read byte from LCD controller | 184 | Low-level function to read byte from LCD controller |
| 193 | Input: rs 1: read data | 185 | Input: rs 1: read data |
| 194 | 0: read busy flag / address counter | 186 | 0: read busy flag / address counter |
| 195 | Returns: byte read from LCD controller | 187 | Returns: byte read from LCD controller |
| 196 | *************************************************************************/ | 188 | *************************************************************************/ |
| 197 | #if LCD_IO_MODE | 189 | #if LCD_IO_MODE |
| 198 | static uint8_t lcd_read(uint8_t rs) | 190 | static uint8_t lcd_read(uint8_t rs) { |
| 199 | { | ||
| 200 | uint8_t data; | 191 | uint8_t data; |
| 201 | 192 | ||
| 202 | |||
| 203 | if (rs) | 193 | if (rs) |
| 204 | lcd_rs_high(); /* RS=1: read data */ | 194 | lcd_rs_high(); /* RS=1: read data */ |
| 205 | else | 195 | else |
| 206 | lcd_rs_low(); /* RS=0: read busy flag */ | 196 | lcd_rs_low(); /* RS=0: read busy flag */ |
| 207 | lcd_rw_high(); /* RW=1 read mode */ | 197 | lcd_rw_high(); /* RW=1 read mode */ |
| 208 | 198 | ||
| 209 | if ( ( &LCD_DATA0_PORT == &LCD_DATA1_PORT) && ( &LCD_DATA1_PORT == &LCD_DATA2_PORT ) && ( &LCD_DATA2_PORT == &LCD_DATA3_PORT ) | 199 | if ((&LCD_DATA0_PORT == &LCD_DATA1_PORT) && (&LCD_DATA1_PORT == &LCD_DATA2_PORT) && (&LCD_DATA2_PORT == &LCD_DATA3_PORT) && (LCD_DATA0_PIN == 0) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3)) { |
| 210 | && ( LCD_DATA0_PIN == 0 )&& (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3) ) | 200 | DDR(LCD_DATA0_PORT) &= 0xF0; /* configure data pins as input */ |
| 211 | { | 201 | |
| 212 | DDR(LCD_DATA0_PORT) &= 0xF0; /* configure data pins as input */ | ||
| 213 | |||
| 214 | lcd_e_high(); | 202 | lcd_e_high(); |
| 215 | lcd_e_delay(); | 203 | lcd_e_delay(); |
| 216 | data = PIN(LCD_DATA0_PORT) << 4; /* read high nibble first */ | 204 | data = PIN(LCD_DATA0_PORT) << 4; /* read high nibble first */ |
| 217 | lcd_e_low(); | 205 | lcd_e_low(); |
| 218 | 206 | ||
| 219 | lcd_e_delay(); /* Enable 500ns low */ | 207 | lcd_e_delay(); /* Enable 500ns low */ |
| 220 | 208 | ||
| 221 | lcd_e_high(); | 209 | lcd_e_high(); |
| 222 | lcd_e_delay(); | 210 | lcd_e_delay(); |
| 223 | data |= PIN(LCD_DATA0_PORT)&0x0F; /* read low nibble */ | 211 | data |= PIN(LCD_DATA0_PORT) & 0x0F; /* read low nibble */ |
| 224 | lcd_e_low(); | 212 | lcd_e_low(); |
| 225 | } | 213 | } else { |
| 226 | else | ||
| 227 | { | ||
| 228 | /* configure data pins as input */ | 214 | /* configure data pins as input */ |
| 229 | DDR(LCD_DATA0_PORT) &= ~_BV(LCD_DATA0_PIN); | 215 | DDR(LCD_DATA0_PORT) &= ~_BV(LCD_DATA0_PIN); |
| 230 | DDR(LCD_DATA1_PORT) &= ~_BV(LCD_DATA1_PIN); | 216 | DDR(LCD_DATA1_PORT) &= ~_BV(LCD_DATA1_PIN); |
| 231 | DDR(LCD_DATA2_PORT) &= ~_BV(LCD_DATA2_PIN); | 217 | DDR(LCD_DATA2_PORT) &= ~_BV(LCD_DATA2_PIN); |
| 232 | DDR(LCD_DATA3_PORT) &= ~_BV(LCD_DATA3_PIN); | 218 | DDR(LCD_DATA3_PORT) &= ~_BV(LCD_DATA3_PIN); |
| 233 | 219 | ||
| 234 | /* read high nibble first */ | 220 | /* read high nibble first */ |
| 235 | lcd_e_high(); | 221 | lcd_e_high(); |
| 236 | lcd_e_delay(); | 222 | lcd_e_delay(); |
| 237 | data = 0; | 223 | data = 0; |
| 238 | if ( PIN(LCD_DATA0_PORT) & _BV(LCD_DATA0_PIN) ) data |= 0x10; | 224 | if (PIN(LCD_DATA0_PORT) & _BV(LCD_DATA0_PIN)) data |= 0x10; |
| 239 | if ( PIN(LCD_DATA1_PORT) & _BV(LCD_DATA1_PIN) ) data |= 0x20; | 225 | if (PIN(LCD_DATA1_PORT) & _BV(LCD_DATA1_PIN)) data |= 0x20; |
| 240 | if ( PIN(LCD_DATA2_PORT) & _BV(LCD_DATA2_PIN) ) data |= 0x40; | 226 | if (PIN(LCD_DATA2_PORT) & _BV(LCD_DATA2_PIN)) data |= 0x40; |
| 241 | if ( PIN(LCD_DATA3_PORT) & _BV(LCD_DATA3_PIN) ) data |= 0x80; | 227 | if (PIN(LCD_DATA3_PORT) & _BV(LCD_DATA3_PIN)) data |= 0x80; |
| 242 | lcd_e_low(); | 228 | lcd_e_low(); |
| 243 | 229 | ||
| 244 | lcd_e_delay(); /* Enable 500ns low */ | 230 | lcd_e_delay(); /* Enable 500ns low */ |
| 245 | 231 | ||
| 246 | /* read low nibble */ | 232 | /* read low nibble */ |
| 247 | lcd_e_high(); | 233 | lcd_e_high(); |
| 248 | lcd_e_delay(); | 234 | lcd_e_delay(); |
| 249 | if ( PIN(LCD_DATA0_PORT) & _BV(LCD_DATA0_PIN) ) data |= 0x01; | 235 | if (PIN(LCD_DATA0_PORT) & _BV(LCD_DATA0_PIN)) data |= 0x01; |
| 250 | if ( PIN(LCD_DATA1_PORT) & _BV(LCD_DATA1_PIN) ) data |= 0x02; | 236 | if (PIN(LCD_DATA1_PORT) & _BV(LCD_DATA1_PIN)) data |= 0x02; |
| 251 | if ( PIN(LCD_DATA2_PORT) & _BV(LCD_DATA2_PIN) ) data |= 0x04; | 237 | if (PIN(LCD_DATA2_PORT) & _BV(LCD_DATA2_PIN)) data |= 0x04; |
| 252 | if ( PIN(LCD_DATA3_PORT) & _BV(LCD_DATA3_PIN) ) data |= 0x08; | 238 | if (PIN(LCD_DATA3_PORT) & _BV(LCD_DATA3_PIN)) data |= 0x08; |
| 253 | lcd_e_low(); | 239 | lcd_e_low(); |
| 254 | } | 240 | } |
| 255 | return data; | 241 | return data; |
| 256 | } | 242 | } |
| 257 | #else | 243 | #else |
| 258 | #define lcd_read(rs) (rs) ? *(volatile uint8_t*)(LCD_IO_DATA+LCD_IO_READ) : *(volatile uint8_t*)(LCD_IO_FUNCTION+LCD_IO_READ) | 244 | # define lcd_read(rs) (rs) ? *(volatile uint8_t *)(LCD_IO_DATA + LCD_IO_READ) : *(volatile uint8_t *)(LCD_IO_FUNCTION + LCD_IO_READ) |
| 259 | /* rs==0 -> read instruction from LCD_IO_FUNCTION */ | 245 | /* rs==0 -> read instruction from LCD_IO_FUNCTION */ |
| 260 | /* rs==1 -> read data from LCD_IO_DATA */ | 246 | /* rs==1 -> read data from LCD_IO_DATA */ |
| 261 | #endif | 247 | #endif |
| 262 | 248 | ||
| 263 | |||
| 264 | /************************************************************************* | 249 | /************************************************************************* |
| 265 | loops while lcd is busy, returns address counter | 250 | loops while lcd is busy, returns address counter |
| 266 | *************************************************************************/ | 251 | *************************************************************************/ |
| @@ -268,65 +253,62 @@ static uint8_t lcd_waitbusy(void) | |||
| 268 | 253 | ||
| 269 | { | 254 | { |
| 270 | register uint8_t c; | 255 | register uint8_t c; |
| 271 | 256 | ||
| 272 | /* wait until busy flag is cleared */ | 257 | /* wait until busy flag is cleared */ |
| 273 | while ( (c=lcd_read(0)) & (1<<LCD_BUSY)) {} | 258 | while ((c = lcd_read(0)) & (1 << LCD_BUSY)) { |
| 274 | 259 | } | |
| 260 | |||
| 275 | /* the address counter is updated 4us after the busy flag is cleared */ | 261 | /* the address counter is updated 4us after the busy flag is cleared */ |
| 276 | delay(LCD_DELAY_BUSY_FLAG); | 262 | delay(LCD_DELAY_BUSY_FLAG); |
| 277 | 263 | ||
| 278 | /* now read the address counter */ | 264 | /* now read the address counter */ |
| 279 | return (lcd_read(0)); // return address counter | 265 | return (lcd_read(0)); // return address counter |
| 280 | |||
| 281 | }/* lcd_waitbusy */ | ||
| 282 | 266 | ||
| 267 | } /* lcd_waitbusy */ | ||
| 283 | 268 | ||
| 284 | /************************************************************************* | 269 | /************************************************************************* |
| 285 | Move cursor to the start of next line or to the first line if the cursor | 270 | Move cursor to the start of next line or to the first line if the cursor |
| 286 | is already on the last line. | 271 | is already on the last line. |
| 287 | *************************************************************************/ | 272 | *************************************************************************/ |
| 288 | static inline void lcd_newline(uint8_t pos) | 273 | static inline void lcd_newline(uint8_t pos) { |
| 289 | { | ||
| 290 | register uint8_t addressCounter; | 274 | register uint8_t addressCounter; |
| 291 | 275 | ||
| 292 | 276 | #if LCD_LINES == 1 | |
| 293 | #if LCD_LINES==1 | ||
| 294 | addressCounter = 0; | 277 | addressCounter = 0; |
| 295 | #endif | 278 | #endif |
| 296 | #if LCD_LINES==2 | 279 | #if LCD_LINES == 2 |
| 297 | if ( pos < (LCD_START_LINE2) ) | 280 | if (pos < (LCD_START_LINE2)) |
| 298 | addressCounter = LCD_START_LINE2; | 281 | addressCounter = LCD_START_LINE2; |
| 299 | else | 282 | else |
| 300 | addressCounter = LCD_START_LINE1; | 283 | addressCounter = LCD_START_LINE1; |
| 301 | #endif | 284 | #endif |
| 302 | #if LCD_LINES==4 | 285 | #if LCD_LINES == 4 |
| 303 | #if KS0073_4LINES_MODE | 286 | # if KS0073_4LINES_MODE |
| 304 | if ( pos < LCD_START_LINE2 ) | 287 | if (pos < LCD_START_LINE2) |
| 305 | addressCounter = LCD_START_LINE2; | 288 | addressCounter = LCD_START_LINE2; |
| 306 | else if ( (pos >= LCD_START_LINE2) && (pos < LCD_START_LINE3) ) | 289 | else if ((pos >= LCD_START_LINE2) && (pos < LCD_START_LINE3)) |
| 307 | addressCounter = LCD_START_LINE3; | 290 | addressCounter = LCD_START_LINE3; |
| 308 | else if ( (pos >= LCD_START_LINE3) && (pos < LCD_START_LINE4) ) | 291 | else if ((pos >= LCD_START_LINE3) && (pos < LCD_START_LINE4)) |
| 309 | addressCounter = LCD_START_LINE4; | 292 | addressCounter = LCD_START_LINE4; |
| 310 | else | 293 | else |
| 311 | addressCounter = LCD_START_LINE1; | 294 | addressCounter = LCD_START_LINE1; |
| 312 | #else | 295 | # else |
| 313 | if ( pos < LCD_START_LINE3 ) | 296 | if (pos < LCD_START_LINE3) |
| 314 | addressCounter = LCD_START_LINE2; | 297 | addressCounter = LCD_START_LINE2; |
| 315 | else if ( (pos >= LCD_START_LINE2) && (pos < LCD_START_LINE4) ) | 298 | else if ((pos >= LCD_START_LINE2) && (pos < LCD_START_LINE4)) |
| 316 | addressCounter = LCD_START_LINE3; | 299 | addressCounter = LCD_START_LINE3; |
| 317 | else if ( (pos >= LCD_START_LINE3) && (pos < LCD_START_LINE2) ) | 300 | else if ((pos >= LCD_START_LINE3) && (pos < LCD_START_LINE2)) |
| 318 | addressCounter = LCD_START_LINE4; | 301 | addressCounter = LCD_START_LINE4; |
| 319 | else | 302 | else |
| 320 | addressCounter = LCD_START_LINE1; | 303 | addressCounter = LCD_START_LINE1; |
| 304 | # endif | ||
| 321 | #endif | 305 | #endif |
| 322 | #endif | 306 | lcd_command((1 << LCD_DDRAM) + addressCounter); |
| 323 | lcd_command((1<<LCD_DDRAM)+addressCounter); | ||
| 324 | |||
| 325 | }/* lcd_newline */ | ||
| 326 | 307 | ||
| 308 | } /* lcd_newline */ | ||
| 327 | 309 | ||
| 328 | /* | 310 | /* |
| 329 | ** PUBLIC FUNCTIONS | 311 | ** PUBLIC FUNCTIONS |
| 330 | */ | 312 | */ |
| 331 | 313 | ||
| 332 | /************************************************************************* | 314 | /************************************************************************* |
| @@ -334,132 +316,107 @@ Send LCD controller instruction command | |||
| 334 | Input: instruction to send to LCD controller, see HD44780 data sheet | 316 | Input: instruction to send to LCD controller, see HD44780 data sheet |
| 335 | Returns: none | 317 | Returns: none |
| 336 | *************************************************************************/ | 318 | *************************************************************************/ |
| 337 | void lcd_command(uint8_t cmd) | 319 | void lcd_command(uint8_t cmd) { |
| 338 | { | ||
| 339 | lcd_waitbusy(); | 320 | lcd_waitbusy(); |
| 340 | lcd_write(cmd,0); | 321 | lcd_write(cmd, 0); |
| 341 | } | 322 | } |
| 342 | 323 | ||
| 343 | |||
| 344 | /************************************************************************* | 324 | /************************************************************************* |
| 345 | Send data byte to LCD controller | 325 | Send data byte to LCD controller |
| 346 | Input: data to send to LCD controller, see HD44780 data sheet | 326 | Input: data to send to LCD controller, see HD44780 data sheet |
| 347 | Returns: none | 327 | Returns: none |
| 348 | *************************************************************************/ | 328 | *************************************************************************/ |
| 349 | void lcd_data(uint8_t data) | 329 | void lcd_data(uint8_t data) { |
| 350 | { | ||
| 351 | lcd_waitbusy(); | 330 | lcd_waitbusy(); |
| 352 | lcd_write(data,1); | 331 | lcd_write(data, 1); |
| 353 | } | 332 | } |
| 354 | 333 | ||
| 355 | |||
| 356 | |||
| 357 | /************************************************************************* | 334 | /************************************************************************* |
| 358 | Set cursor to specified position | 335 | Set cursor to specified position |
| 359 | Input: x horizontal position (0: left most position) | 336 | Input: x horizontal position (0: left most position) |
| 360 | y vertical position (0: first line) | 337 | y vertical position (0: first line) |
| 361 | Returns: none | 338 | Returns: none |
| 362 | *************************************************************************/ | 339 | *************************************************************************/ |
| 363 | void lcd_gotoxy(uint8_t x, uint8_t y) | 340 | void lcd_gotoxy(uint8_t x, uint8_t y) { |
| 364 | { | 341 | #if LCD_LINES == 1 |
| 365 | #if LCD_LINES==1 | 342 | lcd_command((1 << LCD_DDRAM) + LCD_START_LINE1 + x); |
| 366 | lcd_command((1<<LCD_DDRAM)+LCD_START_LINE1+x); | ||
| 367 | #endif | 343 | #endif |
| 368 | #if LCD_LINES==2 | 344 | #if LCD_LINES == 2 |
| 369 | if ( y==0 ) | 345 | if (y == 0) |
| 370 | lcd_command((1<<LCD_DDRAM)+LCD_START_LINE1+x); | 346 | lcd_command((1 << LCD_DDRAM) + LCD_START_LINE1 + x); |
| 371 | else | 347 | else |
| 372 | lcd_command((1<<LCD_DDRAM)+LCD_START_LINE2+x); | 348 | lcd_command((1 << LCD_DDRAM) + LCD_START_LINE2 + x); |
| 373 | #endif | 349 | #endif |
| 374 | #if LCD_LINES==4 | 350 | #if LCD_LINES == 4 |
| 375 | if ( y==0 ) | 351 | if (y == 0) |
| 376 | lcd_command((1<<LCD_DDRAM)+LCD_START_LINE1+x); | 352 | lcd_command((1 << LCD_DDRAM) + LCD_START_LINE1 + x); |
| 377 | else if ( y==1) | 353 | else if (y == 1) |
| 378 | lcd_command((1<<LCD_DDRAM)+LCD_START_LINE2+x); | 354 | lcd_command((1 << LCD_DDRAM) + LCD_START_LINE2 + x); |
| 379 | else if ( y==2) | 355 | else if (y == 2) |
| 380 | lcd_command((1<<LCD_DDRAM)+LCD_START_LINE3+x); | 356 | lcd_command((1 << LCD_DDRAM) + LCD_START_LINE3 + x); |
| 381 | else /* y==3 */ | 357 | else /* y==3 */ |
| 382 | lcd_command((1<<LCD_DDRAM)+LCD_START_LINE4+x); | 358 | lcd_command((1 << LCD_DDRAM) + LCD_START_LINE4 + x); |
| 383 | #endif | 359 | #endif |
| 384 | 360 | ||
| 385 | }/* lcd_gotoxy */ | 361 | } /* lcd_gotoxy */ |
| 386 | |||
| 387 | 362 | ||
| 388 | /************************************************************************* | 363 | /************************************************************************* |
| 389 | *************************************************************************/ | 364 | *************************************************************************/ |
| 390 | int lcd_getxy(void) | 365 | int lcd_getxy(void) { return lcd_waitbusy(); } |
| 391 | { | ||
| 392 | return lcd_waitbusy(); | ||
| 393 | } | ||
| 394 | |||
| 395 | 366 | ||
| 396 | /************************************************************************* | 367 | /************************************************************************* |
| 397 | Clear display and set cursor to home position | 368 | Clear display and set cursor to home position |
| 398 | *************************************************************************/ | 369 | *************************************************************************/ |
| 399 | void lcd_clrscr(void) | 370 | void lcd_clrscr(void) { lcd_command(1 << LCD_CLR); } |
| 400 | { | ||
| 401 | lcd_command(1<<LCD_CLR); | ||
| 402 | } | ||
| 403 | |||
| 404 | 371 | ||
| 405 | /************************************************************************* | 372 | /************************************************************************* |
| 406 | Set cursor to home position | 373 | Set cursor to home position |
| 407 | *************************************************************************/ | 374 | *************************************************************************/ |
| 408 | void lcd_home(void) | 375 | void lcd_home(void) { lcd_command(1 << LCD_HOME); } |
| 409 | { | ||
| 410 | lcd_command(1<<LCD_HOME); | ||
| 411 | } | ||
| 412 | |||
| 413 | 376 | ||
| 414 | /************************************************************************* | 377 | /************************************************************************* |
| 415 | Display character at current cursor position | 378 | Display character at current cursor position |
| 416 | Input: character to be displayed | 379 | Input: character to be displayed |
| 417 | Returns: none | 380 | Returns: none |
| 418 | *************************************************************************/ | 381 | *************************************************************************/ |
| 419 | void lcd_putc(char c) | 382 | void lcd_putc(char c) { |
| 420 | { | ||
| 421 | uint8_t pos; | 383 | uint8_t pos; |
| 422 | 384 | ||
| 423 | 385 | pos = lcd_waitbusy(); // read busy-flag and address counter | |
| 424 | pos = lcd_waitbusy(); // read busy-flag and address counter | 386 | if (c == '\n') { |
| 425 | if (c=='\n') | ||
| 426 | { | ||
| 427 | lcd_newline(pos); | 387 | lcd_newline(pos); |
| 428 | } | 388 | } else { |
| 429 | else | 389 | #if LCD_WRAP_LINES == 1 |
| 430 | { | 390 | # if LCD_LINES == 1 |
| 431 | #if LCD_WRAP_LINES==1 | 391 | if (pos == LCD_START_LINE1 + LCD_DISP_LENGTH) { |
| 432 | #if LCD_LINES==1 | 392 | lcd_write((1 << LCD_DDRAM) + LCD_START_LINE1, 0); |
| 433 | if ( pos == LCD_START_LINE1+LCD_DISP_LENGTH ) { | ||
| 434 | lcd_write((1<<LCD_DDRAM)+LCD_START_LINE1,0); | ||
| 435 | } | 393 | } |
| 436 | #elif LCD_LINES==2 | 394 | # elif LCD_LINES == 2 |
| 437 | if ( pos == LCD_START_LINE1+LCD_DISP_LENGTH ) { | 395 | if (pos == LCD_START_LINE1 + LCD_DISP_LENGTH) { |
| 438 | lcd_write((1<<LCD_DDRAM)+LCD_START_LINE2,0); | 396 | lcd_write((1 << LCD_DDRAM) + LCD_START_LINE2, 0); |
| 439 | }else if ( pos == LCD_START_LINE2+LCD_DISP_LENGTH ){ | 397 | } else if (pos == LCD_START_LINE2 + LCD_DISP_LENGTH) { |
| 440 | lcd_write((1<<LCD_DDRAM)+LCD_START_LINE1,0); | 398 | lcd_write((1 << LCD_DDRAM) + LCD_START_LINE1, 0); |
| 441 | } | 399 | } |
| 442 | #elif LCD_LINES==4 | 400 | # elif LCD_LINES == 4 |
| 443 | if ( pos == LCD_START_LINE1+LCD_DISP_LENGTH ) { | 401 | if (pos == LCD_START_LINE1 + LCD_DISP_LENGTH) { |
| 444 | lcd_write((1<<LCD_DDRAM)+LCD_START_LINE2,0); | 402 | lcd_write((1 << LCD_DDRAM) + LCD_START_LINE2, 0); |
| 445 | }else if ( pos == LCD_START_LINE2+LCD_DISP_LENGTH ) { | 403 | } else if (pos == LCD_START_LINE2 + LCD_DISP_LENGTH) { |
| 446 | lcd_write((1<<LCD_DDRAM)+LCD_START_LINE3,0); | 404 | lcd_write((1 << LCD_DDRAM) + LCD_START_LINE3, 0); |
| 447 | }else if ( pos == LCD_START_LINE3+LCD_DISP_LENGTH ) { | 405 | } else if (pos == LCD_START_LINE3 + LCD_DISP_LENGTH) { |
| 448 | lcd_write((1<<LCD_DDRAM)+LCD_START_LINE4,0); | 406 | lcd_write((1 << LCD_DDRAM) + LCD_START_LINE4, 0); |
| 449 | }else if ( pos == LCD_START_LINE4+LCD_DISP_LENGTH ) { | 407 | } else if (pos == LCD_START_LINE4 + LCD_DISP_LENGTH) { |
| 450 | lcd_write((1<<LCD_DDRAM)+LCD_START_LINE1,0); | 408 | lcd_write((1 << LCD_DDRAM) + LCD_START_LINE1, 0); |
| 451 | } | 409 | } |
| 452 | #endif | 410 | # endif |
| 453 | lcd_waitbusy(); | 411 | lcd_waitbusy(); |
| 454 | #endif | 412 | #endif |
| 455 | lcd_write(c, 1); | 413 | lcd_write(c, 1); |
| 456 | } | 414 | } |
| 457 | 415 | ||
| 458 | }/* lcd_putc */ | 416 | } /* lcd_putc */ |
| 459 | |||
| 460 | 417 | ||
| 461 | /************************************************************************* | 418 | /************************************************************************* |
| 462 | Display string without auto linefeed | 419 | Display string without auto linefeed |
| 463 | Input: string to be displayed | 420 | Input: string to be displayed |
| 464 | Returns: none | 421 | Returns: none |
| 465 | *************************************************************************/ | 422 | *************************************************************************/ |
| @@ -468,16 +425,15 @@ void lcd_puts(const char *s) | |||
| 468 | { | 425 | { |
| 469 | register char c; | 426 | register char c; |
| 470 | 427 | ||
| 471 | while ( (c = *s++) ) { | 428 | while ((c = *s++)) { |
| 472 | lcd_putc(c); | 429 | lcd_putc(c); |
| 473 | } | 430 | } |
| 474 | 431 | ||
| 475 | }/* lcd_puts */ | 432 | } /* lcd_puts */ |
| 476 | |||
| 477 | 433 | ||
| 478 | /************************************************************************* | 434 | /************************************************************************* |
| 479 | Display string from program memory without auto linefeed | 435 | Display string from program memory without auto linefeed |
| 480 | Input: string from program memory be be displayed | 436 | Input: string from program memory be be displayed |
| 481 | Returns: none | 437 | Returns: none |
| 482 | *************************************************************************/ | 438 | *************************************************************************/ |
| 483 | void lcd_puts_p(const char *progmem_s) | 439 | void lcd_puts_p(const char *progmem_s) |
| @@ -485,108 +441,96 @@ void lcd_puts_p(const char *progmem_s) | |||
| 485 | { | 441 | { |
| 486 | register char c; | 442 | register char c; |
| 487 | 443 | ||
| 488 | while ( (c = pgm_read_byte(progmem_s++)) ) { | 444 | while ((c = pgm_read_byte(progmem_s++))) { |
| 489 | lcd_putc(c); | 445 | lcd_putc(c); |
| 490 | } | 446 | } |
| 491 | 447 | ||
| 492 | }/* lcd_puts_p */ | 448 | } /* lcd_puts_p */ |
| 493 | |||
| 494 | 449 | ||
| 495 | /************************************************************************* | 450 | /************************************************************************* |
| 496 | Initialize display and select type of cursor | 451 | Initialize display and select type of cursor |
| 497 | Input: dispAttr LCD_DISP_OFF display off | 452 | Input: dispAttr LCD_DISP_OFF display off |
| 498 | LCD_DISP_ON display on, cursor off | 453 | LCD_DISP_ON display on, cursor off |
| 499 | LCD_DISP_ON_CURSOR display on, cursor on | 454 | LCD_DISP_ON_CURSOR display on, cursor on |
| 500 | LCD_DISP_CURSOR_BLINK display on, cursor on flashing | 455 | LCD_DISP_CURSOR_BLINK display on, cursor on flashing |
| 501 | Returns: none | 456 | Returns: none |
| 502 | *************************************************************************/ | 457 | *************************************************************************/ |
| 503 | void lcd_init(uint8_t dispAttr) | 458 | void lcd_init(uint8_t dispAttr) { |
| 504 | { | ||
| 505 | #if LCD_IO_MODE | 459 | #if LCD_IO_MODE |
| 506 | /* | 460 | /* |
| 507 | * Initialize LCD to 4 bit I/O mode | 461 | * Initialize LCD to 4 bit I/O mode |
| 508 | */ | 462 | */ |
| 509 | 463 | ||
| 510 | if ( ( &LCD_DATA0_PORT == &LCD_DATA1_PORT) && ( &LCD_DATA1_PORT == &LCD_DATA2_PORT ) && ( &LCD_DATA2_PORT == &LCD_DATA3_PORT ) | 464 | if ((&LCD_DATA0_PORT == &LCD_DATA1_PORT) && (&LCD_DATA1_PORT == &LCD_DATA2_PORT) && (&LCD_DATA2_PORT == &LCD_DATA3_PORT) && (&LCD_RS_PORT == &LCD_DATA0_PORT) && (&LCD_RW_PORT == &LCD_DATA0_PORT) && (&LCD_E_PORT == &LCD_DATA0_PORT) && (LCD_DATA0_PIN == 0) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3) && (LCD_RS_PIN == 4) && (LCD_RW_PIN == 5) && (LCD_E_PIN == 6)) { |
| 511 | && ( &LCD_RS_PORT == &LCD_DATA0_PORT) && ( &LCD_RW_PORT == &LCD_DATA0_PORT) && (&LCD_E_PORT == &LCD_DATA0_PORT) | ||
| 512 | && (LCD_DATA0_PIN == 0 ) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3) | ||
| 513 | && (LCD_RS_PIN == 4 ) && (LCD_RW_PIN == 5) && (LCD_E_PIN == 6 ) ) | ||
| 514 | { | ||
| 515 | /* configure all port bits as output (all LCD lines on same port) */ | 465 | /* configure all port bits as output (all LCD lines on same port) */ |
| 516 | DDR(LCD_DATA0_PORT) |= 0x7F; | 466 | DDR(LCD_DATA0_PORT) |= 0x7F; |
| 517 | } | 467 | } else if ((&LCD_DATA0_PORT == &LCD_DATA1_PORT) && (&LCD_DATA1_PORT == &LCD_DATA2_PORT) && (&LCD_DATA2_PORT == &LCD_DATA3_PORT) && (LCD_DATA0_PIN == 0) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3)) { |
| 518 | else if ( ( &LCD_DATA0_PORT == &LCD_DATA1_PORT) && ( &LCD_DATA1_PORT == &LCD_DATA2_PORT ) && ( &LCD_DATA2_PORT == &LCD_DATA3_PORT ) | ||
| 519 | && (LCD_DATA0_PIN == 0 ) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3) ) | ||
| 520 | { | ||
| 521 | /* configure all port bits as output (all LCD data lines on same port, but control lines on different ports) */ | 468 | /* configure all port bits as output (all LCD data lines on same port, but control lines on different ports) */ |
| 522 | DDR(LCD_DATA0_PORT) |= 0x0F; | 469 | DDR(LCD_DATA0_PORT) |= 0x0F; |
| 523 | DDR(LCD_RS_PORT) |= _BV(LCD_RS_PIN); | 470 | DDR(LCD_RS_PORT) |= _BV(LCD_RS_PIN); |
| 524 | DDR(LCD_RW_PORT) |= _BV(LCD_RW_PIN); | 471 | DDR(LCD_RW_PORT) |= _BV(LCD_RW_PIN); |
| 525 | DDR(LCD_E_PORT) |= _BV(LCD_E_PIN); | 472 | DDR(LCD_E_PORT) |= _BV(LCD_E_PIN); |
| 526 | } | 473 | } else { |
| 527 | else | ||
| 528 | { | ||
| 529 | /* configure all port bits as output (LCD data and control lines on different ports */ | 474 | /* configure all port bits as output (LCD data and control lines on different ports */ |
| 530 | DDR(LCD_RS_PORT) |= _BV(LCD_RS_PIN); | 475 | DDR(LCD_RS_PORT) |= _BV(LCD_RS_PIN); |
| 531 | DDR(LCD_RW_PORT) |= _BV(LCD_RW_PIN); | 476 | DDR(LCD_RW_PORT) |= _BV(LCD_RW_PIN); |
| 532 | DDR(LCD_E_PORT) |= _BV(LCD_E_PIN); | 477 | DDR(LCD_E_PORT) |= _BV(LCD_E_PIN); |
| 533 | DDR(LCD_DATA0_PORT) |= _BV(LCD_DATA0_PIN); | 478 | DDR(LCD_DATA0_PORT) |= _BV(LCD_DATA0_PIN); |
| 534 | DDR(LCD_DATA1_PORT) |= _BV(LCD_DATA1_PIN); | 479 | DDR(LCD_DATA1_PORT) |= _BV(LCD_DATA1_PIN); |
| 535 | DDR(LCD_DATA2_PORT) |= _BV(LCD_DATA2_PIN); | 480 | DDR(LCD_DATA2_PORT) |= _BV(LCD_DATA2_PIN); |
| 536 | DDR(LCD_DATA3_PORT) |= _BV(LCD_DATA3_PIN); | 481 | DDR(LCD_DATA3_PORT) |= _BV(LCD_DATA3_PIN); |
| 537 | } | 482 | } |
| 538 | delay(LCD_DELAY_BOOTUP); /* wait 16ms or more after power-on */ | 483 | delay(LCD_DELAY_BOOTUP); /* wait 16ms or more after power-on */ |
| 539 | 484 | ||
| 540 | /* initial write to lcd is 8bit */ | 485 | /* initial write to lcd is 8bit */ |
| 541 | LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN); // LCD_FUNCTION>>4; | 486 | LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN); // LCD_FUNCTION>>4; |
| 542 | LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN); // LCD_FUNCTION_8BIT>>4; | 487 | LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN); // LCD_FUNCTION_8BIT>>4; |
| 488 | lcd_e_toggle(); | ||
| 489 | delay(LCD_DELAY_INIT); /* delay, busy flag can't be checked here */ | ||
| 490 | |||
| 491 | /* repeat last command */ | ||
| 543 | lcd_e_toggle(); | 492 | lcd_e_toggle(); |
| 544 | delay(LCD_DELAY_INIT); /* delay, busy flag can't be checked here */ | 493 | delay(LCD_DELAY_INIT_REP); /* delay, busy flag can't be checked here */ |
| 545 | 494 | ||
| 546 | /* repeat last command */ | ||
| 547 | lcd_e_toggle(); | ||
| 548 | delay(LCD_DELAY_INIT_REP); /* delay, busy flag can't be checked here */ | ||
| 549 | |||
| 550 | /* repeat last command a third time */ | 495 | /* repeat last command a third time */ |
| 551 | lcd_e_toggle(); | 496 | lcd_e_toggle(); |
| 552 | delay(LCD_DELAY_INIT_REP); /* delay, busy flag can't be checked here */ | 497 | delay(LCD_DELAY_INIT_REP); /* delay, busy flag can't be checked here */ |
| 553 | 498 | ||
| 554 | /* now configure for 4bit mode */ | 499 | /* now configure for 4bit mode */ |
| 555 | LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN); // LCD_FUNCTION_4BIT_1LINE>>4 | 500 | LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN); // LCD_FUNCTION_4BIT_1LINE>>4 |
| 556 | lcd_e_toggle(); | 501 | lcd_e_toggle(); |
| 557 | delay(LCD_DELAY_INIT_4BIT); /* some displays need this additional delay */ | 502 | delay(LCD_DELAY_INIT_4BIT); /* some displays need this additional delay */ |
| 558 | 503 | ||
| 559 | /* from now the LCD only accepts 4 bit I/O, we can use lcd_command() */ | 504 | /* from now the LCD only accepts 4 bit I/O, we can use lcd_command() */ |
| 560 | #else | 505 | #else |
| 561 | /* | 506 | /* |
| 562 | * Initialize LCD to 8 bit memory mapped mode | 507 | * Initialize LCD to 8 bit memory mapped mode |
| 563 | */ | 508 | */ |
| 564 | 509 | ||
| 565 | /* enable external SRAM (memory mapped lcd) and one wait state */ | 510 | /* enable external SRAM (memory mapped lcd) and one wait state */ |
| 566 | MCUCR = _BV(SRE) | _BV(SRW); | 511 | MCUCR = _BV(SRE) | _BV(SRW); |
| 567 | 512 | ||
| 568 | /* reset LCD */ | 513 | /* reset LCD */ |
| 569 | delay(LCD_DELAY_BOOTUP); /* wait 16ms after power-on */ | 514 | delay(LCD_DELAY_BOOTUP); /* wait 16ms after power-on */ |
| 570 | lcd_write(LCD_FUNCTION_8BIT_1LINE,0); /* function set: 8bit interface */ | 515 | lcd_write(LCD_FUNCTION_8BIT_1LINE, 0); /* function set: 8bit interface */ |
| 571 | delay(LCD_DELAY_INIT); /* wait 5ms */ | 516 | delay(LCD_DELAY_INIT); /* wait 5ms */ |
| 572 | lcd_write(LCD_FUNCTION_8BIT_1LINE,0); /* function set: 8bit interface */ | 517 | lcd_write(LCD_FUNCTION_8BIT_1LINE, 0); /* function set: 8bit interface */ |
| 573 | delay(LCD_DELAY_INIT_REP); /* wait 64us */ | 518 | delay(LCD_DELAY_INIT_REP); /* wait 64us */ |
| 574 | lcd_write(LCD_FUNCTION_8BIT_1LINE,0); /* function set: 8bit interface */ | 519 | lcd_write(LCD_FUNCTION_8BIT_1LINE, 0); /* function set: 8bit interface */ |
| 575 | delay(LCD_DELAY_INIT_REP); /* wait 64us */ | 520 | delay(LCD_DELAY_INIT_REP); /* wait 64us */ |
| 576 | #endif | 521 | #endif |
| 577 | 522 | ||
| 578 | #if KS0073_4LINES_MODE | 523 | #if KS0073_4LINES_MODE |
| 579 | /* Display with KS0073 controller requires special commands for enabling 4 line mode */ | 524 | /* Display with KS0073 controller requires special commands for enabling 4 line mode */ |
| 580 | lcd_command(KS0073_EXTENDED_FUNCTION_REGISTER_ON); | 525 | lcd_command(KS0073_EXTENDED_FUNCTION_REGISTER_ON); |
| 581 | lcd_command(KS0073_4LINES_MODE); | 526 | lcd_command(KS0073_4LINES_MODE); |
| 582 | lcd_command(KS0073_EXTENDED_FUNCTION_REGISTER_OFF); | 527 | lcd_command(KS0073_EXTENDED_FUNCTION_REGISTER_OFF); |
| 583 | #else | 528 | #else |
| 584 | lcd_command(LCD_FUNCTION_DEFAULT); /* function set: display lines */ | 529 | lcd_command(LCD_FUNCTION_DEFAULT); /* function set: display lines */ |
| 585 | #endif | 530 | #endif |
| 586 | lcd_command(LCD_DISP_OFF); /* display off */ | 531 | lcd_command(LCD_DISP_OFF); /* display off */ |
| 587 | lcd_clrscr(); /* display clear */ | 532 | lcd_clrscr(); /* display clear */ |
| 588 | lcd_command(LCD_MODE_DEFAULT); /* set entry mode */ | 533 | lcd_command(LCD_MODE_DEFAULT); /* set entry mode */ |
| 589 | lcd_command(dispAttr); /* display/cursor control */ | 534 | lcd_command(dispAttr); /* display/cursor control */ |
| 590 | |||
| 591 | }/* lcd_init */ | ||
| 592 | 535 | ||
| 536 | } /* lcd_init */ | ||
diff --git a/drivers/avr/hd44780.h b/drivers/avr/hd44780.h index 7421c8131..e60817e98 100644 --- a/drivers/avr/hd44780.h +++ b/drivers/avr/hd44780.h | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | License: GNU General Public License Version 3 | 6 | License: GNU General Public License Version 3 |
| 7 | File: $Id: lcd.h,v 1.14.2.4 2015/01/20 17:16:07 peter Exp $ | 7 | File: $Id: lcd.h,v 1.14.2.4 2015/01/20 17:16:07 peter Exp $ |
| 8 | Software: AVR-GCC 4.x | 8 | Software: AVR-GCC 4.x |
| 9 | Hardware: any AVR device, memory mapped mode only for AVR with | 9 | Hardware: any AVR device, memory mapped mode only for AVR with |
| 10 | memory mapped interface (AT90S8515/ATmega8515/ATmega128) | 10 | memory mapped interface (AT90S8515/ATmega8515/ATmega128) |
| 11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
| 12 | 12 | ||
| @@ -15,333 +15,315 @@ | |||
| 15 | Collection of libraries for AVR-GCC | 15 | Collection of libraries for AVR-GCC |
| 16 | @author Peter Fleury pfleury@gmx.ch http://tinyurl.com/peterfleury | 16 | @author Peter Fleury pfleury@gmx.ch http://tinyurl.com/peterfleury |
| 17 | @copyright (C) 2015 Peter Fleury, GNU General Public License Version 3 | 17 | @copyright (C) 2015 Peter Fleury, GNU General Public License Version 3 |
| 18 | 18 | ||
| 19 | @file | 19 | @file |
| 20 | @defgroup pfleury_lcd LCD library <lcd.h> | 20 | @defgroup pfleury_lcd LCD library <lcd.h> |
| 21 | @code #include <lcd.h> @endcode | 21 | @code #include <lcd.h> @endcode |
| 22 | 22 | ||
| 23 | @brief Basic routines for interfacing a HD44780U-based character LCD display | 23 | @brief Basic routines for interfacing a HD44780U-based character LCD display |
| 24 | 24 | ||
| 25 | LCD character displays can be found in many devices, like espresso machines, laser printers. | 25 | LCD character displays can be found in many devices, like espresso machines, laser printers. |
| 26 | The Hitachi HD44780 controller and its compatible controllers like Samsung KS0066U have become an industry standard for these types of displays. | 26 | The Hitachi HD44780 controller and its compatible controllers like Samsung KS0066U have become an industry standard for these types of displays. |
| 27 | 27 | ||
| 28 | This library allows easy interfacing with a HD44780 compatible display and can be | 28 | This library allows easy interfacing with a HD44780 compatible display and can be |
| 29 | operated in memory mapped mode (LCD_IO_MODE defined as 0 in the include file lcd.h.) or in | 29 | operated in memory mapped mode (LCD_IO_MODE defined as 0 in the include file lcd.h.) or in |
| 30 | 4-bit IO port mode (LCD_IO_MODE defined as 1). 8-bit IO port mode is not supported. | 30 | 4-bit IO port mode (LCD_IO_MODE defined as 1). 8-bit IO port mode is not supported. |
| 31 | 31 | ||
| 32 | Memory mapped mode is compatible with old Kanda STK200 starter kit, but also supports | 32 | Memory mapped mode is compatible with old Kanda STK200 starter kit, but also supports |
| 33 | generation of R/W signal through A8 address line. | 33 | generation of R/W signal through A8 address line. |
| 34 | 34 | ||
| 35 | @see The chapter <a href=" http://homepage.hispeed.ch/peterfleury/avr-lcd44780.html" target="_blank">Interfacing a HD44780 Based LCD to an AVR</a> | 35 | @see The chapter <a href=" http://homepage.hispeed.ch/peterfleury/avr-lcd44780.html" target="_blank">Interfacing a HD44780 Based LCD to an AVR</a> |
| 36 | on my home page, which shows example circuits how to connect an LCD to an AVR controller. | 36 | on my home page, which shows example circuits how to connect an LCD to an AVR controller. |
| 37 | 37 | ||
| 38 | @author Peter Fleury pfleury@gmx.ch http://tinyurl.com/peterfleury | 38 | @author Peter Fleury pfleury@gmx.ch http://tinyurl.com/peterfleury |
| 39 | 39 | ||
| 40 | @version 2.0 | 40 | @version 2.0 |
| 41 | 41 | ||
| 42 | @copyright (C) 2015 Peter Fleury, GNU General Public License Version 3 | 42 | @copyright (C) 2015 Peter Fleury, GNU General Public License Version 3 |
| 43 | 43 | ||
| 44 | */ | 44 | */ |
| 45 | 45 | ||
| 46 | #include <inttypes.h> | 46 | #include <inttypes.h> |
| 47 | #include <avr/pgmspace.h> | 47 | #include <avr/pgmspace.h> |
| 48 | 48 | ||
| 49 | #if (__GNUC__ * 100 + __GNUC_MINOR__) < 405 | 49 | #if (__GNUC__ * 100 + __GNUC_MINOR__) < 405 |
| 50 | #error "This library requires AVR-GCC 4.5 or later, update to newer AVR-GCC compiler !" | 50 | # error "This library requires AVR-GCC 4.5 or later, update to newer AVR-GCC compiler !" |
| 51 | #endif | 51 | #endif |
| 52 | 52 | ||
| 53 | |||
| 54 | /**@{*/ | 53 | /**@{*/ |
| 55 | 54 | ||
| 56 | /* | 55 | /* |
| 57 | * LCD and target specific definitions below can be defined in a separate include file with name lcd_definitions.h instead modifying this file | 56 | * LCD and target specific definitions below can be defined in a separate include file with name lcd_definitions.h instead modifying this file |
| 58 | * by adding -D_LCD_DEFINITIONS_FILE to the CDEFS section in the Makefile | 57 | * by adding -D_LCD_DEFINITIONS_FILE to the CDEFS section in the Makefile |
| 59 | * All definitions added to the file lcd_definitions.h will override the default definitions from lcd.h | 58 | * All definitions added to the file lcd_definitions.h will override the default definitions from lcd.h |
| 60 | */ | 59 | */ |
| 61 | #ifdef _LCD_DEFINITIONS_FILE | 60 | #ifdef _LCD_DEFINITIONS_FILE |
| 62 | #include "lcd_definitions.h" | 61 | # include "lcd_definitions.h" |
| 63 | #endif | 62 | #endif |
| 64 | 63 | ||
| 65 | |||
| 66 | /** | 64 | /** |
| 67 | * @name Definition for LCD controller type | 65 | * @name Definition for LCD controller type |
| 68 | * Use 0 for HD44780 controller, change to 1 for displays with KS0073 controller. | 66 | * Use 0 for HD44780 controller, change to 1 for displays with KS0073 controller. |
| 69 | */ | 67 | */ |
| 70 | #ifndef LCD_CONTROLLER_KS0073 | 68 | #ifndef LCD_CONTROLLER_KS0073 |
| 71 | #define LCD_CONTROLLER_KS0073 0 /**< Use 0 for HD44780 controller, 1 for KS0073 controller */ | 69 | # define LCD_CONTROLLER_KS0073 0 /**< Use 0 for HD44780 controller, 1 for KS0073 controller */ |
| 72 | #endif | 70 | #endif |
| 73 | 71 | ||
| 74 | /** | 72 | /** |
| 75 | * @name Definitions for Display Size | 73 | * @name Definitions for Display Size |
| 76 | * Change these definitions to adapt setting to your display | 74 | * Change these definitions to adapt setting to your display |
| 77 | * | 75 | * |
| 78 | * These definitions can be defined in a separate include file \b lcd_definitions.h instead modifying this file by | 76 | * These definitions can be defined in a separate include file \b lcd_definitions.h instead modifying this file by |
| 79 | * adding -D_LCD_DEFINITIONS_FILE to the CDEFS section in the Makefile. | 77 | * adding -D_LCD_DEFINITIONS_FILE to the CDEFS section in the Makefile. |
| 80 | * All definitions added to the file lcd_definitions.h will override the default definitions from lcd.h | 78 | * All definitions added to the file lcd_definitions.h will override the default definitions from lcd.h |
| 81 | * | 79 | * |
| 82 | */ | 80 | */ |
| 83 | #ifndef LCD_LINES | 81 | #ifndef LCD_LINES |
| 84 | #define LCD_LINES 2 /**< number of visible lines of the display */ | 82 | # define LCD_LINES 2 /**< number of visible lines of the display */ |
| 85 | #endif | 83 | #endif |
| 86 | #ifndef LCD_DISP_LENGTH | 84 | #ifndef LCD_DISP_LENGTH |
| 87 | #define LCD_DISP_LENGTH 16 /**< visibles characters per line of the display */ | 85 | # define LCD_DISP_LENGTH 16 /**< visibles characters per line of the display */ |
| 88 | #endif | 86 | #endif |
| 89 | #ifndef LCD_LINE_LENGTH | 87 | #ifndef LCD_LINE_LENGTH |
| 90 | #define LCD_LINE_LENGTH 0x40 /**< internal line length of the display */ | 88 | # define LCD_LINE_LENGTH 0x40 /**< internal line length of the display */ |
| 91 | #endif | 89 | #endif |
| 92 | #ifndef LCD_START_LINE1 | 90 | #ifndef LCD_START_LINE1 |
| 93 | #define LCD_START_LINE1 0x00 /**< DDRAM address of first char of line 1 */ | 91 | # define LCD_START_LINE1 0x00 /**< DDRAM address of first char of line 1 */ |
| 94 | #endif | 92 | #endif |
| 95 | #ifndef LCD_START_LINE2 | 93 | #ifndef LCD_START_LINE2 |
| 96 | #define LCD_START_LINE2 0x40 /**< DDRAM address of first char of line 2 */ | 94 | # define LCD_START_LINE2 0x40 /**< DDRAM address of first char of line 2 */ |
| 97 | #endif | 95 | #endif |
| 98 | #ifndef LCD_START_LINE3 | 96 | #ifndef LCD_START_LINE3 |
| 99 | #define LCD_START_LINE3 0x14 /**< DDRAM address of first char of line 3 */ | 97 | # define LCD_START_LINE3 0x14 /**< DDRAM address of first char of line 3 */ |
| 100 | #endif | 98 | #endif |
| 101 | #ifndef LCD_START_LINE4 | 99 | #ifndef LCD_START_LINE4 |
| 102 | #define LCD_START_LINE4 0x54 /**< DDRAM address of first char of line 4 */ | 100 | # define LCD_START_LINE4 0x54 /**< DDRAM address of first char of line 4 */ |
| 103 | #endif | 101 | #endif |
| 104 | #ifndef LCD_WRAP_LINES | 102 | #ifndef LCD_WRAP_LINES |
| 105 | #define LCD_WRAP_LINES 0 /**< 0: no wrap, 1: wrap at end of visibile line */ | 103 | # define LCD_WRAP_LINES 0 /**< 0: no wrap, 1: wrap at end of visibile line */ |
| 106 | #endif | 104 | #endif |
| 107 | 105 | ||
| 108 | |||
| 109 | /** | 106 | /** |
| 110 | * @name Definitions for 4-bit IO mode | 107 | * @name Definitions for 4-bit IO mode |
| 111 | * | 108 | * |
| 112 | * The four LCD data lines and the three control lines RS, RW, E can be on the | 109 | * The four LCD data lines and the three control lines RS, RW, E can be on the |
| 113 | * same port or on different ports. | 110 | * same port or on different ports. |
| 114 | * Change LCD_RS_PORT, LCD_RW_PORT, LCD_E_PORT if you want the control lines on | 111 | * Change LCD_RS_PORT, LCD_RW_PORT, LCD_E_PORT if you want the control lines on |
| 115 | * different ports. | 112 | * different ports. |
| 116 | * | 113 | * |
| 117 | * Normally the four data lines should be mapped to bit 0..3 on one port, but it | 114 | * Normally the four data lines should be mapped to bit 0..3 on one port, but it |
| 118 | * is possible to connect these data lines in different order or even on different | 115 | * is possible to connect these data lines in different order or even on different |
| 119 | * ports by adapting the LCD_DATAx_PORT and LCD_DATAx_PIN definitions. | 116 | * ports by adapting the LCD_DATAx_PORT and LCD_DATAx_PIN definitions. |
| 120 | * | 117 | * |
| 121 | * Adjust these definitions to your target.\n | 118 | * Adjust these definitions to your target.\n |
| 122 | * These definitions can be defined in a separate include file \b lcd_definitions.h instead modifying this file by | 119 | * These definitions can be defined in a separate include file \b lcd_definitions.h instead modifying this file by |
| 123 | * adding \b -D_LCD_DEFINITIONS_FILE to the \b CDEFS section in the Makefile. | 120 | * adding \b -D_LCD_DEFINITIONS_FILE to the \b CDEFS section in the Makefile. |
| 124 | * All definitions added to the file lcd_definitions.h will override the default definitions from lcd.h | 121 | * All definitions added to the file lcd_definitions.h will override the default definitions from lcd.h |
| 125 | * | 122 | * |
| 126 | */ | 123 | */ |
| 127 | #define LCD_IO_MODE 1 /**< 0: memory mapped mode, 1: IO port mode */ | 124 | #define LCD_IO_MODE 1 /**< 0: memory mapped mode, 1: IO port mode */ |
| 128 | 125 | ||
| 129 | #if LCD_IO_MODE | 126 | #if LCD_IO_MODE |
| 130 | 127 | ||
| 131 | #ifndef LCD_PORT | 128 | # ifndef LCD_PORT |
| 132 | #define LCD_PORT PORTA /**< port for the LCD lines */ | 129 | # define LCD_PORT PORTA /**< port for the LCD lines */ |
| 133 | #endif | 130 | # endif |
| 134 | #ifndef LCD_DATA0_PORT | 131 | # ifndef LCD_DATA0_PORT |
| 135 | #define LCD_DATA0_PORT LCD_PORT /**< port for 4bit data bit 0 */ | 132 | # define LCD_DATA0_PORT LCD_PORT /**< port for 4bit data bit 0 */ |
| 136 | #endif | 133 | # endif |
| 137 | #ifndef LCD_DATA1_PORT | 134 | # ifndef LCD_DATA1_PORT |
| 138 | #define LCD_DATA1_PORT LCD_PORT /**< port for 4bit data bit 1 */ | 135 | # define LCD_DATA1_PORT LCD_PORT /**< port for 4bit data bit 1 */ |
| 139 | #endif | 136 | # endif |
| 140 | #ifndef LCD_DATA2_PORT | 137 | # ifndef LCD_DATA2_PORT |
| 141 | #define LCD_DATA2_PORT LCD_PORT /**< port for 4bit data bit 2 */ | 138 | # define LCD_DATA2_PORT LCD_PORT /**< port for 4bit data bit 2 */ |
| 142 | #endif | 139 | # endif |
| 143 | #ifndef LCD_DATA3_PORT | 140 | # ifndef LCD_DATA3_PORT |
| 144 | #define LCD_DATA3_PORT LCD_PORT /**< port for 4bit data bit 3 */ | 141 | # define LCD_DATA3_PORT LCD_PORT /**< port for 4bit data bit 3 */ |
| 145 | #endif | 142 | # endif |
| 146 | #ifndef LCD_DATA0_PIN | 143 | # ifndef LCD_DATA0_PIN |
| 147 | #define LCD_DATA0_PIN 4 /**< pin for 4bit data bit 0 */ | 144 | # define LCD_DATA0_PIN 4 /**< pin for 4bit data bit 0 */ |
| 148 | #endif | 145 | # endif |
| 149 | #ifndef LCD_DATA1_PIN | 146 | # ifndef LCD_DATA1_PIN |
| 150 | #define LCD_DATA1_PIN 5 /**< pin for 4bit data bit 1 */ | 147 | # define LCD_DATA1_PIN 5 /**< pin for 4bit data bit 1 */ |
| 151 | #endif | 148 | # endif |
| 152 | #ifndef LCD_DATA2_PIN | 149 | # ifndef LCD_DATA2_PIN |
| 153 | #define LCD_DATA2_PIN 6 /**< pin for 4bit data bit 2 */ | 150 | # define LCD_DATA2_PIN 6 /**< pin for 4bit data bit 2 */ |
| 154 | #endif | 151 | # endif |
| 155 | #ifndef LCD_DATA3_PIN | 152 | # ifndef LCD_DATA3_PIN |
| 156 | #define LCD_DATA3_PIN 7 /**< pin for 4bit data bit 3 */ | 153 | # define LCD_DATA3_PIN 7 /**< pin for 4bit data bit 3 */ |
| 157 | #endif | 154 | # endif |
| 158 | #ifndef LCD_RS_PORT | 155 | # ifndef LCD_RS_PORT |
| 159 | #define LCD_RS_PORT LCD_PORT /**< port for RS line */ | 156 | # define LCD_RS_PORT LCD_PORT /**< port for RS line */ |
| 160 | #endif | 157 | # endif |
| 161 | #ifndef LCD_RS_PIN | 158 | # ifndef LCD_RS_PIN |
| 162 | #define LCD_RS_PIN 3 /**< pin for RS line */ | 159 | # define LCD_RS_PIN 3 /**< pin for RS line */ |
| 163 | #endif | 160 | # endif |
| 164 | #ifndef LCD_RW_PORT | 161 | # ifndef LCD_RW_PORT |
| 165 | #define LCD_RW_PORT LCD_PORT /**< port for RW line */ | 162 | # define LCD_RW_PORT LCD_PORT /**< port for RW line */ |
| 166 | #endif | 163 | # endif |
| 167 | #ifndef LCD_RW_PIN | 164 | # ifndef LCD_RW_PIN |
| 168 | #define LCD_RW_PIN 2 /**< pin for RW line */ | 165 | # define LCD_RW_PIN 2 /**< pin for RW line */ |
| 169 | #endif | 166 | # endif |
| 170 | #ifndef LCD_E_PORT | 167 | # ifndef LCD_E_PORT |
| 171 | #define LCD_E_PORT LCD_PORT /**< port for Enable line */ | 168 | # define LCD_E_PORT LCD_PORT /**< port for Enable line */ |
| 172 | #endif | 169 | # endif |
| 173 | #ifndef LCD_E_PIN | 170 | # ifndef LCD_E_PIN |
| 174 | #define LCD_E_PIN 1 /**< pin for Enable line */ | 171 | # define LCD_E_PIN 1 /**< pin for Enable line */ |
| 175 | #endif | 172 | # endif |
| 176 | 173 | ||
| 177 | #elif defined(__AVR_AT90S4414__) || defined(__AVR_AT90S8515__) || defined(__AVR_ATmega64__) || \ | 174 | #elif defined(__AVR_AT90S4414__) || defined(__AVR_AT90S8515__) || defined(__AVR_ATmega64__) || defined(__AVR_ATmega8515__) || defined(__AVR_ATmega103__) || defined(__AVR_ATmega128__) || defined(__AVR_ATmega161__) || defined(__AVR_ATmega162__) |
| 178 | defined(__AVR_ATmega8515__)|| defined(__AVR_ATmega103__) || defined(__AVR_ATmega128__) || \ | ||
| 179 | defined(__AVR_ATmega161__) || defined(__AVR_ATmega162__) | ||
| 180 | /* | 175 | /* |
| 181 | * memory mapped mode is only supported when the device has an external data memory interface | 176 | * memory mapped mode is only supported when the device has an external data memory interface |
| 182 | */ | 177 | */ |
| 183 | #define LCD_IO_DATA 0xC000 /* A15=E=1, A14=RS=1 */ | 178 | # define LCD_IO_DATA 0xC000 /* A15=E=1, A14=RS=1 */ |
| 184 | #define LCD_IO_FUNCTION 0x8000 /* A15=E=1, A14=RS=0 */ | 179 | # define LCD_IO_FUNCTION 0x8000 /* A15=E=1, A14=RS=0 */ |
| 185 | #define LCD_IO_READ 0x0100 /* A8 =R/W=1 (R/W: 1=Read, 0=Write */ | 180 | # define LCD_IO_READ 0x0100 /* A8 =R/W=1 (R/W: 1=Read, 0=Write */ |
| 186 | 181 | ||
| 187 | #else | 182 | #else |
| 188 | #error "external data memory interface not available for this device, use 4-bit IO port mode" | 183 | # error "external data memory interface not available for this device, use 4-bit IO port mode" |
| 189 | 184 | ||
| 190 | #endif | 185 | #endif |
| 191 | 186 | ||
| 192 | |||
| 193 | /** | 187 | /** |
| 194 | * @name Definitions of delays | 188 | * @name Definitions of delays |
| 195 | * Used to calculate delay timers. | 189 | * Used to calculate delay timers. |
| 196 | * Adapt the F_CPU define in the Makefile to the clock frequency in Hz of your target | 190 | * Adapt the F_CPU define in the Makefile to the clock frequency in Hz of your target |
| 197 | * | 191 | * |
| 198 | * These delay times can be adjusted, if some displays require different delays.\n | 192 | * These delay times can be adjusted, if some displays require different delays.\n |
| 199 | * These definitions can be defined in a separate include file \b lcd_definitions.h instead modifying this file by | 193 | * These definitions can be defined in a separate include file \b lcd_definitions.h instead modifying this file by |
| 200 | * adding \b -D_LCD_DEFINITIONS_FILE to the \b CDEFS section in the Makefile. | 194 | * adding \b -D_LCD_DEFINITIONS_FILE to the \b CDEFS section in the Makefile. |
| 201 | * All definitions added to the file lcd_definitions.h will override the default definitions from lcd.h | 195 | * All definitions added to the file lcd_definitions.h will override the default definitions from lcd.h |
| 202 | */ | 196 | */ |
| 203 | #ifndef LCD_DELAY_BOOTUP | 197 | #ifndef LCD_DELAY_BOOTUP |
| 204 | #define LCD_DELAY_BOOTUP 16000 /**< delay in micro seconds after power-on */ | 198 | # define LCD_DELAY_BOOTUP 16000 /**< delay in micro seconds after power-on */ |
| 205 | #endif | 199 | #endif |
| 206 | #ifndef LCD_DELAY_INIT | 200 | #ifndef LCD_DELAY_INIT |
| 207 | #define LCD_DELAY_INIT 5000 /**< delay in micro seconds after initialization command sent */ | 201 | # define LCD_DELAY_INIT 5000 /**< delay in micro seconds after initialization command sent */ |
| 208 | #endif | 202 | #endif |
| 209 | #ifndef LCD_DELAY_INIT_REP | 203 | #ifndef LCD_DELAY_INIT_REP |
| 210 | #define LCD_DELAY_INIT_REP 64 /**< delay in micro seconds after initialization command repeated */ | 204 | # define LCD_DELAY_INIT_REP 64 /**< delay in micro seconds after initialization command repeated */ |
| 211 | #endif | 205 | #endif |
| 212 | #ifndef LCD_DELAY_INIT_4BIT | 206 | #ifndef LCD_DELAY_INIT_4BIT |
| 213 | #define LCD_DELAY_INIT_4BIT 64 /**< delay in micro seconds after setting 4-bit mode */ | 207 | # define LCD_DELAY_INIT_4BIT 64 /**< delay in micro seconds after setting 4-bit mode */ |
| 214 | #endif | 208 | #endif |
| 215 | #ifndef LCD_DELAY_BUSY_FLAG | 209 | #ifndef LCD_DELAY_BUSY_FLAG |
| 216 | #define LCD_DELAY_BUSY_FLAG 4 /**< time in micro seconds the address counter is updated after busy flag is cleared */ | 210 | # define LCD_DELAY_BUSY_FLAG 4 /**< time in micro seconds the address counter is updated after busy flag is cleared */ |
| 217 | #endif | 211 | #endif |
| 218 | #ifndef LCD_DELAY_ENABLE_PULSE | 212 | #ifndef LCD_DELAY_ENABLE_PULSE |
| 219 | #define LCD_DELAY_ENABLE_PULSE 1 /**< enable signal pulse width in micro seconds */ | 213 | # define LCD_DELAY_ENABLE_PULSE 1 /**< enable signal pulse width in micro seconds */ |
| 220 | #endif | 214 | #endif |
| 221 | 215 | ||
| 222 | |||
| 223 | /** | 216 | /** |
| 224 | * @name Definitions for LCD command instructions | 217 | * @name Definitions for LCD command instructions |
| 225 | * The constants define the various LCD controller instructions which can be passed to the | 218 | * The constants define the various LCD controller instructions which can be passed to the |
| 226 | * function lcd_command(), see HD44780 data sheet for a complete description. | 219 | * function lcd_command(), see HD44780 data sheet for a complete description. |
| 227 | */ | 220 | */ |
| 228 | 221 | ||
| 229 | /* instruction register bit positions, see HD44780U data sheet */ | 222 | /* instruction register bit positions, see HD44780U data sheet */ |
| 230 | #define LCD_CLR 0 /* DB0: clear display */ | 223 | #define LCD_CLR 0 /* DB0: clear display */ |
| 231 | #define LCD_HOME 1 /* DB1: return to home position */ | 224 | #define LCD_HOME 1 /* DB1: return to home position */ |
| 232 | #define LCD_ENTRY_MODE 2 /* DB2: set entry mode */ | 225 | #define LCD_ENTRY_MODE 2 /* DB2: set entry mode */ |
| 233 | #define LCD_ENTRY_INC 1 /* DB1: 1=increment, 0=decrement */ | 226 | #define LCD_ENTRY_INC 1 /* DB1: 1=increment, 0=decrement */ |
| 234 | #define LCD_ENTRY_SHIFT 0 /* DB2: 1=display shift on */ | 227 | #define LCD_ENTRY_SHIFT 0 /* DB2: 1=display shift on */ |
| 235 | #define LCD_ON 3 /* DB3: turn lcd/cursor on */ | 228 | #define LCD_ON 3 /* DB3: turn lcd/cursor on */ |
| 236 | #define LCD_ON_DISPLAY 2 /* DB2: turn display on */ | 229 | #define LCD_ON_DISPLAY 2 /* DB2: turn display on */ |
| 237 | #define LCD_ON_CURSOR 1 /* DB1: turn cursor on */ | 230 | #define LCD_ON_CURSOR 1 /* DB1: turn cursor on */ |
| 238 | #define LCD_ON_BLINK 0 /* DB0: blinking cursor ? */ | 231 | #define LCD_ON_BLINK 0 /* DB0: blinking cursor ? */ |
| 239 | #define LCD_MOVE 4 /* DB4: move cursor/display */ | 232 | #define LCD_MOVE 4 /* DB4: move cursor/display */ |
| 240 | #define LCD_MOVE_DISP 3 /* DB3: move display (0-> cursor) ? */ | 233 | #define LCD_MOVE_DISP 3 /* DB3: move display (0-> cursor) ? */ |
| 241 | #define LCD_MOVE_RIGHT 2 /* DB2: move right (0-> left) ? */ | 234 | #define LCD_MOVE_RIGHT 2 /* DB2: move right (0-> left) ? */ |
| 242 | #define LCD_FUNCTION 5 /* DB5: function set */ | 235 | #define LCD_FUNCTION 5 /* DB5: function set */ |
| 243 | #define LCD_FUNCTION_8BIT 4 /* DB4: set 8BIT mode (0->4BIT mode) */ | 236 | #define LCD_FUNCTION_8BIT 4 /* DB4: set 8BIT mode (0->4BIT mode) */ |
| 244 | #define LCD_FUNCTION_2LINES 3 /* DB3: two lines (0->one line) */ | 237 | #define LCD_FUNCTION_2LINES 3 /* DB3: two lines (0->one line) */ |
| 245 | #define LCD_FUNCTION_10DOTS 2 /* DB2: 5x10 font (0->5x7 font) */ | 238 | #define LCD_FUNCTION_10DOTS 2 /* DB2: 5x10 font (0->5x7 font) */ |
| 246 | #define LCD_CGRAM 6 /* DB6: set CG RAM address */ | 239 | #define LCD_CGRAM 6 /* DB6: set CG RAM address */ |
| 247 | #define LCD_DDRAM 7 /* DB7: set DD RAM address */ | 240 | #define LCD_DDRAM 7 /* DB7: set DD RAM address */ |
| 248 | #define LCD_BUSY 7 /* DB7: LCD is busy */ | 241 | #define LCD_BUSY 7 /* DB7: LCD is busy */ |
| 249 | 242 | ||
| 250 | /* set entry mode: display shift on/off, dec/inc cursor move direction */ | 243 | /* set entry mode: display shift on/off, dec/inc cursor move direction */ |
| 251 | #define LCD_ENTRY_DEC 0x04 /* display shift off, dec cursor move dir */ | 244 | #define LCD_ENTRY_DEC 0x04 /* display shift off, dec cursor move dir */ |
| 252 | #define LCD_ENTRY_DEC_SHIFT 0x05 /* display shift on, dec cursor move dir */ | 245 | #define LCD_ENTRY_DEC_SHIFT 0x05 /* display shift on, dec cursor move dir */ |
| 253 | #define LCD_ENTRY_INC_ 0x06 /* display shift off, inc cursor move dir */ | 246 | #define LCD_ENTRY_INC_ 0x06 /* display shift off, inc cursor move dir */ |
| 254 | #define LCD_ENTRY_INC_SHIFT 0x07 /* display shift on, inc cursor move dir */ | 247 | #define LCD_ENTRY_INC_SHIFT 0x07 /* display shift on, inc cursor move dir */ |
| 255 | 248 | ||
| 256 | /* display on/off, cursor on/off, blinking char at cursor position */ | 249 | /* display on/off, cursor on/off, blinking char at cursor position */ |
| 257 | #define LCD_DISP_OFF 0x08 /* display off */ | 250 | #define LCD_DISP_OFF 0x08 /* display off */ |
| 258 | #define LCD_DISP_ON 0x0C /* display on, cursor off */ | 251 | #define LCD_DISP_ON 0x0C /* display on, cursor off */ |
| 259 | #define LCD_DISP_ON_BLINK 0x0D /* display on, cursor off, blink char */ | 252 | #define LCD_DISP_ON_BLINK 0x0D /* display on, cursor off, blink char */ |
| 260 | #define LCD_DISP_ON_CURSOR 0x0E /* display on, cursor on */ | 253 | #define LCD_DISP_ON_CURSOR 0x0E /* display on, cursor on */ |
| 261 | #define LCD_DISP_ON_CURSOR_BLINK 0x0F /* display on, cursor on, blink char */ | 254 | #define LCD_DISP_ON_CURSOR_BLINK 0x0F /* display on, cursor on, blink char */ |
| 262 | 255 | ||
| 263 | /* move cursor/shift display */ | 256 | /* move cursor/shift display */ |
| 264 | #define LCD_MOVE_CURSOR_LEFT 0x10 /* move cursor left (decrement) */ | 257 | #define LCD_MOVE_CURSOR_LEFT 0x10 /* move cursor left (decrement) */ |
| 265 | #define LCD_MOVE_CURSOR_RIGHT 0x14 /* move cursor right (increment) */ | 258 | #define LCD_MOVE_CURSOR_RIGHT 0x14 /* move cursor right (increment) */ |
| 266 | #define LCD_MOVE_DISP_LEFT 0x18 /* shift display left */ | 259 | #define LCD_MOVE_DISP_LEFT 0x18 /* shift display left */ |
| 267 | #define LCD_MOVE_DISP_RIGHT 0x1C /* shift display right */ | 260 | #define LCD_MOVE_DISP_RIGHT 0x1C /* shift display right */ |
| 268 | 261 | ||
| 269 | /* function set: set interface data length and number of display lines */ | 262 | /* function set: set interface data length and number of display lines */ |
| 270 | #define LCD_FUNCTION_4BIT_1LINE 0x20 /* 4-bit interface, single line, 5x7 dots */ | 263 | #define LCD_FUNCTION_4BIT_1LINE 0x20 /* 4-bit interface, single line, 5x7 dots */ |
| 271 | #define LCD_FUNCTION_4BIT_2LINES 0x28 /* 4-bit interface, dual line, 5x7 dots */ | 264 | #define LCD_FUNCTION_4BIT_2LINES 0x28 /* 4-bit interface, dual line, 5x7 dots */ |
| 272 | #define LCD_FUNCTION_8BIT_1LINE 0x30 /* 8-bit interface, single line, 5x7 dots */ | 265 | #define LCD_FUNCTION_8BIT_1LINE 0x30 /* 8-bit interface, single line, 5x7 dots */ |
| 273 | #define LCD_FUNCTION_8BIT_2LINES 0x38 /* 8-bit interface, dual line, 5x7 dots */ | 266 | #define LCD_FUNCTION_8BIT_2LINES 0x38 /* 8-bit interface, dual line, 5x7 dots */ |
| 274 | 267 | ||
| 268 | #define LCD_MODE_DEFAULT ((1 << LCD_ENTRY_MODE) | (1 << LCD_ENTRY_INC)) | ||
| 275 | 269 | ||
| 276 | #define LCD_MODE_DEFAULT ((1<<LCD_ENTRY_MODE) | (1<<LCD_ENTRY_INC) ) | 270 | /** |
| 277 | |||
| 278 | |||
| 279 | |||
| 280 | /** | ||
| 281 | * @name Functions | 271 | * @name Functions |
| 282 | */ | 272 | */ |
| 283 | 273 | ||
| 284 | |||
| 285 | /** | 274 | /** |
| 286 | @brief Initialize display and select type of cursor | 275 | @brief Initialize display and select type of cursor |
| 287 | @param dispAttr \b LCD_DISP_OFF display off\n | 276 | @param dispAttr \b LCD_DISP_OFF display off\n |
| 288 | \b LCD_DISP_ON display on, cursor off\n | 277 | \b LCD_DISP_ON display on, cursor off\n |
| 289 | \b LCD_DISP_ON_CURSOR display on, cursor on\n | 278 | \b LCD_DISP_ON_CURSOR display on, cursor on\n |
| 290 | \b LCD_DISP_ON_CURSOR_BLINK display on, cursor on flashing | 279 | \b LCD_DISP_ON_CURSOR_BLINK display on, cursor on flashing |
| 291 | @return none | 280 | @return none |
| 292 | */ | 281 | */ |
| 293 | extern void lcd_init(uint8_t dispAttr); | 282 | extern void lcd_init(uint8_t dispAttr); |
| 294 | 283 | ||
| 295 | |||
| 296 | /** | 284 | /** |
| 297 | @brief Clear display and set cursor to home position | 285 | @brief Clear display and set cursor to home position |
| 298 | @return none | 286 | @return none |
| 299 | */ | 287 | */ |
| 300 | extern void lcd_clrscr(void); | 288 | extern void lcd_clrscr(void); |
| 301 | 289 | ||
| 302 | |||
| 303 | /** | 290 | /** |
| 304 | @brief Set cursor to home position | 291 | @brief Set cursor to home position |
| 305 | @return none | 292 | @return none |
| 306 | */ | 293 | */ |
| 307 | extern void lcd_home(void); | 294 | extern void lcd_home(void); |
| 308 | 295 | ||
| 309 | |||
| 310 | /** | 296 | /** |
| 311 | @brief Set cursor to specified position | 297 | @brief Set cursor to specified position |
| 312 | 298 | ||
| 313 | @param x horizontal position\n (0: left most position) | 299 | @param x horizontal position\n (0: left most position) |
| 314 | @param y vertical position\n (0: first line) | 300 | @param y vertical position\n (0: first line) |
| 315 | @return none | 301 | @return none |
| 316 | */ | 302 | */ |
| 317 | extern void lcd_gotoxy(uint8_t x, uint8_t y); | 303 | extern void lcd_gotoxy(uint8_t x, uint8_t y); |
| 318 | 304 | ||
| 319 | |||
| 320 | /** | 305 | /** |
| 321 | @brief Display character at current cursor position | 306 | @brief Display character at current cursor position |
| 322 | @param c character to be displayed | 307 | @param c character to be displayed |
| 323 | @return none | 308 | @return none |
| 324 | */ | 309 | */ |
| 325 | extern void lcd_putc(char c); | 310 | extern void lcd_putc(char c); |
| 326 | 311 | ||
| 327 | |||
| 328 | /** | 312 | /** |
| 329 | @brief Display string without auto linefeed | 313 | @brief Display string without auto linefeed |
| 330 | @param s string to be displayed | 314 | @param s string to be displayed |
| 331 | @return none | 315 | @return none |
| 332 | */ | 316 | */ |
| 333 | extern void lcd_puts(const char *s); | 317 | extern void lcd_puts(const char *s); |
| 334 | 318 | ||
| 335 | |||
| 336 | /** | 319 | /** |
| 337 | @brief Display string from program memory without auto linefeed | 320 | @brief Display string from program memory without auto linefeed |
| 338 | @param progmem_s string from program memory be be displayed | 321 | @param progmem_s string from program memory be be displayed |
| 339 | @return none | 322 | @return none |
| 340 | @see lcd_puts_P | 323 | @see lcd_puts_P |
| 341 | */ | 324 | */ |
| 342 | extern void lcd_puts_p(const char *progmem_s); | 325 | extern void lcd_puts_p(const char *progmem_s); |
| 343 | 326 | ||
| 344 | |||
| 345 | /** | 327 | /** |
| 346 | @brief Send LCD controller instruction command | 328 | @brief Send LCD controller instruction command |
| 347 | @param cmd instruction to send to LCD controller, see HD44780 data sheet | 329 | @param cmd instruction to send to LCD controller, see HD44780 data sheet |
| @@ -349,23 +331,20 @@ extern void lcd_puts_p(const char *progmem_s); | |||
| 349 | */ | 331 | */ |
| 350 | extern void lcd_command(uint8_t cmd); | 332 | extern void lcd_command(uint8_t cmd); |
| 351 | 333 | ||
| 352 | |||
| 353 | /** | 334 | /** |
| 354 | @brief Send data byte to LCD controller | 335 | @brief Send data byte to LCD controller |
| 355 | 336 | ||
| 356 | Similar to lcd_putc(), but without interpreting LF | 337 | Similar to lcd_putc(), but without interpreting LF |
| 357 | @param data byte to send to LCD controller, see HD44780 data sheet | 338 | @param data byte to send to LCD controller, see HD44780 data sheet |
| 358 | @return none | 339 | @return none |
| 359 | */ | 340 | */ |
| 360 | extern void lcd_data(uint8_t data); | 341 | extern void lcd_data(uint8_t data); |
| 361 | 342 | ||
| 362 | |||
| 363 | /** | 343 | /** |
| 364 | @brief macros for automatically storing string constant in program memory | 344 | @brief macros for automatically storing string constant in program memory |
| 365 | */ | 345 | */ |
| 366 | #define lcd_puts_P(__s) lcd_puts_p(PSTR(__s)) | 346 | #define lcd_puts_P(__s) lcd_puts_p(PSTR(__s)) |
| 367 | 347 | ||
| 368 | /**@}*/ | 348 | /**@}*/ |
| 369 | 349 | ||
| 370 | #endif //LCD_H | 350 | #endif // LCD_H |
| 371 | |||
diff --git a/drivers/avr/i2c_master.c b/drivers/avr/i2c_master.c index 0acc24642..52924437e 100755..100644 --- a/drivers/avr/i2c_master.c +++ b/drivers/avr/i2c_master.c | |||
| @@ -25,200 +25,200 @@ | |||
| 25 | #include "wait.h" | 25 | #include "wait.h" |
| 26 | 26 | ||
| 27 | #ifndef F_SCL | 27 | #ifndef F_SCL |
| 28 | # define F_SCL 400000UL // SCL frequency | 28 | # define F_SCL 400000UL // SCL frequency |
| 29 | #endif | 29 | #endif |
| 30 | #define Prescaler 1 | 30 | #define Prescaler 1 |
| 31 | #define TWBR_val ((((F_CPU / F_SCL) / Prescaler) - 16) / 2) | 31 | #define TWBR_val ((((F_CPU / F_SCL) / Prescaler) - 16) / 2) |
| 32 | 32 | ||
| 33 | void i2c_init(void) { | 33 | void i2c_init(void) { |
| 34 | TWSR = 0; /* no prescaler */ | 34 | TWSR = 0; /* no prescaler */ |
| 35 | TWBR = (uint8_t)TWBR_val; | 35 | TWBR = (uint8_t)TWBR_val; |
| 36 | 36 | ||
| 37 | #ifdef __AVR_ATmega32A__ | 37 | #ifdef __AVR_ATmega32A__ |
| 38 | // set pull-up resistors on I2C bus pins | 38 | // set pull-up resistors on I2C bus pins |
| 39 | PORTC |= 0b11; | 39 | PORTC |= 0b11; |
| 40 | 40 | ||
| 41 | // enable TWI (two-wire interface) | 41 | // enable TWI (two-wire interface) |
| 42 | TWCR |= (1 << TWEN); | 42 | TWCR |= (1 << TWEN); |
| 43 | 43 | ||
| 44 | // enable TWI interrupt and slave address ACK | 44 | // enable TWI interrupt and slave address ACK |
| 45 | TWCR |= (1 << TWIE); | 45 | TWCR |= (1 << TWIE); |
| 46 | TWCR |= (1 << TWEA); | 46 | TWCR |= (1 << TWEA); |
| 47 | #endif | 47 | #endif |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | i2c_status_t i2c_start(uint8_t address, uint16_t timeout) { | 50 | i2c_status_t i2c_start(uint8_t address, uint16_t timeout) { |
| 51 | // reset TWI control register | 51 | // reset TWI control register |
| 52 | TWCR = 0; | 52 | TWCR = 0; |
| 53 | // transmit START condition | 53 | // transmit START condition |
| 54 | TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN); | 54 | TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN); |
| 55 | 55 | ||
| 56 | uint16_t timeout_timer = timer_read(); | 56 | uint16_t timeout_timer = timer_read(); |
| 57 | while (!(TWCR & (1 << TWINT))) { | 57 | while (!(TWCR & (1 << TWINT))) { |
| 58 | if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) { | 58 | if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) { |
| 59 | return I2C_STATUS_TIMEOUT; | 59 | return I2C_STATUS_TIMEOUT; |
| 60 | } | 60 | } |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | // check if the start condition was successfully transmitted | 63 | // check if the start condition was successfully transmitted |
| 64 | if (((TW_STATUS & 0xF8) != TW_START) && ((TW_STATUS & 0xF8) != TW_REP_START)) { | 64 | if (((TW_STATUS & 0xF8) != TW_START) && ((TW_STATUS & 0xF8) != TW_REP_START)) { |
| 65 | return I2C_STATUS_ERROR; | 65 | return I2C_STATUS_ERROR; |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | // load slave address into data register | 68 | // load slave address into data register |
| 69 | TWDR = address; | 69 | TWDR = address; |
| 70 | // start transmission of address | 70 | // start transmission of address |
| 71 | TWCR = (1 << TWINT) | (1 << TWEN); | 71 | TWCR = (1 << TWINT) | (1 << TWEN); |
| 72 | 72 | ||
| 73 | timeout_timer = timer_read(); | 73 | timeout_timer = timer_read(); |
| 74 | while (!(TWCR & (1 << TWINT))) { | 74 | while (!(TWCR & (1 << TWINT))) { |
| 75 | if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) { | 75 | if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) { |
| 76 | return I2C_STATUS_TIMEOUT; | 76 | return I2C_STATUS_TIMEOUT; |
| 77 | } | 77 | } |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | // check if the device has acknowledged the READ / WRITE mode | 80 | // check if the device has acknowledged the READ / WRITE mode |
| 81 | uint8_t twst = TW_STATUS & 0xF8; | 81 | uint8_t twst = TW_STATUS & 0xF8; |
| 82 | if ((twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK)) { | 82 | if ((twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK)) { |
| 83 | return I2C_STATUS_ERROR; | 83 | return I2C_STATUS_ERROR; |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | return I2C_STATUS_SUCCESS; | 86 | return I2C_STATUS_SUCCESS; |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | i2c_status_t i2c_write(uint8_t data, uint16_t timeout) { | 89 | i2c_status_t i2c_write(uint8_t data, uint16_t timeout) { |
| 90 | // load data into data register | 90 | // load data into data register |
| 91 | TWDR = data; | 91 | TWDR = data; |
| 92 | // start transmission of data | 92 | // start transmission of data |
| 93 | TWCR = (1 << TWINT) | (1 << TWEN); | 93 | TWCR = (1 << TWINT) | (1 << TWEN); |
| 94 | 94 | ||
| 95 | uint16_t timeout_timer = timer_read(); | 95 | uint16_t timeout_timer = timer_read(); |
| 96 | while (!(TWCR & (1 << TWINT))) { | 96 | while (!(TWCR & (1 << TWINT))) { |
| 97 | if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) { | 97 | if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) { |
| 98 | return I2C_STATUS_TIMEOUT; | 98 | return I2C_STATUS_TIMEOUT; |
| 99 | } | ||
| 99 | } | 100 | } |
| 100 | } | ||
| 101 | 101 | ||
| 102 | if ((TW_STATUS & 0xF8) != TW_MT_DATA_ACK) { | 102 | if ((TW_STATUS & 0xF8) != TW_MT_DATA_ACK) { |
| 103 | return I2C_STATUS_ERROR; | 103 | return I2C_STATUS_ERROR; |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | return I2C_STATUS_SUCCESS; | 106 | return I2C_STATUS_SUCCESS; |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | int16_t i2c_read_ack(uint16_t timeout) { | 109 | int16_t i2c_read_ack(uint16_t timeout) { |
| 110 | // start TWI module and acknowledge data after reception | 110 | // start TWI module and acknowledge data after reception |
| 111 | TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWEA); | 111 | TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWEA); |
| 112 | 112 | ||
| 113 | uint16_t timeout_timer = timer_read(); | 113 | uint16_t timeout_timer = timer_read(); |
| 114 | while (!(TWCR & (1 << TWINT))) { | 114 | while (!(TWCR & (1 << TWINT))) { |
| 115 | if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) { | 115 | if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) { |
| 116 | return I2C_STATUS_TIMEOUT; | 116 | return I2C_STATUS_TIMEOUT; |
| 117 | } | ||
| 117 | } | 118 | } |
| 118 | } | ||
| 119 | 119 | ||
| 120 | // return received data from TWDR | 120 | // return received data from TWDR |
| 121 | return TWDR; | 121 | return TWDR; |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | int16_t i2c_read_nack(uint16_t timeout) { | 124 | int16_t i2c_read_nack(uint16_t timeout) { |
| 125 | // start receiving without acknowledging reception | 125 | // start receiving without acknowledging reception |
| 126 | TWCR = (1 << TWINT) | (1 << TWEN); | 126 | TWCR = (1 << TWINT) | (1 << TWEN); |
| 127 | 127 | ||
| 128 | uint16_t timeout_timer = timer_read(); | 128 | uint16_t timeout_timer = timer_read(); |
| 129 | while (!(TWCR & (1 << TWINT))) { | 129 | while (!(TWCR & (1 << TWINT))) { |
| 130 | if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) { | 130 | if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) { |
| 131 | return I2C_STATUS_TIMEOUT; | 131 | return I2C_STATUS_TIMEOUT; |
| 132 | } | ||
| 132 | } | 133 | } |
| 133 | } | ||
| 134 | 134 | ||
| 135 | // return received data from TWDR | 135 | // return received data from TWDR |
| 136 | return TWDR; | 136 | return TWDR; |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout) { | 139 | i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout) { |
| 140 | i2c_status_t status = i2c_start(address | I2C_WRITE, timeout); | 140 | i2c_status_t status = i2c_start(address | I2C_WRITE, timeout); |
| 141 | 141 | ||
| 142 | for (uint16_t i = 0; i < length && status >= 0; i++) { | 142 | for (uint16_t i = 0; i < length && status >= 0; i++) { |
| 143 | status = i2c_write(data[i], timeout); | 143 | status = i2c_write(data[i], timeout); |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | i2c_stop(); | 146 | i2c_stop(); |
| 147 | 147 | ||
| 148 | return status; | 148 | return status; |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout) { | 151 | i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout) { |
| 152 | i2c_status_t status = i2c_start(address | I2C_READ, timeout); | 152 | i2c_status_t status = i2c_start(address | I2C_READ, timeout); |
| 153 | 153 | ||
| 154 | for (uint16_t i = 0; i < (length - 1) && status >= 0; i++) { | 154 | for (uint16_t i = 0; i < (length - 1) && status >= 0; i++) { |
| 155 | status = i2c_read_ack(timeout); | 155 | status = i2c_read_ack(timeout); |
| 156 | if (status >= 0) { | 156 | if (status >= 0) { |
| 157 | data[i] = status; | 157 | data[i] = status; |
| 158 | } | ||
| 158 | } | 159 | } |
| 159 | } | ||
| 160 | 160 | ||
| 161 | if (status >= 0) { | ||
| 162 | status = i2c_read_nack(timeout); | ||
| 163 | if (status >= 0) { | 161 | if (status >= 0) { |
| 164 | data[(length - 1)] = status; | 162 | status = i2c_read_nack(timeout); |
| 163 | if (status >= 0) { | ||
| 164 | data[(length - 1)] = status; | ||
| 165 | } | ||
| 165 | } | 166 | } |
| 166 | } | ||
| 167 | 167 | ||
| 168 | i2c_stop(); | 168 | i2c_stop(); |
| 169 | 169 | ||
| 170 | return (status < 0) ? status : I2C_STATUS_SUCCESS; | 170 | return (status < 0) ? status : I2C_STATUS_SUCCESS; |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout) { | 173 | i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout) { |
| 174 | i2c_status_t status = i2c_start(devaddr | 0x00, timeout); | 174 | i2c_status_t status = i2c_start(devaddr | 0x00, timeout); |
| 175 | if (status >= 0) { | 175 | if (status >= 0) { |
| 176 | status = i2c_write(regaddr, timeout); | 176 | status = i2c_write(regaddr, timeout); |
| 177 | 177 | ||
| 178 | for (uint16_t i = 0; i < length && status >= 0; i++) { | 178 | for (uint16_t i = 0; i < length && status >= 0; i++) { |
| 179 | status = i2c_write(data[i], timeout); | 179 | status = i2c_write(data[i], timeout); |
| 180 | } | ||
| 180 | } | 181 | } |
| 181 | } | ||
| 182 | 182 | ||
| 183 | i2c_stop(); | 183 | i2c_stop(); |
| 184 | 184 | ||
| 185 | return status; | 185 | return status; |
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout) { | 188 | i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout) { |
| 189 | i2c_status_t status = i2c_start(devaddr, timeout); | 189 | i2c_status_t status = i2c_start(devaddr, timeout); |
| 190 | if (status < 0) { | 190 | if (status < 0) { |
| 191 | goto error; | 191 | goto error; |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | status = i2c_write(regaddr, timeout); | 194 | status = i2c_write(regaddr, timeout); |
| 195 | if (status < 0) { | 195 | if (status < 0) { |
| 196 | goto error; | 196 | goto error; |
| 197 | } | 197 | } |
| 198 | 198 | ||
| 199 | status = i2c_start(devaddr | 0x01, timeout); | 199 | status = i2c_start(devaddr | 0x01, timeout); |
| 200 | 200 | ||
| 201 | for (uint16_t i = 0; i < (length - 1) && status >= 0; i++) { | 201 | for (uint16_t i = 0; i < (length - 1) && status >= 0; i++) { |
| 202 | status = i2c_read_ack(timeout); | 202 | status = i2c_read_ack(timeout); |
| 203 | if (status >= 0) { | 203 | if (status >= 0) { |
| 204 | data[i] = status; | 204 | data[i] = status; |
| 205 | } | ||
| 205 | } | 206 | } |
| 206 | } | ||
| 207 | 207 | ||
| 208 | if (status >= 0) { | ||
| 209 | status = i2c_read_nack(timeout); | ||
| 210 | if (status >= 0) { | 208 | if (status >= 0) { |
| 211 | data[(length - 1)] = status; | 209 | status = i2c_read_nack(timeout); |
| 210 | if (status >= 0) { | ||
| 211 | data[(length - 1)] = status; | ||
| 212 | } | ||
| 212 | } | 213 | } |
| 213 | } | ||
| 214 | 214 | ||
| 215 | error: | 215 | error: |
| 216 | i2c_stop(); | 216 | i2c_stop(); |
| 217 | 217 | ||
| 218 | return (status < 0) ? status : I2C_STATUS_SUCCESS; | 218 | return (status < 0) ? status : I2C_STATUS_SUCCESS; |
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | void i2c_stop(void) { | 221 | void i2c_stop(void) { |
| 222 | // transmit STOP condition | 222 | // transmit STOP condition |
| 223 | TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO); | 223 | TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO); |
| 224 | } | 224 | } |
diff --git a/drivers/avr/i2c_master.h b/drivers/avr/i2c_master.h index d68142430..0a3b6c508 100755..100644 --- a/drivers/avr/i2c_master.h +++ b/drivers/avr/i2c_master.h | |||
| @@ -26,21 +26,21 @@ | |||
| 26 | typedef int16_t i2c_status_t; | 26 | typedef int16_t i2c_status_t; |
| 27 | 27 | ||
| 28 | #define I2C_STATUS_SUCCESS (0) | 28 | #define I2C_STATUS_SUCCESS (0) |
| 29 | #define I2C_STATUS_ERROR (-1) | 29 | #define I2C_STATUS_ERROR (-1) |
| 30 | #define I2C_STATUS_TIMEOUT (-2) | 30 | #define I2C_STATUS_TIMEOUT (-2) |
| 31 | 31 | ||
| 32 | #define I2C_TIMEOUT_IMMEDIATE (0) | 32 | #define I2C_TIMEOUT_IMMEDIATE (0) |
| 33 | #define I2C_TIMEOUT_INFINITE (0xFFFF) | 33 | #define I2C_TIMEOUT_INFINITE (0xFFFF) |
| 34 | 34 | ||
| 35 | void i2c_init(void); | 35 | void i2c_init(void); |
| 36 | i2c_status_t i2c_start(uint8_t address, uint16_t timeout); | 36 | i2c_status_t i2c_start(uint8_t address, uint16_t timeout); |
| 37 | i2c_status_t i2c_write(uint8_t data, uint16_t timeout); | 37 | i2c_status_t i2c_write(uint8_t data, uint16_t timeout); |
| 38 | int16_t i2c_read_ack(uint16_t timeout); | 38 | int16_t i2c_read_ack(uint16_t timeout); |
| 39 | int16_t i2c_read_nack(uint16_t timeout); | 39 | int16_t i2c_read_nack(uint16_t timeout); |
| 40 | i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout); | 40 | i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout); |
| 41 | i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout); | 41 | i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout); |
| 42 | i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout); | 42 | i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout); |
| 43 | i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout); | 43 | i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout); |
| 44 | void i2c_stop(void); | 44 | void i2c_stop(void); |
| 45 | 45 | ||
| 46 | #endif // I2C_MASTER_H | 46 | #endif // I2C_MASTER_H |
diff --git a/drivers/avr/i2c_slave.c b/drivers/avr/i2c_slave.c index 4958a0f8e..3fb684f70 100755..100644 --- a/drivers/avr/i2c_slave.c +++ b/drivers/avr/i2c_slave.c | |||
| @@ -27,24 +27,24 @@ | |||
| 27 | volatile uint8_t i2c_slave_reg[I2C_SLAVE_REG_COUNT]; | 27 | volatile uint8_t i2c_slave_reg[I2C_SLAVE_REG_COUNT]; |
| 28 | 28 | ||
| 29 | static volatile uint8_t buffer_address; | 29 | static volatile uint8_t buffer_address; |
| 30 | static volatile bool slave_has_register_set = false; | 30 | static volatile bool slave_has_register_set = false; |
| 31 | 31 | ||
| 32 | void i2c_slave_init(uint8_t address){ | 32 | void i2c_slave_init(uint8_t address) { |
| 33 | // load address into TWI address register | 33 | // load address into TWI address register |
| 34 | TWAR = address; | 34 | TWAR = address; |
| 35 | // set the TWCR to enable address matching and enable TWI, clear TWINT, enable TWI interrupt | 35 | // set the TWCR to enable address matching and enable TWI, clear TWINT, enable TWI interrupt |
| 36 | TWCR = (1 << TWIE) | (1 << TWEA) | (1 << TWINT) | (1 << TWEN); | 36 | TWCR = (1 << TWIE) | (1 << TWEA) | (1 << TWINT) | (1 << TWEN); |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | void i2c_slave_stop(void){ | 39 | void i2c_slave_stop(void) { |
| 40 | // clear acknowledge and enable bits | 40 | // clear acknowledge and enable bits |
| 41 | TWCR &= ~((1 << TWEA) | (1 << TWEN)); | 41 | TWCR &= ~((1 << TWEA) | (1 << TWEN)); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | ISR(TWI_vect){ | 44 | ISR(TWI_vect) { |
| 45 | uint8_t ack = 1; | 45 | uint8_t ack = 1; |
| 46 | 46 | ||
| 47 | switch(TW_STATUS){ | 47 | switch (TW_STATUS) { |
| 48 | case TW_SR_SLA_ACK: | 48 | case TW_SR_SLA_ACK: |
| 49 | // The device is now a slave receiver | 49 | // The device is now a slave receiver |
| 50 | slave_has_register_set = false; | 50 | slave_has_register_set = false; |
| @@ -53,14 +53,14 @@ ISR(TWI_vect){ | |||
| 53 | case TW_SR_DATA_ACK: | 53 | case TW_SR_DATA_ACK: |
| 54 | // This device is a slave receiver and has received data | 54 | // This device is a slave receiver and has received data |
| 55 | // First byte is the location then the bytes will be writen in buffer with auto-incriment | 55 | // First byte is the location then the bytes will be writen in buffer with auto-incriment |
| 56 | if(!slave_has_register_set){ | 56 | if (!slave_has_register_set) { |
| 57 | buffer_address = TWDR; | 57 | buffer_address = TWDR; |
| 58 | 58 | ||
| 59 | if (buffer_address >= I2C_SLAVE_REG_COUNT) { // address out of bounds dont ack | 59 | if (buffer_address >= I2C_SLAVE_REG_COUNT) { // address out of bounds dont ack |
| 60 | ack = 0; | 60 | ack = 0; |
| 61 | buffer_address = 0; | 61 | buffer_address = 0; |
| 62 | } | 62 | } |
| 63 | slave_has_register_set = true; // address has been receaved now fill in buffer | 63 | slave_has_register_set = true; // address has been receaved now fill in buffer |
| 64 | } else { | 64 | } else { |
| 65 | i2c_slave_reg[buffer_address] = TWDR; | 65 | i2c_slave_reg[buffer_address] = TWDR; |
| 66 | buffer_address++; | 66 | buffer_address++; |
diff --git a/drivers/avr/i2c_slave.h b/drivers/avr/i2c_slave.h index 2f4589e9c..5ed0b11a8 100755..100644 --- a/drivers/avr/i2c_slave.h +++ b/drivers/avr/i2c_slave.h | |||
| @@ -30,4 +30,4 @@ extern volatile uint8_t i2c_slave_reg[I2C_SLAVE_REG_COUNT]; | |||
| 30 | void i2c_slave_init(uint8_t address); | 30 | void i2c_slave_init(uint8_t address); |
| 31 | void i2c_slave_stop(void); | 31 | void i2c_slave_stop(void); |
| 32 | 32 | ||
| 33 | #endif // I2C_SLAVE_H | 33 | #endif // I2C_SLAVE_H |
diff --git a/drivers/avr/pro_micro.h b/drivers/avr/pro_micro.h index f9e7ed75d..762a99a05 100644 --- a/drivers/avr/pro_micro.h +++ b/drivers/avr/pro_micro.h | |||
| @@ -90,14 +90,14 @@ | |||
| 90 | #undef OCR2_6 | 90 | #undef OCR2_6 |
| 91 | #undef OCR2_7 | 91 | #undef OCR2_7 |
| 92 | 92 | ||
| 93 | #define NUM_DIGITAL_PINS 30 | 93 | #define NUM_DIGITAL_PINS 30 |
| 94 | #define NUM_ANALOG_INPUTS 12 | 94 | #define NUM_ANALOG_INPUTS 12 |
| 95 | 95 | ||
| 96 | #define TX_RX_LED_INIT DDRD |= (1<<5), DDRB |= (1<<0) | 96 | #define TX_RX_LED_INIT DDRD |= (1 << 5), DDRB |= (1 << 0) |
| 97 | #define TXLED0 PORTD |= (1<<5) | 97 | #define TXLED0 PORTD |= (1 << 5) |
| 98 | #define TXLED1 PORTD &= ~(1<<5) | 98 | #define TXLED1 PORTD &= ~(1 << 5) |
| 99 | #define RXLED0 PORTB |= (1<<0) | 99 | #define RXLED0 PORTB |= (1 << 0) |
| 100 | #define RXLED1 PORTB &= ~(1<<0) | 100 | #define RXLED1 PORTB &= ~(1 << 0) |
| 101 | 101 | ||
| 102 | static const uint8_t SDA = 2; | 102 | static const uint8_t SDA = 2; |
| 103 | static const uint8_t SCL = 3; | 103 | static const uint8_t SCL = 3; |
| @@ -111,27 +111,27 @@ static const uint8_t SCK = 15; | |||
| 111 | 111 | ||
| 112 | // Mapping of analog pins as digital I/O | 112 | // Mapping of analog pins as digital I/O |
| 113 | // A6-A11 share with digital pins | 113 | // A6-A11 share with digital pins |
| 114 | static const uint8_t ADC0 = 18; | 114 | static const uint8_t ADC0 = 18; |
| 115 | static const uint8_t ADC1 = 19; | 115 | static const uint8_t ADC1 = 19; |
| 116 | static const uint8_t ADC2 = 20; | 116 | static const uint8_t ADC2 = 20; |
| 117 | static const uint8_t ADC3 = 21; | 117 | static const uint8_t ADC3 = 21; |
| 118 | static const uint8_t ADC4 = 22; | 118 | static const uint8_t ADC4 = 22; |
| 119 | static const uint8_t ADC5 = 23; | 119 | static const uint8_t ADC5 = 23; |
| 120 | static const uint8_t ADC6 = 24; // D4 | 120 | static const uint8_t ADC6 = 24; // D4 |
| 121 | static const uint8_t ADC7 = 25; // D6 | 121 | static const uint8_t ADC7 = 25; // D6 |
| 122 | static const uint8_t ADC8 = 26; // D8 | 122 | static const uint8_t ADC8 = 26; // D8 |
| 123 | static const uint8_t ADC9 = 27; // D9 | 123 | static const uint8_t ADC9 = 27; // D9 |
| 124 | static const uint8_t ADC10 = 28; // D10 | 124 | static const uint8_t ADC10 = 28; // D10 |
| 125 | static const uint8_t ADC11 = 29; // D12 | 125 | static const uint8_t ADC11 = 29; // D12 |
| 126 | 126 | ||
| 127 | #define digitalPinToPCICR(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCICR) : ((uint8_t *)0)) | 127 | #define digitalPinToPCICR(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCICR) : ((uint8_t *)0)) |
| 128 | #define digitalPinToPCICRbit(p) 0 | 128 | #define digitalPinToPCICRbit(p) 0 |
| 129 | #define digitalPinToPCMSK(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCMSK0) : ((uint8_t *)0)) | 129 | #define digitalPinToPCMSK(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCMSK0) : ((uint8_t *)0)) |
| 130 | #define digitalPinToPCMSKbit(p) ( ((p) >= 8 && (p) <= 11) ? (p) - 4 : ((p) == 14 ? 3 : ((p) == 15 ? 1 : ((p) == 16 ? 2 : ((p) == 17 ? 0 : (p - A8 + 4)))))) | 130 | #define digitalPinToPCMSKbit(p) (((p) >= 8 && (p) <= 11) ? (p)-4 : ((p) == 14 ? 3 : ((p) == 15 ? 1 : ((p) == 16 ? 2 : ((p) == 17 ? 0 : (p - A8 + 4)))))) |
| 131 | 131 | ||
| 132 | // __AVR_ATmega32U4__ has an unusual mapping of pins to channels | 132 | // __AVR_ATmega32U4__ has an unusual mapping of pins to channels |
| 133 | extern const uint8_t PROGMEM analog_pin_to_channel_PGM[]; | 133 | extern const uint8_t PROGMEM analog_pin_to_channel_PGM[]; |
| 134 | #define analogPinToChannel(P) ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) ) | 134 | #define analogPinToChannel(P) (pgm_read_byte(analog_pin_to_channel_PGM + (P))) |
| 135 | 135 | ||
| 136 | #define digitalPinToInterrupt(p) ((p) == 0 ? 2 : ((p) == 1 ? 3 : ((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ? 4 : NOT_AN_INTERRUPT))))) | 136 | #define digitalPinToInterrupt(p) ((p) == 0 ? 2 : ((p) == 1 ? 3 : ((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ? 4 : NOT_AN_INTERRUPT))))) |
| 137 | 137 | ||
| @@ -182,159 +182,121 @@ extern const uint8_t PROGMEM analog_pin_to_channel_PGM[]; | |||
| 182 | // appropriate addresses for various functions (e.g. reading | 182 | // appropriate addresses for various functions (e.g. reading |
| 183 | // and writing) | 183 | // and writing) |
| 184 | const uint16_t PROGMEM port_to_mode_PGM[] = { | 184 | const uint16_t PROGMEM port_to_mode_PGM[] = { |
| 185 | NOT_A_PORT, | 185 | NOT_A_PORT, NOT_A_PORT, (uint16_t)&DDRB, (uint16_t)&DDRC, (uint16_t)&DDRD, (uint16_t)&DDRE, (uint16_t)&DDRF, |
| 186 | NOT_A_PORT, | ||
| 187 | (uint16_t) &DDRB, | ||
| 188 | (uint16_t) &DDRC, | ||
| 189 | (uint16_t) &DDRD, | ||
| 190 | (uint16_t) &DDRE, | ||
| 191 | (uint16_t) &DDRF, | ||
| 192 | }; | 186 | }; |
| 193 | 187 | ||
| 194 | const uint16_t PROGMEM port_to_output_PGM[] = { | 188 | const uint16_t PROGMEM port_to_output_PGM[] = { |
| 195 | NOT_A_PORT, | 189 | NOT_A_PORT, NOT_A_PORT, (uint16_t)&PORTB, (uint16_t)&PORTC, (uint16_t)&PORTD, (uint16_t)&PORTE, (uint16_t)&PORTF, |
| 196 | NOT_A_PORT, | ||
| 197 | (uint16_t) &PORTB, | ||
| 198 | (uint16_t) &PORTC, | ||
| 199 | (uint16_t) &PORTD, | ||
| 200 | (uint16_t) &PORTE, | ||
| 201 | (uint16_t) &PORTF, | ||
| 202 | }; | 190 | }; |
| 203 | 191 | ||
| 204 | const uint16_t PROGMEM port_to_input_PGM[] = { | 192 | const uint16_t PROGMEM port_to_input_PGM[] = { |
| 205 | NOT_A_PORT, | 193 | NOT_A_PORT, NOT_A_PORT, (uint16_t)&PINB, (uint16_t)&PINC, (uint16_t)&PIND, (uint16_t)&PINE, (uint16_t)&PINF, |
| 206 | NOT_A_PORT, | ||
| 207 | (uint16_t) &PINB, | ||
| 208 | (uint16_t) &PINC, | ||
| 209 | (uint16_t) &PIND, | ||
| 210 | (uint16_t) &PINE, | ||
| 211 | (uint16_t) &PINF, | ||
| 212 | }; | 194 | }; |
| 213 | 195 | ||
| 214 | const uint8_t PROGMEM digital_pin_to_port_PGM[] = { | 196 | const uint8_t PROGMEM digital_pin_to_port_PGM[] = { |
| 215 | PD, // D0 - PD2 | 197 | PD, // D0 - PD2 |
| 216 | PD, // D1 - PD3 | 198 | PD, // D1 - PD3 |
| 217 | PD, // D2 - PD1 | 199 | PD, // D2 - PD1 |
| 218 | PD, // D3 - PD0 | 200 | PD, // D3 - PD0 |
| 219 | PD, // D4 - PD4 | 201 | PD, // D4 - PD4 |
| 220 | PC, // D5 - PC6 | 202 | PC, // D5 - PC6 |
| 221 | PD, // D6 - PD7 | 203 | PD, // D6 - PD7 |
| 222 | PE, // D7 - PE6 | 204 | PE, // D7 - PE6 |
| 223 | 205 | ||
| 224 | PB, // D8 - PB4 | 206 | PB, // D8 - PB4 |
| 225 | PB, // D9 - PB5 | 207 | PB, // D9 - PB5 |
| 226 | PB, // D10 - PB6 | 208 | PB, // D10 - PB6 |
| 227 | PB, // D11 - PB7 | 209 | PB, // D11 - PB7 |
| 228 | PD, // D12 - PD6 | 210 | PD, // D12 - PD6 |
| 229 | PC, // D13 - PC7 | 211 | PC, // D13 - PC7 |
| 230 | 212 | ||
| 231 | PB, // D14 - MISO - PB3 | 213 | PB, // D14 - MISO - PB3 |
| 232 | PB, // D15 - SCK - PB1 | 214 | PB, // D15 - SCK - PB1 |
| 233 | PB, // D16 - MOSI - PB2 | 215 | PB, // D16 - MOSI - PB2 |
| 234 | PB, // D17 - SS - PB0 | 216 | PB, // D17 - SS - PB0 |
| 235 | 217 | ||
| 236 | PF, // D18 - A0 - PF7 | 218 | PF, // D18 - A0 - PF7 |
| 237 | PF, // D19 - A1 - PF6 | 219 | PF, // D19 - A1 - PF6 |
| 238 | PF, // D20 - A2 - PF5 | 220 | PF, // D20 - A2 - PF5 |
| 239 | PF, // D21 - A3 - PF4 | 221 | PF, // D21 - A3 - PF4 |
| 240 | PF, // D22 - A4 - PF1 | 222 | PF, // D22 - A4 - PF1 |
| 241 | PF, // D23 - A5 - PF0 | 223 | PF, // D23 - A5 - PF0 |
| 242 | 224 | ||
| 243 | PD, // D24 - PD5 | 225 | PD, // D24 - PD5 |
| 244 | PD, // D25 / D6 - A7 - PD7 | 226 | PD, // D25 / D6 - A7 - PD7 |
| 245 | PB, // D26 / D8 - A8 - PB4 | 227 | PB, // D26 / D8 - A8 - PB4 |
| 246 | PB, // D27 / D9 - A9 - PB5 | 228 | PB, // D27 / D9 - A9 - PB5 |
| 247 | PB, // D28 / D10 - A10 - PB6 | 229 | PB, // D28 / D10 - A10 - PB6 |
| 248 | PD, // D29 / D12 - A11 - PD6 | 230 | PD, // D29 / D12 - A11 - PD6 |
| 249 | }; | 231 | }; |
| 250 | 232 | ||
| 251 | const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = { | 233 | const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = { |
| 252 | _BV(2), // D0 - PD2 | 234 | _BV(2), // D0 - PD2 |
| 253 | _BV(3), // D1 - PD3 | 235 | _BV(3), // D1 - PD3 |
| 254 | _BV(1), // D2 - PD1 | 236 | _BV(1), // D2 - PD1 |
| 255 | _BV(0), // D3 - PD0 | 237 | _BV(0), // D3 - PD0 |
| 256 | _BV(4), // D4 - PD4 | 238 | _BV(4), // D4 - PD4 |
| 257 | _BV(6), // D5 - PC6 | 239 | _BV(6), // D5 - PC6 |
| 258 | _BV(7), // D6 - PD7 | 240 | _BV(7), // D6 - PD7 |
| 259 | _BV(6), // D7 - PE6 | 241 | _BV(6), // D7 - PE6 |
| 260 | 242 | ||
| 261 | _BV(4), // D8 - PB4 | 243 | _BV(4), // D8 - PB4 |
| 262 | _BV(5), // D9 - PB5 | 244 | _BV(5), // D9 - PB5 |
| 263 | _BV(6), // D10 - PB6 | 245 | _BV(6), // D10 - PB6 |
| 264 | _BV(7), // D11 - PB7 | 246 | _BV(7), // D11 - PB7 |
| 265 | _BV(6), // D12 - PD6 | 247 | _BV(6), // D12 - PD6 |
| 266 | _BV(7), // D13 - PC7 | 248 | _BV(7), // D13 - PC7 |
| 267 | 249 | ||
| 268 | _BV(3), // D14 - MISO - PB3 | 250 | _BV(3), // D14 - MISO - PB3 |
| 269 | _BV(1), // D15 - SCK - PB1 | 251 | _BV(1), // D15 - SCK - PB1 |
| 270 | _BV(2), // D16 - MOSI - PB2 | 252 | _BV(2), // D16 - MOSI - PB2 |
| 271 | _BV(0), // D17 - SS - PB0 | 253 | _BV(0), // D17 - SS - PB0 |
| 272 | 254 | ||
| 273 | _BV(7), // D18 - A0 - PF7 | 255 | _BV(7), // D18 - A0 - PF7 |
| 274 | _BV(6), // D19 - A1 - PF6 | 256 | _BV(6), // D19 - A1 - PF6 |
| 275 | _BV(5), // D20 - A2 - PF5 | 257 | _BV(5), // D20 - A2 - PF5 |
| 276 | _BV(4), // D21 - A3 - PF4 | 258 | _BV(4), // D21 - A3 - PF4 |
| 277 | _BV(1), // D22 - A4 - PF1 | 259 | _BV(1), // D22 - A4 - PF1 |
| 278 | _BV(0), // D23 - A5 - PF0 | 260 | _BV(0), // D23 - A5 - PF0 |
| 279 | 261 | ||
| 280 | _BV(5), // D24 - PD5 | 262 | _BV(5), // D24 - PD5 |
| 281 | _BV(7), // D25 / D6 - A7 - PD7 | 263 | _BV(7), // D25 / D6 - A7 - PD7 |
| 282 | _BV(4), // D26 / D8 - A8 - PB4 | 264 | _BV(4), // D26 / D8 - A8 - PB4 |
| 283 | _BV(5), // D27 / D9 - A9 - PB5 | 265 | _BV(5), // D27 / D9 - A9 - PB5 |
| 284 | _BV(6), // D28 / D10 - A10 - PB6 | 266 | _BV(6), // D28 / D10 - A10 - PB6 |
| 285 | _BV(6), // D29 / D12 - A11 - PD6 | 267 | _BV(6), // D29 / D12 - A11 - PD6 |
| 286 | }; | 268 | }; |
| 287 | 269 | ||
| 288 | const uint8_t PROGMEM digital_pin_to_timer_PGM[] = { | 270 | const uint8_t PROGMEM digital_pin_to_timer_PGM[] = { |
| 289 | NOT_ON_TIMER, | 271 | NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, TIMER0B, /* 3 */ |
| 290 | NOT_ON_TIMER, | 272 | NOT_ON_TIMER, TIMER3A, /* 5 */ |
| 291 | NOT_ON_TIMER, | 273 | TIMER4D, /* 6 */ |
| 292 | TIMER0B, /* 3 */ | ||
| 293 | NOT_ON_TIMER, | ||
| 294 | TIMER3A, /* 5 */ | ||
| 295 | TIMER4D, /* 6 */ | ||
| 296 | NOT_ON_TIMER, | 274 | NOT_ON_TIMER, |
| 297 | 275 | ||
| 298 | NOT_ON_TIMER, | 276 | NOT_ON_TIMER, TIMER1A, /* 9 */ |
| 299 | TIMER1A, /* 9 */ | 277 | TIMER1B, /* 10 */ |
| 300 | TIMER1B, /* 10 */ | 278 | TIMER0A, /* 11 */ |
| 301 | TIMER0A, /* 11 */ | ||
| 302 | 279 | ||
| 303 | NOT_ON_TIMER, | 280 | NOT_ON_TIMER, TIMER4A, /* 13 */ |
| 304 | TIMER4A, /* 13 */ | ||
| 305 | 281 | ||
| 306 | NOT_ON_TIMER, | 282 | NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, |
| 307 | NOT_ON_TIMER, | ||
| 308 | NOT_ON_TIMER, | ||
| 309 | NOT_ON_TIMER, | ||
| 310 | NOT_ON_TIMER, | ||
| 311 | NOT_ON_TIMER, | ||
| 312 | 283 | ||
| 313 | NOT_ON_TIMER, | 284 | NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, |
| 314 | NOT_ON_TIMER, | ||
| 315 | NOT_ON_TIMER, | ||
| 316 | NOT_ON_TIMER, | ||
| 317 | NOT_ON_TIMER, | ||
| 318 | NOT_ON_TIMER, | ||
| 319 | NOT_ON_TIMER, | ||
| 320 | NOT_ON_TIMER, | ||
| 321 | NOT_ON_TIMER, | ||
| 322 | NOT_ON_TIMER, | ||
| 323 | }; | 285 | }; |
| 324 | 286 | ||
| 325 | const uint8_t PROGMEM analog_pin_to_channel_PGM[] = { | 287 | const uint8_t PROGMEM analog_pin_to_channel_PGM[] = { |
| 326 | 7, // A0 PF7 ADC7 | 288 | 7, // A0 PF7 ADC7 |
| 327 | 6, // A1 PF6 ADC6 | 289 | 6, // A1 PF6 ADC6 |
| 328 | 5, // A2 PF5 ADC5 | 290 | 5, // A2 PF5 ADC5 |
| 329 | 4, // A3 PF4 ADC4 | 291 | 4, // A3 PF4 ADC4 |
| 330 | 1, // A4 PF1 ADC1 | 292 | 1, // A4 PF1 ADC1 |
| 331 | 0, // A5 PF0 ADC0 | 293 | 0, // A5 PF0 ADC0 |
| 332 | 8, // A6 D4 PD4 ADC8 | 294 | 8, // A6 D4 PD4 ADC8 |
| 333 | 10, // A7 D6 PD7 ADC10 | 295 | 10, // A7 D6 PD7 ADC10 |
| 334 | 11, // A8 D8 PB4 ADC11 | 296 | 11, // A8 D8 PB4 ADC11 |
| 335 | 12, // A9 D9 PB5 ADC12 | 297 | 12, // A9 D9 PB5 ADC12 |
| 336 | 13, // A10 D10 PB6 ADC13 | 298 | 13, // A10 D10 PB6 ADC13 |
| 337 | 9 // A11 D12 PD6 ADC9 | 299 | 9 // A11 D12 PD6 ADC9 |
| 338 | }; | 300 | }; |
| 339 | 301 | ||
| 340 | #endif /* ARDUINO_MAIN */ | 302 | #endif /* ARDUINO_MAIN */ |
| @@ -354,9 +316,9 @@ const uint8_t PROGMEM analog_pin_to_channel_PGM[] = { | |||
| 354 | // | 316 | // |
| 355 | // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX | 317 | // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX |
| 356 | // pins are NOT connected to anything by default. | 318 | // pins are NOT connected to anything by default. |
| 357 | #define SERIAL_PORT_MONITOR Serial | 319 | #define SERIAL_PORT_MONITOR Serial |
| 358 | #define SERIAL_PORT_USBVIRTUAL Serial | 320 | #define SERIAL_PORT_USBVIRTUAL Serial |
| 359 | #define SERIAL_PORT_HARDWARE Serial1 | 321 | #define SERIAL_PORT_HARDWARE Serial1 |
| 360 | #define SERIAL_PORT_HARDWARE_OPEN Serial1 | 322 | #define SERIAL_PORT_HARDWARE_OPEN Serial1 |
| 361 | 323 | ||
| 362 | #endif /* Pins_Arduino_h */ | 324 | #endif /* Pins_Arduino_h */ |
diff --git a/drivers/avr/ssd1306.c b/drivers/avr/ssd1306.c index bb8938bba..61d7a9953 100644 --- a/drivers/avr/ssd1306.c +++ b/drivers/avr/ssd1306.c | |||
| @@ -1,325 +1,320 @@ | |||
| 1 | #ifdef SSD1306OLED | 1 | #ifdef SSD1306OLED |
| 2 | 2 | ||
| 3 | #include "ssd1306.h" | 3 | # include "ssd1306.h" |
| 4 | #include "i2c.h" | 4 | # include "i2c.h" |
| 5 | #include <string.h> | 5 | # include <string.h> |
| 6 | #include "print.h" | 6 | # include "print.h" |
| 7 | #include "glcdfont.c" | 7 | # include "glcdfont.c" |
| 8 | #ifdef ADAFRUIT_BLE_ENABLE | 8 | # ifdef ADAFRUIT_BLE_ENABLE |
| 9 | #include "adafruit_ble.h" | 9 | # include "adafruit_ble.h" |
| 10 | #endif | 10 | # endif |
| 11 | #ifdef PROTOCOL_LUFA | 11 | # ifdef PROTOCOL_LUFA |
| 12 | #include "lufa.h" | 12 | # include "lufa.h" |
| 13 | #endif | 13 | # endif |
| 14 | #include "sendchar.h" | 14 | # include "sendchar.h" |
| 15 | #include "timer.h" | 15 | # include "timer.h" |
| 16 | 16 | ||
| 17 | // Set this to 1 to help diagnose early startup problems | 17 | // Set this to 1 to help diagnose early startup problems |
| 18 | // when testing power-on with ble. Turn it off otherwise, | 18 | // when testing power-on with ble. Turn it off otherwise, |
| 19 | // as the latency of printing most of the debug info messes | 19 | // as the latency of printing most of the debug info messes |
| 20 | // with the matrix scan, causing keys to drop. | 20 | // with the matrix scan, causing keys to drop. |
| 21 | #define DEBUG_TO_SCREEN 0 | 21 | # define DEBUG_TO_SCREEN 0 |
| 22 | 22 | ||
| 23 | //static uint16_t last_battery_update; | 23 | // static uint16_t last_battery_update; |
| 24 | //static uint32_t vbat; | 24 | // static uint32_t vbat; |
| 25 | //#define BatteryUpdateInterval 10000 /* milliseconds */ | 25 | //#define BatteryUpdateInterval 10000 /* milliseconds */ |
| 26 | #define ScreenOffInterval 300000 /* milliseconds */ | 26 | # define ScreenOffInterval 300000 /* milliseconds */ |
| 27 | #if DEBUG_TO_SCREEN | 27 | # if DEBUG_TO_SCREEN |
| 28 | static uint8_t displaying; | 28 | static uint8_t displaying; |
| 29 | #endif | 29 | # endif |
| 30 | static uint16_t last_flush; | 30 | static uint16_t last_flush; |
| 31 | 31 | ||
| 32 | // Write command sequence. | 32 | // Write command sequence. |
| 33 | // Returns true on success. | 33 | // Returns true on success. |
| 34 | static inline bool _send_cmd1(uint8_t cmd) { | 34 | static inline bool _send_cmd1(uint8_t cmd) { |
| 35 | bool res = false; | 35 | bool res = false; |
| 36 | 36 | ||
| 37 | if (i2c_start_write(SSD1306_ADDRESS)) { | 37 | if (i2c_start_write(SSD1306_ADDRESS)) { |
| 38 | xprintf("failed to start write to %d\n", SSD1306_ADDRESS); | 38 | xprintf("failed to start write to %d\n", SSD1306_ADDRESS); |
| 39 | goto done; | 39 | goto done; |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | if (i2c_master_write(0x0 /* command byte follows */)) { | 42 | if (i2c_master_write(0x0 /* command byte follows */)) { |
| 43 | print("failed to write control byte\n"); | 43 | print("failed to write control byte\n"); |
| 44 | 44 | ||
| 45 | goto done; | 45 | goto done; |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | if (i2c_master_write(cmd)) { | 48 | if (i2c_master_write(cmd)) { |
| 49 | xprintf("failed to write command %d\n", cmd); | 49 | xprintf("failed to write command %d\n", cmd); |
| 50 | goto done; | 50 | goto done; |
| 51 | } | 51 | } |
| 52 | res = true; | 52 | res = true; |
| 53 | done: | 53 | done: |
| 54 | i2c_master_stop(); | 54 | i2c_master_stop(); |
| 55 | return res; | 55 | return res; |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | // Write 2-byte command sequence. | 58 | // Write 2-byte command sequence. |
| 59 | // Returns true on success | 59 | // Returns true on success |
| 60 | static inline bool _send_cmd2(uint8_t cmd, uint8_t opr) { | 60 | static inline bool _send_cmd2(uint8_t cmd, uint8_t opr) { |
| 61 | if (!_send_cmd1(cmd)) { | 61 | if (!_send_cmd1(cmd)) { |
| 62 | return false; | 62 | return false; |
| 63 | } | 63 | } |
| 64 | return _send_cmd1(opr); | 64 | return _send_cmd1(opr); |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | // Write 3-byte command sequence. | 67 | // Write 3-byte command sequence. |
| 68 | // Returns true on success | 68 | // Returns true on success |
| 69 | static inline bool _send_cmd3(uint8_t cmd, uint8_t opr1, uint8_t opr2) { | 69 | static inline bool _send_cmd3(uint8_t cmd, uint8_t opr1, uint8_t opr2) { |
| 70 | if (!_send_cmd1(cmd)) { | 70 | if (!_send_cmd1(cmd)) { |
| 71 | return false; | 71 | return false; |
| 72 | } | 72 | } |
| 73 | if (!_send_cmd1(opr1)) { | 73 | if (!_send_cmd1(opr1)) { |
| 74 | return false; | 74 | return false; |
| 75 | } | 75 | } |
| 76 | return _send_cmd1(opr2); | 76 | return _send_cmd1(opr2); |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | #define send_cmd1(c) if (!_send_cmd1(c)) {goto done;} | 79 | # define send_cmd1(c) \ |
| 80 | #define send_cmd2(c,o) if (!_send_cmd2(c,o)) {goto done;} | 80 | if (!_send_cmd1(c)) { \ |
| 81 | #define send_cmd3(c,o1,o2) if (!_send_cmd3(c,o1,o2)) {goto done;} | 81 | goto done; \ |
| 82 | } | ||
| 83 | # define send_cmd2(c, o) \ | ||
| 84 | if (!_send_cmd2(c, o)) { \ | ||
| 85 | goto done; \ | ||
| 86 | } | ||
| 87 | # define send_cmd3(c, o1, o2) \ | ||
| 88 | if (!_send_cmd3(c, o1, o2)) { \ | ||
| 89 | goto done; \ | ||
| 90 | } | ||
| 82 | 91 | ||
| 83 | static void clear_display(void) { | 92 | static void clear_display(void) { |
| 84 | matrix_clear(&display); | 93 | matrix_clear(&display); |
| 85 | 94 | ||
| 86 | // Clear all of the display bits (there can be random noise | 95 | // Clear all of the display bits (there can be random noise |
| 87 | // in the RAM on startup) | 96 | // in the RAM on startup) |
| 88 | send_cmd3(PageAddr, 0, (DisplayHeight / 8) - 1); | 97 | send_cmd3(PageAddr, 0, (DisplayHeight / 8) - 1); |
| 89 | send_cmd3(ColumnAddr, 0, DisplayWidth - 1); | 98 | send_cmd3(ColumnAddr, 0, DisplayWidth - 1); |
| 90 | 99 | ||
| 91 | if (i2c_start_write(SSD1306_ADDRESS)) { | 100 | if (i2c_start_write(SSD1306_ADDRESS)) { |
| 92 | goto done; | 101 | goto done; |
| 93 | } | 102 | } |
| 94 | if (i2c_master_write(0x40)) { | 103 | if (i2c_master_write(0x40)) { |
| 95 | // Data mode | 104 | // Data mode |
| 96 | goto done; | 105 | goto done; |
| 97 | } | 106 | } |
| 98 | for (uint8_t row = 0; row < MatrixRows; ++row) { | 107 | for (uint8_t row = 0; row < MatrixRows; ++row) { |
| 99 | for (uint8_t col = 0; col < DisplayWidth; ++col) { | 108 | for (uint8_t col = 0; col < DisplayWidth; ++col) { |
| 100 | i2c_master_write(0); | 109 | i2c_master_write(0); |
| 110 | } | ||
| 101 | } | 111 | } |
| 102 | } | ||
| 103 | 112 | ||
| 104 | display.dirty = false; | 113 | display.dirty = false; |
| 105 | 114 | ||
| 106 | done: | 115 | done: |
| 107 | i2c_master_stop(); | 116 | i2c_master_stop(); |
| 108 | } | 117 | } |
| 109 | 118 | ||
| 110 | #if DEBUG_TO_SCREEN | 119 | # if DEBUG_TO_SCREEN |
| 111 | #undef sendchar | 120 | # undef sendchar |
| 112 | static int8_t capture_sendchar(uint8_t c) { | 121 | static int8_t capture_sendchar(uint8_t c) { |
| 113 | sendchar(c); | 122 | sendchar(c); |
| 114 | iota_gfx_write_char(c); | 123 | iota_gfx_write_char(c); |
| 115 | 124 | ||
| 116 | if (!displaying) { | 125 | if (!displaying) { |
| 117 | iota_gfx_flush(); | 126 | iota_gfx_flush(); |
| 118 | } | 127 | } |
| 119 | return 0; | 128 | return 0; |
| 120 | } | 129 | } |
| 121 | #endif | 130 | # endif |
| 122 | 131 | ||
| 123 | bool iota_gfx_init(void) { | 132 | bool iota_gfx_init(void) { |
| 124 | bool success = false; | 133 | bool success = false; |
| 125 | 134 | ||
| 126 | send_cmd1(DisplayOff); | 135 | send_cmd1(DisplayOff); |
| 127 | send_cmd2(SetDisplayClockDiv, 0x80); | 136 | send_cmd2(SetDisplayClockDiv, 0x80); |
| 128 | send_cmd2(SetMultiPlex, DisplayHeight - 1); | 137 | send_cmd2(SetMultiPlex, DisplayHeight - 1); |
| 129 | 138 | ||
| 130 | send_cmd2(SetDisplayOffset, 0); | 139 | send_cmd2(SetDisplayOffset, 0); |
| 131 | 140 | ||
| 141 | send_cmd1(SetStartLine | 0x0); | ||
| 142 | send_cmd2(SetChargePump, 0x14 /* Enable */); | ||
| 143 | send_cmd2(SetMemoryMode, 0 /* horizontal addressing */); | ||
| 132 | 144 | ||
| 133 | send_cmd1(SetStartLine | 0x0); | 145 | # ifdef OLED_ROTATE180 |
| 134 | send_cmd2(SetChargePump, 0x14 /* Enable */); | 146 | // the following Flip the display orientation 180 degrees |
| 135 | send_cmd2(SetMemoryMode, 0 /* horizontal addressing */); | 147 | send_cmd1(SegRemap); |
| 148 | send_cmd1(ComScanInc); | ||
| 149 | # endif | ||
| 150 | # ifndef OLED_ROTATE180 | ||
| 151 | // Flips the display orientation 0 degrees | ||
| 152 | send_cmd1(SegRemap | 0x1); | ||
| 153 | send_cmd1(ComScanDec); | ||
| 154 | # endif | ||
| 136 | 155 | ||
| 137 | #ifdef OLED_ROTATE180 | 156 | send_cmd2(SetComPins, 0x2); |
| 138 | // the following Flip the display orientation 180 degrees | 157 | send_cmd2(SetContrast, 0x8f); |
| 139 | send_cmd1(SegRemap); | 158 | send_cmd2(SetPreCharge, 0xf1); |
| 140 | send_cmd1(ComScanInc); | 159 | send_cmd2(SetVComDetect, 0x40); |
| 141 | #endif | 160 | send_cmd1(DisplayAllOnResume); |
| 142 | #ifndef OLED_ROTATE180 | 161 | send_cmd1(NormalDisplay); |
| 143 | // Flips the display orientation 0 degrees | 162 | send_cmd1(DeActivateScroll); |
| 144 | send_cmd1(SegRemap | 0x1); | 163 | send_cmd1(DisplayOn); |
| 145 | send_cmd1(ComScanDec); | ||
| 146 | #endif | ||
| 147 | |||
| 148 | send_cmd2(SetComPins, 0x2); | ||
| 149 | send_cmd2(SetContrast, 0x8f); | ||
| 150 | send_cmd2(SetPreCharge, 0xf1); | ||
| 151 | send_cmd2(SetVComDetect, 0x40); | ||
| 152 | send_cmd1(DisplayAllOnResume); | ||
| 153 | send_cmd1(NormalDisplay); | ||
| 154 | send_cmd1(DeActivateScroll); | ||
| 155 | send_cmd1(DisplayOn); | ||
| 156 | 164 | ||
| 157 | send_cmd2(SetContrast, 0); // Dim | 165 | send_cmd2(SetContrast, 0); // Dim |
| 158 | 166 | ||
| 159 | clear_display(); | 167 | clear_display(); |
| 160 | 168 | ||
| 161 | success = true; | 169 | success = true; |
| 162 | 170 | ||
| 163 | iota_gfx_flush(); | 171 | iota_gfx_flush(); |
| 164 | 172 | ||
| 165 | #if DEBUG_TO_SCREEN | 173 | # if DEBUG_TO_SCREEN |
| 166 | print_set_sendchar(capture_sendchar); | 174 | print_set_sendchar(capture_sendchar); |
| 167 | #endif | 175 | # endif |
| 168 | 176 | ||
| 169 | done: | 177 | done: |
| 170 | return success; | 178 | return success; |
| 171 | } | 179 | } |
| 172 | 180 | ||
| 173 | bool iota_gfx_off(void) { | 181 | bool iota_gfx_off(void) { |
| 174 | bool success = false; | 182 | bool success = false; |
| 175 | 183 | ||
| 176 | send_cmd1(DisplayOff); | 184 | send_cmd1(DisplayOff); |
| 177 | success = true; | 185 | success = true; |
| 178 | 186 | ||
| 179 | done: | 187 | done: |
| 180 | return success; | 188 | return success; |
| 181 | } | 189 | } |
| 182 | 190 | ||
| 183 | bool iota_gfx_on(void) { | 191 | bool iota_gfx_on(void) { |
| 184 | bool success = false; | 192 | bool success = false; |
| 185 | 193 | ||
| 186 | send_cmd1(DisplayOn); | 194 | send_cmd1(DisplayOn); |
| 187 | success = true; | 195 | success = true; |
| 188 | 196 | ||
| 189 | done: | 197 | done: |
| 190 | return success; | 198 | return success; |
| 191 | } | 199 | } |
| 192 | 200 | ||
| 193 | void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c) { | 201 | void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c) { |
| 194 | *matrix->cursor = c; | 202 | *matrix->cursor = c; |
| 195 | ++matrix->cursor; | 203 | ++matrix->cursor; |
| 196 | 204 | ||
| 197 | if (matrix->cursor - &matrix->display[0][0] == sizeof(matrix->display)) { | 205 | if (matrix->cursor - &matrix->display[0][0] == sizeof(matrix->display)) { |
| 198 | // We went off the end; scroll the display upwards by one line | 206 | // We went off the end; scroll the display upwards by one line |
| 199 | memmove(&matrix->display[0], &matrix->display[1], | 207 | memmove(&matrix->display[0], &matrix->display[1], MatrixCols * (MatrixRows - 1)); |
| 200 | MatrixCols * (MatrixRows - 1)); | 208 | matrix->cursor = &matrix->display[MatrixRows - 1][0]; |
| 201 | matrix->cursor = &matrix->display[MatrixRows - 1][0]; | 209 | memset(matrix->cursor, ' ', MatrixCols); |
| 202 | memset(matrix->cursor, ' ', MatrixCols); | 210 | } |
| 203 | } | ||
| 204 | } | 211 | } |
| 205 | 212 | ||
| 206 | void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c) { | 213 | void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c) { |
| 207 | matrix->dirty = true; | 214 | matrix->dirty = true; |
| 208 | 215 | ||
| 209 | if (c == '\n') { | 216 | if (c == '\n') { |
| 210 | // Clear to end of line from the cursor and then move to the | 217 | // Clear to end of line from the cursor and then move to the |
| 211 | // start of the next line | 218 | // start of the next line |
| 212 | uint8_t cursor_col = (matrix->cursor - &matrix->display[0][0]) % MatrixCols; | 219 | uint8_t cursor_col = (matrix->cursor - &matrix->display[0][0]) % MatrixCols; |
| 213 | 220 | ||
| 214 | while (cursor_col++ < MatrixCols) { | 221 | while (cursor_col++ < MatrixCols) { |
| 215 | matrix_write_char_inner(matrix, ' '); | 222 | matrix_write_char_inner(matrix, ' '); |
| 223 | } | ||
| 224 | return; | ||
| 216 | } | 225 | } |
| 217 | return; | ||
| 218 | } | ||
| 219 | 226 | ||
| 220 | matrix_write_char_inner(matrix, c); | 227 | matrix_write_char_inner(matrix, c); |
| 221 | } | 228 | } |
| 222 | 229 | ||
| 223 | void iota_gfx_write_char(uint8_t c) { | 230 | void iota_gfx_write_char(uint8_t c) { matrix_write_char(&display, c); } |
| 224 | matrix_write_char(&display, c); | ||
| 225 | } | ||
| 226 | 231 | ||
| 227 | void matrix_write(struct CharacterMatrix *matrix, const char *data) { | 232 | void matrix_write(struct CharacterMatrix *matrix, const char *data) { |
| 228 | const char *end = data + strlen(data); | 233 | const char *end = data + strlen(data); |
| 229 | while (data < end) { | 234 | while (data < end) { |
| 230 | matrix_write_char(matrix, *data); | 235 | matrix_write_char(matrix, *data); |
| 231 | ++data; | 236 | ++data; |
| 232 | } | 237 | } |
| 233 | } | 238 | } |
| 234 | 239 | ||
| 235 | void iota_gfx_write(const char *data) { | 240 | void iota_gfx_write(const char *data) { matrix_write(&display, data); } |
| 236 | matrix_write(&display, data); | ||
| 237 | } | ||
| 238 | 241 | ||
| 239 | void matrix_write_P(struct CharacterMatrix *matrix, const char *data) { | 242 | void matrix_write_P(struct CharacterMatrix *matrix, const char *data) { |
| 240 | while (true) { | 243 | while (true) { |
| 241 | uint8_t c = pgm_read_byte(data); | 244 | uint8_t c = pgm_read_byte(data); |
| 242 | if (c == 0) { | 245 | if (c == 0) { |
| 243 | return; | 246 | return; |
| 247 | } | ||
| 248 | matrix_write_char(matrix, c); | ||
| 249 | ++data; | ||
| 244 | } | 250 | } |
| 245 | matrix_write_char(matrix, c); | ||
| 246 | ++data; | ||
| 247 | } | ||
| 248 | } | 251 | } |
| 249 | 252 | ||
| 250 | void iota_gfx_write_P(const char *data) { | 253 | void iota_gfx_write_P(const char *data) { matrix_write_P(&display, data); } |
| 251 | matrix_write_P(&display, data); | ||
| 252 | } | ||
| 253 | 254 | ||
| 254 | void matrix_clear(struct CharacterMatrix *matrix) { | 255 | void matrix_clear(struct CharacterMatrix *matrix) { |
| 255 | memset(matrix->display, ' ', sizeof(matrix->display)); | 256 | memset(matrix->display, ' ', sizeof(matrix->display)); |
| 256 | matrix->cursor = &matrix->display[0][0]; | 257 | matrix->cursor = &matrix->display[0][0]; |
| 257 | matrix->dirty = true; | 258 | matrix->dirty = true; |
| 258 | } | 259 | } |
| 259 | 260 | ||
| 260 | void iota_gfx_clear_screen(void) { | 261 | void iota_gfx_clear_screen(void) { matrix_clear(&display); } |
| 261 | matrix_clear(&display); | ||
| 262 | } | ||
| 263 | 262 | ||
| 264 | void matrix_render(struct CharacterMatrix *matrix) { | 263 | void matrix_render(struct CharacterMatrix *matrix) { |
| 265 | last_flush = timer_read(); | 264 | last_flush = timer_read(); |
| 266 | iota_gfx_on(); | 265 | iota_gfx_on(); |
| 267 | #if DEBUG_TO_SCREEN | 266 | # if DEBUG_TO_SCREEN |
| 268 | ++displaying; | 267 | ++displaying; |
| 269 | #endif | 268 | # endif |
| 269 | |||
| 270 | // Move to the home position | ||
| 271 | send_cmd3(PageAddr, 0, MatrixRows - 1); | ||
| 272 | send_cmd3(ColumnAddr, 0, (MatrixCols * FontWidth) - 1); | ||
| 273 | |||
| 274 | if (i2c_start_write(SSD1306_ADDRESS)) { | ||
| 275 | goto done; | ||
| 276 | } | ||
| 277 | if (i2c_master_write(0x40)) { | ||
| 278 | // Data mode | ||
| 279 | goto done; | ||
| 280 | } | ||
| 281 | |||
| 282 | for (uint8_t row = 0; row < MatrixRows; ++row) { | ||
| 283 | for (uint8_t col = 0; col < MatrixCols; ++col) { | ||
| 284 | const uint8_t *glyph = font + (matrix->display[row][col] * (FontWidth - 1)); | ||
| 285 | |||
| 286 | for (uint8_t glyphCol = 0; glyphCol < FontWidth - 1; ++glyphCol) { | ||
| 287 | uint8_t colBits = pgm_read_byte(glyph + glyphCol); | ||
| 288 | i2c_master_write(colBits); | ||
| 289 | } | ||
| 270 | 290 | ||
| 271 | // Move to the home position | 291 | // 1 column of space between chars (it's not included in the glyph) |
| 272 | send_cmd3(PageAddr, 0, MatrixRows - 1); | 292 | i2c_master_write(0); |
| 273 | send_cmd3(ColumnAddr, 0, (MatrixCols * FontWidth) - 1); | 293 | } |
| 274 | |||
| 275 | if (i2c_start_write(SSD1306_ADDRESS)) { | ||
| 276 | goto done; | ||
| 277 | } | ||
| 278 | if (i2c_master_write(0x40)) { | ||
| 279 | // Data mode | ||
| 280 | goto done; | ||
| 281 | } | ||
| 282 | |||
| 283 | for (uint8_t row = 0; row < MatrixRows; ++row) { | ||
| 284 | for (uint8_t col = 0; col < MatrixCols; ++col) { | ||
| 285 | const uint8_t *glyph = font + (matrix->display[row][col] * (FontWidth - 1)); | ||
| 286 | |||
| 287 | for (uint8_t glyphCol = 0; glyphCol < FontWidth - 1; ++glyphCol) { | ||
| 288 | uint8_t colBits = pgm_read_byte(glyph + glyphCol); | ||
| 289 | i2c_master_write(colBits); | ||
| 290 | } | ||
| 291 | |||
| 292 | // 1 column of space between chars (it's not included in the glyph) | ||
| 293 | i2c_master_write(0); | ||
| 294 | } | 294 | } |
| 295 | } | ||
| 296 | 295 | ||
| 297 | matrix->dirty = false; | 296 | matrix->dirty = false; |
| 298 | 297 | ||
| 299 | done: | 298 | done: |
| 300 | i2c_master_stop(); | 299 | i2c_master_stop(); |
| 301 | #if DEBUG_TO_SCREEN | 300 | # if DEBUG_TO_SCREEN |
| 302 | --displaying; | 301 | --displaying; |
| 303 | #endif | 302 | # endif |
| 304 | } | 303 | } |
| 305 | 304 | ||
| 306 | void iota_gfx_flush(void) { | 305 | void iota_gfx_flush(void) { matrix_render(&display); } |
| 307 | matrix_render(&display); | ||
| 308 | } | ||
| 309 | 306 | ||
| 310 | __attribute__ ((weak)) | 307 | __attribute__((weak)) void iota_gfx_task_user(void) {} |
| 311 | void iota_gfx_task_user(void) { | ||
| 312 | } | ||
| 313 | 308 | ||
| 314 | void iota_gfx_task(void) { | 309 | void iota_gfx_task(void) { |
| 315 | iota_gfx_task_user(); | 310 | iota_gfx_task_user(); |
| 316 | 311 | ||
| 317 | if (display.dirty) { | 312 | if (display.dirty) { |
| 318 | iota_gfx_flush(); | 313 | iota_gfx_flush(); |
| 319 | } | 314 | } |
| 320 | 315 | ||
| 321 | if (timer_elapsed(last_flush) > ScreenOffInterval) { | 316 | if (timer_elapsed(last_flush) > ScreenOffInterval) { |
| 322 | iota_gfx_off(); | 317 | iota_gfx_off(); |
| 323 | } | 318 | } |
| 324 | } | 319 | } |
| 325 | #endif | 320 | #endif |
diff --git a/drivers/avr/ssd1306.h b/drivers/avr/ssd1306.h index df6a75359..825b0d7d5 100644 --- a/drivers/avr/ssd1306.h +++ b/drivers/avr/ssd1306.h | |||
| @@ -7,49 +7,49 @@ | |||
| 7 | #include "config.h" | 7 | #include "config.h" |
| 8 | 8 | ||
| 9 | enum ssd1306_cmds { | 9 | enum ssd1306_cmds { |
| 10 | DisplayOff = 0xAE, | 10 | DisplayOff = 0xAE, |
| 11 | DisplayOn = 0xAF, | 11 | DisplayOn = 0xAF, |
| 12 | 12 | ||
| 13 | SetContrast = 0x81, | 13 | SetContrast = 0x81, |
| 14 | DisplayAllOnResume = 0xA4, | 14 | DisplayAllOnResume = 0xA4, |
| 15 | 15 | ||
| 16 | DisplayAllOn = 0xA5, | 16 | DisplayAllOn = 0xA5, |
| 17 | NormalDisplay = 0xA6, | 17 | NormalDisplay = 0xA6, |
| 18 | InvertDisplay = 0xA7, | 18 | InvertDisplay = 0xA7, |
| 19 | SetDisplayOffset = 0xD3, | 19 | SetDisplayOffset = 0xD3, |
| 20 | SetComPins = 0xda, | 20 | SetComPins = 0xda, |
| 21 | SetVComDetect = 0xdb, | 21 | SetVComDetect = 0xdb, |
| 22 | SetDisplayClockDiv = 0xD5, | 22 | SetDisplayClockDiv = 0xD5, |
| 23 | SetPreCharge = 0xd9, | 23 | SetPreCharge = 0xd9, |
| 24 | SetMultiPlex = 0xa8, | 24 | SetMultiPlex = 0xa8, |
| 25 | SetLowColumn = 0x00, | 25 | SetLowColumn = 0x00, |
| 26 | SetHighColumn = 0x10, | 26 | SetHighColumn = 0x10, |
| 27 | SetStartLine = 0x40, | 27 | SetStartLine = 0x40, |
| 28 | 28 | ||
| 29 | SetMemoryMode = 0x20, | 29 | SetMemoryMode = 0x20, |
| 30 | ColumnAddr = 0x21, | 30 | ColumnAddr = 0x21, |
| 31 | PageAddr = 0x22, | 31 | PageAddr = 0x22, |
| 32 | 32 | ||
| 33 | ComScanInc = 0xc0, | 33 | ComScanInc = 0xc0, |
| 34 | ComScanDec = 0xc8, | 34 | ComScanDec = 0xc8, |
| 35 | SegRemap = 0xa0, | 35 | SegRemap = 0xa0, |
| 36 | SetChargePump = 0x8d, | 36 | SetChargePump = 0x8d, |
| 37 | ExternalVcc = 0x01, | 37 | ExternalVcc = 0x01, |
| 38 | SwitchCapVcc = 0x02, | 38 | SwitchCapVcc = 0x02, |
| 39 | 39 | ||
| 40 | ActivateScroll = 0x2f, | 40 | ActivateScroll = 0x2f, |
| 41 | DeActivateScroll = 0x2e, | 41 | DeActivateScroll = 0x2e, |
| 42 | SetVerticalScrollArea = 0xa3, | 42 | SetVerticalScrollArea = 0xa3, |
| 43 | RightHorizontalScroll = 0x26, | 43 | RightHorizontalScroll = 0x26, |
| 44 | LeftHorizontalScroll = 0x27, | 44 | LeftHorizontalScroll = 0x27, |
| 45 | VerticalAndRightHorizontalScroll = 0x29, | 45 | VerticalAndRightHorizontalScroll = 0x29, |
| 46 | VerticalAndLeftHorizontalScroll = 0x2a, | 46 | VerticalAndLeftHorizontalScroll = 0x2a, |
| 47 | }; | 47 | }; |
| 48 | 48 | ||
| 49 | // Controls the SSD1306 128x32 OLED display via i2c | 49 | // Controls the SSD1306 128x32 OLED display via i2c |
| 50 | 50 | ||
| 51 | #ifndef SSD1306_ADDRESS | 51 | #ifndef SSD1306_ADDRESS |
| 52 | #define SSD1306_ADDRESS 0x3C | 52 | # define SSD1306_ADDRESS 0x3C |
| 53 | #endif | 53 | #endif |
| 54 | 54 | ||
| 55 | #define DisplayHeight 32 | 55 | #define DisplayHeight 32 |
| @@ -62,9 +62,9 @@ enum ssd1306_cmds { | |||
| 62 | #define MatrixCols (DisplayWidth / FontWidth) | 62 | #define MatrixCols (DisplayWidth / FontWidth) |
| 63 | 63 | ||
| 64 | struct CharacterMatrix { | 64 | struct CharacterMatrix { |
| 65 | uint8_t display[MatrixRows][MatrixCols]; | 65 | uint8_t display[MatrixRows][MatrixCols]; |
| 66 | uint8_t *cursor; | 66 | uint8_t *cursor; |
| 67 | bool dirty; | 67 | bool dirty; |
| 68 | }; | 68 | }; |
| 69 | 69 | ||
| 70 | struct CharacterMatrix display; | 70 | struct CharacterMatrix display; |
| @@ -88,6 +88,4 @@ void matrix_write(struct CharacterMatrix *matrix, const char *data); | |||
| 88 | void matrix_write_P(struct CharacterMatrix *matrix, const char *data); | 88 | void matrix_write_P(struct CharacterMatrix *matrix, const char *data); |
| 89 | void matrix_render(struct CharacterMatrix *matrix); | 89 | void matrix_render(struct CharacterMatrix *matrix); |
| 90 | 90 | ||
| 91 | |||
| 92 | |||
| 93 | #endif | 91 | #endif |
diff --git a/drivers/avr/ws2812.c b/drivers/avr/ws2812.c index 7c3cb5174..0a02c6f7f 100644 --- a/drivers/avr/ws2812.c +++ b/drivers/avr/ws2812.c | |||
| @@ -1,25 +1,25 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * light weight WS2812 lib V2.0b | 2 | * light weight WS2812 lib V2.0b |
| 3 | * | 3 | * |
| 4 | * Controls WS2811/WS2812/WS2812B RGB-LEDs | 4 | * Controls WS2811/WS2812/WS2812B RGB-LEDs |
| 5 | * Author: Tim (cpldcpu@gmail.com) | 5 | * Author: Tim (cpldcpu@gmail.com) |
| 6 | * | 6 | * |
| 7 | * Jan 18th, 2014 v2.0b Initial Version | 7 | * Jan 18th, 2014 v2.0b Initial Version |
| 8 | * Nov 29th, 2015 v2.3 Added SK6812RGBW support | 8 | * Nov 29th, 2015 v2.3 Added SK6812RGBW support |
| 9 | * | 9 | * |
| 10 | * This program is free software: you can redistribute it and/or modify | 10 | * This program is free software: you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by | 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation, either version 2 of the License, or | 12 | * the Free Software Foundation, either version 2 of the License, or |
| 13 | * (at your option) any later version. | 13 | * (at your option) any later version. |
| 14 | * | 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, | 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. | 18 | * GNU General Public License for more details. |
| 19 | * | 19 | * |
| 20 | * You should have received a copy of the GNU General Public License | 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 | */ | 22 | */ |
| 23 | 23 | ||
| 24 | #include "ws2812.h" | 24 | #include "ws2812.h" |
| 25 | #include <avr/interrupt.h> | 25 | #include <avr/interrupt.h> |
| @@ -30,44 +30,40 @@ | |||
| 30 | #if !defined(LED_ARRAY) && defined(RGB_MATRIX_ENABLE) | 30 | #if !defined(LED_ARRAY) && defined(RGB_MATRIX_ENABLE) |
| 31 | // LED color buffer | 31 | // LED color buffer |
| 32 | LED_TYPE led[DRIVER_LED_TOTAL]; | 32 | LED_TYPE led[DRIVER_LED_TOTAL]; |
| 33 | #define LED_ARRAY led | 33 | # define LED_ARRAY led |
| 34 | #endif | 34 | #endif |
| 35 | 35 | ||
| 36 | #ifdef RGBW_BB_TWI | 36 | #ifdef RGBW_BB_TWI |
| 37 | 37 | ||
| 38 | // Port for the I2C | 38 | // Port for the I2C |
| 39 | #define I2C_DDR DDRD | 39 | # define I2C_DDR DDRD |
| 40 | #define I2C_PIN PIND | 40 | # define I2C_PIN PIND |
| 41 | #define I2C_PORT PORTD | 41 | # define I2C_PORT PORTD |
| 42 | 42 | ||
| 43 | // Pins to be used in the bit banging | 43 | // Pins to be used in the bit banging |
| 44 | #define I2C_CLK 0 | 44 | # define I2C_CLK 0 |
| 45 | #define I2C_DAT 1 | 45 | # define I2C_DAT 1 |
| 46 | 46 | ||
| 47 | #define I2C_DATA_HI()\ | 47 | # define I2C_DATA_HI() \ |
| 48 | I2C_DDR &= ~ (1 << I2C_DAT);\ | 48 | I2C_DDR &= ~(1 << I2C_DAT); \ |
| 49 | I2C_PORT |= (1 << I2C_DAT); | 49 | I2C_PORT |= (1 << I2C_DAT); |
| 50 | #define I2C_DATA_LO()\ | 50 | # define I2C_DATA_LO() \ |
| 51 | I2C_DDR |= (1 << I2C_DAT);\ | 51 | I2C_DDR |= (1 << I2C_DAT); \ |
| 52 | I2C_PORT &= ~ (1 << I2C_DAT); | 52 | I2C_PORT &= ~(1 << I2C_DAT); |
| 53 | 53 | ||
| 54 | #define I2C_CLOCK_HI()\ | 54 | # define I2C_CLOCK_HI() \ |
| 55 | I2C_DDR &= ~ (1 << I2C_CLK);\ | 55 | I2C_DDR &= ~(1 << I2C_CLK); \ |
| 56 | I2C_PORT |= (1 << I2C_CLK); | 56 | I2C_PORT |= (1 << I2C_CLK); |
| 57 | #define I2C_CLOCK_LO()\ | 57 | # define I2C_CLOCK_LO() \ |
| 58 | I2C_DDR |= (1 << I2C_CLK);\ | 58 | I2C_DDR |= (1 << I2C_CLK); \ |
| 59 | I2C_PORT &= ~ (1 << I2C_CLK); | 59 | I2C_PORT &= ~(1 << I2C_CLK); |
| 60 | 60 | ||
| 61 | #define I2C_DELAY 1 | 61 | # define I2C_DELAY 1 |
| 62 | 62 | ||
| 63 | void I2C_WriteBit(unsigned char c) | 63 | void I2C_WriteBit(unsigned char c) { |
| 64 | { | 64 | if (c > 0) { |
| 65 | if (c > 0) | ||
| 66 | { | ||
| 67 | I2C_DATA_HI(); | 65 | I2C_DATA_HI(); |
| 68 | } | 66 | } else { |
| 69 | else | ||
| 70 | { | ||
| 71 | I2C_DATA_LO(); | 67 | I2C_DATA_LO(); |
| 72 | } | 68 | } |
| 73 | 69 | ||
| @@ -77,8 +73,7 @@ void I2C_WriteBit(unsigned char c) | |||
| 77 | I2C_CLOCK_LO(); | 73 | I2C_CLOCK_LO(); |
| 78 | _delay_us(I2C_DELAY); | 74 | _delay_us(I2C_DELAY); |
| 79 | 75 | ||
| 80 | if (c > 0) | 76 | if (c > 0) { |
| 81 | { | ||
| 82 | I2C_DATA_LO(); | 77 | I2C_DATA_LO(); |
| 83 | } | 78 | } |
| 84 | 79 | ||
| @@ -87,9 +82,8 @@ void I2C_WriteBit(unsigned char c) | |||
| 87 | 82 | ||
| 88 | // Inits bitbanging port, must be called before using the functions below | 83 | // Inits bitbanging port, must be called before using the functions below |
| 89 | // | 84 | // |
| 90 | void I2C_Init(void) | 85 | void I2C_Init(void) { |
| 91 | { | 86 | I2C_PORT &= ~((1 << I2C_DAT) | (1 << I2C_CLK)); |
| 92 | I2C_PORT &= ~ ((1 << I2C_DAT) | (1 << I2C_CLK)); | ||
| 93 | 87 | ||
| 94 | I2C_CLOCK_HI(); | 88 | I2C_CLOCK_HI(); |
| 95 | I2C_DATA_HI(); | 89 | I2C_DATA_HI(); |
| @@ -99,10 +93,9 @@ void I2C_Init(void) | |||
| 99 | 93 | ||
| 100 | // Send a START Condition | 94 | // Send a START Condition |
| 101 | // | 95 | // |
| 102 | void I2C_Start(void) | 96 | void I2C_Start(void) { |
| 103 | { | ||
| 104 | // set both to high at the same time | 97 | // set both to high at the same time |
| 105 | I2C_DDR &= ~ ((1 << I2C_DAT) | (1 << I2C_CLK)); | 98 | I2C_DDR &= ~((1 << I2C_DAT) | (1 << I2C_CLK)); |
| 106 | _delay_us(I2C_DELAY); | 99 | _delay_us(I2C_DELAY); |
| 107 | 100 | ||
| 108 | I2C_DATA_LO(); | 101 | I2C_DATA_LO(); |
| @@ -114,8 +107,7 @@ void I2C_Start(void) | |||
| 114 | 107 | ||
| 115 | // Send a STOP Condition | 108 | // Send a STOP Condition |
| 116 | // | 109 | // |
| 117 | void I2C_Stop(void) | 110 | void I2C_Stop(void) { |
| 118 | { | ||
| 119 | I2C_CLOCK_HI(); | 111 | I2C_CLOCK_HI(); |
| 120 | _delay_us(I2C_DELAY); | 112 | _delay_us(I2C_DELAY); |
| 121 | 113 | ||
| @@ -125,106 +117,91 @@ void I2C_Stop(void) | |||
| 125 | 117 | ||
| 126 | // write a byte to the I2C slave device | 118 | // write a byte to the I2C slave device |
| 127 | // | 119 | // |
| 128 | unsigned char I2C_Write(unsigned char c) | 120 | unsigned char I2C_Write(unsigned char c) { |
| 129 | { | 121 | for (char i = 0; i < 8; i++) { |
| 130 | for (char i = 0; i < 8; i++) | ||
| 131 | { | ||
| 132 | I2C_WriteBit(c & 128); | 122 | I2C_WriteBit(c & 128); |
| 133 | 123 | ||
| 134 | c <<= 1; | 124 | c <<= 1; |
| 135 | } | 125 | } |
| 136 | 126 | ||
| 137 | |||
| 138 | I2C_WriteBit(0); | 127 | I2C_WriteBit(0); |
| 139 | _delay_us(I2C_DELAY); | 128 | _delay_us(I2C_DELAY); |
| 140 | _delay_us(I2C_DELAY); | 129 | _delay_us(I2C_DELAY); |
| 141 | 130 | ||
| 142 | // _delay_us(I2C_DELAY); | 131 | // _delay_us(I2C_DELAY); |
| 143 | //return I2C_ReadBit(); | 132 | // return I2C_ReadBit(); |
| 144 | return 0; | 133 | return 0; |
| 145 | } | 134 | } |
| 146 | 135 | ||
| 147 | |||
| 148 | #endif | 136 | #endif |
| 149 | 137 | ||
| 150 | #ifdef RGB_MATRIX_ENABLE | 138 | #ifdef RGB_MATRIX_ENABLE |
| 151 | // Set an led in the buffer to a color | 139 | // Set an led in the buffer to a color |
| 152 | void inline ws2812_setled(int i, uint8_t r, uint8_t g, uint8_t b) | 140 | void inline ws2812_setled(int i, uint8_t r, uint8_t g, uint8_t b) { |
| 153 | { | ||
| 154 | led[i].r = r; | 141 | led[i].r = r; |
| 155 | led[i].g = g; | 142 | led[i].g = g; |
| 156 | led[i].b = b; | 143 | led[i].b = b; |
| 157 | } | 144 | } |
| 158 | 145 | ||
| 159 | void ws2812_setled_all (uint8_t r, uint8_t g, uint8_t b) | 146 | void ws2812_setled_all(uint8_t r, uint8_t g, uint8_t b) { |
| 160 | { | 147 | for (int i = 0; i < sizeof(led) / sizeof(led[0]); i++) { |
| 161 | for (int i = 0; i < sizeof(led)/sizeof(led[0]); i++) { | 148 | led[i].r = r; |
| 162 | led[i].r = r; | 149 | led[i].g = g; |
| 163 | led[i].g = g; | 150 | led[i].b = b; |
| 164 | led[i].b = b; | 151 | } |
| 165 | } | ||
| 166 | } | 152 | } |
| 167 | #endif | 153 | #endif |
| 168 | 154 | ||
| 169 | // Setleds for standard RGB | 155 | // Setleds for standard RGB |
| 170 | void inline ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) | 156 | void inline ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) { |
| 171 | { | 157 | // ws2812_setleds_pin(ledarray,leds, _BV(ws2812_pin)); |
| 172 | // ws2812_setleds_pin(ledarray,leds, _BV(ws2812_pin)); | 158 | ws2812_setleds_pin(ledarray, leds, _BV(RGB_DI_PIN & 0xF)); |
| 173 | ws2812_setleds_pin(ledarray,leds, _BV(RGB_DI_PIN & 0xF)); | ||
| 174 | } | 159 | } |
| 175 | 160 | ||
| 176 | void inline ws2812_setleds_pin(LED_TYPE *ledarray, uint16_t leds, uint8_t pinmask) | 161 | void inline ws2812_setleds_pin(LED_TYPE *ledarray, uint16_t leds, uint8_t pinmask) { |
| 177 | { | 162 | // ws2812_DDRREG |= pinmask; // Enable DDR |
| 178 | // ws2812_DDRREG |= pinmask; // Enable DDR | 163 | // new universal format (DDR) |
| 179 | // new universal format (DDR) | 164 | _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= pinmask; |
| 180 | _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= pinmask; | ||
| 181 | 165 | ||
| 182 | ws2812_sendarray_mask((uint8_t*)ledarray,leds+leds+leds,pinmask); | 166 | ws2812_sendarray_mask((uint8_t *)ledarray, leds + leds + leds, pinmask); |
| 183 | _delay_us(50); | 167 | _delay_us(50); |
| 184 | } | 168 | } |
| 185 | 169 | ||
| 186 | // Setleds for SK6812RGBW | 170 | // Setleds for SK6812RGBW |
| 187 | void inline ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t leds) | 171 | void inline ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t leds) { |
| 188 | { | 172 | #ifdef RGBW_BB_TWI |
| 189 | |||
| 190 | #ifdef RGBW_BB_TWI | ||
| 191 | uint8_t sreg_prev, twcr_prev; | 173 | uint8_t sreg_prev, twcr_prev; |
| 192 | sreg_prev=SREG; | 174 | sreg_prev = SREG; |
| 193 | twcr_prev=TWCR; | 175 | twcr_prev = TWCR; |
| 194 | cli(); | 176 | cli(); |
| 195 | TWCR &= ~(1<<TWEN); | 177 | TWCR &= ~(1 << TWEN); |
| 196 | I2C_Init(); | 178 | I2C_Init(); |
| 197 | I2C_Start(); | 179 | I2C_Start(); |
| 198 | I2C_Write(0x84); | 180 | I2C_Write(0x84); |
| 199 | uint16_t datlen = leds<<2; | 181 | uint16_t datlen = leds << 2; |
| 200 | uint8_t curbyte; | 182 | uint8_t curbyte; |
| 201 | uint8_t * data = (uint8_t*)ledarray; | 183 | uint8_t *data = (uint8_t *)ledarray; |
| 202 | while (datlen--) { | 184 | while (datlen--) { |
| 203 | curbyte=*data++; | 185 | curbyte = *data++; |
| 204 | I2C_Write(curbyte); | 186 | I2C_Write(curbyte); |
| 205 | } | 187 | } |
| 206 | I2C_Stop(); | 188 | I2C_Stop(); |
| 207 | SREG=sreg_prev; | 189 | SREG = sreg_prev; |
| 208 | TWCR=twcr_prev; | 190 | TWCR = twcr_prev; |
| 209 | #endif | 191 | #endif |
| 210 | |||
| 211 | |||
| 212 | // ws2812_DDRREG |= _BV(ws2812_pin); // Enable DDR | ||
| 213 | // new universal format (DDR) | ||
| 214 | _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= _BV(RGB_DI_PIN & 0xF); | ||
| 215 | 192 | ||
| 216 | ws2812_sendarray_mask((uint8_t*)ledarray,leds<<2,_BV(RGB_DI_PIN & 0xF)); | 193 | // ws2812_DDRREG |= _BV(ws2812_pin); // Enable DDR |
| 194 | // new universal format (DDR) | ||
| 195 | _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= _BV(RGB_DI_PIN & 0xF); | ||
| 217 | 196 | ||
| 197 | ws2812_sendarray_mask((uint8_t *)ledarray, leds << 2, _BV(RGB_DI_PIN & 0xF)); | ||
| 218 | 198 | ||
| 219 | #ifndef RGBW_BB_TWI | 199 | #ifndef RGBW_BB_TWI |
| 220 | _delay_us(80); | 200 | _delay_us(80); |
| 221 | #endif | 201 | #endif |
| 222 | } | 202 | } |
| 223 | 203 | ||
| 224 | void ws2812_sendarray(uint8_t *data,uint16_t datlen) | 204 | void ws2812_sendarray(uint8_t *data, uint16_t datlen) { ws2812_sendarray_mask(data, datlen, _BV(RGB_DI_PIN & 0xF)); } |
| 225 | { | ||
| 226 | ws2812_sendarray_mask(data,datlen,_BV(RGB_DI_PIN & 0xF)); | ||
| 227 | } | ||
| 228 | 205 | ||
| 229 | /* | 206 | /* |
| 230 | This routine writes an array of bytes with RGB values to the Dataout pin | 207 | This routine writes an array of bytes with RGB values to the Dataout pin |
| @@ -232,136 +209,133 @@ void ws2812_sendarray(uint8_t *data,uint16_t datlen) | |||
| 232 | */ | 209 | */ |
| 233 | 210 | ||
| 234 | // Timing in ns | 211 | // Timing in ns |
| 235 | #define w_zeropulse 350 | 212 | #define w_zeropulse 350 |
| 236 | #define w_onepulse 900 | 213 | #define w_onepulse 900 |
| 237 | #define w_totalperiod 1250 | 214 | #define w_totalperiod 1250 |
| 238 | 215 | ||
| 239 | // Fixed cycles used by the inner loop | 216 | // Fixed cycles used by the inner loop |
| 240 | #define w_fixedlow 2 | 217 | #define w_fixedlow 2 |
| 241 | #define w_fixedhigh 4 | 218 | #define w_fixedhigh 4 |
| 242 | #define w_fixedtotal 8 | 219 | #define w_fixedtotal 8 |
| 243 | 220 | ||
| 244 | // Insert NOPs to match the timing, if possible | 221 | // Insert NOPs to match the timing, if possible |
| 245 | #define w_zerocycles (((F_CPU/1000)*w_zeropulse )/1000000) | 222 | #define w_zerocycles (((F_CPU / 1000) * w_zeropulse) / 1000000) |
| 246 | #define w_onecycles (((F_CPU/1000)*w_onepulse +500000)/1000000) | 223 | #define w_onecycles (((F_CPU / 1000) * w_onepulse + 500000) / 1000000) |
| 247 | #define w_totalcycles (((F_CPU/1000)*w_totalperiod +500000)/1000000) | 224 | #define w_totalcycles (((F_CPU / 1000) * w_totalperiod + 500000) / 1000000) |
| 248 | 225 | ||
| 249 | // w1 - nops between rising edge and falling edge - low | 226 | // w1 - nops between rising edge and falling edge - low |
| 250 | #define w1 (w_zerocycles-w_fixedlow) | 227 | #define w1 (w_zerocycles - w_fixedlow) |
| 251 | // w2 nops between fe low and fe high | 228 | // w2 nops between fe low and fe high |
| 252 | #define w2 (w_onecycles-w_fixedhigh-w1) | 229 | #define w2 (w_onecycles - w_fixedhigh - w1) |
| 253 | // w3 nops to complete loop | 230 | // w3 nops to complete loop |
| 254 | #define w3 (w_totalcycles-w_fixedtotal-w1-w2) | 231 | #define w3 (w_totalcycles - w_fixedtotal - w1 - w2) |
| 255 | 232 | ||
| 256 | #if w1>0 | 233 | #if w1 > 0 |
| 257 | #define w1_nops w1 | 234 | # define w1_nops w1 |
| 258 | #else | 235 | #else |
| 259 | #define w1_nops 0 | 236 | # define w1_nops 0 |
| 260 | #endif | 237 | #endif |
| 261 | 238 | ||
| 262 | // The only critical timing parameter is the minimum pulse length of the "0" | 239 | // The only critical timing parameter is the minimum pulse length of the "0" |
| 263 | // Warn or throw error if this timing can not be met with current F_CPU settings. | 240 | // Warn or throw error if this timing can not be met with current F_CPU settings. |
| 264 | #define w_lowtime ((w1_nops+w_fixedlow)*1000000)/(F_CPU/1000) | 241 | #define w_lowtime ((w1_nops + w_fixedlow) * 1000000) / (F_CPU / 1000) |
| 265 | #if w_lowtime>550 | 242 | #if w_lowtime > 550 |
| 266 | #error "Light_ws2812: Sorry, the clock speed is too low. Did you set F_CPU correctly?" | 243 | # error "Light_ws2812: Sorry, the clock speed is too low. Did you set F_CPU correctly?" |
| 267 | #elif w_lowtime>450 | 244 | #elif w_lowtime > 450 |
| 268 | #warning "Light_ws2812: The timing is critical and may only work on WS2812B, not on WS2812(S)." | 245 | # warning "Light_ws2812: The timing is critical and may only work on WS2812B, not on WS2812(S)." |
| 269 | #warning "Please consider a higher clockspeed, if possible" | 246 | # warning "Please consider a higher clockspeed, if possible" |
| 270 | #endif | 247 | #endif |
| 271 | 248 | ||
| 272 | #if w2>0 | 249 | #if w2 > 0 |
| 273 | #define w2_nops w2 | 250 | # define w2_nops w2 |
| 274 | #else | 251 | #else |
| 275 | #define w2_nops 0 | 252 | # define w2_nops 0 |
| 276 | #endif | 253 | #endif |
| 277 | 254 | ||
| 278 | #if w3>0 | 255 | #if w3 > 0 |
| 279 | #define w3_nops w3 | 256 | # define w3_nops w3 |
| 280 | #else | 257 | #else |
| 281 | #define w3_nops 0 | 258 | # define w3_nops 0 |
| 282 | #endif | 259 | #endif |
| 283 | 260 | ||
| 284 | #define w_nop1 "nop \n\t" | 261 | #define w_nop1 "nop \n\t" |
| 285 | #define w_nop2 "rjmp .+0 \n\t" | 262 | #define w_nop2 "rjmp .+0 \n\t" |
| 286 | #define w_nop4 w_nop2 w_nop2 | 263 | #define w_nop4 w_nop2 w_nop2 |
| 287 | #define w_nop8 w_nop4 w_nop4 | 264 | #define w_nop8 w_nop4 w_nop4 |
| 288 | #define w_nop16 w_nop8 w_nop8 | 265 | #define w_nop16 w_nop8 w_nop8 |
| 289 | 266 | ||
| 290 | void inline ws2812_sendarray_mask(uint8_t *data,uint16_t datlen,uint8_t maskhi) | 267 | void inline ws2812_sendarray_mask(uint8_t *data, uint16_t datlen, uint8_t maskhi) { |
| 291 | { | 268 | uint8_t curbyte, ctr, masklo; |
| 292 | uint8_t curbyte,ctr,masklo; | 269 | uint8_t sreg_prev; |
| 293 | uint8_t sreg_prev; | 270 | |
| 294 | 271 | // masklo =~maskhi&ws2812_PORTREG; | |
| 295 | // masklo =~maskhi&ws2812_PORTREG; | 272 | // maskhi |= ws2812_PORTREG; |
| 296 | // maskhi |= ws2812_PORTREG; | 273 | masklo = ~maskhi & _SFR_IO8((RGB_DI_PIN >> 4) + 2); |
| 297 | masklo =~maskhi&_SFR_IO8((RGB_DI_PIN >> 4) + 2); | 274 | maskhi |= _SFR_IO8((RGB_DI_PIN >> 4) + 2); |
| 298 | maskhi |= _SFR_IO8((RGB_DI_PIN >> 4) + 2); | 275 | sreg_prev = SREG; |
| 299 | sreg_prev=SREG; | 276 | cli(); |
| 300 | cli(); | 277 | |
| 301 | 278 | while (datlen--) { | |
| 302 | while (datlen--) { | 279 | curbyte = (*data++); |
| 303 | curbyte=(*data++); | 280 | |
| 304 | 281 | asm volatile(" ldi %0,8 \n\t" | |
| 305 | asm volatile( | 282 | "loop%=: \n\t" |
| 306 | " ldi %0,8 \n\t" | 283 | " out %2,%3 \n\t" // '1' [01] '0' [01] - re |
| 307 | "loop%=: \n\t" | 284 | #if (w1_nops & 1) |
| 308 | " out %2,%3 \n\t" // '1' [01] '0' [01] - re | 285 | w_nop1 |
| 309 | #if (w1_nops&1) | ||
| 310 | w_nop1 | ||
| 311 | #endif | 286 | #endif |
| 312 | #if (w1_nops&2) | 287 | #if (w1_nops & 2) |
| 313 | w_nop2 | 288 | w_nop2 |
| 314 | #endif | 289 | #endif |
| 315 | #if (w1_nops&4) | 290 | #if (w1_nops & 4) |
| 316 | w_nop4 | 291 | w_nop4 |
| 317 | #endif | 292 | #endif |
| 318 | #if (w1_nops&8) | 293 | #if (w1_nops & 8) |
| 319 | w_nop8 | 294 | w_nop8 |
| 320 | #endif | 295 | #endif |
| 321 | #if (w1_nops&16) | 296 | #if (w1_nops & 16) |
| 322 | w_nop16 | 297 | w_nop16 |
| 323 | #endif | 298 | #endif |
| 324 | " sbrs %1,7 \n\t" // '1' [03] '0' [02] | 299 | " sbrs %1,7 \n\t" // '1' [03] '0' [02] |
| 325 | " out %2,%4 \n\t" // '1' [--] '0' [03] - fe-low | 300 | " out %2,%4 \n\t" // '1' [--] '0' [03] - fe-low |
| 326 | " lsl %1 \n\t" // '1' [04] '0' [04] | 301 | " lsl %1 \n\t" // '1' [04] '0' [04] |
| 327 | #if (w2_nops&1) | 302 | #if (w2_nops & 1) |
| 328 | w_nop1 | 303 | w_nop1 |
| 329 | #endif | 304 | #endif |
| 330 | #if (w2_nops&2) | 305 | #if (w2_nops & 2) |
| 331 | w_nop2 | 306 | w_nop2 |
| 332 | #endif | 307 | #endif |
| 333 | #if (w2_nops&4) | 308 | #if (w2_nops & 4) |
| 334 | w_nop4 | 309 | w_nop4 |
| 335 | #endif | 310 | #endif |
| 336 | #if (w2_nops&8) | 311 | #if (w2_nops & 8) |
| 337 | w_nop8 | 312 | w_nop8 |
| 338 | #endif | 313 | #endif |
| 339 | #if (w2_nops&16) | 314 | #if (w2_nops & 16) |
| 340 | w_nop16 | 315 | w_nop16 |
| 341 | #endif | 316 | #endif |
| 342 | " out %2,%4 \n\t" // '1' [+1] '0' [+1] - fe-high | 317 | " out %2,%4 \n\t" // '1' [+1] '0' [+1] - fe-high |
| 343 | #if (w3_nops&1) | 318 | #if (w3_nops & 1) |
| 344 | w_nop1 | 319 | w_nop1 |
| 345 | #endif | 320 | #endif |
| 346 | #if (w3_nops&2) | 321 | #if (w3_nops & 2) |
| 347 | w_nop2 | 322 | w_nop2 |
| 348 | #endif | 323 | #endif |
| 349 | #if (w3_nops&4) | 324 | #if (w3_nops & 4) |
| 350 | w_nop4 | 325 | w_nop4 |
| 351 | #endif | 326 | #endif |
| 352 | #if (w3_nops&8) | 327 | #if (w3_nops & 8) |
| 353 | w_nop8 | 328 | w_nop8 |
| 354 | #endif | 329 | #endif |
| 355 | #if (w3_nops&16) | 330 | #if (w3_nops & 16) |
| 356 | w_nop16 | 331 | w_nop16 |
| 357 | #endif | 332 | #endif |
| 358 | 333 | ||
| 359 | " dec %0 \n\t" // '1' [+2] '0' [+2] | 334 | " dec %0 \n\t" // '1' [+2] '0' [+2] |
| 360 | " brne loop%=\n\t" // '1' [+3] '0' [+4] | 335 | " brne loop%=\n\t" // '1' [+3] '0' [+4] |
| 361 | : "=&d" (ctr) | 336 | : "=&d"(ctr) |
| 362 | : "r" (curbyte), "I" (_SFR_IO_ADDR(_SFR_IO8((RGB_DI_PIN >> 4) + 2))), "r" (maskhi), "r" (masklo) | 337 | : "r"(curbyte), "I"(_SFR_IO_ADDR(_SFR_IO8((RGB_DI_PIN >> 4) + 2))), "r"(maskhi), "r"(masklo)); |
| 363 | ); | 338 | } |
| 364 | } | ||
| 365 | 339 | ||
| 366 | SREG=sreg_prev; | 340 | SREG = sreg_prev; |
| 367 | } | 341 | } |
diff --git a/drivers/avr/ws2812.h b/drivers/avr/ws2812.h index 95f540b18..a9dd89718 100644 --- a/drivers/avr/ws2812.h +++ b/drivers/avr/ws2812.h | |||
| @@ -43,12 +43,12 @@ | |||
| 43 | * - Wait 50�s to reset the LEDs | 43 | * - Wait 50�s to reset the LEDs |
| 44 | */ | 44 | */ |
| 45 | #ifdef RGB_MATRIX_ENABLE | 45 | #ifdef RGB_MATRIX_ENABLE |
| 46 | void ws2812_setled (int index, uint8_t r, uint8_t g, uint8_t b); | 46 | void ws2812_setled(int index, uint8_t r, uint8_t g, uint8_t b); |
| 47 | void ws2812_setled_all (uint8_t r, uint8_t g, uint8_t b); | 47 | void ws2812_setled_all(uint8_t r, uint8_t g, uint8_t b); |
| 48 | #endif | 48 | #endif |
| 49 | 49 | ||
| 50 | void ws2812_setleds (LED_TYPE *ledarray, uint16_t number_of_leds); | 50 | void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds); |
| 51 | void ws2812_setleds_pin (LED_TYPE *ledarray, uint16_t number_of_leds,uint8_t pinmask); | 51 | void ws2812_setleds_pin(LED_TYPE *ledarray, uint16_t number_of_leds, uint8_t pinmask); |
| 52 | void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds); | 52 | void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds); |
| 53 | 53 | ||
| 54 | /* | 54 | /* |
| @@ -58,18 +58,17 @@ void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds); | |||
| 58 | * The length is the number of bytes to send - three per LED. | 58 | * The length is the number of bytes to send - three per LED. |
| 59 | */ | 59 | */ |
| 60 | 60 | ||
| 61 | void ws2812_sendarray (uint8_t *array,uint16_t length); | 61 | void ws2812_sendarray(uint8_t *array, uint16_t length); |
| 62 | void ws2812_sendarray_mask(uint8_t *array,uint16_t length, uint8_t pinmask); | 62 | void ws2812_sendarray_mask(uint8_t *array, uint16_t length, uint8_t pinmask); |
| 63 | |||
| 64 | 63 | ||
| 65 | /* | 64 | /* |
| 66 | * Internal defines | 65 | * Internal defines |
| 67 | */ | 66 | */ |
| 68 | #ifndef CONCAT | 67 | #ifndef CONCAT |
| 69 | #define CONCAT(a, b) a ## b | 68 | # define CONCAT(a, b) a##b |
| 70 | #endif | 69 | #endif |
| 71 | #ifndef CONCAT_EXP | 70 | #ifndef CONCAT_EXP |
| 72 | #define CONCAT_EXP(a, b) CONCAT(a, b) | 71 | # define CONCAT_EXP(a, b) CONCAT(a, b) |
| 73 | #endif | 72 | #endif |
| 74 | 73 | ||
| 75 | #endif /* LIGHT_WS2812_H_ */ | 74 | #endif /* LIGHT_WS2812_H_ */ |
diff --git a/drivers/boards/GENERIC_STM32_F303XC/board.c b/drivers/boards/GENERIC_STM32_F303XC/board.c index 4331155df..60c191d9b 100644 --- a/drivers/boards/GENERIC_STM32_F303XC/board.c +++ b/drivers/boards/GENERIC_STM32_F303XC/board.c | |||
| @@ -23,42 +23,33 @@ | |||
| 23 | * This variable is used by the HAL when initializing the PAL driver. | 23 | * This variable is used by the HAL when initializing the PAL driver. |
| 24 | */ | 24 | */ |
| 25 | const PALConfig pal_default_config = { | 25 | const PALConfig pal_default_config = { |
| 26 | #if STM32_HAS_GPIOA | 26 | # if STM32_HAS_GPIOA |
| 27 | {VAL_GPIOA_MODER, VAL_GPIOA_OTYPER, VAL_GPIOA_OSPEEDR, VAL_GPIOA_PUPDR, | 27 | {VAL_GPIOA_MODER, VAL_GPIOA_OTYPER, VAL_GPIOA_OSPEEDR, VAL_GPIOA_PUPDR, VAL_GPIOA_ODR, VAL_GPIOA_AFRL, VAL_GPIOA_AFRH}, |
| 28 | VAL_GPIOA_ODR, VAL_GPIOA_AFRL, VAL_GPIOA_AFRH}, | 28 | # endif |
| 29 | #endif | 29 | # if STM32_HAS_GPIOB |
| 30 | #if STM32_HAS_GPIOB | 30 | {VAL_GPIOB_MODER, VAL_GPIOB_OTYPER, VAL_GPIOB_OSPEEDR, VAL_GPIOB_PUPDR, VAL_GPIOB_ODR, VAL_GPIOB_AFRL, VAL_GPIOB_AFRH}, |
| 31 | {VAL_GPIOB_MODER, VAL_GPIOB_OTYPER, VAL_GPIOB_OSPEEDR, VAL_GPIOB_PUPDR, | 31 | # endif |
| 32 | VAL_GPIOB_ODR, VAL_GPIOB_AFRL, VAL_GPIOB_AFRH}, | 32 | # if STM32_HAS_GPIOC |
| 33 | #endif | 33 | {VAL_GPIOC_MODER, VAL_GPIOC_OTYPER, VAL_GPIOC_OSPEEDR, VAL_GPIOC_PUPDR, VAL_GPIOC_ODR, VAL_GPIOC_AFRL, VAL_GPIOC_AFRH}, |
| 34 | #if STM32_HAS_GPIOC | 34 | # endif |
| 35 | {VAL_GPIOC_MODER, VAL_GPIOC_OTYPER, VAL_GPIOC_OSPEEDR, VAL_GPIOC_PUPDR, | 35 | # if STM32_HAS_GPIOD |
| 36 | VAL_GPIOC_ODR, VAL_GPIOC_AFRL, VAL_GPIOC_AFRH}, | 36 | {VAL_GPIOD_MODER, VAL_GPIOD_OTYPER, VAL_GPIOD_OSPEEDR, VAL_GPIOD_PUPDR, VAL_GPIOD_ODR, VAL_GPIOD_AFRL, VAL_GPIOD_AFRH}, |
| 37 | #endif | 37 | # endif |
| 38 | #if STM32_HAS_GPIOD | 38 | # if STM32_HAS_GPIOE |
| 39 | {VAL_GPIOD_MODER, VAL_GPIOD_OTYPER, VAL_GPIOD_OSPEEDR, VAL_GPIOD_PUPDR, | 39 | {VAL_GPIOE_MODER, VAL_GPIOE_OTYPER, VAL_GPIOE_OSPEEDR, VAL_GPIOE_PUPDR, VAL_GPIOE_ODR, VAL_GPIOE_AFRL, VAL_GPIOE_AFRH}, |
| 40 | VAL_GPIOD_ODR, VAL_GPIOD_AFRL, VAL_GPIOD_AFRH}, | 40 | # endif |
| 41 | #endif | 41 | # if STM32_HAS_GPIOF |
| 42 | #if STM32_HAS_GPIOE | 42 | {VAL_GPIOF_MODER, VAL_GPIOF_OTYPER, VAL_GPIOF_OSPEEDR, VAL_GPIOF_PUPDR, VAL_GPIOF_ODR, VAL_GPIOF_AFRL, VAL_GPIOF_AFRH}, |
| 43 | {VAL_GPIOE_MODER, VAL_GPIOE_OTYPER, VAL_GPIOE_OSPEEDR, VAL_GPIOE_PUPDR, | 43 | # endif |
| 44 | VAL_GPIOE_ODR, VAL_GPIOE_AFRL, VAL_GPIOE_AFRH}, | 44 | # if STM32_HAS_GPIOG |
| 45 | #endif | 45 | {VAL_GPIOG_MODER, VAL_GPIOG_OTYPER, VAL_GPIOG_OSPEEDR, VAL_GPIOG_PUPDR, VAL_GPIOG_ODR, VAL_GPIOG_AFRL, VAL_GPIOG_AFRH}, |
| 46 | #if STM32_HAS_GPIOF | 46 | # endif |
| 47 | {VAL_GPIOF_MODER, VAL_GPIOF_OTYPER, VAL_GPIOF_OSPEEDR, VAL_GPIOF_PUPDR, | 47 | # if STM32_HAS_GPIOH |
| 48 | VAL_GPIOF_ODR, VAL_GPIOF_AFRL, VAL_GPIOF_AFRH}, | 48 | {VAL_GPIOH_MODER, VAL_GPIOH_OTYPER, VAL_GPIOH_OSPEEDR, VAL_GPIOH_PUPDR, VAL_GPIOH_ODR, VAL_GPIOH_AFRL, VAL_GPIOH_AFRH}, |
| 49 | #endif | 49 | # endif |
| 50 | #if STM32_HAS_GPIOG | 50 | # if STM32_HAS_GPIOI |
| 51 | {VAL_GPIOG_MODER, VAL_GPIOG_OTYPER, VAL_GPIOG_OSPEEDR, VAL_GPIOG_PUPDR, | 51 | {VAL_GPIOI_MODER, VAL_GPIOI_OTYPER, VAL_GPIOI_OSPEEDR, VAL_GPIOI_PUPDR, VAL_GPIOI_ODR, VAL_GPIOI_AFRL, VAL_GPIOI_AFRH} |
| 52 | VAL_GPIOG_ODR, VAL_GPIOG_AFRL, VAL_GPIOG_AFRH}, | 52 | # endif |
| 53 | #endif | ||
| 54 | #if STM32_HAS_GPIOH | ||
| 55 | {VAL_GPIOH_MODER, VAL_GPIOH_OTYPER, VAL_GPIOH_OSPEEDR, VAL_GPIOH_PUPDR, | ||
| 56 | VAL_GPIOH_ODR, VAL_GPIOH_AFRL, VAL_GPIOH_AFRH}, | ||
| 57 | #endif | ||
| 58 | #if STM32_HAS_GPIOI | ||
| 59 | {VAL_GPIOI_MODER, VAL_GPIOI_OTYPER, VAL_GPIOI_OSPEEDR, VAL_GPIOI_PUPDR, | ||
| 60 | VAL_GPIOI_ODR, VAL_GPIOI_AFRL, VAL_GPIOI_AFRH} | ||
| 61 | #endif | ||
| 62 | }; | 53 | }; |
| 63 | #endif | 54 | #endif |
| 64 | 55 | ||
| @@ -70,8 +61,8 @@ void enter_bootloader_mode_if_requested(void); | |||
| 70 | * and before any other initialization. | 61 | * and before any other initialization. |
| 71 | */ | 62 | */ |
| 72 | void __early_init(void) { | 63 | void __early_init(void) { |
| 73 | enter_bootloader_mode_if_requested(); | 64 | enter_bootloader_mode_if_requested(); |
| 74 | stm32_clock_init(); | 65 | stm32_clock_init(); |
| 75 | } | 66 | } |
| 76 | 67 | ||
| 77 | #if HAL_USE_SDC || defined(__DOXYGEN__) | 68 | #if HAL_USE_SDC || defined(__DOXYGEN__) |
| @@ -79,20 +70,18 @@ void __early_init(void) { | |||
| 79 | * @brief SDC card detection. | 70 | * @brief SDC card detection. |
| 80 | */ | 71 | */ |
| 81 | bool sdc_lld_is_card_inserted(SDCDriver *sdcp) { | 72 | bool sdc_lld_is_card_inserted(SDCDriver *sdcp) { |
| 82 | 73 | (void)sdcp; | |
| 83 | (void)sdcp; | 74 | /* TODO: Fill the implementation.*/ |
| 84 | /* TODO: Fill the implementation.*/ | 75 | return true; |
| 85 | return true; | ||
| 86 | } | 76 | } |
| 87 | 77 | ||
| 88 | /** | 78 | /** |
| 89 | * @brief SDC card write protection detection. | 79 | * @brief SDC card write protection detection. |
| 90 | */ | 80 | */ |
| 91 | bool sdc_lld_is_write_protected(SDCDriver *sdcp) { | 81 | bool sdc_lld_is_write_protected(SDCDriver *sdcp) { |
| 92 | 82 | (void)sdcp; | |
| 93 | (void)sdcp; | 83 | /* TODO: Fill the implementation.*/ |
| 94 | /* TODO: Fill the implementation.*/ | 84 | return false; |
| 95 | return false; | ||
| 96 | } | 85 | } |
| 97 | #endif /* HAL_USE_SDC */ | 86 | #endif /* HAL_USE_SDC */ |
| 98 | 87 | ||
| @@ -101,20 +90,18 @@ bool sdc_lld_is_write_protected(SDCDriver *sdcp) { | |||
| 101 | * @brief MMC_SPI card detection. | 90 | * @brief MMC_SPI card detection. |
| 102 | */ | 91 | */ |
| 103 | bool mmc_lld_is_card_inserted(MMCDriver *mmcp) { | 92 | bool mmc_lld_is_card_inserted(MMCDriver *mmcp) { |
| 104 | 93 | (void)mmcp; | |
| 105 | (void)mmcp; | 94 | /* TODO: Fill the implementation.*/ |
| 106 | /* TODO: Fill the implementation.*/ | 95 | return true; |
| 107 | return true; | ||
| 108 | } | 96 | } |
| 109 | 97 | ||
| 110 | /** | 98 | /** |
| 111 | * @brief MMC_SPI card write protection detection. | 99 | * @brief MMC_SPI card write protection detection. |
| 112 | */ | 100 | */ |
| 113 | bool mmc_lld_is_write_protected(MMCDriver *mmcp) { | 101 | bool mmc_lld_is_write_protected(MMCDriver *mmcp) { |
| 114 | 102 | (void)mmcp; | |
| 115 | (void)mmcp; | 103 | /* TODO: Fill the implementation.*/ |
| 116 | /* TODO: Fill the implementation.*/ | 104 | return false; |
| 117 | return false; | ||
| 118 | } | 105 | } |
| 119 | #endif | 106 | #endif |
| 120 | 107 | ||
| @@ -122,5 +109,4 @@ bool mmc_lld_is_write_protected(MMCDriver *mmcp) { | |||
| 122 | * @brief Board-specific initialization code. | 109 | * @brief Board-specific initialization code. |
| 123 | * @todo Add your board-specific code, if any. | 110 | * @todo Add your board-specific code, if any. |
| 124 | */ | 111 | */ |
| 125 | void boardInit(void) { | 112 | void boardInit(void) {} |
| 126 | } | ||
diff --git a/drivers/boards/GENERIC_STM32_F303XC/board.h b/drivers/boards/GENERIC_STM32_F303XC/board.h index 11120dfd7..3579c8277 100644 --- a/drivers/boards/GENERIC_STM32_F303XC/board.h +++ b/drivers/boards/GENERIC_STM32_F303XC/board.h | |||
| @@ -25,20 +25,20 @@ | |||
| 25 | * Board identifier. | 25 | * Board identifier. |
| 26 | */ | 26 | */ |
| 27 | #define BOARD_GENERIC_STM32_F303XC | 27 | #define BOARD_GENERIC_STM32_F303XC |
| 28 | #define BOARD_NAME "STM32_F303" | 28 | #define BOARD_NAME "STM32_F303" |
| 29 | 29 | ||
| 30 | /* | 30 | /* |
| 31 | * Board oscillators-related settings. | 31 | * Board oscillators-related settings. |
| 32 | * NOTE: LSE not fitted. | 32 | * NOTE: LSE not fitted. |
| 33 | */ | 33 | */ |
| 34 | #if !defined(STM32_LSECLK) | 34 | #if !defined(STM32_LSECLK) |
| 35 | #define STM32_LSECLK 0U | 35 | # define STM32_LSECLK 0U |
| 36 | #endif | 36 | #endif |
| 37 | 37 | ||
| 38 | #define STM32_LSEDRV (3U << 3U) | 38 | #define STM32_LSEDRV (3U << 3U) |
| 39 | 39 | ||
| 40 | #if !defined(STM32_HSECLK) | 40 | #if !defined(STM32_HSECLK) |
| 41 | #define STM32_HSECLK 8000000U | 41 | # define STM32_HSECLK 8000000U |
| 42 | #endif | 42 | #endif |
| 43 | 43 | ||
| 44 | // #define STM32_HSE_BYPASS | 44 | // #define STM32_HSE_BYPASS |
| @@ -51,178 +51,177 @@ | |||
| 51 | /* | 51 | /* |
| 52 | * IO pins assignments. | 52 | * IO pins assignments. |
| 53 | */ | 53 | */ |
| 54 | #define GPIOA_PIN0 0U | 54 | #define GPIOA_PIN0 0U |
| 55 | #define GPIOA_PIN1 1U | 55 | #define GPIOA_PIN1 1U |
| 56 | #define GPIOA_PIN2 2U | 56 | #define GPIOA_PIN2 2U |
| 57 | #define GPIOA_PIN3 3U | 57 | #define GPIOA_PIN3 3U |
| 58 | #define GPIOA_PIN4 4U | 58 | #define GPIOA_PIN4 4U |
| 59 | #define GPIOA_PIN5 5U | 59 | #define GPIOA_PIN5 5U |
| 60 | #define GPIOA_PIN6 6U | 60 | #define GPIOA_PIN6 6U |
| 61 | #define GPIOA_PIN7 7U | 61 | #define GPIOA_PIN7 7U |
| 62 | #define GPIOA_PIN8 8U | 62 | #define GPIOA_PIN8 8U |
| 63 | #define GPIOA_PIN9 9U | 63 | #define GPIOA_PIN9 9U |
| 64 | #define GPIOA_PIN10 10U | 64 | #define GPIOA_PIN10 10U |
| 65 | #define GPIOA_USB_DM 11U | 65 | #define GPIOA_USB_DM 11U |
| 66 | #define GPIOA_USB_DP 12U | 66 | #define GPIOA_USB_DP 12U |
| 67 | #define GPIOA_SWDIO 13U | 67 | #define GPIOA_SWDIO 13U |
| 68 | #define GPIOA_SWCLK 14U | 68 | #define GPIOA_SWCLK 14U |
| 69 | #define GPIOA_PIN15 15U | 69 | #define GPIOA_PIN15 15U |
| 70 | 70 | ||
| 71 | #define GPIOB_PIN0 0U | 71 | #define GPIOB_PIN0 0U |
| 72 | #define GPIOB_PIN1 1U | 72 | #define GPIOB_PIN1 1U |
| 73 | #define GPIOB_PIN2 2U | 73 | #define GPIOB_PIN2 2U |
| 74 | #define GPIOB_PIN3 3U | 74 | #define GPIOB_PIN3 3U |
| 75 | #define GPIOB_PIN4 4U | 75 | #define GPIOB_PIN4 4U |
| 76 | #define GPIOB_PIN5 5U | 76 | #define GPIOB_PIN5 5U |
| 77 | #define GPIOB_PIN6 6U | 77 | #define GPIOB_PIN6 6U |
| 78 | #define GPIOB_PIN7 7U | 78 | #define GPIOB_PIN7 7U |
| 79 | #define GPIOB_PIN8 8U | 79 | #define GPIOB_PIN8 8U |
| 80 | #define GPIOB_PIN9 9U | 80 | #define GPIOB_PIN9 9U |
| 81 | #define GPIOB_PIN10 10U | 81 | #define GPIOB_PIN10 10U |
| 82 | #define GPIOB_PIN11 11U | 82 | #define GPIOB_PIN11 11U |
| 83 | #define GPIOB_PIN12 12U | 83 | #define GPIOB_PIN12 12U |
| 84 | #define GPIOB_PIN13 13U | 84 | #define GPIOB_PIN13 13U |
| 85 | #define GPIOB_PIN14 14U | 85 | #define GPIOB_PIN14 14U |
| 86 | #define GPIOB_PIN15 15U | 86 | #define GPIOB_PIN15 15U |
| 87 | 87 | ||
| 88 | #define GPIOC_PIN0 0U | 88 | #define GPIOC_PIN0 0U |
| 89 | #define GPIOC_PIN1 1U | 89 | #define GPIOC_PIN1 1U |
| 90 | #define GPIOC_PIN2 2U | 90 | #define GPIOC_PIN2 2U |
| 91 | #define GPIOC_PIN3 3U | 91 | #define GPIOC_PIN3 3U |
| 92 | #define GPIOC_PIN4 4U | 92 | #define GPIOC_PIN4 4U |
| 93 | #define GPIOC_PIN5 5U | 93 | #define GPIOC_PIN5 5U |
| 94 | #define GPIOC_PIN6 6U | 94 | #define GPIOC_PIN6 6U |
| 95 | #define GPIOC_PIN7 7U | 95 | #define GPIOC_PIN7 7U |
| 96 | #define GPIOC_PIN8 8U | 96 | #define GPIOC_PIN8 8U |
| 97 | #define GPIOC_PIN9 9U | 97 | #define GPIOC_PIN9 9U |
| 98 | #define GPIOC_PIN10 10U | 98 | #define GPIOC_PIN10 10U |
| 99 | #define GPIOC_PIN11 11U | 99 | #define GPIOC_PIN11 11U |
| 100 | #define GPIOC_PIN12 12U | 100 | #define GPIOC_PIN12 12U |
| 101 | #define GPIOC_PIN13 13U | 101 | #define GPIOC_PIN13 13U |
| 102 | #define GPIOC_PIN14 14U | 102 | #define GPIOC_PIN14 14U |
| 103 | #define GPIOC_PIN15 15U | 103 | #define GPIOC_PIN15 15U |
| 104 | 104 | ||
| 105 | #define GPIOD_PIN0 0U | 105 | #define GPIOD_PIN0 0U |
| 106 | #define GPIOD_PIN1 1U | 106 | #define GPIOD_PIN1 1U |
| 107 | #define GPIOD_PIN2 2U | 107 | #define GPIOD_PIN2 2U |
| 108 | #define GPIOD_PIN3 3U | 108 | #define GPIOD_PIN3 3U |
| 109 | #define GPIOD_PIN4 4U | 109 | #define GPIOD_PIN4 4U |
| 110 | #define GPIOD_PIN5 5U | 110 | #define GPIOD_PIN5 5U |
| 111 | #define GPIOD_PIN6 6U | 111 | #define GPIOD_PIN6 6U |
| 112 | #define GPIOD_PIN7 7U | 112 | #define GPIOD_PIN7 7U |
| 113 | #define GPIOD_PIN8 8U | 113 | #define GPIOD_PIN8 8U |
| 114 | #define GPIOD_PIN9 9U | 114 | #define GPIOD_PIN9 9U |
| 115 | #define GPIOD_PIN10 10U | 115 | #define GPIOD_PIN10 10U |
| 116 | #define GPIOD_PIN11 11U | 116 | #define GPIOD_PIN11 11U |
| 117 | #define GPIOD_PIN12 12U | 117 | #define GPIOD_PIN12 12U |
| 118 | #define GPIOD_PIN13 13U | 118 | #define GPIOD_PIN13 13U |
| 119 | #define GPIOD_PIN14 14U | 119 | #define GPIOD_PIN14 14U |
| 120 | #define GPIOD_PIN15 15U | 120 | #define GPIOD_PIN15 15U |
| 121 | 121 | ||
| 122 | #define GPIOE_PIN0 0U | 122 | #define GPIOE_PIN0 0U |
| 123 | #define GPIOE_PIN1 1U | 123 | #define GPIOE_PIN1 1U |
| 124 | #define GPIOE_PIN2 2U | 124 | #define GPIOE_PIN2 2U |
| 125 | #define GPIOE_PIN3 3U | 125 | #define GPIOE_PIN3 3U |
| 126 | #define GPIOE_PIN4 4U | 126 | #define GPIOE_PIN4 4U |
| 127 | #define GPIOE_PIN5 5U | 127 | #define GPIOE_PIN5 5U |
| 128 | #define GPIOE_PIN6 6U | 128 | #define GPIOE_PIN6 6U |
| 129 | #define GPIOE_PIN7 7U | 129 | #define GPIOE_PIN7 7U |
| 130 | #define GPIOE_PIN8 8U | 130 | #define GPIOE_PIN8 8U |
| 131 | #define GPIOE_PIN9 9U | 131 | #define GPIOE_PIN9 9U |
| 132 | #define GPIOE_PIN10 10U | 132 | #define GPIOE_PIN10 10U |
| 133 | #define GPIOE_PIN11 11U | 133 | #define GPIOE_PIN11 11U |
| 134 | #define GPIOE_PIN12 12U | 134 | #define GPIOE_PIN12 12U |
| 135 | #define GPIOE_PIN13 13U | 135 | #define GPIOE_PIN13 13U |
| 136 | #define GPIOE_PIN14 14U | 136 | #define GPIOE_PIN14 14U |
| 137 | #define GPIOE_PIN15 15U | 137 | #define GPIOE_PIN15 15U |
| 138 | 138 | ||
| 139 | #define GPIOF_I2C2_SDA 0U | 139 | #define GPIOF_I2C2_SDA 0U |
| 140 | #define GPIOF_I2C2_SCL 1U | 140 | #define GPIOF_I2C2_SCL 1U |
| 141 | #define GPIOF_PIN2 2U | 141 | #define GPIOF_PIN2 2U |
| 142 | #define GPIOF_PIN3 3U | 142 | #define GPIOF_PIN3 3U |
| 143 | #define GPIOF_PIN4 4U | 143 | #define GPIOF_PIN4 4U |
| 144 | #define GPIOF_PIN5 5U | 144 | #define GPIOF_PIN5 5U |
| 145 | #define GPIOF_PIN6 6U | 145 | #define GPIOF_PIN6 6U |
| 146 | #define GPIOF_PIN7 7U | 146 | #define GPIOF_PIN7 7U |
| 147 | #define GPIOF_PIN8 8U | 147 | #define GPIOF_PIN8 8U |
| 148 | #define GPIOF_PIN9 9U | 148 | #define GPIOF_PIN9 9U |
| 149 | #define GPIOF_PIN10 10U | 149 | #define GPIOF_PIN10 10U |
| 150 | #define GPIOF_PIN11 11U | 150 | #define GPIOF_PIN11 11U |
| 151 | #define GPIOF_PIN12 12U | 151 | #define GPIOF_PIN12 12U |
| 152 | #define GPIOF_PIN13 13U | 152 | #define GPIOF_PIN13 13U |
| 153 | #define GPIOF_PIN14 14U | 153 | #define GPIOF_PIN14 14U |
| 154 | #define GPIOF_PIN15 15U | 154 | #define GPIOF_PIN15 15U |
| 155 | 155 | ||
| 156 | #define GPIOG_PIN0 0U | 156 | #define GPIOG_PIN0 0U |
| 157 | #define GPIOG_PIN1 1U | 157 | #define GPIOG_PIN1 1U |
| 158 | #define GPIOG_PIN2 2U | 158 | #define GPIOG_PIN2 2U |
| 159 | #define GPIOG_PIN3 3U | 159 | #define GPIOG_PIN3 3U |
| 160 | #define GPIOG_PIN4 4U | 160 | #define GPIOG_PIN4 4U |
| 161 | #define GPIOG_PIN5 5U | 161 | #define GPIOG_PIN5 5U |
| 162 | #define GPIOG_PIN6 6U | 162 | #define GPIOG_PIN6 6U |
| 163 | #define GPIOG_PIN7 7U | 163 | #define GPIOG_PIN7 7U |
| 164 | #define GPIOG_PIN8 8U | 164 | #define GPIOG_PIN8 8U |
| 165 | #define GPIOG_PIN9 9U | 165 | #define GPIOG_PIN9 9U |
| 166 | #define GPIOG_PIN10 10U | 166 | #define GPIOG_PIN10 10U |
| 167 | #define GPIOG_PIN11 11U | 167 | #define GPIOG_PIN11 11U |
| 168 | #define GPIOG_PIN12 12U | 168 | #define GPIOG_PIN12 12U |
| 169 | #define GPIOG_PIN13 13U | 169 | #define GPIOG_PIN13 13U |
| 170 | #define GPIOG_PIN14 14U | 170 | #define GPIOG_PIN14 14U |
| 171 | #define GPIOG_PIN15 15U | 171 | #define GPIOG_PIN15 15U |
| 172 | 172 | ||
| 173 | #define GPIOH_PIN0 0U | 173 | #define GPIOH_PIN0 0U |
| 174 | #define GPIOH_PIN1 1U | 174 | #define GPIOH_PIN1 1U |
| 175 | #define GPIOH_PIN2 2U | 175 | #define GPIOH_PIN2 2U |
| 176 | #define GPIOH_PIN3 3U | 176 | #define GPIOH_PIN3 3U |
| 177 | #define GPIOH_PIN4 4U | 177 | #define GPIOH_PIN4 4U |
| 178 | #define GPIOH_PIN5 5U | 178 | #define GPIOH_PIN5 5U |
| 179 | #define GPIOH_PIN6 6U | 179 | #define GPIOH_PIN6 6U |
| 180 | #define GPIOH_PIN7 7U | 180 | #define GPIOH_PIN7 7U |
| 181 | #define GPIOH_PIN8 8U | 181 | #define GPIOH_PIN8 8U |
| 182 | #define GPIOH_PIN9 9U | 182 | #define GPIOH_PIN9 9U |
| 183 | #define GPIOH_PIN10 10U | 183 | #define GPIOH_PIN10 10U |
| 184 | #define GPIOH_PIN11 11U | 184 | #define GPIOH_PIN11 11U |
| 185 | #define GPIOH_PIN12 12U | 185 | #define GPIOH_PIN12 12U |
| 186 | #define GPIOH_PIN13 13U | 186 | #define GPIOH_PIN13 13U |
| 187 | #define GPIOH_PIN14 14U | 187 | #define GPIOH_PIN14 14U |
| 188 | #define GPIOH_PIN15 15U | 188 | #define GPIOH_PIN15 15U |
| 189 | 189 | ||
| 190 | /* | 190 | /* |
| 191 | * IO lines assignments. | 191 | * IO lines assignments. |
| 192 | */ | 192 | */ |
| 193 | #define LINE_L3GD20_SDI PAL_LINE(GPIOA, 7U) | 193 | #define LINE_L3GD20_SDI PAL_LINE(GPIOA, 7U) |
| 194 | #define LINE_USB_DM PAL_LINE(GPIOA, 11U) | 194 | #define LINE_USB_DM PAL_LINE(GPIOA, 11U) |
| 195 | #define LINE_USB_DP PAL_LINE(GPIOA, 12U) | 195 | #define LINE_USB_DP PAL_LINE(GPIOA, 12U) |
| 196 | #define LINE_SWDIO PAL_LINE(GPIOA, 13U) | 196 | #define LINE_SWDIO PAL_LINE(GPIOA, 13U) |
| 197 | #define LINE_SWCLK PAL_LINE(GPIOA, 14U) | 197 | #define LINE_SWCLK PAL_LINE(GPIOA, 14U) |
| 198 | |||
| 199 | #define LINE_PIN6 PAL_LINE(GPIOF, 0U) | ||
| 200 | #define LINE_PIN7 PAL_LINE(GPIOF, 1U) | ||
| 201 | 198 | ||
| 202 | #define LINE_CAPS_LOCK PAL_LINE(GPIOB, 7U) | 199 | #define LINE_PIN6 PAL_LINE(GPIOF, 0U) |
| 200 | #define LINE_PIN7 PAL_LINE(GPIOF, 1U) | ||
| 203 | 201 | ||
| 202 | #define LINE_CAPS_LOCK PAL_LINE(GPIOB, 7U) | ||
| 204 | 203 | ||
| 205 | /* | 204 | /* |
| 206 | * I/O ports initial setup, this configuration is established soon after reset | 205 | * I/O ports initial setup, this configuration is established soon after reset |
| 207 | * in the initialization code. | 206 | * in the initialization code. |
| 208 | * Please refer to the STM32 Reference Manual for details. | 207 | * Please refer to the STM32 Reference Manual for details. |
| 209 | */ | 208 | */ |
| 210 | #define PIN_MODE_INPUT(n) (0U << ((n) * 2U)) | 209 | #define PIN_MODE_INPUT(n) (0U << ((n)*2U)) |
| 211 | #define PIN_MODE_OUTPUT(n) (1U << ((n) * 2U)) | 210 | #define PIN_MODE_OUTPUT(n) (1U << ((n)*2U)) |
| 212 | #define PIN_MODE_ALTERNATE(n) (2U << ((n) * 2U)) | 211 | #define PIN_MODE_ALTERNATE(n) (2U << ((n)*2U)) |
| 213 | #define PIN_MODE_ANALOG(n) (3U << ((n) * 2U)) | 212 | #define PIN_MODE_ANALOG(n) (3U << ((n)*2U)) |
| 214 | #define PIN_ODR_LOW(n) (0U << (n)) | 213 | #define PIN_ODR_LOW(n) (0U << (n)) |
| 215 | #define PIN_ODR_HIGH(n) (1U << (n)) | 214 | #define PIN_ODR_HIGH(n) (1U << (n)) |
| 216 | #define PIN_OTYPE_PUSHPULL(n) (0U << (n)) | 215 | #define PIN_OTYPE_PUSHPULL(n) (0U << (n)) |
| 217 | #define PIN_OTYPE_OPENDRAIN(n) (1U << (n)) | 216 | #define PIN_OTYPE_OPENDRAIN(n) (1U << (n)) |
| 218 | #define PIN_OSPEED_VERYLOW(n) (0U << ((n) * 2U)) | 217 | #define PIN_OSPEED_VERYLOW(n) (0U << ((n)*2U)) |
| 219 | #define PIN_OSPEED_LOW(n) (1U << ((n) * 2U)) | 218 | #define PIN_OSPEED_LOW(n) (1U << ((n)*2U)) |
| 220 | #define PIN_OSPEED_MEDIUM(n) (2U << ((n) * 2U)) | 219 | #define PIN_OSPEED_MEDIUM(n) (2U << ((n)*2U)) |
| 221 | #define PIN_OSPEED_HIGH(n) (3U << ((n) * 2U)) | 220 | #define PIN_OSPEED_HIGH(n) (3U << ((n)*2U)) |
| 222 | #define PIN_PUPDR_FLOATING(n) (0U << ((n) * 2U)) | 221 | #define PIN_PUPDR_FLOATING(n) (0U << ((n)*2U)) |
| 223 | #define PIN_PUPDR_PULLUP(n) (1U << ((n) * 2U)) | 222 | #define PIN_PUPDR_PULLUP(n) (1U << ((n)*2U)) |
| 224 | #define PIN_PUPDR_PULLDOWN(n) (2U << ((n) * 2U)) | 223 | #define PIN_PUPDR_PULLDOWN(n) (2U << ((n)*2U)) |
| 225 | #define PIN_AFIO_AF(n, v) ((v) << (((n) % 8U) * 4U)) | 224 | #define PIN_AFIO_AF(n, v) ((v) << (((n) % 8U) * 4U)) |
| 226 | 225 | ||
| 227 | /* | 226 | /* |
| 228 | * GPIOA setup: | 227 | * GPIOA setup: |
| @@ -244,102 +243,13 @@ | |||
| 244 | * PA14 - SWCLK (alternate 0). | 243 | * PA14 - SWCLK (alternate 0). |
| 245 | * PA15 - ROW4 | 244 | * PA15 - ROW4 |
| 246 | */ | 245 | */ |
| 247 | #define VAL_GPIOA_MODER (PIN_MODE_INPUT(GPIOA_PIN0) | \ | 246 | #define VAL_GPIOA_MODER (PIN_MODE_INPUT(GPIOA_PIN0) | PIN_MODE_ALTERNATE(GPIOA_PIN1) | PIN_MODE_INPUT(GPIOA_PIN2) | PIN_MODE_INPUT(GPIOA_PIN3) | PIN_MODE_INPUT(GPIOA_PIN4) | PIN_MODE_INPUT(GPIOA_PIN5) | PIN_MODE_INPUT(GPIOA_PIN6) | PIN_MODE_INPUT(GPIOA_PIN7) | PIN_MODE_INPUT(GPIOA_PIN8) | PIN_MODE_INPUT(GPIOA_PIN9) | PIN_MODE_INPUT(GPIOA_PIN10) | PIN_MODE_ALTERNATE(GPIOA_USB_DM) | PIN_MODE_ALTERNATE(GPIOA_USB_DP) | PIN_MODE_ALTERNATE(GPIOA_SWDIO) | PIN_MODE_ALTERNATE(GPIOA_SWCLK) | PIN_MODE_INPUT(GPIOA_PIN15)) |
| 248 | PIN_MODE_ALTERNATE(GPIOA_PIN1) | \ | 247 | #define VAL_GPIOA_OTYPER (PIN_OTYPE_PUSHPULL(GPIOA_PIN0) | PIN_OTYPE_PUSHPULL(GPIOA_PIN1) | PIN_OTYPE_PUSHPULL(GPIOA_PIN2) | PIN_OTYPE_PUSHPULL(GPIOA_PIN3) | PIN_OTYPE_PUSHPULL(GPIOA_PIN4) | PIN_OTYPE_PUSHPULL(GPIOA_PIN5) | PIN_OTYPE_PUSHPULL(GPIOA_PIN6) | PIN_OTYPE_PUSHPULL(GPIOA_PIN7) | PIN_OTYPE_PUSHPULL(GPIOA_PIN8) | PIN_OTYPE_PUSHPULL(GPIOA_PIN9) | PIN_OTYPE_PUSHPULL(GPIOA_PIN10) | PIN_OTYPE_PUSHPULL(GPIOA_USB_DM) | PIN_OTYPE_PUSHPULL(GPIOA_USB_DP) | PIN_OTYPE_PUSHPULL(GPIOA_SWDIO) | PIN_OTYPE_PUSHPULL(GPIOA_SWCLK) | PIN_OTYPE_PUSHPULL(GPIOA_PIN15)) |
| 249 | PIN_MODE_INPUT(GPIOA_PIN2) | \ | 248 | #define VAL_GPIOA_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOA_PIN0) | PIN_OSPEED_HIGH(GPIOA_PIN1) | PIN_OSPEED_VERYLOW(GPIOA_PIN2) | PIN_OSPEED_VERYLOW(GPIOA_PIN3) | PIN_OSPEED_VERYLOW(GPIOA_PIN4) | PIN_OSPEED_VERYLOW(GPIOA_PIN5) | PIN_OSPEED_VERYLOW(GPIOA_PIN6) | PIN_OSPEED_VERYLOW(GPIOA_PIN7) | PIN_OSPEED_VERYLOW(GPIOA_PIN8) | PIN_OSPEED_VERYLOW(GPIOA_PIN9) | PIN_OSPEED_VERYLOW(GPIOA_PIN10) | PIN_OSPEED_HIGH(GPIOA_USB_DM) | PIN_OSPEED_VERYLOW(GPIOA_USB_DP) | PIN_OSPEED_HIGH(GPIOA_SWDIO) | PIN_OSPEED_HIGH(GPIOA_SWCLK) | PIN_OSPEED_VERYLOW(GPIOA_PIN15)) |
| 250 | PIN_MODE_INPUT(GPIOA_PIN3) | \ | 249 | #define VAL_GPIOA_PUPDR (PIN_PUPDR_FLOATING(GPIOA_PIN0) | PIN_PUPDR_FLOATING(GPIOA_PIN1) | PIN_PUPDR_PULLUP(GPIOA_PIN2) | PIN_PUPDR_PULLUP(GPIOA_PIN3) | PIN_PUPDR_PULLUP(GPIOA_PIN4) | PIN_PUPDR_PULLUP(GPIOA_PIN5) | PIN_PUPDR_PULLUP(GPIOA_PIN6) | PIN_PUPDR_FLOATING(GPIOA_PIN7) | PIN_PUPDR_PULLUP(GPIOA_PIN8) | PIN_PUPDR_PULLUP(GPIOA_PIN9) | PIN_PUPDR_PULLUP(GPIOA_PIN10) | PIN_PUPDR_FLOATING(GPIOA_USB_DM) | PIN_PUPDR_FLOATING(GPIOA_USB_DP) | PIN_PUPDR_PULLUP(GPIOA_SWDIO) | PIN_PUPDR_PULLDOWN(GPIOA_SWCLK) | PIN_PUPDR_PULLUP(GPIOA_PIN15)) |
| 251 | PIN_MODE_INPUT(GPIOA_PIN4) | \ | 250 | #define VAL_GPIOA_ODR (PIN_ODR_HIGH(GPIOA_PIN0) | PIN_ODR_HIGH(GPIOA_PIN1) | PIN_ODR_HIGH(GPIOA_PIN2) | PIN_ODR_HIGH(GPIOA_PIN3) | PIN_ODR_HIGH(GPIOA_PIN4) | PIN_ODR_HIGH(GPIOA_PIN5) | PIN_ODR_HIGH(GPIOA_PIN6) | PIN_ODR_HIGH(GPIOA_PIN7) | PIN_ODR_HIGH(GPIOA_PIN8) | PIN_ODR_HIGH(GPIOA_PIN9) | PIN_ODR_HIGH(GPIOA_PIN10) | PIN_ODR_HIGH(GPIOA_USB_DM) | PIN_ODR_HIGH(GPIOA_USB_DP) | PIN_ODR_HIGH(GPIOA_SWDIO) | PIN_ODR_HIGH(GPIOA_SWCLK) | PIN_ODR_HIGH(GPIOA_PIN15)) |
| 252 | PIN_MODE_INPUT(GPIOA_PIN5) | \ | 251 | #define VAL_GPIOA_AFRL (PIN_AFIO_AF(GPIOA_PIN0, 0) | PIN_AFIO_AF(GPIOA_PIN1, 1) | PIN_AFIO_AF(GPIOA_PIN2, 0) | PIN_AFIO_AF(GPIOA_PIN3, 0) | PIN_AFIO_AF(GPIOA_PIN4, 0) | PIN_AFIO_AF(GPIOA_PIN5, 5) | PIN_AFIO_AF(GPIOA_PIN6, 5) | PIN_AFIO_AF(GPIOA_PIN7, 5)) |
| 253 | PIN_MODE_INPUT(GPIOA_PIN6) | \ | 252 | #define VAL_GPIOA_AFRH (PIN_AFIO_AF(GPIOA_PIN8, 0) | PIN_AFIO_AF(GPIOA_PIN9, 0) | PIN_AFIO_AF(GPIOA_PIN10, 0) | PIN_AFIO_AF(GPIOA_USB_DM, 14) | PIN_AFIO_AF(GPIOA_USB_DP, 14) | PIN_AFIO_AF(GPIOA_SWDIO, 0) | PIN_AFIO_AF(GPIOA_SWCLK, 0) | PIN_AFIO_AF(GPIOA_PIN15, 0)) |
| 254 | PIN_MODE_INPUT(GPIOA_PIN7) | \ | ||
| 255 | PIN_MODE_INPUT(GPIOA_PIN8) | \ | ||
| 256 | PIN_MODE_INPUT(GPIOA_PIN9) | \ | ||
| 257 | PIN_MODE_INPUT(GPIOA_PIN10) | \ | ||
| 258 | PIN_MODE_ALTERNATE(GPIOA_USB_DM) | \ | ||
| 259 | PIN_MODE_ALTERNATE(GPIOA_USB_DP) | \ | ||
| 260 | PIN_MODE_ALTERNATE(GPIOA_SWDIO) | \ | ||
| 261 | PIN_MODE_ALTERNATE(GPIOA_SWCLK) | \ | ||
| 262 | PIN_MODE_INPUT(GPIOA_PIN15)) | ||
| 263 | #define VAL_GPIOA_OTYPER (PIN_OTYPE_PUSHPULL(GPIOA_PIN0) | \ | ||
| 264 | PIN_OTYPE_PUSHPULL(GPIOA_PIN1) | \ | ||
| 265 | PIN_OTYPE_PUSHPULL(GPIOA_PIN2) | \ | ||
| 266 | PIN_OTYPE_PUSHPULL(GPIOA_PIN3) | \ | ||
| 267 | PIN_OTYPE_PUSHPULL(GPIOA_PIN4) | \ | ||
| 268 | PIN_OTYPE_PUSHPULL(GPIOA_PIN5) | \ | ||
| 269 | PIN_OTYPE_PUSHPULL(GPIOA_PIN6) | \ | ||
| 270 | PIN_OTYPE_PUSHPULL(GPIOA_PIN7) | \ | ||
| 271 | PIN_OTYPE_PUSHPULL(GPIOA_PIN8) | \ | ||
| 272 | PIN_OTYPE_PUSHPULL(GPIOA_PIN9) | \ | ||
| 273 | PIN_OTYPE_PUSHPULL(GPIOA_PIN10) | \ | ||
| 274 | PIN_OTYPE_PUSHPULL(GPIOA_USB_DM) | \ | ||
| 275 | PIN_OTYPE_PUSHPULL(GPIOA_USB_DP) | \ | ||
| 276 | PIN_OTYPE_PUSHPULL(GPIOA_SWDIO) | \ | ||
| 277 | PIN_OTYPE_PUSHPULL(GPIOA_SWCLK) | \ | ||
| 278 | PIN_OTYPE_PUSHPULL(GPIOA_PIN15)) | ||
| 279 | #define VAL_GPIOA_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOA_PIN0) | \ | ||
| 280 | PIN_OSPEED_HIGH(GPIOA_PIN1) | \ | ||
| 281 | PIN_OSPEED_VERYLOW(GPIOA_PIN2) | \ | ||
| 282 | PIN_OSPEED_VERYLOW(GPIOA_PIN3) | \ | ||
| 283 | PIN_OSPEED_VERYLOW(GPIOA_PIN4) | \ | ||
| 284 | PIN_OSPEED_VERYLOW(GPIOA_PIN5) | \ | ||
| 285 | PIN_OSPEED_VERYLOW(GPIOA_PIN6) | \ | ||
| 286 | PIN_OSPEED_VERYLOW(GPIOA_PIN7) | \ | ||
| 287 | PIN_OSPEED_VERYLOW(GPIOA_PIN8) | \ | ||
| 288 | PIN_OSPEED_VERYLOW(GPIOA_PIN9) | \ | ||
| 289 | PIN_OSPEED_VERYLOW(GPIOA_PIN10) | \ | ||
| 290 | PIN_OSPEED_HIGH(GPIOA_USB_DM) | \ | ||
| 291 | PIN_OSPEED_VERYLOW(GPIOA_USB_DP) | \ | ||
| 292 | PIN_OSPEED_HIGH(GPIOA_SWDIO) | \ | ||
| 293 | PIN_OSPEED_HIGH(GPIOA_SWCLK) | \ | ||
| 294 | PIN_OSPEED_VERYLOW(GPIOA_PIN15)) | ||
| 295 | #define VAL_GPIOA_PUPDR (PIN_PUPDR_FLOATING(GPIOA_PIN0) | \ | ||
| 296 | PIN_PUPDR_FLOATING(GPIOA_PIN1) | \ | ||
| 297 | PIN_PUPDR_PULLUP(GPIOA_PIN2) | \ | ||
| 298 | PIN_PUPDR_PULLUP(GPIOA_PIN3) | \ | ||
| 299 | PIN_PUPDR_PULLUP(GPIOA_PIN4) | \ | ||
| 300 | PIN_PUPDR_PULLUP(GPIOA_PIN5) | \ | ||
| 301 | PIN_PUPDR_PULLUP(GPIOA_PIN6) | \ | ||
| 302 | PIN_PUPDR_FLOATING(GPIOA_PIN7) | \ | ||
| 303 | PIN_PUPDR_PULLUP(GPIOA_PIN8) | \ | ||
| 304 | PIN_PUPDR_PULLUP(GPIOA_PIN9) | \ | ||
| 305 | PIN_PUPDR_PULLUP(GPIOA_PIN10) | \ | ||
| 306 | PIN_PUPDR_FLOATING(GPIOA_USB_DM) | \ | ||
| 307 | PIN_PUPDR_FLOATING(GPIOA_USB_DP) | \ | ||
| 308 | PIN_PUPDR_PULLUP(GPIOA_SWDIO) | \ | ||
| 309 | PIN_PUPDR_PULLDOWN(GPIOA_SWCLK) | \ | ||
| 310 | PIN_PUPDR_PULLUP(GPIOA_PIN15)) | ||
| 311 | #define VAL_GPIOA_ODR (PIN_ODR_HIGH(GPIOA_PIN0) | \ | ||
| 312 | PIN_ODR_HIGH(GPIOA_PIN1) | \ | ||
| 313 | PIN_ODR_HIGH(GPIOA_PIN2) | \ | ||
| 314 | PIN_ODR_HIGH(GPIOA_PIN3) | \ | ||
| 315 | PIN_ODR_HIGH(GPIOA_PIN4) | \ | ||
| 316 | PIN_ODR_HIGH(GPIOA_PIN5) | \ | ||
| 317 | PIN_ODR_HIGH(GPIOA_PIN6) | \ | ||
| 318 | PIN_ODR_HIGH(GPIOA_PIN7) | \ | ||
| 319 | PIN_ODR_HIGH(GPIOA_PIN8) | \ | ||
| 320 | PIN_ODR_HIGH(GPIOA_PIN9) | \ | ||
| 321 | PIN_ODR_HIGH(GPIOA_PIN10) | \ | ||
| 322 | PIN_ODR_HIGH(GPIOA_USB_DM) | \ | ||
| 323 | PIN_ODR_HIGH(GPIOA_USB_DP) | \ | ||
| 324 | PIN_ODR_HIGH(GPIOA_SWDIO) | \ | ||
| 325 | PIN_ODR_HIGH(GPIOA_SWCLK) | \ | ||
| 326 | PIN_ODR_HIGH(GPIOA_PIN15)) | ||
| 327 | #define VAL_GPIOA_AFRL (PIN_AFIO_AF(GPIOA_PIN0, 0) | \ | ||
| 328 | PIN_AFIO_AF(GPIOA_PIN1, 1) | \ | ||
| 329 | PIN_AFIO_AF(GPIOA_PIN2, 0) | \ | ||
| 330 | PIN_AFIO_AF(GPIOA_PIN3, 0) | \ | ||
| 331 | PIN_AFIO_AF(GPIOA_PIN4, 0) | \ | ||
| 332 | PIN_AFIO_AF(GPIOA_PIN5, 5) | \ | ||
| 333 | PIN_AFIO_AF(GPIOA_PIN6, 5) | \ | ||
| 334 | PIN_AFIO_AF(GPIOA_PIN7, 5)) | ||
| 335 | #define VAL_GPIOA_AFRH (PIN_AFIO_AF(GPIOA_PIN8, 0) | \ | ||
| 336 | PIN_AFIO_AF(GPIOA_PIN9, 0) | \ | ||
| 337 | PIN_AFIO_AF(GPIOA_PIN10, 0) | \ | ||
| 338 | PIN_AFIO_AF(GPIOA_USB_DM, 14) | \ | ||
| 339 | PIN_AFIO_AF(GPIOA_USB_DP, 14) | \ | ||
| 340 | PIN_AFIO_AF(GPIOA_SWDIO, 0) | \ | ||
| 341 | PIN_AFIO_AF(GPIOA_SWCLK, 0) | \ | ||
| 342 | PIN_AFIO_AF(GPIOA_PIN15, 0)) | ||
| 343 | 253 | ||
| 344 | /* | 254 | /* |
| 345 | * GPIOB setup: | 255 | * GPIOB setup: |
| @@ -361,102 +271,13 @@ | |||
| 361 | * PB14 - PIN14 (input pullup). | 271 | * PB14 - PIN14 (input pullup). |
| 362 | * PB15 - PIN15 (input pullup). | 272 | * PB15 - PIN15 (input pullup). |
| 363 | */ | 273 | */ |
| 364 | #define VAL_GPIOB_MODER (PIN_MODE_INPUT(GPIOB_PIN0) | \ | 274 | #define VAL_GPIOB_MODER (PIN_MODE_INPUT(GPIOB_PIN0) | PIN_MODE_INPUT(GPIOB_PIN1) | PIN_MODE_INPUT(GPIOB_PIN2) | PIN_MODE_ALTERNATE(GPIOB_PIN3) | PIN_MODE_INPUT(GPIOB_PIN4) | PIN_MODE_INPUT(GPIOB_PIN5) | PIN_MODE_ALTERNATE(GPIOB_PIN6) | PIN_MODE_OUTPUT(GPIOB_PIN7) | PIN_MODE_INPUT(GPIOB_PIN8) | PIN_MODE_INPUT(GPIOB_PIN9) | PIN_MODE_INPUT(GPIOB_PIN10) | PIN_MODE_INPUT(GPIOB_PIN11) | PIN_MODE_INPUT(GPIOB_PIN12) | PIN_MODE_INPUT(GPIOB_PIN13) | PIN_MODE_INPUT(GPIOB_PIN14) | PIN_MODE_INPUT(GPIOB_PIN15)) |
| 365 | PIN_MODE_INPUT(GPIOB_PIN1) | \ | 275 | #define VAL_GPIOB_OTYPER (PIN_OTYPE_PUSHPULL(GPIOB_PIN0) | PIN_OTYPE_PUSHPULL(GPIOB_PIN1) | PIN_OTYPE_PUSHPULL(GPIOB_PIN2) | PIN_OTYPE_PUSHPULL(GPIOB_PIN3) | PIN_OTYPE_PUSHPULL(GPIOB_PIN4) | PIN_OTYPE_PUSHPULL(GPIOB_PIN5) | PIN_OTYPE_OPENDRAIN(GPIOB_PIN6) | PIN_OTYPE_PUSHPULL(GPIOB_PIN7) | PIN_OTYPE_PUSHPULL(GPIOB_PIN8) | PIN_OTYPE_PUSHPULL(GPIOB_PIN9) | PIN_OTYPE_PUSHPULL(GPIOB_PIN10) | PIN_OTYPE_PUSHPULL(GPIOB_PIN11) | PIN_OTYPE_PUSHPULL(GPIOB_PIN12) | PIN_OTYPE_PUSHPULL(GPIOB_PIN13) | PIN_OTYPE_PUSHPULL(GPIOB_PIN14) | PIN_OTYPE_PUSHPULL(GPIOB_PIN15)) |
| 366 | PIN_MODE_INPUT(GPIOB_PIN2) | \ | 276 | #define VAL_GPIOB_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOB_PIN0) | PIN_OSPEED_VERYLOW(GPIOB_PIN1) | PIN_OSPEED_VERYLOW(GPIOB_PIN2) | PIN_OSPEED_HIGH(GPIOB_PIN3) | PIN_OSPEED_VERYLOW(GPIOB_PIN4) | PIN_OSPEED_VERYLOW(GPIOB_PIN5) | PIN_OSPEED_HIGH(GPIOB_PIN6) | PIN_OSPEED_VERYLOW(GPIOB_PIN7) | PIN_OSPEED_VERYLOW(GPIOB_PIN8) | PIN_OSPEED_VERYLOW(GPIOB_PIN9) | PIN_OSPEED_VERYLOW(GPIOB_PIN10) | PIN_OSPEED_VERYLOW(GPIOB_PIN11) | PIN_OSPEED_VERYLOW(GPIOB_PIN12) | PIN_OSPEED_VERYLOW(GPIOB_PIN13) | PIN_OSPEED_VERYLOW(GPIOB_PIN14) | PIN_OSPEED_VERYLOW(GPIOB_PIN15)) |
| 367 | PIN_MODE_ALTERNATE(GPIOB_PIN3) | \ | 277 | #define VAL_GPIOB_PUPDR (PIN_PUPDR_PULLUP(GPIOB_PIN0) | PIN_PUPDR_PULLUP(GPIOB_PIN1) | PIN_PUPDR_PULLUP(GPIOB_PIN2) | PIN_PUPDR_FLOATING(GPIOB_PIN3) | PIN_PUPDR_PULLUP(GPIOB_PIN4) | PIN_PUPDR_PULLUP(GPIOB_PIN5) | PIN_PUPDR_FLOATING(GPIOB_PIN6) | PIN_PUPDR_PULLDOWN(GPIOB_PIN7) | PIN_PUPDR_PULLUP(GPIOB_PIN8) | PIN_PUPDR_PULLUP(GPIOB_PIN9) | PIN_PUPDR_PULLUP(GPIOB_PIN10) | PIN_PUPDR_PULLUP(GPIOB_PIN11) | PIN_PUPDR_PULLUP(GPIOB_PIN12) | PIN_PUPDR_PULLUP(GPIOB_PIN13) | PIN_PUPDR_PULLUP(GPIOB_PIN14) | PIN_PUPDR_PULLUP(GPIOB_PIN15)) |
| 368 | PIN_MODE_INPUT(GPIOB_PIN4) | \ | 278 | #define VAL_GPIOB_ODR (PIN_ODR_HIGH(GPIOB_PIN0) | PIN_ODR_HIGH(GPIOB_PIN1) | PIN_ODR_HIGH(GPIOB_PIN2) | PIN_ODR_HIGH(GPIOB_PIN3) | PIN_ODR_HIGH(GPIOB_PIN4) | PIN_ODR_HIGH(GPIOB_PIN5) | PIN_ODR_HIGH(GPIOB_PIN6) | PIN_ODR_LOW(GPIOB_PIN7) | PIN_ODR_HIGH(GPIOB_PIN8) | PIN_ODR_HIGH(GPIOB_PIN9) | PIN_ODR_HIGH(GPIOB_PIN10) | PIN_ODR_HIGH(GPIOB_PIN11) | PIN_ODR_HIGH(GPIOB_PIN12) | PIN_ODR_HIGH(GPIOB_PIN13) | PIN_ODR_HIGH(GPIOB_PIN14) | PIN_ODR_HIGH(GPIOB_PIN15)) |
| 369 | PIN_MODE_INPUT(GPIOB_PIN5) | \ | 279 | #define VAL_GPIOB_AFRL (PIN_AFIO_AF(GPIOB_PIN0, 0) | PIN_AFIO_AF(GPIOB_PIN1, 0) | PIN_AFIO_AF(GPIOB_PIN2, 0) | PIN_AFIO_AF(GPIOB_PIN3, 0) | PIN_AFIO_AF(GPIOB_PIN4, 0) | PIN_AFIO_AF(GPIOB_PIN5, 0) | PIN_AFIO_AF(GPIOB_PIN6, 4) | PIN_AFIO_AF(GPIOB_PIN7, 0)) |
| 370 | PIN_MODE_ALTERNATE(GPIOB_PIN6) | \ | 280 | #define VAL_GPIOB_AFRH (PIN_AFIO_AF(GPIOB_PIN8, 0) | PIN_AFIO_AF(GPIOB_PIN9, 0) | PIN_AFIO_AF(GPIOB_PIN10, 0) | PIN_AFIO_AF(GPIOB_PIN11, 0) | PIN_AFIO_AF(GPIOB_PIN12, 0) | PIN_AFIO_AF(GPIOB_PIN13, 0) | PIN_AFIO_AF(GPIOB_PIN14, 0) | PIN_AFIO_AF(GPIOB_PIN15, 0)) |
| 371 | PIN_MODE_OUTPUT(GPIOB_PIN7) | \ | ||
| 372 | PIN_MODE_INPUT(GPIOB_PIN8) | \ | ||
| 373 | PIN_MODE_INPUT(GPIOB_PIN9) | \ | ||
| 374 | PIN_MODE_INPUT(GPIOB_PIN10) | \ | ||
| 375 | PIN_MODE_INPUT(GPIOB_PIN11) | \ | ||
| 376 | PIN_MODE_INPUT(GPIOB_PIN12) | \ | ||
| 377 | PIN_MODE_INPUT(GPIOB_PIN13) | \ | ||
| 378 | PIN_MODE_INPUT(GPIOB_PIN14) | \ | ||
| 379 | PIN_MODE_INPUT(GPIOB_PIN15)) | ||
| 380 | #define VAL_GPIOB_OTYPER (PIN_OTYPE_PUSHPULL(GPIOB_PIN0) | \ | ||
| 381 | PIN_OTYPE_PUSHPULL(GPIOB_PIN1) | \ | ||
| 382 | PIN_OTYPE_PUSHPULL(GPIOB_PIN2) | \ | ||
| 383 | PIN_OTYPE_PUSHPULL(GPIOB_PIN3) | \ | ||
| 384 | PIN_OTYPE_PUSHPULL(GPIOB_PIN4) | \ | ||
| 385 | PIN_OTYPE_PUSHPULL(GPIOB_PIN5) | \ | ||
| 386 | PIN_OTYPE_OPENDRAIN(GPIOB_PIN6) | \ | ||
| 387 | PIN_OTYPE_PUSHPULL(GPIOB_PIN7) | \ | ||
| 388 | PIN_OTYPE_PUSHPULL(GPIOB_PIN8) | \ | ||
| 389 | PIN_OTYPE_PUSHPULL(GPIOB_PIN9) | \ | ||
| 390 | PIN_OTYPE_PUSHPULL(GPIOB_PIN10) | \ | ||
| 391 | PIN_OTYPE_PUSHPULL(GPIOB_PIN11) | \ | ||
| 392 | PIN_OTYPE_PUSHPULL(GPIOB_PIN12) | \ | ||
| 393 | PIN_OTYPE_PUSHPULL(GPIOB_PIN13) | \ | ||
| 394 | PIN_OTYPE_PUSHPULL(GPIOB_PIN14) | \ | ||
| 395 | PIN_OTYPE_PUSHPULL(GPIOB_PIN15)) | ||
| 396 | #define VAL_GPIOB_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOB_PIN0) | \ | ||
| 397 | PIN_OSPEED_VERYLOW(GPIOB_PIN1) | \ | ||
| 398 | PIN_OSPEED_VERYLOW(GPIOB_PIN2) | \ | ||
| 399 | PIN_OSPEED_HIGH(GPIOB_PIN3) | \ | ||
| 400 | PIN_OSPEED_VERYLOW(GPIOB_PIN4) | \ | ||
| 401 | PIN_OSPEED_VERYLOW(GPIOB_PIN5) | \ | ||
| 402 | PIN_OSPEED_HIGH(GPIOB_PIN6) | \ | ||
| 403 | PIN_OSPEED_VERYLOW(GPIOB_PIN7) | \ | ||
| 404 | PIN_OSPEED_VERYLOW(GPIOB_PIN8) | \ | ||
| 405 | PIN_OSPEED_VERYLOW(GPIOB_PIN9) | \ | ||
| 406 | PIN_OSPEED_VERYLOW(GPIOB_PIN10) | \ | ||
| 407 | PIN_OSPEED_VERYLOW(GPIOB_PIN11) | \ | ||
| 408 | PIN_OSPEED_VERYLOW(GPIOB_PIN12) | \ | ||
| 409 | PIN_OSPEED_VERYLOW(GPIOB_PIN13) | \ | ||
| 410 | PIN_OSPEED_VERYLOW(GPIOB_PIN14) | \ | ||
| 411 | PIN_OSPEED_VERYLOW(GPIOB_PIN15)) | ||
| 412 | #define VAL_GPIOB_PUPDR (PIN_PUPDR_PULLUP(GPIOB_PIN0) | \ | ||
| 413 | PIN_PUPDR_PULLUP(GPIOB_PIN1) | \ | ||
| 414 | PIN_PUPDR_PULLUP(GPIOB_PIN2) | \ | ||
| 415 | PIN_PUPDR_FLOATING(GPIOB_PIN3) | \ | ||
| 416 | PIN_PUPDR_PULLUP(GPIOB_PIN4) | \ | ||
| 417 | PIN_PUPDR_PULLUP(GPIOB_PIN5) | \ | ||
| 418 | PIN_PUPDR_FLOATING(GPIOB_PIN6) | \ | ||
| 419 | PIN_PUPDR_PULLDOWN(GPIOB_PIN7) | \ | ||
| 420 | PIN_PUPDR_PULLUP(GPIOB_PIN8) | \ | ||
| 421 | PIN_PUPDR_PULLUP(GPIOB_PIN9) | \ | ||
| 422 | PIN_PUPDR_PULLUP(GPIOB_PIN10) | \ | ||
| 423 | PIN_PUPDR_PULLUP(GPIOB_PIN11) | \ | ||
| 424 | PIN_PUPDR_PULLUP(GPIOB_PIN12) | \ | ||
| 425 | PIN_PUPDR_PULLUP(GPIOB_PIN13) | \ | ||
| 426 | PIN_PUPDR_PULLUP(GPIOB_PIN14) | \ | ||
| 427 | PIN_PUPDR_PULLUP(GPIOB_PIN15)) | ||
| 428 | #define VAL_GPIOB_ODR (PIN_ODR_HIGH(GPIOB_PIN0) | \ | ||
| 429 | PIN_ODR_HIGH(GPIOB_PIN1) | \ | ||
| 430 | PIN_ODR_HIGH(GPIOB_PIN2) | \ | ||
| 431 | PIN_ODR_HIGH(GPIOB_PIN3) | \ | ||
| 432 | PIN_ODR_HIGH(GPIOB_PIN4) | \ | ||
| 433 | PIN_ODR_HIGH(GPIOB_PIN5) | \ | ||
| 434 | PIN_ODR_HIGH(GPIOB_PIN6) | \ | ||
| 435 | PIN_ODR_LOW(GPIOB_PIN7) | \ | ||
| 436 | PIN_ODR_HIGH(GPIOB_PIN8) | \ | ||
| 437 | PIN_ODR_HIGH(GPIOB_PIN9) | \ | ||
| 438 | PIN_ODR_HIGH(GPIOB_PIN10) | \ | ||
| 439 | PIN_ODR_HIGH(GPIOB_PIN11) | \ | ||
| 440 | PIN_ODR_HIGH(GPIOB_PIN12) | \ | ||
| 441 | PIN_ODR_HIGH(GPIOB_PIN13) | \ | ||
| 442 | PIN_ODR_HIGH(GPIOB_PIN14) | \ | ||
| 443 | PIN_ODR_HIGH(GPIOB_PIN15)) | ||
| 444 | #define VAL_GPIOB_AFRL (PIN_AFIO_AF(GPIOB_PIN0, 0) | \ | ||
| 445 | PIN_AFIO_AF(GPIOB_PIN1, 0) | \ | ||
| 446 | PIN_AFIO_AF(GPIOB_PIN2, 0) | \ | ||
| 447 | PIN_AFIO_AF(GPIOB_PIN3, 0) | \ | ||
| 448 | PIN_AFIO_AF(GPIOB_PIN4, 0) | \ | ||
| 449 | PIN_AFIO_AF(GPIOB_PIN5, 0) | \ | ||
| 450 | PIN_AFIO_AF(GPIOB_PIN6, 4) | \ | ||
| 451 | PIN_AFIO_AF(GPIOB_PIN7, 0)) | ||
| 452 | #define VAL_GPIOB_AFRH (PIN_AFIO_AF(GPIOB_PIN8, 0) | \ | ||
| 453 | PIN_AFIO_AF(GPIOB_PIN9, 0) | \ | ||
| 454 | PIN_AFIO_AF(GPIOB_PIN10, 0) | \ | ||
| 455 | PIN_AFIO_AF(GPIOB_PIN11, 0) | \ | ||
| 456 | PIN_AFIO_AF(GPIOB_PIN12, 0) | \ | ||
| 457 | PIN_AFIO_AF(GPIOB_PIN13, 0) | \ | ||
| 458 | PIN_AFIO_AF(GPIOB_PIN14, 0) | \ | ||
| 459 | PIN_AFIO_AF(GPIOB_PIN15, 0)) | ||
| 460 | 281 | ||
| 461 | /* | 282 | /* |
| 462 | * GPIOC setup: | 283 | * GPIOC setup: |
| @@ -478,102 +299,13 @@ | |||
| 478 | * PC14 - PIN14 (input floating). | 299 | * PC14 - PIN14 (input floating). |
| 479 | * PC15 - PIN15 (input floating). | 300 | * PC15 - PIN15 (input floating). |
| 480 | */ | 301 | */ |
| 481 | #define VAL_GPIOC_MODER (PIN_MODE_INPUT(GPIOC_PIN0) | \ | 302 | #define VAL_GPIOC_MODER (PIN_MODE_INPUT(GPIOC_PIN0) | PIN_MODE_INPUT(GPIOC_PIN1) | PIN_MODE_INPUT(GPIOC_PIN2) | PIN_MODE_INPUT(GPIOC_PIN3) | PIN_MODE_INPUT(GPIOC_PIN4) | PIN_MODE_INPUT(GPIOC_PIN5) | PIN_MODE_INPUT(GPIOC_PIN6) | PIN_MODE_INPUT(GPIOC_PIN7) | PIN_MODE_INPUT(GPIOC_PIN8) | PIN_MODE_INPUT(GPIOC_PIN9) | PIN_MODE_INPUT(GPIOC_PIN10) | PIN_MODE_INPUT(GPIOC_PIN11) | PIN_MODE_INPUT(GPIOC_PIN12) | PIN_MODE_INPUT(GPIOC_PIN13) | PIN_MODE_INPUT(GPIOC_PIN14) | PIN_MODE_INPUT(GPIOC_PIN15)) |
| 482 | PIN_MODE_INPUT(GPIOC_PIN1) | \ | 303 | #define VAL_GPIOC_OTYPER (PIN_OTYPE_PUSHPULL(GPIOC_PIN0) | PIN_OTYPE_PUSHPULL(GPIOC_PIN1) | PIN_OTYPE_PUSHPULL(GPIOC_PIN2) | PIN_OTYPE_PUSHPULL(GPIOC_PIN3) | PIN_OTYPE_PUSHPULL(GPIOC_PIN4) | PIN_OTYPE_PUSHPULL(GPIOC_PIN5) | PIN_OTYPE_PUSHPULL(GPIOC_PIN6) | PIN_OTYPE_PUSHPULL(GPIOC_PIN7) | PIN_OTYPE_PUSHPULL(GPIOC_PIN8) | PIN_OTYPE_PUSHPULL(GPIOC_PIN9) | PIN_OTYPE_PUSHPULL(GPIOC_PIN10) | PIN_OTYPE_PUSHPULL(GPIOC_PIN11) | PIN_OTYPE_PUSHPULL(GPIOC_PIN12) | PIN_OTYPE_PUSHPULL(GPIOC_PIN13) | PIN_OTYPE_PUSHPULL(GPIOC_PIN14) | PIN_OTYPE_PUSHPULL(GPIOC_PIN15)) |
| 483 | PIN_MODE_INPUT(GPIOC_PIN2) | \ | 304 | #define VAL_GPIOC_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOC_PIN0) | PIN_OSPEED_VERYLOW(GPIOC_PIN1) | PIN_OSPEED_VERYLOW(GPIOC_PIN2) | PIN_OSPEED_VERYLOW(GPIOC_PIN3) | PIN_OSPEED_VERYLOW(GPIOC_PIN4) | PIN_OSPEED_VERYLOW(GPIOC_PIN5) | PIN_OSPEED_VERYLOW(GPIOC_PIN6) | PIN_OSPEED_VERYLOW(GPIOC_PIN7) | PIN_OSPEED_VERYLOW(GPIOC_PIN8) | PIN_OSPEED_VERYLOW(GPIOC_PIN9) | PIN_OSPEED_VERYLOW(GPIOC_PIN10) | PIN_OSPEED_VERYLOW(GPIOC_PIN11) | PIN_OSPEED_VERYLOW(GPIOC_PIN12) | PIN_OSPEED_VERYLOW(GPIOC_PIN13) | PIN_OSPEED_HIGH(GPIOC_PIN14) | PIN_OSPEED_HIGH(GPIOC_PIN15)) |
| 484 | PIN_MODE_INPUT(GPIOC_PIN3) | \ | 305 | #define VAL_GPIOC_PUPDR (PIN_PUPDR_PULLUP(GPIOC_PIN0) | PIN_PUPDR_PULLUP(GPIOC_PIN1) | PIN_PUPDR_PULLUP(GPIOC_PIN2) | PIN_PUPDR_PULLUP(GPIOC_PIN3) | PIN_PUPDR_PULLUP(GPIOC_PIN4) | PIN_PUPDR_PULLUP(GPIOC_PIN5) | PIN_PUPDR_PULLUP(GPIOC_PIN6) | PIN_PUPDR_PULLUP(GPIOC_PIN7) | PIN_PUPDR_PULLUP(GPIOC_PIN8) | PIN_PUPDR_PULLUP(GPIOC_PIN9) | PIN_PUPDR_PULLUP(GPIOC_PIN10) | PIN_PUPDR_PULLUP(GPIOC_PIN11) | PIN_PUPDR_PULLUP(GPIOC_PIN12) | PIN_PUPDR_PULLUP(GPIOC_PIN13) | PIN_PUPDR_FLOATING(GPIOC_PIN14) | PIN_PUPDR_FLOATING(GPIOC_PIN15)) |
| 485 | PIN_MODE_INPUT(GPIOC_PIN4) | \ | 306 | #define VAL_GPIOC_ODR (PIN_ODR_HIGH(GPIOC_PIN0) | PIN_ODR_HIGH(GPIOC_PIN1) | PIN_ODR_HIGH(GPIOC_PIN2) | PIN_ODR_HIGH(GPIOC_PIN3) | PIN_ODR_HIGH(GPIOC_PIN4) | PIN_ODR_HIGH(GPIOC_PIN5) | PIN_ODR_HIGH(GPIOC_PIN6) | PIN_ODR_HIGH(GPIOC_PIN7) | PIN_ODR_HIGH(GPIOC_PIN8) | PIN_ODR_HIGH(GPIOC_PIN9) | PIN_ODR_HIGH(GPIOC_PIN10) | PIN_ODR_HIGH(GPIOC_PIN11) | PIN_ODR_HIGH(GPIOC_PIN12) | PIN_ODR_HIGH(GPIOC_PIN13) | PIN_ODR_HIGH(GPIOC_PIN14) | PIN_ODR_HIGH(GPIOC_PIN15)) |
| 486 | PIN_MODE_INPUT(GPIOC_PIN5) | \ | 307 | #define VAL_GPIOC_AFRL (PIN_AFIO_AF(GPIOC_PIN0, 0) | PIN_AFIO_AF(GPIOC_PIN1, 0) | PIN_AFIO_AF(GPIOC_PIN2, 0) | PIN_AFIO_AF(GPIOC_PIN3, 0) | PIN_AFIO_AF(GPIOC_PIN4, 0) | PIN_AFIO_AF(GPIOC_PIN5, 0) | PIN_AFIO_AF(GPIOC_PIN6, 0) | PIN_AFIO_AF(GPIOC_PIN7, 0)) |
| 487 | PIN_MODE_INPUT(GPIOC_PIN6) | \ | 308 | #define VAL_GPIOC_AFRH (PIN_AFIO_AF(GPIOC_PIN8, 0) | PIN_AFIO_AF(GPIOC_PIN9, 0) | PIN_AFIO_AF(GPIOC_PIN10, 0) | PIN_AFIO_AF(GPIOC_PIN11, 0) | PIN_AFIO_AF(GPIOC_PIN12, 0) | PIN_AFIO_AF(GPIOC_PIN13, 0) | PIN_AFIO_AF(GPIOC_PIN14, 0) | PIN_AFIO_AF(GPIOC_PIN15, 0)) |
| 488 | PIN_MODE_INPUT(GPIOC_PIN7) | \ | ||
| 489 | PIN_MODE_INPUT(GPIOC_PIN8) | \ | ||
| 490 | PIN_MODE_INPUT(GPIOC_PIN9) | \ | ||
| 491 | PIN_MODE_INPUT(GPIOC_PIN10) | \ | ||
| 492 | PIN_MODE_INPUT(GPIOC_PIN11) | \ | ||
| 493 | PIN_MODE_INPUT(GPIOC_PIN12) | \ | ||
| 494 | PIN_MODE_INPUT(GPIOC_PIN13) | \ | ||
| 495 | PIN_MODE_INPUT(GPIOC_PIN14) | \ | ||
| 496 | PIN_MODE_INPUT(GPIOC_PIN15)) | ||
| 497 | #define VAL_GPIOC_OTYPER (PIN_OTYPE_PUSHPULL(GPIOC_PIN0) | \ | ||
| 498 | PIN_OTYPE_PUSHPULL(GPIOC_PIN1) | \ | ||
| 499 | PIN_OTYPE_PUSHPULL(GPIOC_PIN2) | \ | ||
| 500 | PIN_OTYPE_PUSHPULL(GPIOC_PIN3) | \ | ||
| 501 | PIN_OTYPE_PUSHPULL(GPIOC_PIN4) | \ | ||
| 502 | PIN_OTYPE_PUSHPULL(GPIOC_PIN5) | \ | ||
| 503 | PIN_OTYPE_PUSHPULL(GPIOC_PIN6) | \ | ||
| 504 | PIN_OTYPE_PUSHPULL(GPIOC_PIN7) | \ | ||
| 505 | PIN_OTYPE_PUSHPULL(GPIOC_PIN8) | \ | ||
| 506 | PIN_OTYPE_PUSHPULL(GPIOC_PIN9) | \ | ||
| 507 | PIN_OTYPE_PUSHPULL(GPIOC_PIN10) | \ | ||
| 508 | PIN_OTYPE_PUSHPULL(GPIOC_PIN11) | \ | ||
| 509 | PIN_OTYPE_PUSHPULL(GPIOC_PIN12) | \ | ||
| 510 | PIN_OTYPE_PUSHPULL(GPIOC_PIN13) | \ | ||
| 511 | PIN_OTYPE_PUSHPULL(GPIOC_PIN14) | \ | ||
| 512 | PIN_OTYPE_PUSHPULL(GPIOC_PIN15)) | ||
| 513 | #define VAL_GPIOC_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOC_PIN0) | \ | ||
| 514 | PIN_OSPEED_VERYLOW(GPIOC_PIN1) | \ | ||
| 515 | PIN_OSPEED_VERYLOW(GPIOC_PIN2) | \ | ||
| 516 | PIN_OSPEED_VERYLOW(GPIOC_PIN3) | \ | ||
| 517 | PIN_OSPEED_VERYLOW(GPIOC_PIN4) | \ | ||
| 518 | PIN_OSPEED_VERYLOW(GPIOC_PIN5) | \ | ||
| 519 | PIN_OSPEED_VERYLOW(GPIOC_PIN6) | \ | ||
| 520 | PIN_OSPEED_VERYLOW(GPIOC_PIN7) | \ | ||
| 521 | PIN_OSPEED_VERYLOW(GPIOC_PIN8) | \ | ||
| 522 | PIN_OSPEED_VERYLOW(GPIOC_PIN9) | \ | ||
| 523 | PIN_OSPEED_VERYLOW(GPIOC_PIN10) | \ | ||
| 524 | PIN_OSPEED_VERYLOW(GPIOC_PIN11) | \ | ||
| 525 | PIN_OSPEED_VERYLOW(GPIOC_PIN12) | \ | ||
| 526 | PIN_OSPEED_VERYLOW(GPIOC_PIN13) | \ | ||
| 527 | PIN_OSPEED_HIGH(GPIOC_PIN14) | \ | ||
| 528 | PIN_OSPEED_HIGH(GPIOC_PIN15)) | ||
| 529 | #define VAL_GPIOC_PUPDR (PIN_PUPDR_PULLUP(GPIOC_PIN0) | \ | ||
| 530 | PIN_PUPDR_PULLUP(GPIOC_PIN1) | \ | ||
| 531 | PIN_PUPDR_PULLUP(GPIOC_PIN2) | \ | ||
| 532 | PIN_PUPDR_PULLUP(GPIOC_PIN3) | \ | ||
| 533 | PIN_PUPDR_PULLUP(GPIOC_PIN4) | \ | ||
| 534 | PIN_PUPDR_PULLUP(GPIOC_PIN5) | \ | ||
| 535 | PIN_PUPDR_PULLUP(GPIOC_PIN6) | \ | ||
| 536 | PIN_PUPDR_PULLUP(GPIOC_PIN7) | \ | ||
| 537 | PIN_PUPDR_PULLUP(GPIOC_PIN8) | \ | ||
| 538 | PIN_PUPDR_PULLUP(GPIOC_PIN9) | \ | ||
| 539 | PIN_PUPDR_PULLUP(GPIOC_PIN10) | \ | ||
| 540 | PIN_PUPDR_PULLUP(GPIOC_PIN11) | \ | ||
| 541 | PIN_PUPDR_PULLUP(GPIOC_PIN12) | \ | ||
| 542 | PIN_PUPDR_PULLUP(GPIOC_PIN13) | \ | ||
| 543 | PIN_PUPDR_FLOATING(GPIOC_PIN14) | \ | ||
| 544 | PIN_PUPDR_FLOATING(GPIOC_PIN15)) | ||
| 545 | #define VAL_GPIOC_ODR (PIN_ODR_HIGH(GPIOC_PIN0) | \ | ||
| 546 | PIN_ODR_HIGH(GPIOC_PIN1) | \ | ||
| 547 | PIN_ODR_HIGH(GPIOC_PIN2) | \ | ||
| 548 | PIN_ODR_HIGH(GPIOC_PIN3) | \ | ||
| 549 | PIN_ODR_HIGH(GPIOC_PIN4) | \ | ||
| 550 | PIN_ODR_HIGH(GPIOC_PIN5) | \ | ||
| 551 | PIN_ODR_HIGH(GPIOC_PIN6) | \ | ||
| 552 | PIN_ODR_HIGH(GPIOC_PIN7) | \ | ||
| 553 | PIN_ODR_HIGH(GPIOC_PIN8) | \ | ||
| 554 | PIN_ODR_HIGH(GPIOC_PIN9) | \ | ||
| 555 | PIN_ODR_HIGH(GPIOC_PIN10) | \ | ||
| 556 | PIN_ODR_HIGH(GPIOC_PIN11) | \ | ||
| 557 | PIN_ODR_HIGH(GPIOC_PIN12) | \ | ||
| 558 | PIN_ODR_HIGH(GPIOC_PIN13) | \ | ||
| 559 | PIN_ODR_HIGH(GPIOC_PIN14) | \ | ||
| 560 | PIN_ODR_HIGH(GPIOC_PIN15)) | ||
| 561 | #define VAL_GPIOC_AFRL (PIN_AFIO_AF(GPIOC_PIN0, 0) | \ | ||
| 562 | PIN_AFIO_AF(GPIOC_PIN1, 0) | \ | ||
| 563 | PIN_AFIO_AF(GPIOC_PIN2, 0) | \ | ||
| 564 | PIN_AFIO_AF(GPIOC_PIN3, 0) | \ | ||
| 565 | PIN_AFIO_AF(GPIOC_PIN4, 0) | \ | ||
| 566 | PIN_AFIO_AF(GPIOC_PIN5, 0) | \ | ||
| 567 | PIN_AFIO_AF(GPIOC_PIN6, 0) | \ | ||
| 568 | PIN_AFIO_AF(GPIOC_PIN7, 0)) | ||
| 569 | #define VAL_GPIOC_AFRH (PIN_AFIO_AF(GPIOC_PIN8, 0) | \ | ||
| 570 | PIN_AFIO_AF(GPIOC_PIN9, 0) | \ | ||
| 571 | PIN_AFIO_AF(GPIOC_PIN10, 0) | \ | ||
| 572 | PIN_AFIO_AF(GPIOC_PIN11, 0) | \ | ||
| 573 | PIN_AFIO_AF(GPIOC_PIN12, 0) | \ | ||
| 574 | PIN_AFIO_AF(GPIOC_PIN13, 0) | \ | ||
| 575 | PIN_AFIO_AF(GPIOC_PIN14, 0) | \ | ||
| 576 | PIN_AFIO_AF(GPIOC_PIN15, 0)) | ||
| 577 | 309 | ||
| 578 | /* | 310 | /* |
| 579 | * GPIOD setup: | 311 | * GPIOD setup: |
| @@ -595,102 +327,13 @@ | |||
| 595 | * PD14 - PIN14 (input pullup). | 327 | * PD14 - PIN14 (input pullup). |
| 596 | * PD15 - PIN15 (input pullup). | 328 | * PD15 - PIN15 (input pullup). |
| 597 | */ | 329 | */ |
| 598 | #define VAL_GPIOD_MODER (PIN_MODE_INPUT(GPIOD_PIN0) | \ | 330 | #define VAL_GPIOD_MODER (PIN_MODE_INPUT(GPIOD_PIN0) | PIN_MODE_INPUT(GPIOD_PIN1) | PIN_MODE_INPUT(GPIOD_PIN2) | PIN_MODE_INPUT(GPIOD_PIN3) | PIN_MODE_INPUT(GPIOD_PIN4) | PIN_MODE_INPUT(GPIOD_PIN5) | PIN_MODE_INPUT(GPIOD_PIN6) | PIN_MODE_INPUT(GPIOD_PIN7) | PIN_MODE_INPUT(GPIOD_PIN8) | PIN_MODE_INPUT(GPIOD_PIN9) | PIN_MODE_INPUT(GPIOD_PIN10) | PIN_MODE_INPUT(GPIOD_PIN11) | PIN_MODE_INPUT(GPIOD_PIN12) | PIN_MODE_INPUT(GPIOD_PIN13) | PIN_MODE_INPUT(GPIOD_PIN14) | PIN_MODE_INPUT(GPIOD_PIN15)) |
| 599 | PIN_MODE_INPUT(GPIOD_PIN1) | \ | 331 | #define VAL_GPIOD_OTYPER (PIN_OTYPE_PUSHPULL(GPIOD_PIN0) | PIN_OTYPE_PUSHPULL(GPIOD_PIN1) | PIN_OTYPE_PUSHPULL(GPIOD_PIN2) | PIN_OTYPE_PUSHPULL(GPIOD_PIN3) | PIN_OTYPE_PUSHPULL(GPIOD_PIN4) | PIN_OTYPE_PUSHPULL(GPIOD_PIN5) | PIN_OTYPE_PUSHPULL(GPIOD_PIN6) | PIN_OTYPE_PUSHPULL(GPIOD_PIN7) | PIN_OTYPE_PUSHPULL(GPIOD_PIN8) | PIN_OTYPE_PUSHPULL(GPIOD_PIN9) | PIN_OTYPE_PUSHPULL(GPIOD_PIN10) | PIN_OTYPE_PUSHPULL(GPIOD_PIN11) | PIN_OTYPE_PUSHPULL(GPIOD_PIN12) | PIN_OTYPE_PUSHPULL(GPIOD_PIN13) | PIN_OTYPE_PUSHPULL(GPIOD_PIN14) | PIN_OTYPE_PUSHPULL(GPIOD_PIN15)) |
| 600 | PIN_MODE_INPUT(GPIOD_PIN2) | \ | 332 | #define VAL_GPIOD_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOD_PIN0) | PIN_OSPEED_VERYLOW(GPIOD_PIN1) | PIN_OSPEED_VERYLOW(GPIOD_PIN2) | PIN_OSPEED_VERYLOW(GPIOD_PIN3) | PIN_OSPEED_VERYLOW(GPIOD_PIN4) | PIN_OSPEED_VERYLOW(GPIOD_PIN5) | PIN_OSPEED_VERYLOW(GPIOD_PIN6) | PIN_OSPEED_VERYLOW(GPIOD_PIN7) | PIN_OSPEED_VERYLOW(GPIOD_PIN8) | PIN_OSPEED_VERYLOW(GPIOD_PIN9) | PIN_OSPEED_VERYLOW(GPIOD_PIN10) | PIN_OSPEED_VERYLOW(GPIOD_PIN11) | PIN_OSPEED_VERYLOW(GPIOD_PIN12) | PIN_OSPEED_VERYLOW(GPIOD_PIN13) | PIN_OSPEED_VERYLOW(GPIOD_PIN14) | PIN_OSPEED_VERYLOW(GPIOD_PIN15)) |
| 601 | PIN_MODE_INPUT(GPIOD_PIN3) | \ | 333 | #define VAL_GPIOD_PUPDR (PIN_PUPDR_PULLUP(GPIOD_PIN0) | PIN_PUPDR_PULLUP(GPIOD_PIN1) | PIN_PUPDR_PULLUP(GPIOD_PIN2) | PIN_PUPDR_PULLUP(GPIOD_PIN3) | PIN_PUPDR_PULLUP(GPIOD_PIN4) | PIN_PUPDR_PULLUP(GPIOD_PIN5) | PIN_PUPDR_PULLUP(GPIOD_PIN6) | PIN_PUPDR_PULLUP(GPIOD_PIN7) | PIN_PUPDR_PULLUP(GPIOD_PIN8) | PIN_PUPDR_PULLUP(GPIOD_PIN9) | PIN_PUPDR_PULLUP(GPIOD_PIN10) | PIN_PUPDR_PULLUP(GPIOD_PIN11) | PIN_PUPDR_PULLUP(GPIOD_PIN12) | PIN_PUPDR_PULLUP(GPIOD_PIN13) | PIN_PUPDR_PULLUP(GPIOD_PIN14) | PIN_PUPDR_PULLUP(GPIOD_PIN15)) |
| 602 | PIN_MODE_INPUT(GPIOD_PIN4) | \ | 334 | #define VAL_GPIOD_ODR (PIN_ODR_HIGH(GPIOD_PIN0) | PIN_ODR_HIGH(GPIOD_PIN1) | PIN_ODR_HIGH(GPIOD_PIN2) | PIN_ODR_HIGH(GPIOD_PIN3) | PIN_ODR_HIGH(GPIOD_PIN4) | PIN_ODR_HIGH(GPIOD_PIN5) | PIN_ODR_HIGH(GPIOD_PIN6) | PIN_ODR_HIGH(GPIOD_PIN7) | PIN_ODR_HIGH(GPIOD_PIN8) | PIN_ODR_HIGH(GPIOD_PIN9) | PIN_ODR_HIGH(GPIOD_PIN10) | PIN_ODR_HIGH(GPIOD_PIN11) | PIN_ODR_HIGH(GPIOD_PIN12) | PIN_ODR_HIGH(GPIOD_PIN13) | PIN_ODR_HIGH(GPIOD_PIN14) | PIN_ODR_HIGH(GPIOD_PIN15)) |
| 603 | PIN_MODE_INPUT(GPIOD_PIN5) | \ | 335 | #define VAL_GPIOD_AFRL (PIN_AFIO_AF(GPIOD_PIN0, 0) | PIN_AFIO_AF(GPIOD_PIN1, 0) | PIN_AFIO_AF(GPIOD_PIN2, 0) | PIN_AFIO_AF(GPIOD_PIN3, 0) | PIN_AFIO_AF(GPIOD_PIN4, 0) | PIN_AFIO_AF(GPIOD_PIN5, 0) | PIN_AFIO_AF(GPIOD_PIN6, 0) | PIN_AFIO_AF(GPIOD_PIN7, 0)) |
| 604 | PIN_MODE_INPUT(GPIOD_PIN6) | \ | 336 | #define VAL_GPIOD_AFRH (PIN_AFIO_AF(GPIOD_PIN8, 0) | PIN_AFIO_AF(GPIOD_PIN9, 0) | PIN_AFIO_AF(GPIOD_PIN10, 0) | PIN_AFIO_AF(GPIOD_PIN11, 0) | PIN_AFIO_AF(GPIOD_PIN12, 0) | PIN_AFIO_AF(GPIOD_PIN13, 0) | PIN_AFIO_AF(GPIOD_PIN14, 0) | PIN_AFIO_AF(GPIOD_PIN15, 0)) |
| 605 | PIN_MODE_INPUT(GPIOD_PIN7) | \ | ||
| 606 | PIN_MODE_INPUT(GPIOD_PIN8) | \ | ||
| 607 | PIN_MODE_INPUT(GPIOD_PIN9) | \ | ||
| 608 | PIN_MODE_INPUT(GPIOD_PIN10) | \ | ||
| 609 | PIN_MODE_INPUT(GPIOD_PIN11) | \ | ||
| 610 | PIN_MODE_INPUT(GPIOD_PIN12) | \ | ||
| 611 | PIN_MODE_INPUT(GPIOD_PIN13) | \ | ||
| 612 | PIN_MODE_INPUT(GPIOD_PIN14) | \ | ||
| 613 | PIN_MODE_INPUT(GPIOD_PIN15)) | ||
| 614 | #define VAL_GPIOD_OTYPER (PIN_OTYPE_PUSHPULL(GPIOD_PIN0) | \ | ||
| 615 | PIN_OTYPE_PUSHPULL(GPIOD_PIN1) | \ | ||
| 616 | PIN_OTYPE_PUSHPULL(GPIOD_PIN2) | \ | ||
| 617 | PIN_OTYPE_PUSHPULL(GPIOD_PIN3) | \ | ||
| 618 | PIN_OTYPE_PUSHPULL(GPIOD_PIN4) | \ | ||
| 619 | PIN_OTYPE_PUSHPULL(GPIOD_PIN5) | \ | ||
| 620 | PIN_OTYPE_PUSHPULL(GPIOD_PIN6) | \ | ||
| 621 | PIN_OTYPE_PUSHPULL(GPIOD_PIN7) | \ | ||
| 622 | PIN_OTYPE_PUSHPULL(GPIOD_PIN8) | \ | ||
| 623 | PIN_OTYPE_PUSHPULL(GPIOD_PIN9) | \ | ||
| 624 | PIN_OTYPE_PUSHPULL(GPIOD_PIN10) | \ | ||
| 625 | PIN_OTYPE_PUSHPULL(GPIOD_PIN11) | \ | ||
| 626 | PIN_OTYPE_PUSHPULL(GPIOD_PIN12) | \ | ||
| 627 | PIN_OTYPE_PUSHPULL(GPIOD_PIN13) | \ | ||
| 628 | PIN_OTYPE_PUSHPULL(GPIOD_PIN14) | \ | ||
| 629 | PIN_OTYPE_PUSHPULL(GPIOD_PIN15)) | ||
| 630 | #define VAL_GPIOD_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOD_PIN0) | \ | ||
| 631 | PIN_OSPEED_VERYLOW(GPIOD_PIN1) | \ | ||
| 632 | PIN_OSPEED_VERYLOW(GPIOD_PIN2) | \ | ||
| 633 | PIN_OSPEED_VERYLOW(GPIOD_PIN3) | \ | ||
| 634 | PIN_OSPEED_VERYLOW(GPIOD_PIN4) | \ | ||
| 635 | PIN_OSPEED_VERYLOW(GPIOD_PIN5) | \ | ||
| 636 | PIN_OSPEED_VERYLOW(GPIOD_PIN6) | \ | ||
| 637 | PIN_OSPEED_VERYLOW(GPIOD_PIN7) | \ | ||
| 638 | PIN_OSPEED_VERYLOW(GPIOD_PIN8) | \ | ||
| 639 | PIN_OSPEED_VERYLOW(GPIOD_PIN9) | \ | ||
| 640 | PIN_OSPEED_VERYLOW(GPIOD_PIN10) | \ | ||
| 641 | PIN_OSPEED_VERYLOW(GPIOD_PIN11) | \ | ||
| 642 | PIN_OSPEED_VERYLOW(GPIOD_PIN12) | \ | ||
| 643 | PIN_OSPEED_VERYLOW(GPIOD_PIN13) | \ | ||
| 644 | PIN_OSPEED_VERYLOW(GPIOD_PIN14) | \ | ||
| 645 | PIN_OSPEED_VERYLOW(GPIOD_PIN15)) | ||
| 646 | #define VAL_GPIOD_PUPDR (PIN_PUPDR_PULLUP(GPIOD_PIN0) | \ | ||
| 647 | PIN_PUPDR_PULLUP(GPIOD_PIN1) | \ | ||
| 648 | PIN_PUPDR_PULLUP(GPIOD_PIN2) | \ | ||
| 649 | PIN_PUPDR_PULLUP(GPIOD_PIN3) | \ | ||
| 650 | PIN_PUPDR_PULLUP(GPIOD_PIN4) | \ | ||
| 651 | PIN_PUPDR_PULLUP(GPIOD_PIN5) | \ | ||
| 652 | PIN_PUPDR_PULLUP(GPIOD_PIN6) | \ | ||
| 653 | PIN_PUPDR_PULLUP(GPIOD_PIN7) | \ | ||
| 654 | PIN_PUPDR_PULLUP(GPIOD_PIN8) | \ | ||
| 655 | PIN_PUPDR_PULLUP(GPIOD_PIN9) | \ | ||
| 656 | PIN_PUPDR_PULLUP(GPIOD_PIN10) | \ | ||
| 657 | PIN_PUPDR_PULLUP(GPIOD_PIN11) | \ | ||
| 658 | PIN_PUPDR_PULLUP(GPIOD_PIN12) | \ | ||
| 659 | PIN_PUPDR_PULLUP(GPIOD_PIN13) | \ | ||
| 660 | PIN_PUPDR_PULLUP(GPIOD_PIN14) | \ | ||
| 661 | PIN_PUPDR_PULLUP(GPIOD_PIN15)) | ||
| 662 | #define VAL_GPIOD_ODR (PIN_ODR_HIGH(GPIOD_PIN0) | \ | ||
| 663 | PIN_ODR_HIGH(GPIOD_PIN1) | \ | ||
| 664 | PIN_ODR_HIGH(GPIOD_PIN2) | \ | ||
| 665 | PIN_ODR_HIGH(GPIOD_PIN3) | \ | ||
| 666 | PIN_ODR_HIGH(GPIOD_PIN4) | \ | ||
| 667 | PIN_ODR_HIGH(GPIOD_PIN5) | \ | ||
| 668 | PIN_ODR_HIGH(GPIOD_PIN6) | \ | ||
| 669 | PIN_ODR_HIGH(GPIOD_PIN7) | \ | ||
| 670 | PIN_ODR_HIGH(GPIOD_PIN8) | \ | ||
| 671 | PIN_ODR_HIGH(GPIOD_PIN9) | \ | ||
| 672 | PIN_ODR_HIGH(GPIOD_PIN10) | \ | ||
| 673 | PIN_ODR_HIGH(GPIOD_PIN11) | \ | ||
| 674 | PIN_ODR_HIGH(GPIOD_PIN12) | \ | ||
| 675 | PIN_ODR_HIGH(GPIOD_PIN13) | \ | ||
| 676 | PIN_ODR_HIGH(GPIOD_PIN14) | \ | ||
| 677 | PIN_ODR_HIGH(GPIOD_PIN15)) | ||
| 678 | #define VAL_GPIOD_AFRL (PIN_AFIO_AF(GPIOD_PIN0, 0) | \ | ||
| 679 | PIN_AFIO_AF(GPIOD_PIN1, 0) | \ | ||
| 680 | PIN_AFIO_AF(GPIOD_PIN2, 0) | \ | ||
| 681 | PIN_AFIO_AF(GPIOD_PIN3, 0) | \ | ||
| 682 | PIN_AFIO_AF(GPIOD_PIN4, 0) | \ | ||
| 683 | PIN_AFIO_AF(GPIOD_PIN5, 0) | \ | ||
| 684 | PIN_AFIO_AF(GPIOD_PIN6, 0) | \ | ||
| 685 | PIN_AFIO_AF(GPIOD_PIN7, 0)) | ||
| 686 | #define VAL_GPIOD_AFRH (PIN_AFIO_AF(GPIOD_PIN8, 0) | \ | ||
| 687 | PIN_AFIO_AF(GPIOD_PIN9, 0) | \ | ||
| 688 | PIN_AFIO_AF(GPIOD_PIN10, 0) | \ | ||
| 689 | PIN_AFIO_AF(GPIOD_PIN11, 0) | \ | ||
| 690 | PIN_AFIO_AF(GPIOD_PIN12, 0) | \ | ||
| 691 | PIN_AFIO_AF(GPIOD_PIN13, 0) | \ | ||
| 692 | PIN_AFIO_AF(GPIOD_PIN14, 0) | \ | ||
| 693 | PIN_AFIO_AF(GPIOD_PIN15, 0)) | ||
| 694 | 337 | ||
| 695 | /* | 338 | /* |
| 696 | * GPIOE setup: | 339 | * GPIOE setup: |
| @@ -712,102 +355,13 @@ | |||
| 712 | * PE14 - PIN14 (output pushpull maximum). | 355 | * PE14 - PIN14 (output pushpull maximum). |
| 713 | * PE15 - PIN15 (output pushpull maximum). | 356 | * PE15 - PIN15 (output pushpull maximum). |
| 714 | */ | 357 | */ |
| 715 | #define VAL_GPIOE_MODER (PIN_MODE_INPUT(GPIOE_PIN0) | \ | 358 | #define VAL_GPIOE_MODER (PIN_MODE_INPUT(GPIOE_PIN0) | PIN_MODE_INPUT(GPIOE_PIN1) | PIN_MODE_INPUT(GPIOE_PIN2) | PIN_MODE_OUTPUT(GPIOE_PIN3) | PIN_MODE_INPUT(GPIOE_PIN4) | PIN_MODE_INPUT(GPIOE_PIN5) | PIN_MODE_INPUT(GPIOE_PIN6) | PIN_MODE_INPUT(GPIOE_PIN7) | PIN_MODE_OUTPUT(GPIOE_PIN8) | PIN_MODE_OUTPUT(GPIOE_PIN9) | PIN_MODE_OUTPUT(GPIOE_PIN10) | PIN_MODE_OUTPUT(GPIOE_PIN11) | PIN_MODE_OUTPUT(GPIOE_PIN12) | PIN_MODE_OUTPUT(GPIOE_PIN13) | PIN_MODE_OUTPUT(GPIOE_PIN14) | PIN_MODE_OUTPUT(GPIOE_PIN15)) |
| 716 | PIN_MODE_INPUT(GPIOE_PIN1) | \ | 359 | #define VAL_GPIOE_OTYPER (PIN_OTYPE_PUSHPULL(GPIOE_PIN0) | PIN_OTYPE_PUSHPULL(GPIOE_PIN1) | PIN_OTYPE_PUSHPULL(GPIOE_PIN2) | PIN_OTYPE_PUSHPULL(GPIOE_PIN3) | PIN_OTYPE_PUSHPULL(GPIOE_PIN4) | PIN_OTYPE_PUSHPULL(GPIOE_PIN5) | PIN_OTYPE_PUSHPULL(GPIOE_PIN6) | PIN_OTYPE_PUSHPULL(GPIOE_PIN7) | PIN_OTYPE_PUSHPULL(GPIOE_PIN8) | PIN_OTYPE_PUSHPULL(GPIOE_PIN9) | PIN_OTYPE_PUSHPULL(GPIOE_PIN10) | PIN_OTYPE_PUSHPULL(GPIOE_PIN11) | PIN_OTYPE_PUSHPULL(GPIOE_PIN12) | PIN_OTYPE_PUSHPULL(GPIOE_PIN13) | PIN_OTYPE_PUSHPULL(GPIOE_PIN14) | PIN_OTYPE_PUSHPULL(GPIOE_PIN15)) |
| 717 | PIN_MODE_INPUT(GPIOE_PIN2) |\ | 360 | #define VAL_GPIOE_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOE_PIN0) | PIN_OSPEED_VERYLOW(GPIOE_PIN1) | PIN_OSPEED_VERYLOW(GPIOE_PIN2) | PIN_OSPEED_HIGH(GPIOE_PIN3) | PIN_OSPEED_VERYLOW(GPIOE_PIN4) | PIN_OSPEED_VERYLOW(GPIOE_PIN5) | PIN_OSPEED_VERYLOW(GPIOE_PIN6) | PIN_OSPEED_VERYLOW(GPIOE_PIN7) | PIN_OSPEED_HIGH(GPIOE_PIN8) | PIN_OSPEED_HIGH(GPIOE_PIN9) | PIN_OSPEED_HIGH(GPIOE_PIN10) | PIN_OSPEED_HIGH(GPIOE_PIN11) | PIN_OSPEED_HIGH(GPIOE_PIN12) | PIN_OSPEED_HIGH(GPIOE_PIN13) | PIN_OSPEED_HIGH(GPIOE_PIN14) | PIN_OSPEED_HIGH(GPIOE_PIN15)) |
| 718 | PIN_MODE_OUTPUT(GPIOE_PIN3) | \ | 361 | #define VAL_GPIOE_PUPDR (PIN_PUPDR_PULLUP(GPIOE_PIN0) | PIN_PUPDR_PULLUP(GPIOE_PIN1) | PIN_PUPDR_PULLUP(GPIOE_PIN2) | PIN_PUPDR_FLOATING(GPIOE_PIN3) | PIN_PUPDR_PULLUP(GPIOE_PIN4) | PIN_PUPDR_PULLUP(GPIOE_PIN5) | PIN_PUPDR_PULLUP(GPIOE_PIN6) | PIN_PUPDR_PULLUP(GPIOE_PIN7) | PIN_PUPDR_PULLUP(GPIOE_PIN8) | PIN_PUPDR_PULLUP(GPIOE_PIN9) | PIN_PUPDR_PULLUP(GPIOE_PIN10) | PIN_PUPDR_FLOATING(GPIOE_PIN11) | PIN_PUPDR_PULLUP(GPIOE_PIN12) | PIN_PUPDR_FLOATING(GPIOE_PIN13) | PIN_PUPDR_FLOATING(GPIOE_PIN14) | PIN_PUPDR_FLOATING(GPIOE_PIN15)) |
| 719 | PIN_MODE_INPUT(GPIOE_PIN4) |\ | 362 | #define VAL_GPIOE_ODR (PIN_ODR_HIGH(GPIOE_PIN0) | PIN_ODR_HIGH(GPIOE_PIN1) | PIN_ODR_HIGH(GPIOE_PIN2) | PIN_ODR_HIGH(GPIOE_PIN3) | PIN_ODR_HIGH(GPIOE_PIN4) | PIN_ODR_HIGH(GPIOE_PIN5) | PIN_ODR_HIGH(GPIOE_PIN6) | PIN_ODR_HIGH(GPIOE_PIN7) | PIN_ODR_LOW(GPIOE_PIN8) | PIN_ODR_LOW(GPIOE_PIN9) | PIN_ODR_LOW(GPIOE_PIN10) | PIN_ODR_LOW(GPIOE_PIN11) | PIN_ODR_LOW(GPIOE_PIN12) | PIN_ODR_LOW(GPIOE_PIN13) | PIN_ODR_LOW(GPIOE_PIN14) | PIN_ODR_LOW(GPIOE_PIN15)) |
| 720 | PIN_MODE_INPUT(GPIOE_PIN5) |\ | 363 | #define VAL_GPIOE_AFRL (PIN_AFIO_AF(GPIOE_PIN0, 0) | PIN_AFIO_AF(GPIOE_PIN1, 0) | PIN_AFIO_AF(GPIOE_PIN2, 0) | PIN_AFIO_AF(GPIOE_PIN3, 0) | PIN_AFIO_AF(GPIOE_PIN4, 0) | PIN_AFIO_AF(GPIOE_PIN5, 0) | PIN_AFIO_AF(GPIOE_PIN6, 0) | PIN_AFIO_AF(GPIOE_PIN7, 0)) |
| 721 | PIN_MODE_INPUT(GPIOE_PIN6) | \ | 364 | #define VAL_GPIOE_AFRH (PIN_AFIO_AF(GPIOE_PIN8, 0) | PIN_AFIO_AF(GPIOE_PIN9, 0) | PIN_AFIO_AF(GPIOE_PIN10, 0) | PIN_AFIO_AF(GPIOE_PIN11, 0) | PIN_AFIO_AF(GPIOE_PIN12, 0) | PIN_AFIO_AF(GPIOE_PIN13, 0) | PIN_AFIO_AF(GPIOE_PIN14, 0) | PIN_AFIO_AF(GPIOE_PIN15, 0)) |
| 722 | PIN_MODE_INPUT(GPIOE_PIN7) | \ | ||
| 723 | PIN_MODE_OUTPUT(GPIOE_PIN8) | \ | ||
| 724 | PIN_MODE_OUTPUT(GPIOE_PIN9) | \ | ||
| 725 | PIN_MODE_OUTPUT(GPIOE_PIN10) | \ | ||
| 726 | PIN_MODE_OUTPUT(GPIOE_PIN11) | \ | ||
| 727 | PIN_MODE_OUTPUT(GPIOE_PIN12) | \ | ||
| 728 | PIN_MODE_OUTPUT(GPIOE_PIN13) | \ | ||
| 729 | PIN_MODE_OUTPUT(GPIOE_PIN14) | \ | ||
| 730 | PIN_MODE_OUTPUT(GPIOE_PIN15)) | ||
| 731 | #define VAL_GPIOE_OTYPER (PIN_OTYPE_PUSHPULL(GPIOE_PIN0) |\ | ||
| 732 | PIN_OTYPE_PUSHPULL(GPIOE_PIN1) |\ | ||
| 733 | PIN_OTYPE_PUSHPULL(GPIOE_PIN2) |\ | ||
| 734 | PIN_OTYPE_PUSHPULL(GPIOE_PIN3) | \ | ||
| 735 | PIN_OTYPE_PUSHPULL(GPIOE_PIN4) |\ | ||
| 736 | PIN_OTYPE_PUSHPULL(GPIOE_PIN5) |\ | ||
| 737 | PIN_OTYPE_PUSHPULL(GPIOE_PIN6) | \ | ||
| 738 | PIN_OTYPE_PUSHPULL(GPIOE_PIN7) | \ | ||
| 739 | PIN_OTYPE_PUSHPULL(GPIOE_PIN8) | \ | ||
| 740 | PIN_OTYPE_PUSHPULL(GPIOE_PIN9) | \ | ||
| 741 | PIN_OTYPE_PUSHPULL(GPIOE_PIN10) |\ | ||
| 742 | PIN_OTYPE_PUSHPULL(GPIOE_PIN11) | \ | ||
| 743 | PIN_OTYPE_PUSHPULL(GPIOE_PIN12) | \ | ||
| 744 | PIN_OTYPE_PUSHPULL(GPIOE_PIN13) | \ | ||
| 745 | PIN_OTYPE_PUSHPULL(GPIOE_PIN14) |\ | ||
| 746 | PIN_OTYPE_PUSHPULL(GPIOE_PIN15)) | ||
| 747 | #define VAL_GPIOE_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOE_PIN0) |\ | ||
| 748 | PIN_OSPEED_VERYLOW(GPIOE_PIN1) |\ | ||
| 749 | PIN_OSPEED_VERYLOW(GPIOE_PIN2) |\ | ||
| 750 | PIN_OSPEED_HIGH(GPIOE_PIN3) | \ | ||
| 751 | PIN_OSPEED_VERYLOW(GPIOE_PIN4) |\ | ||
| 752 | PIN_OSPEED_VERYLOW(GPIOE_PIN5) |\ | ||
| 753 | PIN_OSPEED_VERYLOW(GPIOE_PIN6) | \ | ||
| 754 | PIN_OSPEED_VERYLOW(GPIOE_PIN7) | \ | ||
| 755 | PIN_OSPEED_HIGH(GPIOE_PIN8) | \ | ||
| 756 | PIN_OSPEED_HIGH(GPIOE_PIN9) | \ | ||
| 757 | PIN_OSPEED_HIGH(GPIOE_PIN10) | \ | ||
| 758 | PIN_OSPEED_HIGH(GPIOE_PIN11) | \ | ||
| 759 | PIN_OSPEED_HIGH(GPIOE_PIN12) | \ | ||
| 760 | PIN_OSPEED_HIGH(GPIOE_PIN13) | \ | ||
| 761 | PIN_OSPEED_HIGH(GPIOE_PIN14) | \ | ||
| 762 | PIN_OSPEED_HIGH(GPIOE_PIN15)) | ||
| 763 | #define VAL_GPIOE_PUPDR (PIN_PUPDR_PULLUP(GPIOE_PIN0) | \ | ||
| 764 | PIN_PUPDR_PULLUP(GPIOE_PIN1) | \ | ||
| 765 | PIN_PUPDR_PULLUP(GPIOE_PIN2) |\ | ||
| 766 | PIN_PUPDR_FLOATING(GPIOE_PIN3) | \ | ||
| 767 | PIN_PUPDR_PULLUP(GPIOE_PIN4) |\ | ||
| 768 | PIN_PUPDR_PULLUP(GPIOE_PIN5) |\ | ||
| 769 | PIN_PUPDR_PULLUP(GPIOE_PIN6) | \ | ||
| 770 | PIN_PUPDR_PULLUP(GPIOE_PIN7) | \ | ||
| 771 | PIN_PUPDR_PULLUP(GPIOE_PIN8) | \ | ||
| 772 | PIN_PUPDR_PULLUP(GPIOE_PIN9) | \ | ||
| 773 | PIN_PUPDR_PULLUP(GPIOE_PIN10) | \ | ||
| 774 | PIN_PUPDR_FLOATING(GPIOE_PIN11) | \ | ||
| 775 | PIN_PUPDR_PULLUP(GPIOE_PIN12) | \ | ||
| 776 | PIN_PUPDR_FLOATING(GPIOE_PIN13) | \ | ||
| 777 | PIN_PUPDR_FLOATING(GPIOE_PIN14) |\ | ||
| 778 | PIN_PUPDR_FLOATING(GPIOE_PIN15)) | ||
| 779 | #define VAL_GPIOE_ODR (PIN_ODR_HIGH(GPIOE_PIN0) | \ | ||
| 780 | PIN_ODR_HIGH(GPIOE_PIN1) | \ | ||
| 781 | PIN_ODR_HIGH(GPIOE_PIN2) | \ | ||
| 782 | PIN_ODR_HIGH(GPIOE_PIN3) | \ | ||
| 783 | PIN_ODR_HIGH(GPIOE_PIN4) | \ | ||
| 784 | PIN_ODR_HIGH(GPIOE_PIN5) | \ | ||
| 785 | PIN_ODR_HIGH(GPIOE_PIN6) | \ | ||
| 786 | PIN_ODR_HIGH(GPIOE_PIN7) | \ | ||
| 787 | PIN_ODR_LOW(GPIOE_PIN8) | \ | ||
| 788 | PIN_ODR_LOW(GPIOE_PIN9) | \ | ||
| 789 | PIN_ODR_LOW(GPIOE_PIN10) | \ | ||
| 790 | PIN_ODR_LOW(GPIOE_PIN11) | \ | ||
| 791 | PIN_ODR_LOW(GPIOE_PIN12) | \ | ||
| 792 | PIN_ODR_LOW(GPIOE_PIN13) | \ | ||
| 793 | PIN_ODR_LOW(GPIOE_PIN14) | \ | ||
| 794 | PIN_ODR_LOW(GPIOE_PIN15)) | ||
| 795 | #define VAL_GPIOE_AFRL (PIN_AFIO_AF(GPIOE_PIN0, 0) | \ | ||
| 796 | PIN_AFIO_AF(GPIOE_PIN1, 0) | \ | ||
| 797 | PIN_AFIO_AF(GPIOE_PIN2, 0) |\ | ||
| 798 | PIN_AFIO_AF(GPIOE_PIN3, 0) | \ | ||
| 799 | PIN_AFIO_AF(GPIOE_PIN4, 0) |\ | ||
| 800 | PIN_AFIO_AF(GPIOE_PIN5, 0) |\ | ||
| 801 | PIN_AFIO_AF(GPIOE_PIN6, 0) | \ | ||
| 802 | PIN_AFIO_AF(GPIOE_PIN7, 0)) | ||
| 803 | #define VAL_GPIOE_AFRH (PIN_AFIO_AF(GPIOE_PIN8, 0) | \ | ||
| 804 | PIN_AFIO_AF(GPIOE_PIN9, 0) | \ | ||
| 805 | PIN_AFIO_AF(GPIOE_PIN10, 0) | \ | ||
| 806 | PIN_AFIO_AF(GPIOE_PIN11, 0) | \ | ||
| 807 | PIN_AFIO_AF(GPIOE_PIN12, 0) | \ | ||
| 808 | PIN_AFIO_AF(GPIOE_PIN13, 0) | \ | ||
| 809 | PIN_AFIO_AF(GPIOE_PIN14, 0) | \ | ||
| 810 | PIN_AFIO_AF(GPIOE_PIN15, 0)) | ||
| 811 | 365 | ||
| 812 | /* | 366 | /* |
| 813 | * GPIOF setup: | 367 | * GPIOF setup: |
| @@ -829,102 +383,13 @@ | |||
| 829 | * PF14 - PIN14 (input pullup). | 383 | * PF14 - PIN14 (input pullup). |
| 830 | * PF15 - PIN15 (input pullup). | 384 | * PF15 - PIN15 (input pullup). |
| 831 | */ | 385 | */ |
| 832 | #define VAL_GPIOF_MODER (PIN_MODE_INPUT(GPIOF_I2C2_SDA) | \ | 386 | #define VAL_GPIOF_MODER (PIN_MODE_INPUT(GPIOF_I2C2_SDA) | PIN_MODE_INPUT(GPIOF_I2C2_SCL) | PIN_MODE_INPUT(GPIOF_PIN2) | PIN_MODE_INPUT(GPIOF_PIN3) | PIN_MODE_INPUT(GPIOF_PIN4) | PIN_MODE_INPUT(GPIOF_PIN5) | PIN_MODE_INPUT(GPIOF_PIN6) | PIN_MODE_INPUT(GPIOF_PIN7) | PIN_MODE_INPUT(GPIOF_PIN8) | PIN_MODE_INPUT(GPIOF_PIN9) | PIN_MODE_INPUT(GPIOF_PIN10) | PIN_MODE_INPUT(GPIOF_PIN11) | PIN_MODE_INPUT(GPIOF_PIN12) | PIN_MODE_INPUT(GPIOF_PIN13) | PIN_MODE_INPUT(GPIOF_PIN14) | PIN_MODE_INPUT(GPIOF_PIN15)) |
| 833 | PIN_MODE_INPUT(GPIOF_I2C2_SCL) | \ | 387 | #define VAL_GPIOF_OTYPER (PIN_OTYPE_PUSHPULL(GPIOF_I2C2_SDA) | PIN_OTYPE_PUSHPULL(GPIOF_I2C2_SCL) | PIN_OTYPE_PUSHPULL(GPIOF_PIN2) | PIN_OTYPE_PUSHPULL(GPIOF_PIN3) | PIN_OTYPE_PUSHPULL(GPIOF_PIN4) | PIN_OTYPE_PUSHPULL(GPIOF_PIN5) | PIN_OTYPE_PUSHPULL(GPIOF_PIN6) | PIN_OTYPE_PUSHPULL(GPIOF_PIN7) | PIN_OTYPE_PUSHPULL(GPIOF_PIN8) | PIN_OTYPE_PUSHPULL(GPIOF_PIN9) | PIN_OTYPE_PUSHPULL(GPIOF_PIN10) | PIN_OTYPE_PUSHPULL(GPIOF_PIN11) | PIN_OTYPE_PUSHPULL(GPIOF_PIN12) | PIN_OTYPE_PUSHPULL(GPIOF_PIN13) | PIN_OTYPE_PUSHPULL(GPIOF_PIN14) | PIN_OTYPE_PUSHPULL(GPIOF_PIN15)) |
| 834 | PIN_MODE_INPUT(GPIOF_PIN2) | \ | 388 | #define VAL_GPIOF_OSPEEDR (PIN_OSPEED_HIGH(GPIOF_I2C2_SDA) | PIN_OSPEED_HIGH(GPIOF_I2C2_SCL) | PIN_OSPEED_VERYLOW(GPIOF_PIN2) | PIN_OSPEED_VERYLOW(GPIOF_PIN3) | PIN_OSPEED_VERYLOW(GPIOF_PIN4) | PIN_OSPEED_VERYLOW(GPIOF_PIN5) | PIN_OSPEED_VERYLOW(GPIOF_PIN6) | PIN_OSPEED_VERYLOW(GPIOF_PIN7) | PIN_OSPEED_VERYLOW(GPIOF_PIN8) | PIN_OSPEED_VERYLOW(GPIOF_PIN9) | PIN_OSPEED_VERYLOW(GPIOF_PIN10) | PIN_OSPEED_VERYLOW(GPIOF_PIN11) | PIN_OSPEED_VERYLOW(GPIOF_PIN12) | PIN_OSPEED_VERYLOW(GPIOF_PIN13) | PIN_OSPEED_VERYLOW(GPIOF_PIN14) | PIN_OSPEED_VERYLOW(GPIOF_PIN15)) |
| 835 | PIN_MODE_INPUT(GPIOF_PIN3) | \ | 389 | #define VAL_GPIOF_PUPDR (PIN_PUPDR_FLOATING(GPIOF_I2C2_SDA) | PIN_PUPDR_FLOATING(GPIOF_I2C2_SCL) | PIN_PUPDR_PULLUP(GPIOF_PIN2) | PIN_PUPDR_PULLUP(GPIOF_PIN3) | PIN_PUPDR_PULLUP(GPIOF_PIN4) | PIN_PUPDR_PULLUP(GPIOF_PIN5) | PIN_PUPDR_PULLUP(GPIOF_PIN6) | PIN_PUPDR_PULLUP(GPIOF_PIN7) | PIN_PUPDR_PULLUP(GPIOF_PIN8) | PIN_PUPDR_PULLUP(GPIOF_PIN9) | PIN_PUPDR_PULLUP(GPIOF_PIN10) | PIN_PUPDR_PULLUP(GPIOF_PIN11) | PIN_PUPDR_PULLUP(GPIOF_PIN12) | PIN_PUPDR_PULLUP(GPIOF_PIN13) | PIN_PUPDR_PULLUP(GPIOF_PIN14) | PIN_PUPDR_PULLUP(GPIOF_PIN15)) |
| 836 | PIN_MODE_INPUT(GPIOF_PIN4) | \ | 390 | #define VAL_GPIOF_ODR (PIN_ODR_HIGH(GPIOF_I2C2_SDA) | PIN_ODR_HIGH(GPIOF_I2C2_SCL) | PIN_ODR_HIGH(GPIOF_PIN2) | PIN_ODR_HIGH(GPIOF_PIN3) | PIN_ODR_HIGH(GPIOF_PIN4) | PIN_ODR_HIGH(GPIOF_PIN5) | PIN_ODR_HIGH(GPIOF_PIN6) | PIN_ODR_HIGH(GPIOF_PIN7) | PIN_ODR_HIGH(GPIOF_PIN8) | PIN_ODR_HIGH(GPIOF_PIN9) | PIN_ODR_HIGH(GPIOF_PIN10) | PIN_ODR_HIGH(GPIOF_PIN11) | PIN_ODR_HIGH(GPIOF_PIN12) | PIN_ODR_HIGH(GPIOF_PIN13) | PIN_ODR_HIGH(GPIOF_PIN14) | PIN_ODR_HIGH(GPIOF_PIN15)) |
| 837 | PIN_MODE_INPUT(GPIOF_PIN5) | \ | 391 | #define VAL_GPIOF_AFRL (PIN_AFIO_AF(GPIOF_I2C2_SDA, 0) | PIN_AFIO_AF(GPIOF_I2C2_SCL, 0) | PIN_AFIO_AF(GPIOF_PIN2, 0) | PIN_AFIO_AF(GPIOF_PIN3, 0) | PIN_AFIO_AF(GPIOF_PIN4, 0) | PIN_AFIO_AF(GPIOF_PIN5, 0) | PIN_AFIO_AF(GPIOF_PIN6, 0) | PIN_AFIO_AF(GPIOF_PIN7, 0)) |
| 838 | PIN_MODE_INPUT(GPIOF_PIN6) | \ | 392 | #define VAL_GPIOF_AFRH (PIN_AFIO_AF(GPIOF_PIN8, 0) | PIN_AFIO_AF(GPIOF_PIN9, 0) | PIN_AFIO_AF(GPIOF_PIN10, 0) | PIN_AFIO_AF(GPIOF_PIN11, 0) | PIN_AFIO_AF(GPIOF_PIN12, 0) | PIN_AFIO_AF(GPIOF_PIN13, 0) | PIN_AFIO_AF(GPIOF_PIN14, 0) | PIN_AFIO_AF(GPIOF_PIN15, 0)) |
| 839 | PIN_MODE_INPUT(GPIOF_PIN7) | \ | ||
| 840 | PIN_MODE_INPUT(GPIOF_PIN8) | \ | ||
| 841 | PIN_MODE_INPUT(GPIOF_PIN9) | \ | ||
| 842 | PIN_MODE_INPUT(GPIOF_PIN10) | \ | ||
| 843 | PIN_MODE_INPUT(GPIOF_PIN11) | \ | ||
| 844 | PIN_MODE_INPUT(GPIOF_PIN12) | \ | ||
| 845 | PIN_MODE_INPUT(GPIOF_PIN13) | \ | ||
| 846 | PIN_MODE_INPUT(GPIOF_PIN14) | \ | ||
| 847 | PIN_MODE_INPUT(GPIOF_PIN15)) | ||
| 848 | #define VAL_GPIOF_OTYPER (PIN_OTYPE_PUSHPULL(GPIOF_I2C2_SDA) | \ | ||
| 849 | PIN_OTYPE_PUSHPULL(GPIOF_I2C2_SCL) | \ | ||
| 850 | PIN_OTYPE_PUSHPULL(GPIOF_PIN2) | \ | ||
| 851 | PIN_OTYPE_PUSHPULL(GPIOF_PIN3) | \ | ||
| 852 | PIN_OTYPE_PUSHPULL(GPIOF_PIN4) | \ | ||
| 853 | PIN_OTYPE_PUSHPULL(GPIOF_PIN5) | \ | ||
| 854 | PIN_OTYPE_PUSHPULL(GPIOF_PIN6) | \ | ||
| 855 | PIN_OTYPE_PUSHPULL(GPIOF_PIN7) | \ | ||
| 856 | PIN_OTYPE_PUSHPULL(GPIOF_PIN8) | \ | ||
| 857 | PIN_OTYPE_PUSHPULL(GPIOF_PIN9) | \ | ||
| 858 | PIN_OTYPE_PUSHPULL(GPIOF_PIN10) | \ | ||
| 859 | PIN_OTYPE_PUSHPULL(GPIOF_PIN11) | \ | ||
| 860 | PIN_OTYPE_PUSHPULL(GPIOF_PIN12) | \ | ||
| 861 | PIN_OTYPE_PUSHPULL(GPIOF_PIN13) | \ | ||
| 862 | PIN_OTYPE_PUSHPULL(GPIOF_PIN14) | \ | ||
| 863 | PIN_OTYPE_PUSHPULL(GPIOF_PIN15)) | ||
| 864 | #define VAL_GPIOF_OSPEEDR (PIN_OSPEED_HIGH(GPIOF_I2C2_SDA) | \ | ||
| 865 | PIN_OSPEED_HIGH(GPIOF_I2C2_SCL) | \ | ||
| 866 | PIN_OSPEED_VERYLOW(GPIOF_PIN2) | \ | ||
| 867 | PIN_OSPEED_VERYLOW(GPIOF_PIN3) | \ | ||
| 868 | PIN_OSPEED_VERYLOW(GPIOF_PIN4) | \ | ||
| 869 | PIN_OSPEED_VERYLOW(GPIOF_PIN5) | \ | ||
| 870 | PIN_OSPEED_VERYLOW(GPIOF_PIN6) | \ | ||
| 871 | PIN_OSPEED_VERYLOW(GPIOF_PIN7) | \ | ||
| 872 | PIN_OSPEED_VERYLOW(GPIOF_PIN8) | \ | ||
| 873 | PIN_OSPEED_VERYLOW(GPIOF_PIN9) | \ | ||
| 874 | PIN_OSPEED_VERYLOW(GPIOF_PIN10) | \ | ||
| 875 | PIN_OSPEED_VERYLOW(GPIOF_PIN11) | \ | ||
| 876 | PIN_OSPEED_VERYLOW(GPIOF_PIN12) | \ | ||
| 877 | PIN_OSPEED_VERYLOW(GPIOF_PIN13) | \ | ||
| 878 | PIN_OSPEED_VERYLOW(GPIOF_PIN14) | \ | ||
| 879 | PIN_OSPEED_VERYLOW(GPIOF_PIN15)) | ||
| 880 | #define VAL_GPIOF_PUPDR (PIN_PUPDR_FLOATING(GPIOF_I2C2_SDA) | \ | ||
| 881 | PIN_PUPDR_FLOATING(GPIOF_I2C2_SCL) | \ | ||
| 882 | PIN_PUPDR_PULLUP(GPIOF_PIN2) | \ | ||
| 883 | PIN_PUPDR_PULLUP(GPIOF_PIN3) | \ | ||
| 884 | PIN_PUPDR_PULLUP(GPIOF_PIN4) | \ | ||
| 885 | PIN_PUPDR_PULLUP(GPIOF_PIN5) | \ | ||
| 886 | PIN_PUPDR_PULLUP(GPIOF_PIN6) | \ | ||
| 887 | PIN_PUPDR_PULLUP(GPIOF_PIN7) | \ | ||
| 888 | PIN_PUPDR_PULLUP(GPIOF_PIN8) | \ | ||
| 889 | PIN_PUPDR_PULLUP(GPIOF_PIN9) | \ | ||
| 890 | PIN_PUPDR_PULLUP(GPIOF_PIN10) | \ | ||
| 891 | PIN_PUPDR_PULLUP(GPIOF_PIN11) | \ | ||
| 892 | PIN_PUPDR_PULLUP(GPIOF_PIN12) | \ | ||
| 893 | PIN_PUPDR_PULLUP(GPIOF_PIN13) | \ | ||
| 894 | PIN_PUPDR_PULLUP(GPIOF_PIN14) | \ | ||
| 895 | PIN_PUPDR_PULLUP(GPIOF_PIN15)) | ||
| 896 | #define VAL_GPIOF_ODR (PIN_ODR_HIGH(GPIOF_I2C2_SDA) | \ | ||
| 897 | PIN_ODR_HIGH(GPIOF_I2C2_SCL) | \ | ||
| 898 | PIN_ODR_HIGH(GPIOF_PIN2) | \ | ||
| 899 | PIN_ODR_HIGH(GPIOF_PIN3) | \ | ||
| 900 | PIN_ODR_HIGH(GPIOF_PIN4) | \ | ||
| 901 | PIN_ODR_HIGH(GPIOF_PIN5) | \ | ||
| 902 | PIN_ODR_HIGH(GPIOF_PIN6) | \ | ||
| 903 | PIN_ODR_HIGH(GPIOF_PIN7) | \ | ||
| 904 | PIN_ODR_HIGH(GPIOF_PIN8) | \ | ||
| 905 | PIN_ODR_HIGH(GPIOF_PIN9) | \ | ||
| 906 | PIN_ODR_HIGH(GPIOF_PIN10) | \ | ||
| 907 | PIN_ODR_HIGH(GPIOF_PIN11) | \ | ||
| 908 | PIN_ODR_HIGH(GPIOF_PIN12) | \ | ||
| 909 | PIN_ODR_HIGH(GPIOF_PIN13) | \ | ||
| 910 | PIN_ODR_HIGH(GPIOF_PIN14) | \ | ||
| 911 | PIN_ODR_HIGH(GPIOF_PIN15)) | ||
| 912 | #define VAL_GPIOF_AFRL (PIN_AFIO_AF(GPIOF_I2C2_SDA, 0) | \ | ||
| 913 | PIN_AFIO_AF(GPIOF_I2C2_SCL, 0) | \ | ||
| 914 | PIN_AFIO_AF(GPIOF_PIN2, 0) | \ | ||
| 915 | PIN_AFIO_AF(GPIOF_PIN3, 0) | \ | ||
| 916 | PIN_AFIO_AF(GPIOF_PIN4, 0) | \ | ||
| 917 | PIN_AFIO_AF(GPIOF_PIN5, 0) | \ | ||
| 918 | PIN_AFIO_AF(GPIOF_PIN6, 0) | \ | ||
| 919 | PIN_AFIO_AF(GPIOF_PIN7, 0)) | ||
| 920 | #define VAL_GPIOF_AFRH (PIN_AFIO_AF(GPIOF_PIN8, 0) | \ | ||
| 921 | PIN_AFIO_AF(GPIOF_PIN9, 0) | \ | ||
| 922 | PIN_AFIO_AF(GPIOF_PIN10, 0) | \ | ||
| 923 | PIN_AFIO_AF(GPIOF_PIN11, 0) | \ | ||
| 924 | PIN_AFIO_AF(GPIOF_PIN12, 0) | \ | ||
| 925 | PIN_AFIO_AF(GPIOF_PIN13, 0) | \ | ||
| 926 | PIN_AFIO_AF(GPIOF_PIN14, 0) | \ | ||
| 927 | PIN_AFIO_AF(GPIOF_PIN15, 0)) | ||
| 928 | 393 | ||
| 929 | /* | 394 | /* |
| 930 | * GPIOG setup: | 395 | * GPIOG setup: |
| @@ -946,102 +411,13 @@ | |||
| 946 | * PG14 - PIN14 (input pullup). | 411 | * PG14 - PIN14 (input pullup). |
| 947 | * PG15 - PIN15 (input pullup). | 412 | * PG15 - PIN15 (input pullup). |
| 948 | */ | 413 | */ |
| 949 | #define VAL_GPIOG_MODER (PIN_MODE_INPUT(GPIOG_PIN0) | \ | 414 | #define VAL_GPIOG_MODER (PIN_MODE_INPUT(GPIOG_PIN0) | PIN_MODE_INPUT(GPIOG_PIN1) | PIN_MODE_INPUT(GPIOG_PIN2) | PIN_MODE_INPUT(GPIOG_PIN3) | PIN_MODE_INPUT(GPIOG_PIN4) | PIN_MODE_INPUT(GPIOG_PIN5) | PIN_MODE_INPUT(GPIOG_PIN6) | PIN_MODE_INPUT(GPIOG_PIN7) | PIN_MODE_INPUT(GPIOG_PIN8) | PIN_MODE_INPUT(GPIOG_PIN9) | PIN_MODE_INPUT(GPIOG_PIN10) | PIN_MODE_INPUT(GPIOG_PIN11) | PIN_MODE_INPUT(GPIOG_PIN12) | PIN_MODE_INPUT(GPIOG_PIN13) | PIN_MODE_INPUT(GPIOG_PIN14) | PIN_MODE_INPUT(GPIOG_PIN15)) |
| 950 | PIN_MODE_INPUT(GPIOG_PIN1) | \ | 415 | #define VAL_GPIOG_OTYPER (PIN_OTYPE_PUSHPULL(GPIOG_PIN0) | PIN_OTYPE_PUSHPULL(GPIOG_PIN1) | PIN_OTYPE_PUSHPULL(GPIOG_PIN2) | PIN_OTYPE_PUSHPULL(GPIOG_PIN3) | PIN_OTYPE_PUSHPULL(GPIOG_PIN4) | PIN_OTYPE_PUSHPULL(GPIOG_PIN5) | PIN_OTYPE_PUSHPULL(GPIOG_PIN6) | PIN_OTYPE_PUSHPULL(GPIOG_PIN7) | PIN_OTYPE_PUSHPULL(GPIOG_PIN8) | PIN_OTYPE_PUSHPULL(GPIOG_PIN9) | PIN_OTYPE_PUSHPULL(GPIOG_PIN10) | PIN_OTYPE_PUSHPULL(GPIOG_PIN11) | PIN_OTYPE_PUSHPULL(GPIOG_PIN12) | PIN_OTYPE_PUSHPULL(GPIOG_PIN13) | PIN_OTYPE_PUSHPULL(GPIOG_PIN14) | PIN_OTYPE_PUSHPULL(GPIOG_PIN15)) |
| 951 | PIN_MODE_INPUT(GPIOG_PIN2) | \ | 416 | #define VAL_GPIOG_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOG_PIN0) | PIN_OSPEED_VERYLOW(GPIOG_PIN1) | PIN_OSPEED_VERYLOW(GPIOG_PIN2) | PIN_OSPEED_VERYLOW(GPIOG_PIN3) | PIN_OSPEED_VERYLOW(GPIOG_PIN4) | PIN_OSPEED_VERYLOW(GPIOG_PIN5) | PIN_OSPEED_VERYLOW(GPIOG_PIN6) | PIN_OSPEED_VERYLOW(GPIOG_PIN7) | PIN_OSPEED_VERYLOW(GPIOG_PIN8) | PIN_OSPEED_VERYLOW(GPIOG_PIN9) | PIN_OSPEED_VERYLOW(GPIOG_PIN10) | PIN_OSPEED_VERYLOW(GPIOG_PIN11) | PIN_OSPEED_VERYLOW(GPIOG_PIN12) | PIN_OSPEED_VERYLOW(GPIOG_PIN13) | PIN_OSPEED_VERYLOW(GPIOG_PIN14) | PIN_OSPEED_VERYLOW(GPIOG_PIN15)) |
| 952 | PIN_MODE_INPUT(GPIOG_PIN3) | \ | 417 | #define VAL_GPIOG_PUPDR (PIN_PUPDR_PULLUP(GPIOG_PIN0) | PIN_PUPDR_PULLUP(GPIOG_PIN1) | PIN_PUPDR_PULLUP(GPIOG_PIN2) | PIN_PUPDR_PULLUP(GPIOG_PIN3) | PIN_PUPDR_PULLUP(GPIOG_PIN4) | PIN_PUPDR_PULLUP(GPIOG_PIN5) | PIN_PUPDR_PULLUP(GPIOG_PIN6) | PIN_PUPDR_PULLUP(GPIOG_PIN7) | PIN_PUPDR_PULLUP(GPIOG_PIN8) | PIN_PUPDR_PULLUP(GPIOG_PIN9) | PIN_PUPDR_PULLUP(GPIOG_PIN10) | PIN_PUPDR_PULLUP(GPIOG_PIN11) | PIN_PUPDR_PULLUP(GPIOG_PIN12) | PIN_PUPDR_PULLUP(GPIOG_PIN13) | PIN_PUPDR_PULLUP(GPIOG_PIN14) | PIN_PUPDR_PULLUP(GPIOG_PIN15)) |
| 953 | PIN_MODE_INPUT(GPIOG_PIN4) | \ | 418 | #define VAL_GPIOG_ODR (PIN_ODR_HIGH(GPIOG_PIN0) | PIN_ODR_HIGH(GPIOG_PIN1) | PIN_ODR_HIGH(GPIOG_PIN2) | PIN_ODR_HIGH(GPIOG_PIN3) | PIN_ODR_HIGH(GPIOG_PIN4) | PIN_ODR_HIGH(GPIOG_PIN5) | PIN_ODR_HIGH(GPIOG_PIN6) | PIN_ODR_HIGH(GPIOG_PIN7) | PIN_ODR_HIGH(GPIOG_PIN8) | PIN_ODR_HIGH(GPIOG_PIN9) | PIN_ODR_HIGH(GPIOG_PIN10) | PIN_ODR_HIGH(GPIOG_PIN11) | PIN_ODR_HIGH(GPIOG_PIN12) | PIN_ODR_HIGH(GPIOG_PIN13) | PIN_ODR_HIGH(GPIOG_PIN14) | PIN_ODR_HIGH(GPIOG_PIN15)) |
| 954 | PIN_MODE_INPUT(GPIOG_PIN5) | \ | 419 | #define VAL_GPIOG_AFRL (PIN_AFIO_AF(GPIOG_PIN0, 0) | PIN_AFIO_AF(GPIOG_PIN1, 0) | PIN_AFIO_AF(GPIOG_PIN2, 0) | PIN_AFIO_AF(GPIOG_PIN3, 0) | PIN_AFIO_AF(GPIOG_PIN4, 0) | PIN_AFIO_AF(GPIOG_PIN5, 0) | PIN_AFIO_AF(GPIOG_PIN6, 0) | PIN_AFIO_AF(GPIOG_PIN7, 0)) |
| 955 | PIN_MODE_INPUT(GPIOG_PIN6) | \ | 420 | #define VAL_GPIOG_AFRH (PIN_AFIO_AF(GPIOG_PIN8, 0) | PIN_AFIO_AF(GPIOG_PIN9, 0) | PIN_AFIO_AF(GPIOG_PIN10, 0) | PIN_AFIO_AF(GPIOG_PIN11, 0) | PIN_AFIO_AF(GPIOG_PIN12, 0) | PIN_AFIO_AF(GPIOG_PIN13, 0) | PIN_AFIO_AF(GPIOG_PIN14, 0) | PIN_AFIO_AF(GPIOG_PIN15, 0)) |
| 956 | PIN_MODE_INPUT(GPIOG_PIN7) | \ | ||
| 957 | PIN_MODE_INPUT(GPIOG_PIN8) | \ | ||
| 958 | PIN_MODE_INPUT(GPIOG_PIN9) | \ | ||
| 959 | PIN_MODE_INPUT(GPIOG_PIN10) | \ | ||
| 960 | PIN_MODE_INPUT(GPIOG_PIN11) | \ | ||
| 961 | PIN_MODE_INPUT(GPIOG_PIN12) | \ | ||
| 962 | PIN_MODE_INPUT(GPIOG_PIN13) | \ | ||
| 963 | PIN_MODE_INPUT(GPIOG_PIN14) | \ | ||
| 964 | PIN_MODE_INPUT(GPIOG_PIN15)) | ||
| 965 | #define VAL_GPIOG_OTYPER (PIN_OTYPE_PUSHPULL(GPIOG_PIN0) | \ | ||
| 966 | PIN_OTYPE_PUSHPULL(GPIOG_PIN1) | \ | ||
| 967 | PIN_OTYPE_PUSHPULL(GPIOG_PIN2) | \ | ||
| 968 | PIN_OTYPE_PUSHPULL(GPIOG_PIN3) | \ | ||
| 969 | PIN_OTYPE_PUSHPULL(GPIOG_PIN4) | \ | ||
| 970 | PIN_OTYPE_PUSHPULL(GPIOG_PIN5) | \ | ||
| 971 | PIN_OTYPE_PUSHPULL(GPIOG_PIN6) | \ | ||
| 972 | PIN_OTYPE_PUSHPULL(GPIOG_PIN7) | \ | ||
| 973 | PIN_OTYPE_PUSHPULL(GPIOG_PIN8) | \ | ||
| 974 | PIN_OTYPE_PUSHPULL(GPIOG_PIN9) | \ | ||
| 975 | PIN_OTYPE_PUSHPULL(GPIOG_PIN10) | \ | ||
| 976 | PIN_OTYPE_PUSHPULL(GPIOG_PIN11) | \ | ||
| 977 | PIN_OTYPE_PUSHPULL(GPIOG_PIN12) | \ | ||
| 978 | PIN_OTYPE_PUSHPULL(GPIOG_PIN13) | \ | ||
| 979 | PIN_OTYPE_PUSHPULL(GPIOG_PIN14) | \ | ||
| 980 | PIN_OTYPE_PUSHPULL(GPIOG_PIN15)) | ||
| 981 | #define VAL_GPIOG_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOG_PIN0) | \ | ||
| 982 | PIN_OSPEED_VERYLOW(GPIOG_PIN1) | \ | ||
| 983 | PIN_OSPEED_VERYLOW(GPIOG_PIN2) | \ | ||
| 984 | PIN_OSPEED_VERYLOW(GPIOG_PIN3) | \ | ||
| 985 | PIN_OSPEED_VERYLOW(GPIOG_PIN4) | \ | ||
| 986 | PIN_OSPEED_VERYLOW(GPIOG_PIN5) | \ | ||
| 987 | PIN_OSPEED_VERYLOW(GPIOG_PIN6) | \ | ||
| 988 | PIN_OSPEED_VERYLOW(GPIOG_PIN7) | \ | ||
| 989 | PIN_OSPEED_VERYLOW(GPIOG_PIN8) | \ | ||
| 990 | PIN_OSPEED_VERYLOW(GPIOG_PIN9) | \ | ||
| 991 | PIN_OSPEED_VERYLOW(GPIOG_PIN10) | \ | ||
| 992 | PIN_OSPEED_VERYLOW(GPIOG_PIN11) | \ | ||
| 993 | PIN_OSPEED_VERYLOW(GPIOG_PIN12) | \ | ||
| 994 | PIN_OSPEED_VERYLOW(GPIOG_PIN13) | \ | ||
| 995 | PIN_OSPEED_VERYLOW(GPIOG_PIN14) | \ | ||
| 996 | PIN_OSPEED_VERYLOW(GPIOG_PIN15)) | ||
| 997 | #define VAL_GPIOG_PUPDR (PIN_PUPDR_PULLUP(GPIOG_PIN0) | \ | ||
| 998 | PIN_PUPDR_PULLUP(GPIOG_PIN1) | \ | ||
| 999 | PIN_PUPDR_PULLUP(GPIOG_PIN2) | \ | ||
| 1000 | PIN_PUPDR_PULLUP(GPIOG_PIN3) | \ | ||
| 1001 | PIN_PUPDR_PULLUP(GPIOG_PIN4) | \ | ||
| 1002 | PIN_PUPDR_PULLUP(GPIOG_PIN5) | \ | ||
| 1003 | PIN_PUPDR_PULLUP(GPIOG_PIN6) | \ | ||
| 1004 | PIN_PUPDR_PULLUP(GPIOG_PIN7) | \ | ||
| 1005 | PIN_PUPDR_PULLUP(GPIOG_PIN8) | \ | ||
| 1006 | PIN_PUPDR_PULLUP(GPIOG_PIN9) | \ | ||
| 1007 | PIN_PUPDR_PULLUP(GPIOG_PIN10) | \ | ||
| 1008 | PIN_PUPDR_PULLUP(GPIOG_PIN11) | \ | ||
| 1009 | PIN_PUPDR_PULLUP(GPIOG_PIN12) | \ | ||
| 1010 | PIN_PUPDR_PULLUP(GPIOG_PIN13) | \ | ||
| 1011 | PIN_PUPDR_PULLUP(GPIOG_PIN14) | \ | ||
| 1012 | PIN_PUPDR_PULLUP(GPIOG_PIN15)) | ||
| 1013 | #define VAL_GPIOG_ODR (PIN_ODR_HIGH(GPIOG_PIN0) | \ | ||
| 1014 | PIN_ODR_HIGH(GPIOG_PIN1) | \ | ||
| 1015 | PIN_ODR_HIGH(GPIOG_PIN2) | \ | ||
| 1016 | PIN_ODR_HIGH(GPIOG_PIN3) | \ | ||
| 1017 | PIN_ODR_HIGH(GPIOG_PIN4) | \ | ||
| 1018 | PIN_ODR_HIGH(GPIOG_PIN5) | \ | ||
| 1019 | PIN_ODR_HIGH(GPIOG_PIN6) | \ | ||
| 1020 | PIN_ODR_HIGH(GPIOG_PIN7) | \ | ||
| 1021 | PIN_ODR_HIGH(GPIOG_PIN8) | \ | ||
| 1022 | PIN_ODR_HIGH(GPIOG_PIN9) | \ | ||
| 1023 | PIN_ODR_HIGH(GPIOG_PIN10) | \ | ||
| 1024 | PIN_ODR_HIGH(GPIOG_PIN11) | \ | ||
| 1025 | PIN_ODR_HIGH(GPIOG_PIN12) | \ | ||
| 1026 | PIN_ODR_HIGH(GPIOG_PIN13) | \ | ||
| 1027 | PIN_ODR_HIGH(GPIOG_PIN14) | \ | ||
| 1028 | PIN_ODR_HIGH(GPIOG_PIN15)) | ||
| 1029 | #define VAL_GPIOG_AFRL (PIN_AFIO_AF(GPIOG_PIN0, 0) | \ | ||
| 1030 | PIN_AFIO_AF(GPIOG_PIN1, 0) | \ | ||
| 1031 | PIN_AFIO_AF(GPIOG_PIN2, 0) | \ | ||
| 1032 | PIN_AFIO_AF(GPIOG_PIN3, 0) | \ | ||
| 1033 | PIN_AFIO_AF(GPIOG_PIN4, 0) | \ | ||
| 1034 | PIN_AFIO_AF(GPIOG_PIN5, 0) | \ | ||
| 1035 | PIN_AFIO_AF(GPIOG_PIN6, 0) | \ | ||
| 1036 | PIN_AFIO_AF(GPIOG_PIN7, 0)) | ||
| 1037 | #define VAL_GPIOG_AFRH (PIN_AFIO_AF(GPIOG_PIN8, 0) | \ | ||
| 1038 | PIN_AFIO_AF(GPIOG_PIN9, 0) | \ | ||
| 1039 | PIN_AFIO_AF(GPIOG_PIN10, 0) | \ | ||
| 1040 | PIN_AFIO_AF(GPIOG_PIN11, 0) | \ | ||
| 1041 | PIN_AFIO_AF(GPIOG_PIN12, 0) | \ | ||
| 1042 | PIN_AFIO_AF(GPIOG_PIN13, 0) | \ | ||
| 1043 | PIN_AFIO_AF(GPIOG_PIN14, 0) | \ | ||
| 1044 | PIN_AFIO_AF(GPIOG_PIN15, 0)) | ||
| 1045 | 421 | ||
| 1046 | /* | 422 | /* |
| 1047 | * GPIOH setup: | 423 | * GPIOH setup: |
| @@ -1063,103 +439,13 @@ | |||
| 1063 | * PH14 - PIN14 (input pullup). | 439 | * PH14 - PIN14 (input pullup). |
| 1064 | * PH15 - PIN15 (input pullup). | 440 | * PH15 - PIN15 (input pullup). |
| 1065 | */ | 441 | */ |
| 1066 | #define VAL_GPIOH_MODER (PIN_MODE_INPUT(GPIOH_PIN0) | \ | 442 | #define VAL_GPIOH_MODER (PIN_MODE_INPUT(GPIOH_PIN0) | PIN_MODE_INPUT(GPIOH_PIN1) | PIN_MODE_INPUT(GPIOH_PIN2) | PIN_MODE_INPUT(GPIOH_PIN3) | PIN_MODE_INPUT(GPIOH_PIN4) | PIN_MODE_INPUT(GPIOH_PIN5) | PIN_MODE_INPUT(GPIOH_PIN6) | PIN_MODE_INPUT(GPIOH_PIN7) | PIN_MODE_INPUT(GPIOH_PIN8) | PIN_MODE_INPUT(GPIOH_PIN9) | PIN_MODE_INPUT(GPIOH_PIN10) | PIN_MODE_INPUT(GPIOH_PIN11) | PIN_MODE_INPUT(GPIOH_PIN12) | PIN_MODE_INPUT(GPIOH_PIN13) | PIN_MODE_INPUT(GPIOH_PIN14) | PIN_MODE_INPUT(GPIOH_PIN15)) |
| 1067 | PIN_MODE_INPUT(GPIOH_PIN1) | \ | 443 | #define VAL_GPIOH_OTYPER (PIN_OTYPE_PUSHPULL(GPIOH_PIN0) | PIN_OTYPE_PUSHPULL(GPIOH_PIN1) | PIN_OTYPE_PUSHPULL(GPIOH_PIN2) | PIN_OTYPE_PUSHPULL(GPIOH_PIN3) | PIN_OTYPE_PUSHPULL(GPIOH_PIN4) | PIN_OTYPE_PUSHPULL(GPIOH_PIN5) | PIN_OTYPE_PUSHPULL(GPIOH_PIN6) | PIN_OTYPE_PUSHPULL(GPIOH_PIN7) | PIN_OTYPE_PUSHPULL(GPIOH_PIN8) | PIN_OTYPE_PUSHPULL(GPIOH_PIN9) | PIN_OTYPE_PUSHPULL(GPIOH_PIN10) | PIN_OTYPE_PUSHPULL(GPIOH_PIN11) | PIN_OTYPE_PUSHPULL(GPIOH_PIN12) | PIN_OTYPE_PUSHPULL(GPIOH_PIN13) | PIN_OTYPE_PUSHPULL(GPIOH_PIN14) | PIN_OTYPE_PUSHPULL(GPIOH_PIN15)) |
| 1068 | PIN_MODE_INPUT(GPIOH_PIN2) | \ | 444 | #define VAL_GPIOH_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOH_PIN0) | PIN_OSPEED_VERYLOW(GPIOH_PIN1) | PIN_OSPEED_VERYLOW(GPIOH_PIN2) | PIN_OSPEED_VERYLOW(GPIOH_PIN3) | PIN_OSPEED_VERYLOW(GPIOH_PIN4) | PIN_OSPEED_VERYLOW(GPIOH_PIN5) | PIN_OSPEED_VERYLOW(GPIOH_PIN6) | PIN_OSPEED_VERYLOW(GPIOH_PIN7) | PIN_OSPEED_VERYLOW(GPIOH_PIN8) | PIN_OSPEED_VERYLOW(GPIOH_PIN9) | PIN_OSPEED_VERYLOW(GPIOH_PIN10) | PIN_OSPEED_VERYLOW(GPIOH_PIN11) | PIN_OSPEED_VERYLOW(GPIOH_PIN12) | PIN_OSPEED_VERYLOW(GPIOH_PIN13) | PIN_OSPEED_VERYLOW(GPIOH_PIN14) | PIN_OSPEED_VERYLOW(GPIOH_PIN15)) |
| 1069 | PIN_MODE_INPUT(GPIOH_PIN3) | \ | 445 | #define VAL_GPIOH_PUPDR (PIN_PUPDR_PULLUP(GPIOH_PIN0) | PIN_PUPDR_PULLUP(GPIOH_PIN1) | PIN_PUPDR_PULLUP(GPIOH_PIN2) | PIN_PUPDR_PULLUP(GPIOH_PIN3) | PIN_PUPDR_PULLUP(GPIOH_PIN4) | PIN_PUPDR_PULLUP(GPIOH_PIN5) | PIN_PUPDR_PULLUP(GPIOH_PIN6) | PIN_PUPDR_PULLUP(GPIOH_PIN7) | PIN_PUPDR_PULLUP(GPIOH_PIN8) | PIN_PUPDR_PULLUP(GPIOH_PIN9) | PIN_PUPDR_PULLUP(GPIOH_PIN10) | PIN_PUPDR_PULLUP(GPIOH_PIN11) | PIN_PUPDR_PULLUP(GPIOH_PIN12) | PIN_PUPDR_PULLUP(GPIOH_PIN13) | PIN_PUPDR_PULLUP(GPIOH_PIN14) | PIN_PUPDR_PULLUP(GPIOH_PIN15)) |
| 1070 | PIN_MODE_INPUT(GPIOH_PIN4) | \ | 446 | #define VAL_GPIOH_ODR (PIN_ODR_HIGH(GPIOH_PIN0) | PIN_ODR_HIGH(GPIOH_PIN1) | PIN_ODR_HIGH(GPIOH_PIN2) | PIN_ODR_HIGH(GPIOH_PIN3) | PIN_ODR_HIGH(GPIOH_PIN4) | PIN_ODR_HIGH(GPIOH_PIN5) | PIN_ODR_HIGH(GPIOH_PIN6) | PIN_ODR_HIGH(GPIOH_PIN7) | PIN_ODR_HIGH(GPIOH_PIN8) | PIN_ODR_HIGH(GPIOH_PIN9) | PIN_ODR_HIGH(GPIOH_PIN10) | PIN_ODR_HIGH(GPIOH_PIN11) | PIN_ODR_HIGH(GPIOH_PIN12) | PIN_ODR_HIGH(GPIOH_PIN13) | PIN_ODR_HIGH(GPIOH_PIN14) | PIN_ODR_HIGH(GPIOH_PIN15)) |
| 1071 | PIN_MODE_INPUT(GPIOH_PIN5) | \ | 447 | #define VAL_GPIOH_AFRL (PIN_AFIO_AF(GPIOH_PIN0, 0) | PIN_AFIO_AF(GPIOH_PIN1, 0) | PIN_AFIO_AF(GPIOH_PIN2, 0) | PIN_AFIO_AF(GPIOH_PIN3, 0) | PIN_AFIO_AF(GPIOH_PIN4, 0) | PIN_AFIO_AF(GPIOH_PIN5, 0) | PIN_AFIO_AF(GPIOH_PIN6, 0) | PIN_AFIO_AF(GPIOH_PIN7, 0)) |
| 1072 | PIN_MODE_INPUT(GPIOH_PIN6) | \ | 448 | #define VAL_GPIOH_AFRH (PIN_AFIO_AF(GPIOH_PIN8, 0) | PIN_AFIO_AF(GPIOH_PIN9, 0) | PIN_AFIO_AF(GPIOH_PIN10, 0) | PIN_AFIO_AF(GPIOH_PIN11, 0) | PIN_AFIO_AF(GPIOH_PIN12, 0) | PIN_AFIO_AF(GPIOH_PIN13, 0) | PIN_AFIO_AF(GPIOH_PIN14, 0) | PIN_AFIO_AF(GPIOH_PIN15, 0)) |
| 1073 | PIN_MODE_INPUT(GPIOH_PIN7) | \ | ||
| 1074 | PIN_MODE_INPUT(GPIOH_PIN8) | \ | ||
| 1075 | PIN_MODE_INPUT(GPIOH_PIN9) | \ | ||
| 1076 | PIN_MODE_INPUT(GPIOH_PIN10) | \ | ||
| 1077 | PIN_MODE_INPUT(GPIOH_PIN11) | \ | ||
| 1078 | PIN_MODE_INPUT(GPIOH_PIN12) | \ | ||
| 1079 | PIN_MODE_INPUT(GPIOH_PIN13) | \ | ||
| 1080 | PIN_MODE_INPUT(GPIOH_PIN14) | \ | ||
| 1081 | PIN_MODE_INPUT(GPIOH_PIN15)) | ||
| 1082 | #define VAL_GPIOH_OTYPER (PIN_OTYPE_PUSHPULL(GPIOH_PIN0) | \ | ||
| 1083 | PIN_OTYPE_PUSHPULL(GPIOH_PIN1) | \ | ||
| 1084 | PIN_OTYPE_PUSHPULL(GPIOH_PIN2) | \ | ||
| 1085 | PIN_OTYPE_PUSHPULL(GPIOH_PIN3) | \ | ||
| 1086 | PIN_OTYPE_PUSHPULL(GPIOH_PIN4) | \ | ||
| 1087 | PIN_OTYPE_PUSHPULL(GPIOH_PIN5) | \ | ||
| 1088 | PIN_OTYPE_PUSHPULL(GPIOH_PIN6) | \ | ||
| 1089 | PIN_OTYPE_PUSHPULL(GPIOH_PIN7) | \ | ||
| 1090 | PIN_OTYPE_PUSHPULL(GPIOH_PIN8) | \ | ||
| 1091 | PIN_OTYPE_PUSHPULL(GPIOH_PIN9) | \ | ||
| 1092 | PIN_OTYPE_PUSHPULL(GPIOH_PIN10) | \ | ||
| 1093 | PIN_OTYPE_PUSHPULL(GPIOH_PIN11) | \ | ||
| 1094 | PIN_OTYPE_PUSHPULL(GPIOH_PIN12) | \ | ||
| 1095 | PIN_OTYPE_PUSHPULL(GPIOH_PIN13) | \ | ||
| 1096 | PIN_OTYPE_PUSHPULL(GPIOH_PIN14) | \ | ||
| 1097 | PIN_OTYPE_PUSHPULL(GPIOH_PIN15)) | ||
| 1098 | #define VAL_GPIOH_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOH_PIN0) | \ | ||
| 1099 | PIN_OSPEED_VERYLOW(GPIOH_PIN1) | \ | ||
| 1100 | PIN_OSPEED_VERYLOW(GPIOH_PIN2) | \ | ||
| 1101 | PIN_OSPEED_VERYLOW(GPIOH_PIN3) | \ | ||
| 1102 | PIN_OSPEED_VERYLOW(GPIOH_PIN4) | \ | ||
| 1103 | PIN_OSPEED_VERYLOW(GPIOH_PIN5) | \ | ||
| 1104 | PIN_OSPEED_VERYLOW(GPIOH_PIN6) | \ | ||
| 1105 | PIN_OSPEED_VERYLOW(GPIOH_PIN7) | \ | ||
| 1106 | PIN_OSPEED_VERYLOW(GPIOH_PIN8) | \ | ||
| 1107 | PIN_OSPEED_VERYLOW(GPIOH_PIN9) | \ | ||
| 1108 | PIN_OSPEED_VERYLOW(GPIOH_PIN10) | \ | ||
| 1109 | PIN_OSPEED_VERYLOW(GPIOH_PIN11) | \ | ||
| 1110 | PIN_OSPEED_VERYLOW(GPIOH_PIN12) | \ | ||
| 1111 | PIN_OSPEED_VERYLOW(GPIOH_PIN13) | \ | ||
| 1112 | PIN_OSPEED_VERYLOW(GPIOH_PIN14) | \ | ||
| 1113 | PIN_OSPEED_VERYLOW(GPIOH_PIN15)) | ||
| 1114 | #define VAL_GPIOH_PUPDR (PIN_PUPDR_PULLUP(GPIOH_PIN0) | \ | ||
| 1115 | PIN_PUPDR_PULLUP(GPIOH_PIN1) | \ | ||
| 1116 | PIN_PUPDR_PULLUP(GPIOH_PIN2) | \ | ||
| 1117 | PIN_PUPDR_PULLUP(GPIOH_PIN3) | \ | ||
| 1118 | PIN_PUPDR_PULLUP(GPIOH_PIN4) | \ | ||
| 1119 | PIN_PUPDR_PULLUP(GPIOH_PIN5) | \ | ||
| 1120 | PIN_PUPDR_PULLUP(GPIOH_PIN6) | \ | ||
| 1121 | PIN_PUPDR_PULLUP(GPIOH_PIN7) | \ | ||
| 1122 | PIN_PUPDR_PULLUP(GPIOH_PIN8) | \ | ||
| 1123 | PIN_PUPDR_PULLUP(GPIOH_PIN9) | \ | ||
| 1124 | PIN_PUPDR_PULLUP(GPIOH_PIN10) | \ | ||
| 1125 | PIN_PUPDR_PULLUP(GPIOH_PIN11) | \ | ||
| 1126 | PIN_PUPDR_PULLUP(GPIOH_PIN12) | \ | ||
| 1127 | PIN_PUPDR_PULLUP(GPIOH_PIN13) | \ | ||
| 1128 | PIN_PUPDR_PULLUP(GPIOH_PIN14) | \ | ||
| 1129 | PIN_PUPDR_PULLUP(GPIOH_PIN15)) | ||
| 1130 | #define VAL_GPIOH_ODR (PIN_ODR_HIGH(GPIOH_PIN0) | \ | ||
| 1131 | PIN_ODR_HIGH(GPIOH_PIN1) | \ | ||
| 1132 | PIN_ODR_HIGH(GPIOH_PIN2) | \ | ||
| 1133 | PIN_ODR_HIGH(GPIOH_PIN3) | \ | ||
| 1134 | PIN_ODR_HIGH(GPIOH_PIN4) | \ | ||
| 1135 | PIN_ODR_HIGH(GPIOH_PIN5) | \ | ||
| 1136 | PIN_ODR_HIGH(GPIOH_PIN6) | \ | ||
| 1137 | PIN_ODR_HIGH(GPIOH_PIN7) | \ | ||
| 1138 | PIN_ODR_HIGH(GPIOH_PIN8) | \ | ||
| 1139 | PIN_ODR_HIGH(GPIOH_PIN9) | \ | ||
| 1140 | PIN_ODR_HIGH(GPIOH_PIN10) | \ | ||
| 1141 | PIN_ODR_HIGH(GPIOH_PIN11) | \ | ||
| 1142 | PIN_ODR_HIGH(GPIOH_PIN12) | \ | ||
| 1143 | PIN_ODR_HIGH(GPIOH_PIN13) | \ | ||
| 1144 | PIN_ODR_HIGH(GPIOH_PIN14) | \ | ||
| 1145 | PIN_ODR_HIGH(GPIOH_PIN15)) | ||
| 1146 | #define VAL_GPIOH_AFRL (PIN_AFIO_AF(GPIOH_PIN0, 0) | \ | ||
| 1147 | PIN_AFIO_AF(GPIOH_PIN1, 0) | \ | ||
| 1148 | PIN_AFIO_AF(GPIOH_PIN2, 0) | \ | ||
| 1149 | PIN_AFIO_AF(GPIOH_PIN3, 0) | \ | ||
| 1150 | PIN_AFIO_AF(GPIOH_PIN4, 0) | \ | ||
| 1151 | PIN_AFIO_AF(GPIOH_PIN5, 0) | \ | ||
| 1152 | PIN_AFIO_AF(GPIOH_PIN6, 0) | \ | ||
| 1153 | PIN_AFIO_AF(GPIOH_PIN7, 0)) | ||
| 1154 | #define VAL_GPIOH_AFRH (PIN_AFIO_AF(GPIOH_PIN8, 0) | \ | ||
| 1155 | PIN_AFIO_AF(GPIOH_PIN9, 0) | \ | ||
| 1156 | PIN_AFIO_AF(GPIOH_PIN10, 0) | \ | ||
| 1157 | PIN_AFIO_AF(GPIOH_PIN11, 0) | \ | ||
| 1158 | PIN_AFIO_AF(GPIOH_PIN12, 0) | \ | ||
| 1159 | PIN_AFIO_AF(GPIOH_PIN13, 0) | \ | ||
| 1160 | PIN_AFIO_AF(GPIOH_PIN14, 0) | \ | ||
| 1161 | PIN_AFIO_AF(GPIOH_PIN15, 0)) | ||
| 1162 | |||
| 1163 | 449 | ||
| 1164 | /* | 450 | /* |
| 1165 | * USB bus activation macro, required by the USB driver. | 451 | * USB bus activation macro, required by the USB driver. |
| @@ -1171,17 +457,19 @@ | |||
| 1171 | * USB bus de-activation macro, required by the USB driver. | 457 | * USB bus de-activation macro, required by the USB driver. |
| 1172 | */ | 458 | */ |
| 1173 | // #define usb_lld_disconnect_bus(usbp) | 459 | // #define usb_lld_disconnect_bus(usbp) |
| 1174 | #define usb_lld_disconnect_bus(usbp) (palSetPadMode(GPIOA, GPIOA_USB_DP, PAL_MODE_OUTPUT_PUSHPULL)); palClearPad(GPIOA, GPIOA_USB_DP) | 460 | #define usb_lld_disconnect_bus(usbp) \ |
| 461 | (palSetPadMode(GPIOA, GPIOA_USB_DP, PAL_MODE_OUTPUT_PUSHPULL)); \ | ||
| 462 | palClearPad(GPIOA, GPIOA_USB_DP) | ||
| 1175 | // #define usb_lld_disconnect_bus(usbp) palSetPadMode(GPIOA, 12, PAL_MODE_OUTPUT_PUSHPULL); palClearPad(GPIOA, 12) | 463 | // #define usb_lld_disconnect_bus(usbp) palSetPadMode(GPIOA, 12, PAL_MODE_OUTPUT_PUSHPULL); palClearPad(GPIOA, 12) |
| 1176 | 464 | ||
| 1177 | #if !defined(_FROM_ASM_) | 465 | #if !defined(_FROM_ASM_) |
| 1178 | #ifdef __cplusplus | 466 | # ifdef __cplusplus |
| 1179 | extern "C" { | 467 | extern "C" { |
| 1180 | #endif | 468 | # endif |
| 1181 | void boardInit(void); | 469 | void boardInit(void); |
| 1182 | #ifdef __cplusplus | 470 | # ifdef __cplusplus |
| 1183 | } | 471 | } |
| 1184 | #endif | 472 | # endif |
| 1185 | #endif /* _FROM_ASM_ */ | 473 | #endif /* _FROM_ASM_ */ |
| 1186 | 474 | ||
| 1187 | #endif /* _BOARD_H_ */ | 475 | #endif /* _BOARD_H_ */ |
diff --git a/drivers/boards/IC_TEENSY_3_1/board.c b/drivers/boards/IC_TEENSY_3_1/board.c index 1e952883d..63e3f6492 100644 --- a/drivers/boards/IC_TEENSY_3_1/board.c +++ b/drivers/boards/IC_TEENSY_3_1/board.c | |||
| @@ -21,154 +21,109 @@ | |||
| 21 | * @details Digital I/O ports static configuration as defined in @p board.h. | 21 | * @details Digital I/O ports static configuration as defined in @p board.h. |
| 22 | * This variable is used by the HAL when initializing the PAL driver. | 22 | * This variable is used by the HAL when initializing the PAL driver. |
| 23 | */ | 23 | */ |
| 24 | const PALConfig pal_default_config = | 24 | const PALConfig pal_default_config = { |
| 25 | { | 25 | .ports = |
| 26 | .ports = { | ||
| 27 | { | 26 | { |
| 28 | /* | 27 | { |
| 29 | * PORTA setup. | 28 | /* |
| 30 | * | 29 | * PORTA setup. |
| 31 | * PTA4 - PIN33 | 30 | * |
| 32 | * PTA5 - PIN24 | 31 | * PTA4 - PIN33 |
| 33 | * PTA12 - PIN3 | 32 | * PTA5 - PIN24 |
| 34 | * PTA13 - PIN4 | 33 | * PTA12 - PIN3 |
| 35 | * | 34 | * PTA13 - PIN4 |
| 36 | * PTA18/19 crystal | 35 | * |
| 37 | * PTA0/3 SWD | 36 | * PTA18/19 crystal |
| 38 | */ | 37 | * PTA0/3 SWD |
| 39 | .port = IOPORT1, | 38 | */ |
| 40 | .pads = { | 39 | .port = IOPORT1, |
| 41 | PAL_MODE_ALTERNATIVE_7, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | 40 | .pads = |
| 42 | PAL_MODE_ALTERNATIVE_7, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, | 41 | { |
| 43 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | 42 | PAL_MODE_ALTERNATIVE_7, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_ALTERNATIVE_7, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_INPUT_ANALOG, PAL_MODE_INPUT_ANALOG, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, |
| 44 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | 43 | }, |
| 45 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, | ||
| 46 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 47 | PAL_MODE_INPUT_ANALOG, PAL_MODE_INPUT_ANALOG, PAL_MODE_UNCONNECTED, | ||
| 48 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 49 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 50 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 51 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 52 | }, | 44 | }, |
| 53 | }, | 45 | { |
| 54 | { | 46 | /* |
| 55 | /* | 47 | * PORTB setup. |
| 56 | * PORTB setup. | 48 | * |
| 57 | * | 49 | * PTB0 - PIN16 |
| 58 | * PTB0 - PIN16 | 50 | * PTB1 - PIN17 |
| 59 | * PTB1 - PIN17 | 51 | * PTB2 - PIN19 |
| 60 | * PTB2 - PIN19 | 52 | * PTB3 - PIN18 |
| 61 | * PTB3 - PIN18 | 53 | * PTB16 - PIN0 - UART0_TX |
| 62 | * PTB16 - PIN0 - UART0_TX | 54 | * PTB17 - PIN1 - UART0_RX |
| 63 | * PTB17 - PIN1 - UART0_RX | 55 | * PTB18 - PIN32 |
| 64 | * PTB18 - PIN32 | 56 | * PTB19 - PIN25 |
| 65 | * PTB19 - PIN25 | 57 | */ |
| 66 | */ | 58 | .port = IOPORT2, |
| 67 | .port = IOPORT2, | 59 | .pads = |
| 68 | .pads = { | 60 | { |
| 69 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, | 61 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_ALTERNATIVE_3, PAL_MODE_ALTERNATIVE_3, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, |
| 70 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | 62 | }, |
| 71 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 72 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 73 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 74 | PAL_MODE_UNCONNECTED, PAL_MODE_ALTERNATIVE_3, PAL_MODE_ALTERNATIVE_3, | ||
| 75 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, | ||
| 76 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 77 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 78 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 79 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 80 | }, | 63 | }, |
| 81 | }, | 64 | { |
| 82 | { | 65 | /* |
| 83 | /* | 66 | * PORTC setup. |
| 84 | * PORTC setup. | 67 | * |
| 85 | * | 68 | * PTC0 - PIN15 |
| 86 | * PTC0 - PIN15 | 69 | * PTC1 - PIN22 |
| 87 | * PTC1 - PIN22 | 70 | * PTC2 - PIN23 |
| 88 | * PTC2 - PIN23 | 71 | * PTC3 - PIN9 |
| 89 | * PTC3 - PIN9 | 72 | * PTC4 - PIN10 |
| 90 | * PTC4 - PIN10 | 73 | * PTC5 - PIN13 |
| 91 | * PTC5 - PIN13 | 74 | * PTC6 - PIN11 |
| 92 | * PTC6 - PIN11 | 75 | * PTC7 - PIN12 |
| 93 | * PTC7 - PIN12 | 76 | * PTC8 - PIN28 |
| 94 | * PTC8 - PIN28 | 77 | * PTC9 - PIN27 |
| 95 | * PTC9 - PIN27 | 78 | * PTC10 - PIN29 |
| 96 | * PTC10 - PIN29 | 79 | * PTC11 - PIN30 |
| 97 | * PTC11 - PIN30 | 80 | */ |
| 98 | */ | 81 | .port = IOPORT3, |
| 99 | .port = IOPORT3, | 82 | .pads = |
| 100 | .pads = { | 83 | { |
| 101 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, | 84 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, |
| 102 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, | 85 | }, |
| 103 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, | ||
| 104 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, | ||
| 105 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 106 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 107 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 108 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 109 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 110 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 111 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 112 | }, | 86 | }, |
| 113 | }, | 87 | { |
| 114 | { | 88 | /* |
| 115 | /* | 89 | * PORTD setup. |
| 116 | * PORTD setup. | 90 | * |
| 117 | * | 91 | * PTD0 - PIN2 |
| 118 | * PTD0 - PIN2 | 92 | * PTD1 - PIN14 |
| 119 | * PTD1 - PIN14 | 93 | * PTD2 - PIN7 |
| 120 | * PTD2 - PIN7 | 94 | * PTD3 - PIN8 |
| 121 | * PTD3 - PIN8 | 95 | * PTD4 - PIN6 |
| 122 | * PTD4 - PIN6 | 96 | * PTD5 - PIN20 |
| 123 | * PTD5 - PIN20 | 97 | * PTD6 - PIN21 |
| 124 | * PTD6 - PIN21 | 98 | * PTD7 - PIN5 |
| 125 | * PTD7 - PIN5 | 99 | */ |
| 126 | */ | 100 | .port = IOPORT4, |
| 127 | .port = IOPORT4, | 101 | .pads = |
| 128 | .pads = { | 102 | { |
| 129 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, | 103 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, |
| 130 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, | 104 | }, |
| 131 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, | ||
| 132 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 133 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 134 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 135 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 136 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 137 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 138 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 139 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 140 | }, | 105 | }, |
| 141 | }, | 106 | { |
| 142 | { | 107 | /* |
| 143 | /* | 108 | * PORTE setup. |
| 144 | * PORTE setup. | 109 | * |
| 145 | * | 110 | * PTE0 - PIN31 |
| 146 | * PTE0 - PIN31 | 111 | * PTE1 - PIN26 |
| 147 | * PTE1 - PIN26 | 112 | */ |
| 148 | */ | 113 | .port = IOPORT5, |
| 149 | .port = IOPORT5, | 114 | .pads = |
| 150 | .pads = { | 115 | { |
| 151 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, | 116 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, |
| 152 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | 117 | }, |
| 153 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 154 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 155 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 156 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 157 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 158 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 159 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 160 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 161 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
| 162 | }, | 118 | }, |
| 163 | }, | 119 | }, |
| 164 | }, | ||
| 165 | }; | 120 | }; |
| 166 | #endif | 121 | #endif |
| 167 | 122 | ||
| 168 | // NOTE: This value comes from kiibohd/controller and is the location of a value | 123 | // NOTE: This value comes from kiibohd/controller and is the location of a value |
| 169 | // which needs to be checked before disabling the watchdog (which happens in | 124 | // which needs to be checked before disabling the watchdog (which happens in |
| 170 | // k20x_clock_init) | 125 | // k20x_clock_init) |
| 171 | #define WDOG_TMROUTL *(volatile uint16_t *)0x40052012 | 126 | #define WDOG_TMROUTL *(volatile uint16_t *)0x40052012 |
| 172 | 127 | ||
| 173 | /** | 128 | /** |
| 174 | * @brief Early initialization code. | 129 | * @brief Early initialization code. |
| @@ -176,16 +131,16 @@ const PALConfig pal_default_config = | |||
| 176 | * and before any other initialization. | 131 | * and before any other initialization. |
| 177 | */ | 132 | */ |
| 178 | void __early_init(void) { | 133 | void __early_init(void) { |
| 179 | // This is a dirty hack and should only be used as a temporary fix until this | 134 | // This is a dirty hack and should only be used as a temporary fix until this |
| 180 | // is upstreamed. | 135 | // is upstreamed. |
| 181 | while (WDOG_TMROUTL < 2); // Must wait for WDOG timer if already running, before jumping | 136 | while (WDOG_TMROUTL < 2) |
| 137 | ; // Must wait for WDOG timer if already running, before jumping | ||
| 182 | 138 | ||
| 183 | k20x_clock_init(); | 139 | k20x_clock_init(); |
| 184 | } | 140 | } |
| 185 | 141 | ||
| 186 | /** | 142 | /** |
| 187 | * @brief Board-specific initialization code. | 143 | * @brief Board-specific initialization code. |
| 188 | * @todo Add your board-specific code, if any. | 144 | * @todo Add your board-specific code, if any. |
| 189 | */ | 145 | */ |
| 190 | void boardInit(void) { | 146 | void boardInit(void) {} |
| 191 | } | ||
diff --git a/drivers/boards/IC_TEENSY_3_1/board.h b/drivers/boards/IC_TEENSY_3_1/board.h index 8853395ef..c8259ab0c 100644 --- a/drivers/boards/IC_TEENSY_3_1/board.h +++ b/drivers/boards/IC_TEENSY_3_1/board.h | |||
| @@ -25,13 +25,13 @@ | |||
| 25 | * Board identifier. | 25 | * Board identifier. |
| 26 | */ | 26 | */ |
| 27 | #define BOARD_PJRC_TEENSY_3_1 | 27 | #define BOARD_PJRC_TEENSY_3_1 |
| 28 | #define BOARD_NAME "PJRC Teensy 3.1" | 28 | #define BOARD_NAME "PJRC Teensy 3.1" |
| 29 | 29 | ||
| 30 | /* External 16 MHz crystal */ | 30 | /* External 16 MHz crystal */ |
| 31 | #define KINETIS_XTAL_FREQUENCY 16000000UL | 31 | #define KINETIS_XTAL_FREQUENCY 16000000UL |
| 32 | 32 | ||
| 33 | /* Use internal capacitors for the crystal */ | 33 | /* Use internal capacitors for the crystal */ |
| 34 | #define KINETIS_BOARD_OSCILLATOR_SETTING OSC_CR_SC8P|OSC_CR_SC2P | 34 | #define KINETIS_BOARD_OSCILLATOR_SETTING OSC_CR_SC8P | OSC_CR_SC2P |
| 35 | 35 | ||
| 36 | /* | 36 | /* |
| 37 | * MCU type | 37 | * MCU type |
| @@ -41,79 +41,79 @@ | |||
| 41 | /* | 41 | /* |
| 42 | * IO pins assignments. | 42 | * IO pins assignments. |
| 43 | */ | 43 | */ |
| 44 | #define PORTA_PIN0 0 | 44 | #define PORTA_PIN0 0 |
| 45 | #define PORTA_PIN1 1 | 45 | #define PORTA_PIN1 1 |
| 46 | #define PORTA_PIN2 2 | 46 | #define PORTA_PIN2 2 |
| 47 | #define PORTA_PIN3 3 | 47 | #define PORTA_PIN3 3 |
| 48 | #define TEENSY_PIN33 4 | 48 | #define TEENSY_PIN33 4 |
| 49 | #define TEENSY_PIN24 5 | 49 | #define TEENSY_PIN24 5 |
| 50 | #define PORTA_PIN6 6 | 50 | #define PORTA_PIN6 6 |
| 51 | #define PORTA_PIN7 7 | 51 | #define PORTA_PIN7 7 |
| 52 | #define PORTA_PIN8 8 | 52 | #define PORTA_PIN8 8 |
| 53 | #define PORTA_PIN9 9 | 53 | #define PORTA_PIN9 9 |
| 54 | #define PORTA_PIN10 10 | 54 | #define PORTA_PIN10 10 |
| 55 | #define PORTA_PIN11 11 | 55 | #define PORTA_PIN11 11 |
| 56 | #define TEENSY_PIN3 12 | 56 | #define TEENSY_PIN3 12 |
| 57 | #define TEENSY_PIN4 13 | 57 | #define TEENSY_PIN4 13 |
| 58 | #define PORTA_PIN14 14 | 58 | #define PORTA_PIN14 14 |
| 59 | #define PORTA_PIN15 15 | 59 | #define PORTA_PIN15 15 |
| 60 | #define PORTA_PIN16 16 | 60 | #define PORTA_PIN16 16 |
| 61 | #define PORTA_PIN17 17 | 61 | #define PORTA_PIN17 17 |
| 62 | #define PORTA_PIN18 18 | 62 | #define PORTA_PIN18 18 |
| 63 | #define PORTA_PIN19 19 | 63 | #define PORTA_PIN19 19 |
| 64 | #define PORTA_PIN20 20 | 64 | #define PORTA_PIN20 20 |
| 65 | #define PORTA_PIN21 21 | 65 | #define PORTA_PIN21 21 |
| 66 | #define PORTA_PIN22 22 | 66 | #define PORTA_PIN22 22 |
| 67 | #define PORTA_PIN23 23 | 67 | #define PORTA_PIN23 23 |
| 68 | #define PORTA_PIN24 24 | 68 | #define PORTA_PIN24 24 |
| 69 | #define PORTA_PIN25 25 | 69 | #define PORTA_PIN25 25 |
| 70 | #define PORTA_PIN26 26 | 70 | #define PORTA_PIN26 26 |
| 71 | #define PORTA_PIN27 27 | 71 | #define PORTA_PIN27 27 |
| 72 | #define PORTA_PIN28 28 | 72 | #define PORTA_PIN28 28 |
| 73 | #define PORTA_PIN29 29 | 73 | #define PORTA_PIN29 29 |
| 74 | #define PORTA_PIN30 30 | 74 | #define PORTA_PIN30 30 |
| 75 | #define PORTA_PIN31 31 | 75 | #define PORTA_PIN31 31 |
| 76 | 76 | ||
| 77 | #define TEENSY_PIN3_IOPORT IOPORT1 | 77 | #define TEENSY_PIN3_IOPORT IOPORT1 |
| 78 | #define TEENSY_PIN4_IOPORT IOPORT1 | 78 | #define TEENSY_PIN4_IOPORT IOPORT1 |
| 79 | #define TEENSY_PIN24_IOPORT IOPORT1 | 79 | #define TEENSY_PIN24_IOPORT IOPORT1 |
| 80 | #define TEENSY_PIN33_IOPORT IOPORT1 | 80 | #define TEENSY_PIN33_IOPORT IOPORT1 |
| 81 | 81 | ||
| 82 | #define TEENSY_PIN16 0 | 82 | #define TEENSY_PIN16 0 |
| 83 | #define TEENSY_PIN17 1 | 83 | #define TEENSY_PIN17 1 |
| 84 | #define TEENSY_PIN19 2 | 84 | #define TEENSY_PIN19 2 |
| 85 | #define TEENSY_PIN18 3 | 85 | #define TEENSY_PIN18 3 |
| 86 | #define PORTB_PIN4 4 | 86 | #define PORTB_PIN4 4 |
| 87 | #define PORTB_PIN5 5 | 87 | #define PORTB_PIN5 5 |
| 88 | #define PORTB_PIN6 6 | 88 | #define PORTB_PIN6 6 |
| 89 | #define PORTB_PIN7 7 | 89 | #define PORTB_PIN7 7 |
| 90 | #define PORTB_PIN8 8 | 90 | #define PORTB_PIN8 8 |
| 91 | #define PORTB_PIN9 9 | 91 | #define PORTB_PIN9 9 |
| 92 | #define PORTB_PIN10 10 | 92 | #define PORTB_PIN10 10 |
| 93 | #define PORTB_PIN11 11 | 93 | #define PORTB_PIN11 11 |
| 94 | #define PORTB_PIN12 12 | 94 | #define PORTB_PIN12 12 |
| 95 | #define PORTB_PIN13 13 | 95 | #define PORTB_PIN13 13 |
| 96 | #define PORTB_PIN14 14 | 96 | #define PORTB_PIN14 14 |
| 97 | #define PORTB_PIN15 15 | 97 | #define PORTB_PIN15 15 |
| 98 | #define TEENSY_PIN0 16 | 98 | #define TEENSY_PIN0 16 |
| 99 | #define TEENSY_PIN1 17 | 99 | #define TEENSY_PIN1 17 |
| 100 | #define TEENSY_PIN32 18 | 100 | #define TEENSY_PIN32 18 |
| 101 | #define TEENSY_PIN25 19 | 101 | #define TEENSY_PIN25 19 |
| 102 | #define PORTB_PIN20 20 | 102 | #define PORTB_PIN20 20 |
| 103 | #define PORTB_PIN21 21 | 103 | #define PORTB_PIN21 21 |
| 104 | #define PORTB_PIN22 22 | 104 | #define PORTB_PIN22 22 |
| 105 | #define PORTB_PIN23 23 | 105 | #define PORTB_PIN23 23 |
| 106 | #define PORTB_PIN24 24 | 106 | #define PORTB_PIN24 24 |
| 107 | #define PORTB_PIN25 25 | 107 | #define PORTB_PIN25 25 |
| 108 | #define PORTB_PIN26 26 | 108 | #define PORTB_PIN26 26 |
| 109 | #define PORTB_PIN27 27 | 109 | #define PORTB_PIN27 27 |
| 110 | #define PORTB_PIN28 28 | 110 | #define PORTB_PIN28 28 |
| 111 | #define PORTB_PIN29 29 | 111 | #define PORTB_PIN29 29 |
| 112 | #define PORTB_PIN30 30 | 112 | #define PORTB_PIN30 30 |
| 113 | #define PORTB_PIN31 31 | 113 | #define PORTB_PIN31 31 |
| 114 | 114 | ||
| 115 | #define TEENSY_PIN0_IOPORT IOPORT2 | 115 | #define TEENSY_PIN0_IOPORT IOPORT2 |
| 116 | #define TEENSY_PIN1_IOPORT IOPORT2 | 116 | #define TEENSY_PIN1_IOPORT IOPORT2 |
| 117 | #define TEENSY_PIN16_IOPORT IOPORT2 | 117 | #define TEENSY_PIN16_IOPORT IOPORT2 |
| 118 | #define TEENSY_PIN17_IOPORT IOPORT2 | 118 | #define TEENSY_PIN17_IOPORT IOPORT2 |
| 119 | #define TEENSY_PIN18_IOPORT IOPORT2 | 119 | #define TEENSY_PIN18_IOPORT IOPORT2 |
| @@ -121,40 +121,40 @@ | |||
| 121 | #define TEENSY_PIN25_IOPORT IOPORT2 | 121 | #define TEENSY_PIN25_IOPORT IOPORT2 |
| 122 | #define TEENSY_PIN32_IOPORT IOPORT2 | 122 | #define TEENSY_PIN32_IOPORT IOPORT2 |
| 123 | 123 | ||
| 124 | #define TEENSY_PIN15 0 | 124 | #define TEENSY_PIN15 0 |
| 125 | #define TEENSY_PIN22 1 | 125 | #define TEENSY_PIN22 1 |
| 126 | #define TEENSY_PIN23 2 | 126 | #define TEENSY_PIN23 2 |
| 127 | #define TEENSY_PIN9 3 | 127 | #define TEENSY_PIN9 3 |
| 128 | #define TEENSY_PIN10 4 | 128 | #define TEENSY_PIN10 4 |
| 129 | #define TEENSY_PIN13 5 | 129 | #define TEENSY_PIN13 5 |
| 130 | #define TEENSY_PIN11 6 | 130 | #define TEENSY_PIN11 6 |
| 131 | #define TEENSY_PIN12 7 | 131 | #define TEENSY_PIN12 7 |
| 132 | #define TEENSY_PIN28 8 | 132 | #define TEENSY_PIN28 8 |
| 133 | #define TEENSY_PIN27 9 | 133 | #define TEENSY_PIN27 9 |
| 134 | #define TEENSY_PIN29 10 | 134 | #define TEENSY_PIN29 10 |
| 135 | #define TEENSY_PIN30 11 | 135 | #define TEENSY_PIN30 11 |
| 136 | #define PORTC_PIN12 12 | 136 | #define PORTC_PIN12 12 |
| 137 | #define PORTC_PIN13 13 | 137 | #define PORTC_PIN13 13 |
| 138 | #define PORTC_PIN14 14 | 138 | #define PORTC_PIN14 14 |
| 139 | #define PORTC_PIN15 15 | 139 | #define PORTC_PIN15 15 |
| 140 | #define PORTC_PIN16 16 | 140 | #define PORTC_PIN16 16 |
| 141 | #define PORTC_PIN17 17 | 141 | #define PORTC_PIN17 17 |
| 142 | #define PORTC_PIN18 18 | 142 | #define PORTC_PIN18 18 |
| 143 | #define PORTC_PIN19 19 | 143 | #define PORTC_PIN19 19 |
| 144 | #define PORTC_PIN20 20 | 144 | #define PORTC_PIN20 20 |
| 145 | #define PORTC_PIN21 21 | 145 | #define PORTC_PIN21 21 |
| 146 | #define PORTC_PIN22 22 | 146 | #define PORTC_PIN22 22 |
| 147 | #define PORTC_PIN23 23 | 147 | #define PORTC_PIN23 23 |
| 148 | #define PORTC_PIN24 24 | 148 | #define PORTC_PIN24 24 |
| 149 | #define PORTC_PIN25 25 | 149 | #define PORTC_PIN25 25 |
| 150 | #define PORTC_PIN26 26 | 150 | #define PORTC_PIN26 26 |
| 151 | #define PORTC_PIN27 27 | 151 | #define PORTC_PIN27 27 |
| 152 | #define PORTC_PIN28 28 | 152 | #define PORTC_PIN28 28 |
| 153 | #define PORTC_PIN29 29 | 153 | #define PORTC_PIN29 29 |
| 154 | #define PORTC_PIN30 30 | 154 | #define PORTC_PIN30 30 |
| 155 | #define PORTC_PIN31 31 | 155 | #define PORTC_PIN31 31 |
| 156 | 156 | ||
| 157 | #define TEENSY_PIN9_IOPORT IOPORT3 | 157 | #define TEENSY_PIN9_IOPORT IOPORT3 |
| 158 | #define TEENSY_PIN10_IOPORT IOPORT3 | 158 | #define TEENSY_PIN10_IOPORT IOPORT3 |
| 159 | #define TEENSY_PIN11_IOPORT IOPORT3 | 159 | #define TEENSY_PIN11_IOPORT IOPORT3 |
| 160 | #define TEENSY_PIN12_IOPORT IOPORT3 | 160 | #define TEENSY_PIN12_IOPORT IOPORT3 |
| @@ -167,129 +167,129 @@ | |||
| 167 | #define TEENSY_PIN29_IOPORT IOPORT3 | 167 | #define TEENSY_PIN29_IOPORT IOPORT3 |
| 168 | #define TEENSY_PIN30_IOPORT IOPORT3 | 168 | #define TEENSY_PIN30_IOPORT IOPORT3 |
| 169 | 169 | ||
| 170 | #define TEENSY_PIN2 0 | 170 | #define TEENSY_PIN2 0 |
| 171 | #define TEENSY_PIN14 1 | 171 | #define TEENSY_PIN14 1 |
| 172 | #define TEENSY_PIN7 2 | 172 | #define TEENSY_PIN7 2 |
| 173 | #define TEENSY_PIN8 3 | 173 | #define TEENSY_PIN8 3 |
| 174 | #define TEENSY_PIN6 4 | 174 | #define TEENSY_PIN6 4 |
| 175 | #define TEENSY_PIN20 5 | 175 | #define TEENSY_PIN20 5 |
| 176 | #define TEENSY_PIN21 6 | 176 | #define TEENSY_PIN21 6 |
| 177 | #define TEENSY_PIN5 7 | 177 | #define TEENSY_PIN5 7 |
| 178 | #define PORTD_PIN8 8 | 178 | #define PORTD_PIN8 8 |
| 179 | #define PORTD_PIN9 9 | 179 | #define PORTD_PIN9 9 |
| 180 | #define PORTD_PIN10 10 | 180 | #define PORTD_PIN10 10 |
| 181 | #define PORTD_PIN11 11 | 181 | #define PORTD_PIN11 11 |
| 182 | #define PORTD_PIN12 12 | 182 | #define PORTD_PIN12 12 |
| 183 | #define PORTD_PIN13 13 | 183 | #define PORTD_PIN13 13 |
| 184 | #define PORTD_PIN14 14 | 184 | #define PORTD_PIN14 14 |
| 185 | #define PORTD_PIN15 15 | 185 | #define PORTD_PIN15 15 |
| 186 | #define PORTD_PIN16 16 | 186 | #define PORTD_PIN16 16 |
| 187 | #define PORTD_PIN17 17 | 187 | #define PORTD_PIN17 17 |
| 188 | #define PORTD_PIN18 18 | 188 | #define PORTD_PIN18 18 |
| 189 | #define PORTD_PIN19 19 | 189 | #define PORTD_PIN19 19 |
| 190 | #define PORTD_PIN20 20 | 190 | #define PORTD_PIN20 20 |
| 191 | #define PORTD_PIN21 21 | 191 | #define PORTD_PIN21 21 |
| 192 | #define PORTD_PIN22 22 | 192 | #define PORTD_PIN22 22 |
| 193 | #define PORTD_PIN23 23 | 193 | #define PORTD_PIN23 23 |
| 194 | #define PORTD_PIN24 24 | 194 | #define PORTD_PIN24 24 |
| 195 | #define PORTD_PIN25 25 | 195 | #define PORTD_PIN25 25 |
| 196 | #define PORTD_PIN26 26 | 196 | #define PORTD_PIN26 26 |
| 197 | #define PORTD_PIN27 27 | 197 | #define PORTD_PIN27 27 |
| 198 | #define PORTD_PIN28 28 | 198 | #define PORTD_PIN28 28 |
| 199 | #define PORTD_PIN29 29 | 199 | #define PORTD_PIN29 29 |
| 200 | #define PORTD_PIN30 30 | 200 | #define PORTD_PIN30 30 |
| 201 | #define PORTD_PIN31 31 | 201 | #define PORTD_PIN31 31 |
| 202 | 202 | ||
| 203 | #define TEENSY_PIN2_IOPORT IOPORT4 | 203 | #define TEENSY_PIN2_IOPORT IOPORT4 |
| 204 | #define TEENSY_PIN5_IOPORT IOPORT4 | 204 | #define TEENSY_PIN5_IOPORT IOPORT4 |
| 205 | #define TEENSY_PIN6_IOPORT IOPORT4 | 205 | #define TEENSY_PIN6_IOPORT IOPORT4 |
| 206 | #define TEENSY_PIN7_IOPORT IOPORT4 | 206 | #define TEENSY_PIN7_IOPORT IOPORT4 |
| 207 | #define TEENSY_PIN8_IOPORT IOPORT4 | 207 | #define TEENSY_PIN8_IOPORT IOPORT4 |
| 208 | #define TEENSY_PIN14_IOPORT IOPORT4 | 208 | #define TEENSY_PIN14_IOPORT IOPORT4 |
| 209 | #define TEENSY_PIN20_IOPORT IOPORT4 | 209 | #define TEENSY_PIN20_IOPORT IOPORT4 |
| 210 | #define TEENSY_PIN21_IOPORT IOPORT4 | 210 | #define TEENSY_PIN21_IOPORT IOPORT4 |
| 211 | 211 | ||
| 212 | #define TEENSY_PIN31 0 | 212 | #define TEENSY_PIN31 0 |
| 213 | #define TEENSY_PIN26 1 | 213 | #define TEENSY_PIN26 1 |
| 214 | #define PORTE_PIN2 2 | 214 | #define PORTE_PIN2 2 |
| 215 | #define PORTE_PIN3 3 | 215 | #define PORTE_PIN3 3 |
| 216 | #define PORTE_PIN4 4 | 216 | #define PORTE_PIN4 4 |
| 217 | #define PORTE_PIN5 5 | 217 | #define PORTE_PIN5 5 |
| 218 | #define PORTE_PIN6 6 | 218 | #define PORTE_PIN6 6 |
| 219 | #define PORTE_PIN7 7 | 219 | #define PORTE_PIN7 7 |
| 220 | #define PORTE_PIN8 8 | 220 | #define PORTE_PIN8 8 |
| 221 | #define PORTE_PIN9 9 | 221 | #define PORTE_PIN9 9 |
| 222 | #define PORTE_PIN10 10 | 222 | #define PORTE_PIN10 10 |
| 223 | #define PORTE_PIN11 11 | 223 | #define PORTE_PIN11 11 |
| 224 | #define PORTE_PIN12 12 | 224 | #define PORTE_PIN12 12 |
| 225 | #define PORTE_PIN13 13 | 225 | #define PORTE_PIN13 13 |
| 226 | #define PORTE_PIN14 14 | 226 | #define PORTE_PIN14 14 |
| 227 | #define PORTE_PIN15 15 | 227 | #define PORTE_PIN15 15 |
| 228 | #define PORTE_PIN16 16 | 228 | #define PORTE_PIN16 16 |
| 229 | #define PORTE_PIN17 17 | 229 | #define PORTE_PIN17 17 |
| 230 | #define PORTE_PIN18 18 | 230 | #define PORTE_PIN18 18 |
| 231 | #define PORTE_PIN19 19 | 231 | #define PORTE_PIN19 19 |
| 232 | #define PORTE_PIN20 20 | 232 | #define PORTE_PIN20 20 |
| 233 | #define PORTE_PIN21 21 | 233 | #define PORTE_PIN21 21 |
| 234 | #define PORTE_PIN22 22 | 234 | #define PORTE_PIN22 22 |
| 235 | #define PORTE_PIN23 23 | 235 | #define PORTE_PIN23 23 |
| 236 | #define PORTE_PIN24 24 | 236 | #define PORTE_PIN24 24 |
| 237 | #define PORTE_PIN25 25 | 237 | #define PORTE_PIN25 25 |
| 238 | #define PORTE_PIN26 26 | 238 | #define PORTE_PIN26 26 |
| 239 | #define PORTE_PIN27 27 | 239 | #define PORTE_PIN27 27 |
| 240 | #define PORTE_PIN28 28 | 240 | #define PORTE_PIN28 28 |
| 241 | #define PORTE_PIN29 29 | 241 | #define PORTE_PIN29 29 |
| 242 | #define PORTE_PIN30 30 | 242 | #define PORTE_PIN30 30 |
| 243 | #define PORTE_PIN31 31 | 243 | #define PORTE_PIN31 31 |
| 244 | 244 | ||
| 245 | #define TEENSY_PIN26_IOPORT IOPORT5 | 245 | #define TEENSY_PIN26_IOPORT IOPORT5 |
| 246 | #define TEENSY_PIN31_IOPORT IOPORT5 | 246 | #define TEENSY_PIN31_IOPORT IOPORT5 |
| 247 | 247 | ||
| 248 | #define LINE_PIN1 PAL_LINE(TEENSY_PIN1_IOPORT, TEENSY_PIN1) | 248 | #define LINE_PIN1 PAL_LINE(TEENSY_PIN1_IOPORT, TEENSY_PIN1) |
| 249 | #define LINE_PIN2 PAL_LINE(TEENSY_PIN2_IOPORT, TEENSY_PIN2) | 249 | #define LINE_PIN2 PAL_LINE(TEENSY_PIN2_IOPORT, TEENSY_PIN2) |
| 250 | #define LINE_PIN3 PAL_LINE(TEENSY_PIN3_IOPORT, TEENSY_PIN3) | 250 | #define LINE_PIN3 PAL_LINE(TEENSY_PIN3_IOPORT, TEENSY_PIN3) |
| 251 | #define LINE_PIN4 PAL_LINE(TEENSY_PIN4_IOPORT, TEENSY_PIN4) | 251 | #define LINE_PIN4 PAL_LINE(TEENSY_PIN4_IOPORT, TEENSY_PIN4) |
| 252 | #define LINE_PIN5 PAL_LINE(TEENSY_PIN5_IOPORT, TEENSY_PIN5) | 252 | #define LINE_PIN5 PAL_LINE(TEENSY_PIN5_IOPORT, TEENSY_PIN5) |
| 253 | #define LINE_PIN6 PAL_LINE(TEENSY_PIN6_IOPORT, TEENSY_PIN6) | 253 | #define LINE_PIN6 PAL_LINE(TEENSY_PIN6_IOPORT, TEENSY_PIN6) |
| 254 | #define LINE_PIN7 PAL_LINE(TEENSY_PIN7_IOPORT, TEENSY_PIN7) | 254 | #define LINE_PIN7 PAL_LINE(TEENSY_PIN7_IOPORT, TEENSY_PIN7) |
| 255 | #define LINE_PIN8 PAL_LINE(TEENSY_PIN8_IOPORT, TEENSY_PIN8) | 255 | #define LINE_PIN8 PAL_LINE(TEENSY_PIN8_IOPORT, TEENSY_PIN8) |
| 256 | #define LINE_PIN9 PAL_LINE(TEENSY_PIN9_IOPORT, TEENSY_PIN9) | 256 | #define LINE_PIN9 PAL_LINE(TEENSY_PIN9_IOPORT, TEENSY_PIN9) |
| 257 | #define LINE_PIN10 PAL_LINE(TEENSY_PIN10_IOPORT, TEENSY_PIN10) | 257 | #define LINE_PIN10 PAL_LINE(TEENSY_PIN10_IOPORT, TEENSY_PIN10) |
| 258 | #define LINE_PIN11 PAL_LINE(TEENSY_PIN11_IOPORT, TEENSY_PIN11) | 258 | #define LINE_PIN11 PAL_LINE(TEENSY_PIN11_IOPORT, TEENSY_PIN11) |
| 259 | #define LINE_PIN12 PAL_LINE(TEENSY_PIN12_IOPORT, TEENSY_PIN12) | 259 | #define LINE_PIN12 PAL_LINE(TEENSY_PIN12_IOPORT, TEENSY_PIN12) |
| 260 | #define LINE_PIN13 PAL_LINE(TEENSY_PIN13_IOPORT, TEENSY_PIN13) | 260 | #define LINE_PIN13 PAL_LINE(TEENSY_PIN13_IOPORT, TEENSY_PIN13) |
| 261 | #define LINE_PIN14 PAL_LINE(TEENSY_PIN14_IOPORT, TEENSY_PIN14) | 261 | #define LINE_PIN14 PAL_LINE(TEENSY_PIN14_IOPORT, TEENSY_PIN14) |
| 262 | #define LINE_PIN15 PAL_LINE(TEENSY_PIN15_IOPORT, TEENSY_PIN15) | 262 | #define LINE_PIN15 PAL_LINE(TEENSY_PIN15_IOPORT, TEENSY_PIN15) |
| 263 | #define LINE_PIN16 PAL_LINE(TEENSY_PIN16_IOPORT, TEENSY_PIN16) | 263 | #define LINE_PIN16 PAL_LINE(TEENSY_PIN16_IOPORT, TEENSY_PIN16) |
| 264 | #define LINE_PIN17 PAL_LINE(TEENSY_PIN17_IOPORT, TEENSY_PIN17) | 264 | #define LINE_PIN17 PAL_LINE(TEENSY_PIN17_IOPORT, TEENSY_PIN17) |
| 265 | #define LINE_PIN18 PAL_LINE(TEENSY_PIN18_IOPORT, TEENSY_PIN18) | 265 | #define LINE_PIN18 PAL_LINE(TEENSY_PIN18_IOPORT, TEENSY_PIN18) |
| 266 | #define LINE_PIN19 PAL_LINE(TEENSY_PIN19_IOPORT, TEENSY_PIN19) | 266 | #define LINE_PIN19 PAL_LINE(TEENSY_PIN19_IOPORT, TEENSY_PIN19) |
| 267 | #define LINE_PIN20 PAL_LINE(TEENSY_PIN20_IOPORT, TEENSY_PIN20) | 267 | #define LINE_PIN20 PAL_LINE(TEENSY_PIN20_IOPORT, TEENSY_PIN20) |
| 268 | #define LINE_PIN21 PAL_LINE(TEENSY_PIN21_IOPORT, TEENSY_PIN21) | 268 | #define LINE_PIN21 PAL_LINE(TEENSY_PIN21_IOPORT, TEENSY_PIN21) |
| 269 | #define LINE_PIN22 PAL_LINE(TEENSY_PIN22_IOPORT, TEENSY_PIN22) | 269 | #define LINE_PIN22 PAL_LINE(TEENSY_PIN22_IOPORT, TEENSY_PIN22) |
| 270 | #define LINE_PIN23 PAL_LINE(TEENSY_PIN23_IOPORT, TEENSY_PIN23) | 270 | #define LINE_PIN23 PAL_LINE(TEENSY_PIN23_IOPORT, TEENSY_PIN23) |
| 271 | #define LINE_PIN24 PAL_LINE(TEENSY_PIN24_IOPORT, TEENSY_PIN24) | 271 | #define LINE_PIN24 PAL_LINE(TEENSY_PIN24_IOPORT, TEENSY_PIN24) |
| 272 | #define LINE_PIN25 PAL_LINE(TEENSY_PIN25_IOPORT, TEENSY_PIN25) | 272 | #define LINE_PIN25 PAL_LINE(TEENSY_PIN25_IOPORT, TEENSY_PIN25) |
| 273 | #define LINE_PIN25 PAL_LINE(TEENSY_PIN25_IOPORT, TEENSY_PIN25) | 273 | #define LINE_PIN25 PAL_LINE(TEENSY_PIN25_IOPORT, TEENSY_PIN25) |
| 274 | #define LINE_PIN26 PAL_LINE(TEENSY_PIN26_IOPORT, TEENSY_PIN26) | 274 | #define LINE_PIN26 PAL_LINE(TEENSY_PIN26_IOPORT, TEENSY_PIN26) |
| 275 | #define LINE_PIN27 PAL_LINE(TEENSY_PIN27_IOPORT, TEENSY_PIN27) | 275 | #define LINE_PIN27 PAL_LINE(TEENSY_PIN27_IOPORT, TEENSY_PIN27) |
| 276 | #define LINE_PIN28 PAL_LINE(TEENSY_PIN28_IOPORT, TEENSY_PIN28) | 276 | #define LINE_PIN28 PAL_LINE(TEENSY_PIN28_IOPORT, TEENSY_PIN28) |
| 277 | #define LINE_PIN29 PAL_LINE(TEENSY_PIN29_IOPORT, TEENSY_PIN29) | 277 | #define LINE_PIN29 PAL_LINE(TEENSY_PIN29_IOPORT, TEENSY_PIN29) |
| 278 | #define LINE_PIN30 PAL_LINE(TEENSY_PIN30_IOPORT, TEENSY_PIN30) | 278 | #define LINE_PIN30 PAL_LINE(TEENSY_PIN30_IOPORT, TEENSY_PIN30) |
| 279 | #define LINE_PIN31 PAL_LINE(TEENSY_PIN31_IOPORT, TEENSY_PIN31) | 279 | #define LINE_PIN31 PAL_LINE(TEENSY_PIN31_IOPORT, TEENSY_PIN31) |
| 280 | #define LINE_PIN32 PAL_LINE(TEENSY_PIN32_IOPORT, TEENSY_PIN32) | 280 | #define LINE_PIN32 PAL_LINE(TEENSY_PIN32_IOPORT, TEENSY_PIN32) |
| 281 | #define LINE_PIN33 PAL_LINE(TEENSY_PIN33_IOPORT, TEENSY_PIN33) | 281 | #define LINE_PIN33 PAL_LINE(TEENSY_PIN33_IOPORT, TEENSY_PIN33) |
| 282 | 282 | ||
| 283 | #define LINE_LED LINE_PIN13 | 283 | #define LINE_LED LINE_PIN13 |
| 284 | 284 | ||
| 285 | #if !defined(_FROM_ASM_) | 285 | #if !defined(_FROM_ASM_) |
| 286 | #ifdef __cplusplus | 286 | # ifdef __cplusplus |
| 287 | extern "C" { | 287 | extern "C" { |
| 288 | #endif | 288 | # endif |
| 289 | void boardInit(void); | 289 | void boardInit(void); |
| 290 | #ifdef __cplusplus | 290 | # ifdef __cplusplus |
| 291 | } | 291 | } |
| 292 | #endif | 292 | # endif |
| 293 | #endif /* _FROM_ASM_ */ | 293 | #endif /* _FROM_ASM_ */ |
| 294 | 294 | ||
| 295 | #endif /* _BOARD_H_ */ | 295 | #endif /* _BOARD_H_ */ |
diff --git a/drivers/gpio/pca9555.c b/drivers/gpio/pca9555.c index b0e542d8d..496bbca04 100644 --- a/drivers/gpio/pca9555.c +++ b/drivers/gpio/pca9555.c | |||
| @@ -22,57 +22,57 @@ | |||
| 22 | #define TIMEOUT 100 | 22 | #define TIMEOUT 100 |
| 23 | 23 | ||
| 24 | enum { | 24 | enum { |
| 25 | CMD_INPUT_0 = 0, | 25 | CMD_INPUT_0 = 0, |
| 26 | CMD_INPUT_1, | 26 | CMD_INPUT_1, |
| 27 | CMD_OUTPUT_0, | 27 | CMD_OUTPUT_0, |
| 28 | CMD_OUTPUT_1, | 28 | CMD_OUTPUT_1, |
| 29 | CMD_INVERSION_0, | 29 | CMD_INVERSION_0, |
| 30 | CMD_INVERSION_1, | 30 | CMD_INVERSION_1, |
| 31 | CMD_CONFIG_0, | 31 | CMD_CONFIG_0, |
| 32 | CMD_CONFIG_1, | 32 | CMD_CONFIG_1, |
| 33 | }; | 33 | }; |
| 34 | 34 | ||
| 35 | void pca9555_init(uint8_t slave_addr) { | 35 | void pca9555_init(uint8_t slave_addr) { |
| 36 | static uint8_t s_init = 0; | 36 | static uint8_t s_init = 0; |
| 37 | if (!s_init) { | 37 | if (!s_init) { |
| 38 | i2c_init(); | 38 | i2c_init(); |
| 39 | 39 | ||
| 40 | s_init = 1; | 40 | s_init = 1; |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | // TODO: could check device connected | 43 | // TODO: could check device connected |
| 44 | // i2c_start(SLAVE_TO_ADDR(slave) | I2C_WRITE); | 44 | // i2c_start(SLAVE_TO_ADDR(slave) | I2C_WRITE); |
| 45 | // i2c_stop(); | 45 | // i2c_stop(); |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | void pca9555_set_config(uint8_t slave_addr, uint8_t port, uint8_t conf) { | 48 | void pca9555_set_config(uint8_t slave_addr, uint8_t port, uint8_t conf) { |
| 49 | uint8_t addr = SLAVE_TO_ADDR(slave_addr); | 49 | uint8_t addr = SLAVE_TO_ADDR(slave_addr); |
| 50 | uint8_t cmd = port ? CMD_CONFIG_1 : CMD_CONFIG_0; | 50 | uint8_t cmd = port ? CMD_CONFIG_1 : CMD_CONFIG_0; |
| 51 | 51 | ||
| 52 | i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT); | 52 | i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT); |
| 53 | if (ret != I2C_STATUS_SUCCESS) { | 53 | if (ret != I2C_STATUS_SUCCESS) { |
| 54 | print("pca9555_set_config::FAILED\n"); | 54 | print("pca9555_set_config::FAILED\n"); |
| 55 | } | 55 | } |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | void pca9555_set_output(uint8_t slave_addr, uint8_t port, uint8_t conf) { | 58 | void pca9555_set_output(uint8_t slave_addr, uint8_t port, uint8_t conf) { |
| 59 | uint8_t addr = SLAVE_TO_ADDR(slave_addr); | 59 | uint8_t addr = SLAVE_TO_ADDR(slave_addr); |
| 60 | uint8_t cmd = port ? CMD_OUTPUT_1 : CMD_OUTPUT_0; | 60 | uint8_t cmd = port ? CMD_OUTPUT_1 : CMD_OUTPUT_0; |
| 61 | 61 | ||
| 62 | i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT); | 62 | i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT); |
| 63 | if (ret != I2C_STATUS_SUCCESS) { | 63 | if (ret != I2C_STATUS_SUCCESS) { |
| 64 | print("pca9555_set_output::FAILED\n"); | 64 | print("pca9555_set_output::FAILED\n"); |
| 65 | } | 65 | } |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | uint8_t pca9555_readPins(uint8_t slave_addr, uint8_t port) { | 68 | uint8_t pca9555_readPins(uint8_t slave_addr, uint8_t port) { |
| 69 | uint8_t addr = SLAVE_TO_ADDR(slave_addr); | 69 | uint8_t addr = SLAVE_TO_ADDR(slave_addr); |
| 70 | uint8_t cmd = port ? CMD_INPUT_1 : CMD_INPUT_0; | 70 | uint8_t cmd = port ? CMD_INPUT_1 : CMD_INPUT_0; |
| 71 | 71 | ||
| 72 | uint8_t data = 0; | 72 | uint8_t data = 0; |
| 73 | i2c_status_t ret = i2c_readReg(addr, cmd, &data, sizeof(data), TIMEOUT); | 73 | i2c_status_t ret = i2c_readReg(addr, cmd, &data, sizeof(data), TIMEOUT); |
| 74 | if (ret != I2C_STATUS_SUCCESS) { | 74 | if (ret != I2C_STATUS_SUCCESS) { |
| 75 | print("pca9555_readPins::FAILED\n"); | 75 | print("pca9555_readPins::FAILED\n"); |
| 76 | } | 76 | } |
| 77 | return data; | 77 | return data; |
| 78 | } | 78 | } |
diff --git a/drivers/haptic/DRV2605L.c b/drivers/haptic/DRV2605L.c index 215e6be3e..f74c96525 100644 --- a/drivers/haptic/DRV2605L.c +++ b/drivers/haptic/DRV2605L.c | |||
| @@ -20,110 +20,102 @@ | |||
| 20 | #include <stdio.h> | 20 | #include <stdio.h> |
| 21 | #include <math.h> | 21 | #include <math.h> |
| 22 | 22 | ||
| 23 | |||
| 24 | uint8_t DRV2605L_transfer_buffer[2]; | 23 | uint8_t DRV2605L_transfer_buffer[2]; |
| 25 | uint8_t DRV2605L_tx_register[0]; | 24 | uint8_t DRV2605L_tx_register[0]; |
| 26 | uint8_t DRV2605L_read_buffer[0]; | 25 | uint8_t DRV2605L_read_buffer[0]; |
| 27 | uint8_t DRV2605L_read_register; | 26 | uint8_t DRV2605L_read_register; |
| 28 | 27 | ||
| 29 | |||
| 30 | void DRV_write(uint8_t drv_register, uint8_t settings) { | 28 | void DRV_write(uint8_t drv_register, uint8_t settings) { |
| 31 | DRV2605L_transfer_buffer[0] = drv_register; | 29 | DRV2605L_transfer_buffer[0] = drv_register; |
| 32 | DRV2605L_transfer_buffer[1] = settings; | 30 | DRV2605L_transfer_buffer[1] = settings; |
| 33 | i2c_transmit(DRV2605L_BASE_ADDRESS << 1, DRV2605L_transfer_buffer, 2, 100); | 31 | i2c_transmit(DRV2605L_BASE_ADDRESS << 1, DRV2605L_transfer_buffer, 2, 100); |
| 34 | } | 32 | } |
| 35 | 33 | ||
| 36 | uint8_t DRV_read(uint8_t regaddress) { | 34 | uint8_t DRV_read(uint8_t regaddress) { |
| 37 | #ifdef __AVR__ | 35 | #ifdef __AVR__ |
| 38 | i2c_readReg(DRV2605L_BASE_ADDRESS << 1, | 36 | i2c_readReg(DRV2605L_BASE_ADDRESS << 1, regaddress, DRV2605L_read_buffer, 1, 100); |
| 39 | regaddress, DRV2605L_read_buffer, 1, 100); | 37 | DRV2605L_read_register = (uint8_t)DRV2605L_read_buffer[0]; |
| 40 | DRV2605L_read_register = (uint8_t)DRV2605L_read_buffer[0]; | ||
| 41 | #else | 38 | #else |
| 42 | DRV2605L_tx_register[0] = regaddress; | 39 | DRV2605L_tx_register[0] = regaddress; |
| 43 | if (MSG_OK != i2c_transmit_receive(DRV2605L_BASE_ADDRESS << 1, | 40 | if (MSG_OK != i2c_transmit_receive(DRV2605L_BASE_ADDRESS << 1, DRV2605L_tx_register, 1, DRV2605L_read_buffer, 1)) { |
| 44 | DRV2605L_tx_register, 1, | 41 | printf("err reading reg \n"); |
| 45 | DRV2605L_read_buffer, 1 | 42 | } |
| 46 | )){ | 43 | DRV2605L_read_register = (uint8_t)DRV2605L_read_buffer[0]; |
| 47 | printf("err reading reg \n"); | ||
| 48 | } | ||
| 49 | DRV2605L_read_register = (uint8_t)DRV2605L_read_buffer[0]; | ||
| 50 | #endif | 44 | #endif |
| 51 | return DRV2605L_read_register; | 45 | return DRV2605L_read_register; |
| 52 | } | 46 | } |
| 53 | 47 | ||
| 54 | void DRV_init(void) | 48 | void DRV_init(void) { |
| 55 | { | 49 | i2c_init(); |
| 56 | i2c_init(); | 50 | /* 0x07 sets DRV2605 into calibration mode */ |
| 57 | /* 0x07 sets DRV2605 into calibration mode */ | 51 | DRV_write(DRV_MODE, 0x07); |
| 58 | DRV_write(DRV_MODE,0x07); | 52 | |
| 53 | // DRV_write(DRV_FEEDBACK_CTRL,0xB6); | ||
| 59 | 54 | ||
| 60 | // DRV_write(DRV_FEEDBACK_CTRL,0xB6); | 55 | #if FB_ERM_LRA == 0 |
| 61 | |||
| 62 | #if FB_ERM_LRA == 0 | ||
| 63 | /* ERM settings */ | 56 | /* ERM settings */ |
| 64 | DRV_write(DRV_RATED_VOLT, (RATED_VOLTAGE/21.33)*1000); | 57 | DRV_write(DRV_RATED_VOLT, (RATED_VOLTAGE / 21.33) * 1000); |
| 65 | #if ERM_OPEN_LOOP == 0 | 58 | # if ERM_OPEN_LOOP == 0 |
| 66 | DRV_write(DRV_OVERDRIVE_CLAMP_VOLT, (((V_PEAK*(DRIVE_TIME+BLANKING_TIME+IDISS_TIME))/0.02133)/(DRIVE_TIME-0.0003))); | 59 | DRV_write(DRV_OVERDRIVE_CLAMP_VOLT, (((V_PEAK * (DRIVE_TIME + BLANKING_TIME + IDISS_TIME)) / 0.02133) / (DRIVE_TIME - 0.0003))); |
| 67 | #elif ERM_OPEN_LOOP == 1 | 60 | # elif ERM_OPEN_LOOP == 1 |
| 68 | DRV_write(DRV_OVERDRIVE_CLAMP_VOLT, (V_PEAK/0.02196)); | 61 | DRV_write(DRV_OVERDRIVE_CLAMP_VOLT, (V_PEAK / 0.02196)); |
| 69 | #endif | 62 | # endif |
| 70 | #elif FB_ERM_LRA == 1 | 63 | #elif FB_ERM_LRA == 1 |
| 71 | DRV_write(DRV_RATED_VOLT, ((V_RMS * sqrt(1 - ((4 * ((150+(SAMPLE_TIME*50))*0.000001)) + 0.0003)* F_LRA)/0.02071))); | 64 | DRV_write(DRV_RATED_VOLT, ((V_RMS * sqrt(1 - ((4 * ((150 + (SAMPLE_TIME * 50)) * 0.000001)) + 0.0003) * F_LRA) / 0.02071))); |
| 72 | #if LRA_OPEN_LOOP == 0 | 65 | # if LRA_OPEN_LOOP == 0 |
| 73 | DRV_write(DRV_OVERDRIVE_CLAMP_VOLT, ((V_PEAK/sqrt(1-(F_LRA*0.0008))/0.02133))); | 66 | DRV_write(DRV_OVERDRIVE_CLAMP_VOLT, ((V_PEAK / sqrt(1 - (F_LRA * 0.0008)) / 0.02133))); |
| 74 | #elif LRA_OPEN_LOOP == 1 | 67 | # elif LRA_OPEN_LOOP == 1 |
| 75 | DRV_write(DRV_OVERDRIVE_CLAMP_VOLT, (V_PEAK/0.02196)); | 68 | DRV_write(DRV_OVERDRIVE_CLAMP_VOLT, (V_PEAK / 0.02196)); |
| 76 | #endif | 69 | # endif |
| 77 | #endif | 70 | #endif |
| 78 | 71 | ||
| 79 | DRVREG_FBR FB_SET; | 72 | DRVREG_FBR FB_SET; |
| 80 | FB_SET.Bits.ERM_LRA = FB_ERM_LRA; | 73 | FB_SET.Bits.ERM_LRA = FB_ERM_LRA; |
| 81 | FB_SET.Bits.BRAKE_FACTOR = FB_BRAKEFACTOR; | 74 | FB_SET.Bits.BRAKE_FACTOR = FB_BRAKEFACTOR; |
| 82 | FB_SET.Bits.LOOP_GAIN =FB_LOOPGAIN; | 75 | FB_SET.Bits.LOOP_GAIN = FB_LOOPGAIN; |
| 83 | FB_SET.Bits.BEMF_GAIN = 0; /* auto-calibration populates this field*/ | 76 | FB_SET.Bits.BEMF_GAIN = 0; /* auto-calibration populates this field*/ |
| 84 | DRV_write(DRV_FEEDBACK_CTRL, (uint8_t) FB_SET.Byte); | 77 | DRV_write(DRV_FEEDBACK_CTRL, (uint8_t)FB_SET.Byte); |
| 85 | DRVREG_CTRL1 C1_SET; | 78 | DRVREG_CTRL1 C1_SET; |
| 86 | C1_SET.Bits.C1_DRIVE_TIME = DRIVE_TIME; | 79 | C1_SET.Bits.C1_DRIVE_TIME = DRIVE_TIME; |
| 87 | C1_SET.Bits.C1_AC_COUPLE = AC_COUPLE; | 80 | C1_SET.Bits.C1_AC_COUPLE = AC_COUPLE; |
| 88 | C1_SET.Bits.C1_STARTUP_BOOST = STARTUP_BOOST; | 81 | C1_SET.Bits.C1_STARTUP_BOOST = STARTUP_BOOST; |
| 89 | DRV_write(DRV_CTRL_1, (uint8_t) C1_SET.Byte); | 82 | DRV_write(DRV_CTRL_1, (uint8_t)C1_SET.Byte); |
| 90 | DRVREG_CTRL2 C2_SET; | 83 | DRVREG_CTRL2 C2_SET; |
| 91 | C2_SET.Bits.C2_BIDIR_INPUT = BIDIR_INPUT; | 84 | C2_SET.Bits.C2_BIDIR_INPUT = BIDIR_INPUT; |
| 92 | C2_SET.Bits.C2_BRAKE_STAB = BRAKE_STAB; | 85 | C2_SET.Bits.C2_BRAKE_STAB = BRAKE_STAB; |
| 93 | C2_SET.Bits.C2_SAMPLE_TIME = SAMPLE_TIME; | 86 | C2_SET.Bits.C2_SAMPLE_TIME = SAMPLE_TIME; |
| 94 | C2_SET.Bits.C2_BLANKING_TIME = BLANKING_TIME; | 87 | C2_SET.Bits.C2_BLANKING_TIME = BLANKING_TIME; |
| 95 | C2_SET.Bits.C2_IDISS_TIME = IDISS_TIME; | 88 | C2_SET.Bits.C2_IDISS_TIME = IDISS_TIME; |
| 96 | DRV_write(DRV_CTRL_2, (uint8_t) C2_SET.Byte); | 89 | DRV_write(DRV_CTRL_2, (uint8_t)C2_SET.Byte); |
| 97 | DRVREG_CTRL3 C3_SET; | 90 | DRVREG_CTRL3 C3_SET; |
| 98 | C3_SET.Bits.C3_LRA_OPEN_LOOP = LRA_OPEN_LOOP; | 91 | C3_SET.Bits.C3_LRA_OPEN_LOOP = LRA_OPEN_LOOP; |
| 99 | C3_SET.Bits.C3_N_PWM_ANALOG = N_PWM_ANALOG; | 92 | C3_SET.Bits.C3_N_PWM_ANALOG = N_PWM_ANALOG; |
| 100 | C3_SET.Bits.C3_LRA_DRIVE_MODE = LRA_DRIVE_MODE; | 93 | C3_SET.Bits.C3_LRA_DRIVE_MODE = LRA_DRIVE_MODE; |
| 101 | C3_SET.Bits.C3_DATA_FORMAT_RTO = DATA_FORMAT_RTO; | 94 | C3_SET.Bits.C3_DATA_FORMAT_RTO = DATA_FORMAT_RTO; |
| 102 | C3_SET.Bits.C3_SUPPLY_COMP_DIS = SUPPLY_COMP_DIS; | 95 | C3_SET.Bits.C3_SUPPLY_COMP_DIS = SUPPLY_COMP_DIS; |
| 103 | C3_SET.Bits.C3_ERM_OPEN_LOOP = ERM_OPEN_LOOP; | 96 | C3_SET.Bits.C3_ERM_OPEN_LOOP = ERM_OPEN_LOOP; |
| 104 | C3_SET.Bits.C3_NG_THRESH = NG_THRESH; | 97 | C3_SET.Bits.C3_NG_THRESH = NG_THRESH; |
| 105 | DRV_write(DRV_CTRL_3, (uint8_t) C3_SET.Byte); | 98 | DRV_write(DRV_CTRL_3, (uint8_t)C3_SET.Byte); |
| 106 | DRVREG_CTRL4 C4_SET; | 99 | DRVREG_CTRL4 C4_SET; |
| 107 | C4_SET.Bits.C4_ZC_DET_TIME = ZC_DET_TIME; | 100 | C4_SET.Bits.C4_ZC_DET_TIME = ZC_DET_TIME; |
| 108 | C4_SET.Bits.C4_AUTO_CAL_TIME = AUTO_CAL_TIME; | 101 | C4_SET.Bits.C4_AUTO_CAL_TIME = AUTO_CAL_TIME; |
| 109 | DRV_write(DRV_CTRL_4, (uint8_t) C4_SET.Byte); | 102 | DRV_write(DRV_CTRL_4, (uint8_t)C4_SET.Byte); |
| 110 | DRV_write(DRV_LIB_SELECTION,LIB_SELECTION); | 103 | DRV_write(DRV_LIB_SELECTION, LIB_SELECTION); |
| 111 | 104 | ||
| 112 | DRV_write(DRV_GO, 0x01); | 105 | DRV_write(DRV_GO, 0x01); |
| 113 | 106 | ||
| 114 | /* 0x00 sets DRV2605 out of standby and to use internal trigger | 107 | /* 0x00 sets DRV2605 out of standby and to use internal trigger |
| 115 | * 0x01 sets DRV2605 out of standby and to use external trigger */ | 108 | * 0x01 sets DRV2605 out of standby and to use external trigger */ |
| 116 | DRV_write(DRV_MODE,0x00); | 109 | DRV_write(DRV_MODE, 0x00); |
| 117 | 110 | ||
| 118 | //Play greeting sequence | 111 | // Play greeting sequence |
| 119 | DRV_write(DRV_GO, 0x00); | 112 | DRV_write(DRV_GO, 0x00); |
| 120 | DRV_write(DRV_WAVEFORM_SEQ_1, DRV_GREETING); | 113 | DRV_write(DRV_WAVEFORM_SEQ_1, DRV_GREETING); |
| 121 | DRV_write(DRV_GO, 0x01); | 114 | DRV_write(DRV_GO, 0x01); |
| 122 | } | 115 | } |
| 123 | 116 | ||
| 124 | void DRV_pulse(uint8_t sequence) | 117 | void DRV_pulse(uint8_t sequence) { |
| 125 | { | 118 | DRV_write(DRV_GO, 0x00); |
| 126 | DRV_write(DRV_GO, 0x00); | 119 | DRV_write(DRV_WAVEFORM_SEQ_1, sequence); |
| 127 | DRV_write(DRV_WAVEFORM_SEQ_1, sequence); | 120 | DRV_write(DRV_GO, 0x01); |
| 128 | DRV_write(DRV_GO, 0x01); | ||
| 129 | } \ No newline at end of file | 121 | } \ No newline at end of file |
diff --git a/drivers/haptic/DRV2605L.h b/drivers/haptic/DRV2605L.h index 836e9cbcd..f550b859f 100644 --- a/drivers/haptic/DRV2605L.h +++ b/drivers/haptic/DRV2605L.h | |||
| @@ -22,383 +22,383 @@ | |||
| 22 | 22 | ||
| 23 | * Feedback Control Settings */ | 23 | * Feedback Control Settings */ |
| 24 | #ifndef FB_ERM_LRA | 24 | #ifndef FB_ERM_LRA |
| 25 | #define FB_ERM_LRA 1 /* For ERM:0 or LRA:1*/ | 25 | # define FB_ERM_LRA 1 /* For ERM:0 or LRA:1*/ |
| 26 | #endif | 26 | #endif |
| 27 | #ifndef FB_BRAKEFACTOR | 27 | #ifndef FB_BRAKEFACTOR |
| 28 | #define FB_BRAKEFACTOR 3 /* For 1x:0, 2x:1, 3x:2, 4x:3, 6x:4, 8x:5, 16x:6, Disable Braking:7 */ | 28 | # define FB_BRAKEFACTOR 3 /* For 1x:0, 2x:1, 3x:2, 4x:3, 6x:4, 8x:5, 16x:6, Disable Braking:7 */ |
| 29 | #endif | 29 | #endif |
| 30 | #ifndef FB_LOOPGAIN | 30 | #ifndef FB_LOOPGAIN |
| 31 | #define FB_LOOPGAIN 1 /* For Low:0, Medium:1, High:2, Very High:3 */ | 31 | # define FB_LOOPGAIN 1 /* For Low:0, Medium:1, High:2, Very High:3 */ |
| 32 | #endif | 32 | #endif |
| 33 | 33 | ||
| 34 | /* LRA specific settings */ | 34 | /* LRA specific settings */ |
| 35 | #if FB_ERM_LRA == 1 | 35 | #if FB_ERM_LRA == 1 |
| 36 | #ifndef V_RMS | 36 | # ifndef V_RMS |
| 37 | #define V_RMS 2.0 | 37 | # define V_RMS 2.0 |
| 38 | #endif | 38 | # endif |
| 39 | #ifndef V_PEAK | 39 | # ifndef V_PEAK |
| 40 | #define V_PEAK 2.1 | 40 | # define V_PEAK 2.1 |
| 41 | #endif | 41 | # endif |
| 42 | #ifndef F_LRA | 42 | # ifndef F_LRA |
| 43 | #define F_LRA 205 | 43 | # define F_LRA 205 |
| 44 | #endif | 44 | # endif |
| 45 | #ifndef RATED_VOLTAGE | 45 | # ifndef RATED_VOLTAGE |
| 46 | #define RATED_VOLTAGE 2 /* 2v as safe range in case device voltage is not set */ | 46 | # define RATED_VOLTAGE 2 /* 2v as safe range in case device voltage is not set */ |
| 47 | #endif | 47 | # endif |
| 48 | #endif | 48 | #endif |
| 49 | 49 | ||
| 50 | #ifndef RATED_VOLTAGE | 50 | #ifndef RATED_VOLTAGE |
| 51 | #define RATED_VOLTAGE 2 /* 2v as safe range in case device voltage is not set */ | 51 | # define RATED_VOLTAGE 2 /* 2v as safe range in case device voltage is not set */ |
| 52 | #endif | 52 | #endif |
| 53 | #ifndef V_PEAK | 53 | #ifndef V_PEAK |
| 54 | #define V_PEAK 2.8 | 54 | # define V_PEAK 2.8 |
| 55 | #endif | 55 | #endif |
| 56 | 56 | ||
| 57 | /* Library Selection */ | 57 | /* Library Selection */ |
| 58 | #ifndef LIB_SELECTION | 58 | #ifndef LIB_SELECTION |
| 59 | #if FB_ERM_LRA == 1 | 59 | # if FB_ERM_LRA == 1 |
| 60 | #define LIB_SELECTION 6 /* For Empty:0' TS2200 library A to D:1-5, LRA Library: 6 */ | 60 | # define LIB_SELECTION 6 /* For Empty:0' TS2200 library A to D:1-5, LRA Library: 6 */ |
| 61 | #else | 61 | # else |
| 62 | #define LIB_SELECTION 1 | 62 | # define LIB_SELECTION 1 |
| 63 | #endif | 63 | # endif |
| 64 | #endif | 64 | #endif |
| 65 | 65 | ||
| 66 | #ifndef DRV_GREETING | 66 | #ifndef DRV_GREETING |
| 67 | #define DRV_GREETING alert_750ms | 67 | # define DRV_GREETING alert_750ms |
| 68 | #endif | 68 | #endif |
| 69 | #ifndef DRV_MODE_DEFAULT | 69 | #ifndef DRV_MODE_DEFAULT |
| 70 | #define DRV_MODE_DEFAULT strong_click1 | 70 | # define DRV_MODE_DEFAULT strong_click1 |
| 71 | #endif | 71 | #endif |
| 72 | 72 | ||
| 73 | /* Control 1 register settings */ | 73 | /* Control 1 register settings */ |
| 74 | #ifndef DRIVE_TIME | 74 | #ifndef DRIVE_TIME |
| 75 | #define DRIVE_TIME 25 | 75 | # define DRIVE_TIME 25 |
| 76 | #endif | 76 | #endif |
| 77 | #ifndef AC_COUPLE | 77 | #ifndef AC_COUPLE |
| 78 | #define AC_COUPLE 0 | 78 | # define AC_COUPLE 0 |
| 79 | #endif | 79 | #endif |
| 80 | #ifndef STARTUP_BOOST | 80 | #ifndef STARTUP_BOOST |
| 81 | #define STARTUP_BOOST 1 | 81 | # define STARTUP_BOOST 1 |
| 82 | #endif | 82 | #endif |
| 83 | 83 | ||
| 84 | /* Control 2 Settings */ | 84 | /* Control 2 Settings */ |
| 85 | #ifndef BIDIR_INPUT | 85 | #ifndef BIDIR_INPUT |
| 86 | #define BIDIR_INPUT 1 | 86 | # define BIDIR_INPUT 1 |
| 87 | #endif | 87 | #endif |
| 88 | #ifndef BRAKE_STAB | 88 | #ifndef BRAKE_STAB |
| 89 | #define BRAKE_STAB 1 /* Loopgain is reduced when braking is almost complete to improve stability */ | 89 | # define BRAKE_STAB 1 /* Loopgain is reduced when braking is almost complete to improve stability */ |
| 90 | #endif | 90 | #endif |
| 91 | #ifndef SAMPLE_TIME | 91 | #ifndef SAMPLE_TIME |
| 92 | #define SAMPLE_TIME 3 | 92 | # define SAMPLE_TIME 3 |
| 93 | #endif | 93 | #endif |
| 94 | #ifndef BLANKING_TIME | 94 | #ifndef BLANKING_TIME |
| 95 | #define BLANKING_TIME 1 | 95 | # define BLANKING_TIME 1 |
| 96 | #endif | 96 | #endif |
| 97 | #ifndef IDISS_TIME | 97 | #ifndef IDISS_TIME |
| 98 | #define IDISS_TIME 1 | 98 | # define IDISS_TIME 1 |
| 99 | #endif | 99 | #endif |
| 100 | 100 | ||
| 101 | /* Control 3 settings */ | 101 | /* Control 3 settings */ |
| 102 | #ifndef NG_THRESH | 102 | #ifndef NG_THRESH |
| 103 | #define NG_THRESH 2 | 103 | # define NG_THRESH 2 |
| 104 | #endif | 104 | #endif |
| 105 | #ifndef ERM_OPEN_LOOP | 105 | #ifndef ERM_OPEN_LOOP |
| 106 | #define ERM_OPEN_LOOP 1 | 106 | # define ERM_OPEN_LOOP 1 |
| 107 | #endif | 107 | #endif |
| 108 | #ifndef SUPPLY_COMP_DIS | 108 | #ifndef SUPPLY_COMP_DIS |
| 109 | #define SUPPLY_COMP_DIS 0 | 109 | # define SUPPLY_COMP_DIS 0 |
| 110 | #endif | 110 | #endif |
| 111 | #ifndef DATA_FORMAT_RTO | 111 | #ifndef DATA_FORMAT_RTO |
| 112 | #define DATA_FORMAT_RTO 0 | 112 | # define DATA_FORMAT_RTO 0 |
| 113 | #endif | 113 | #endif |
| 114 | #ifndef LRA_DRIVE_MODE | 114 | #ifndef LRA_DRIVE_MODE |
| 115 | #define LRA_DRIVE_MODE 0 | 115 | # define LRA_DRIVE_MODE 0 |
| 116 | #endif | 116 | #endif |
| 117 | #ifndef N_PWM_ANALOG | 117 | #ifndef N_PWM_ANALOG |
| 118 | #define N_PWM_ANALOG 0 | 118 | # define N_PWM_ANALOG 0 |
| 119 | #endif | 119 | #endif |
| 120 | #ifndef LRA_OPEN_LOOP | 120 | #ifndef LRA_OPEN_LOOP |
| 121 | #define LRA_OPEN_LOOP 0 | 121 | # define LRA_OPEN_LOOP 0 |
| 122 | #endif | 122 | #endif |
| 123 | 123 | ||
| 124 | /* Control 4 settings */ | 124 | /* Control 4 settings */ |
| 125 | #ifndef ZC_DET_TIME | 125 | #ifndef ZC_DET_TIME |
| 126 | #define ZC_DET_TIME 0 | 126 | # define ZC_DET_TIME 0 |
| 127 | #endif | 127 | #endif |
| 128 | #ifndef AUTO_CAL_TIME | 128 | #ifndef AUTO_CAL_TIME |
| 129 | #define AUTO_CAL_TIME 3 | 129 | # define AUTO_CAL_TIME 3 |
| 130 | #endif | 130 | #endif |
| 131 | 131 | ||
| 132 | /* register defines -------------------------------------------------------- */ | 132 | /* register defines -------------------------------------------------------- */ |
| 133 | #define DRV2605L_BASE_ADDRESS 0x5A /* DRV2605L Base address */ | 133 | #define DRV2605L_BASE_ADDRESS 0x5A /* DRV2605L Base address */ |
| 134 | #define DRV_STATUS 0x00 | 134 | #define DRV_STATUS 0x00 |
| 135 | #define DRV_MODE 0x01 | 135 | #define DRV_MODE 0x01 |
| 136 | #define DRV_RTP_INPUT 0x02 | 136 | #define DRV_RTP_INPUT 0x02 |
| 137 | #define DRV_LIB_SELECTION 0x03 | 137 | #define DRV_LIB_SELECTION 0x03 |
| 138 | #define DRV_WAVEFORM_SEQ_1 0x04 | 138 | #define DRV_WAVEFORM_SEQ_1 0x04 |
| 139 | #define DRV_WAVEFORM_SEQ_2 0x05 | 139 | #define DRV_WAVEFORM_SEQ_2 0x05 |
| 140 | #define DRV_WAVEFORM_SEQ_3 0x06 | 140 | #define DRV_WAVEFORM_SEQ_3 0x06 |
| 141 | #define DRV_WAVEFORM_SEQ_4 0x07 | 141 | #define DRV_WAVEFORM_SEQ_4 0x07 |
| 142 | #define DRV_WAVEFORM_SEQ_5 0x08 | 142 | #define DRV_WAVEFORM_SEQ_5 0x08 |
| 143 | #define DRV_WAVEFORM_SEQ_6 0x09 | 143 | #define DRV_WAVEFORM_SEQ_6 0x09 |
| 144 | #define DRV_WAVEFORM_SEQ_7 0x0A | 144 | #define DRV_WAVEFORM_SEQ_7 0x0A |
| 145 | #define DRV_WAVEFORM_SEQ_8 0x0B | 145 | #define DRV_WAVEFORM_SEQ_8 0x0B |
| 146 | #define DRV_GO 0x0C | 146 | #define DRV_GO 0x0C |
| 147 | #define DRV_OVERDRIVE_TIME_OFFSET 0x0D | 147 | #define DRV_OVERDRIVE_TIME_OFFSET 0x0D |
| 148 | #define DRV_SUSTAIN_TIME_OFFSET_P 0x0E | 148 | #define DRV_SUSTAIN_TIME_OFFSET_P 0x0E |
| 149 | #define DRV_SUSTAIN_TIME_OFFSET_N 0x0F | 149 | #define DRV_SUSTAIN_TIME_OFFSET_N 0x0F |
| 150 | #define DRV_BRAKE_TIME_OFFSET 0x10 | 150 | #define DRV_BRAKE_TIME_OFFSET 0x10 |
| 151 | #define DRV_AUDIO_2_VIBE_CTRL 0x11 | 151 | #define DRV_AUDIO_2_VIBE_CTRL 0x11 |
| 152 | #define DRV_AUDIO_2_VIBE_MIN_IN 0x12 | 152 | #define DRV_AUDIO_2_VIBE_MIN_IN 0x12 |
| 153 | #define DRV_AUDIO_2_VIBE_MAX_IN 0x13 | 153 | #define DRV_AUDIO_2_VIBE_MAX_IN 0x13 |
| 154 | #define DRV_AUDIO_2_VIBE_MIN_OUTDRV 0x14 | 154 | #define DRV_AUDIO_2_VIBE_MIN_OUTDRV 0x14 |
| 155 | #define DRV_AUDIO_2_VIBE_MAX_OUTDRV 0x15 | 155 | #define DRV_AUDIO_2_VIBE_MAX_OUTDRV 0x15 |
| 156 | #define DRV_RATED_VOLT 0x16 | 156 | #define DRV_RATED_VOLT 0x16 |
| 157 | #define DRV_OVERDRIVE_CLAMP_VOLT 0x17 | 157 | #define DRV_OVERDRIVE_CLAMP_VOLT 0x17 |
| 158 | #define DRV_AUTO_CALIB_COMP_RESULT 0x18 | 158 | #define DRV_AUTO_CALIB_COMP_RESULT 0x18 |
| 159 | #define DRV_AUTO_CALIB_BEMF_RESULT 0x19 | 159 | #define DRV_AUTO_CALIB_BEMF_RESULT 0x19 |
| 160 | #define DRV_FEEDBACK_CTRL 0x1A | 160 | #define DRV_FEEDBACK_CTRL 0x1A |
| 161 | #define DRV_CTRL_1 0x1B | 161 | #define DRV_CTRL_1 0x1B |
| 162 | #define DRV_CTRL_2 0x1C | 162 | #define DRV_CTRL_2 0x1C |
| 163 | #define DRV_CTRL_3 0x1D | 163 | #define DRV_CTRL_3 0x1D |
| 164 | #define DRV_CTRL_4 0x1E | 164 | #define DRV_CTRL_4 0x1E |
| 165 | #define DRV_CTRL_5 0x1F | 165 | #define DRV_CTRL_5 0x1F |
| 166 | #define DRV_OPEN_LOOP_PERIOD 0x20 | 166 | #define DRV_OPEN_LOOP_PERIOD 0x20 |
| 167 | #define DRV_VBAT_VOLT_MONITOR 0x21 | 167 | #define DRV_VBAT_VOLT_MONITOR 0x21 |
| 168 | #define DRV_LRA_RESONANCE_PERIOD 0x22 | 168 | #define DRV_LRA_RESONANCE_PERIOD 0x22 |
| 169 | 169 | ||
| 170 | void DRV_init(void); | 170 | void DRV_init(void); |
| 171 | void DRV_write(const uint8_t drv_register, const uint8_t settings); | 171 | void DRV_write(const uint8_t drv_register, const uint8_t settings); |
| 172 | uint8_t DRV_read(const uint8_t regaddress); | 172 | uint8_t DRV_read(const uint8_t regaddress); |
| 173 | void DRV_pulse(const uint8_t sequence); | 173 | void DRV_pulse(const uint8_t sequence); |
| 174 | 174 | ||
| 175 | typedef enum DRV_EFFECT{ | 175 | typedef enum DRV_EFFECT { |
| 176 | clear_sequence = 0, | 176 | clear_sequence = 0, |
| 177 | strong_click = 1, | 177 | strong_click = 1, |
| 178 | strong_click_60 = 2, | 178 | strong_click_60 = 2, |
| 179 | strong_click_30 = 3, | 179 | strong_click_30 = 3, |
| 180 | sharp_click = 4, | 180 | sharp_click = 4, |
| 181 | sharp_click_60 = 5, | 181 | sharp_click_60 = 5, |
| 182 | sharp_click_30 = 6, | 182 | sharp_click_30 = 6, |
| 183 | soft_bump = 7, | 183 | soft_bump = 7, |
| 184 | soft_bump_60 = 8, | 184 | soft_bump_60 = 8, |
| 185 | soft_bump_30 = 9, | 185 | soft_bump_30 = 9, |
| 186 | dbl_click = 10, | 186 | dbl_click = 10, |
| 187 | dbl_click_60 = 11, | 187 | dbl_click_60 = 11, |
| 188 | trp_click = 12, | 188 | trp_click = 12, |
| 189 | soft_fuzz = 13, | 189 | soft_fuzz = 13, |
| 190 | strong_buzz = 14, | 190 | strong_buzz = 14, |
| 191 | alert_750ms = 15, | 191 | alert_750ms = 15, |
| 192 | alert_1000ms = 16, | 192 | alert_1000ms = 16, |
| 193 | strong_click1 = 17, | 193 | strong_click1 = 17, |
| 194 | strong_click2_80 = 18, | 194 | strong_click2_80 = 18, |
| 195 | strong_click3_60 = 19, | 195 | strong_click3_60 = 19, |
| 196 | strong_click4_30 = 20, | 196 | strong_click4_30 = 20, |
| 197 | medium_click1 = 21, | 197 | medium_click1 = 21, |
| 198 | medium_click2_80 = 22, | 198 | medium_click2_80 = 22, |
| 199 | medium_click3_60 = 23, | 199 | medium_click3_60 = 23, |
| 200 | sharp_tick1 = 24, | 200 | sharp_tick1 = 24, |
| 201 | sharp_tick2_80 = 25, | 201 | sharp_tick2_80 = 25, |
| 202 | sharp_tick3_60 = 26, | 202 | sharp_tick3_60 = 26, |
| 203 | sh_dblclick_str = 27, | 203 | sh_dblclick_str = 27, |
| 204 | sh_dblclick_str_80 = 28, | 204 | sh_dblclick_str_80 = 28, |
| 205 | sh_dblclick_str_60 = 29, | 205 | sh_dblclick_str_60 = 29, |
| 206 | sh_dblclick_str_30 = 30, | 206 | sh_dblclick_str_30 = 30, |
| 207 | sh_dblclick_med = 31, | 207 | sh_dblclick_med = 31, |
| 208 | sh_dblclick_med_80 = 32, | 208 | sh_dblclick_med_80 = 32, |
| 209 | sh_dblclick_med_60 = 33, | 209 | sh_dblclick_med_60 = 33, |
| 210 | sh_dblsharp_tick = 34, | 210 | sh_dblsharp_tick = 34, |
| 211 | sh_dblsharp_tick_80 = 35, | 211 | sh_dblsharp_tick_80 = 35, |
| 212 | sh_dblsharp_tick_60 = 36, | 212 | sh_dblsharp_tick_60 = 36, |
| 213 | lg_dblclick_str = 37, | 213 | lg_dblclick_str = 37, |
| 214 | lg_dblclick_str_80 = 38, | 214 | lg_dblclick_str_80 = 38, |
| 215 | lg_dblclick_str_60 = 39, | 215 | lg_dblclick_str_60 = 39, |
| 216 | lg_dblclick_str_30 = 40, | 216 | lg_dblclick_str_30 = 40, |
| 217 | lg_dblclick_med = 41, | 217 | lg_dblclick_med = 41, |
| 218 | lg_dblclick_med_80 = 42, | 218 | lg_dblclick_med_80 = 42, |
| 219 | lg_dblclick_med_60 = 43, | 219 | lg_dblclick_med_60 = 43, |
| 220 | lg_dblsharp_tick = 44, | 220 | lg_dblsharp_tick = 44, |
| 221 | lg_dblsharp_tick_80 = 45, | 221 | lg_dblsharp_tick_80 = 45, |
| 222 | lg_dblsharp_tick_60 = 46, | 222 | lg_dblsharp_tick_60 = 46, |
| 223 | buzz = 47, | 223 | buzz = 47, |
| 224 | buzz_80 = 48, | 224 | buzz_80 = 48, |
| 225 | buzz_60 = 49, | 225 | buzz_60 = 49, |
| 226 | buzz_40 = 50, | 226 | buzz_40 = 50, |
| 227 | buzz_20 = 51, | 227 | buzz_20 = 51, |
| 228 | pulsing_strong = 52, | 228 | pulsing_strong = 52, |
| 229 | pulsing_strong_80 = 53, | 229 | pulsing_strong_80 = 53, |
| 230 | pulsing_medium = 54, | 230 | pulsing_medium = 54, |
| 231 | pulsing_medium_80 = 55, | 231 | pulsing_medium_80 = 55, |
| 232 | pulsing_sharp = 56, | 232 | pulsing_sharp = 56, |
| 233 | pulsing_sharp_80 = 57, | 233 | pulsing_sharp_80 = 57, |
| 234 | transition_click = 58, | 234 | transition_click = 58, |
| 235 | transition_click_80 = 59, | 235 | transition_click_80 = 59, |
| 236 | transition_click_60 = 60, | 236 | transition_click_60 = 60, |
| 237 | transition_click_40 = 61, | 237 | transition_click_40 = 61, |
| 238 | transition_click_20 = 62, | 238 | transition_click_20 = 62, |
| 239 | transition_click_10 = 63, | 239 | transition_click_10 = 63, |
| 240 | transition_hum = 64, | 240 | transition_hum = 64, |
| 241 | transition_hum_80 = 65, | 241 | transition_hum_80 = 65, |
| 242 | transition_hum_60 = 66, | 242 | transition_hum_60 = 66, |
| 243 | transition_hum_40 = 67, | 243 | transition_hum_40 = 67, |
| 244 | transition_hum_20 = 68, | 244 | transition_hum_20 = 68, |
| 245 | transition_hum_10 = 69, | 245 | transition_hum_10 = 69, |
| 246 | transition_rampdown_long_smooth1 = 70, | 246 | transition_rampdown_long_smooth1 = 70, |
| 247 | transition_rampdown_long_smooth2 = 71, | 247 | transition_rampdown_long_smooth2 = 71, |
| 248 | transition_rampdown_med_smooth1 = 72, | 248 | transition_rampdown_med_smooth1 = 72, |
| 249 | transition_rampdown_med_smooth2 = 73, | 249 | transition_rampdown_med_smooth2 = 73, |
| 250 | transition_rampdown_short_smooth1 = 74, | 250 | transition_rampdown_short_smooth1 = 74, |
| 251 | transition_rampdown_short_smooth2 = 75, | 251 | transition_rampdown_short_smooth2 = 75, |
| 252 | transition_rampdown_long_sharp1 = 76, | 252 | transition_rampdown_long_sharp1 = 76, |
| 253 | transition_rampdown_long_sharp2 = 77, | 253 | transition_rampdown_long_sharp2 = 77, |
| 254 | transition_rampdown_med_sharp1 = 78, | 254 | transition_rampdown_med_sharp1 = 78, |
| 255 | transition_rampdown_med_sharp2 = 79, | 255 | transition_rampdown_med_sharp2 = 79, |
| 256 | transition_rampdown_short_sharp1 = 80, | 256 | transition_rampdown_short_sharp1 = 80, |
| 257 | transition_rampdown_short_sharp2 = 81, | 257 | transition_rampdown_short_sharp2 = 81, |
| 258 | transition_rampup_long_smooth1 = 82, | 258 | transition_rampup_long_smooth1 = 82, |
| 259 | transition_rampup_long_smooth2 = 83, | 259 | transition_rampup_long_smooth2 = 83, |
| 260 | transition_rampup_med_smooth1 = 84, | 260 | transition_rampup_med_smooth1 = 84, |
| 261 | transition_rampup_med_smooth2 = 85, | 261 | transition_rampup_med_smooth2 = 85, |
| 262 | transition_rampup_short_smooth1 = 86, | 262 | transition_rampup_short_smooth1 = 86, |
| 263 | transition_rampup_short_smooth2 = 87, | 263 | transition_rampup_short_smooth2 = 87, |
| 264 | transition_rampup_long_sharp1 = 88, | 264 | transition_rampup_long_sharp1 = 88, |
| 265 | transition_rampup_long_sharp2 = 89, | 265 | transition_rampup_long_sharp2 = 89, |
| 266 | transition_rampup_med_sharp1 = 90, | 266 | transition_rampup_med_sharp1 = 90, |
| 267 | transition_rampup_med_sharp2 = 91, | 267 | transition_rampup_med_sharp2 = 91, |
| 268 | transition_rampup_short_sharp1 = 92, | 268 | transition_rampup_short_sharp1 = 92, |
| 269 | transition_rampup_short_sharp2 = 93, | 269 | transition_rampup_short_sharp2 = 93, |
| 270 | transition_rampdown_long_smooth1_50 = 94, | 270 | transition_rampdown_long_smooth1_50 = 94, |
| 271 | transition_rampdown_long_smooth2_50 = 95, | 271 | transition_rampdown_long_smooth2_50 = 95, |
| 272 | transition_rampdown_med_smooth1_50 = 96, | 272 | transition_rampdown_med_smooth1_50 = 96, |
| 273 | transition_rampdown_med_smooth2_50 = 97, | 273 | transition_rampdown_med_smooth2_50 = 97, |
| 274 | transition_rampdown_short_smooth1_50 = 98, | 274 | transition_rampdown_short_smooth1_50 = 98, |
| 275 | transition_rampdown_short_smooth2_50 = 99, | 275 | transition_rampdown_short_smooth2_50 = 99, |
| 276 | transition_rampdown_long_sharp1_50 = 100, | 276 | transition_rampdown_long_sharp1_50 = 100, |
| 277 | transition_rampdown_long_sharp2_50 = 101, | 277 | transition_rampdown_long_sharp2_50 = 101, |
| 278 | transition_rampdown_med_sharp1_50 = 102, | 278 | transition_rampdown_med_sharp1_50 = 102, |
| 279 | transition_rampdown_med_sharp2_50 = 103, | 279 | transition_rampdown_med_sharp2_50 = 103, |
| 280 | transition_rampdown_short_sharp1_50 = 104, | 280 | transition_rampdown_short_sharp1_50 = 104, |
| 281 | transition_rampdown_short_sharp2_50 = 105, | 281 | transition_rampdown_short_sharp2_50 = 105, |
| 282 | transition_rampup_long_smooth1_50 = 106, | 282 | transition_rampup_long_smooth1_50 = 106, |
| 283 | transition_rampup_long_smooth2_50 = 107, | 283 | transition_rampup_long_smooth2_50 = 107, |
| 284 | transition_rampup_med_smooth1_50 = 108, | 284 | transition_rampup_med_smooth1_50 = 108, |
| 285 | transition_rampup_med_smooth2_50 = 109, | 285 | transition_rampup_med_smooth2_50 = 109, |
| 286 | transition_rampup_short_smooth1_50 = 110, | 286 | transition_rampup_short_smooth1_50 = 110, |
| 287 | transition_rampup_short_smooth2_50 = 111, | 287 | transition_rampup_short_smooth2_50 = 111, |
| 288 | transition_rampup_long_sharp1_50 = 112, | 288 | transition_rampup_long_sharp1_50 = 112, |
| 289 | transition_rampup_long_sharp2_50 = 113, | 289 | transition_rampup_long_sharp2_50 = 113, |
| 290 | transition_rampup_med_sharp1_50 = 114, | 290 | transition_rampup_med_sharp1_50 = 114, |
| 291 | transition_rampup_med_sharp2_50 = 115, | 291 | transition_rampup_med_sharp2_50 = 115, |
| 292 | transition_rampup_short_sharp1_50 = 116, | 292 | transition_rampup_short_sharp1_50 = 116, |
| 293 | transition_rampup_short_sharp2_50 = 117, | 293 | transition_rampup_short_sharp2_50 = 117, |
| 294 | long_buzz_for_programmatic_stopping = 118, | 294 | long_buzz_for_programmatic_stopping = 118, |
| 295 | smooth_hum1_50 = 119, | 295 | smooth_hum1_50 = 119, |
| 296 | smooth_hum2_40 = 120, | 296 | smooth_hum2_40 = 120, |
| 297 | smooth_hum3_30 = 121, | 297 | smooth_hum3_30 = 121, |
| 298 | smooth_hum4_20 = 122, | 298 | smooth_hum4_20 = 122, |
| 299 | smooth_hum5_10 = 123, | 299 | smooth_hum5_10 = 123, |
| 300 | drv_effect_max = 124, | 300 | drv_effect_max = 124, |
| 301 | } DRV_EFFECT; | 301 | } DRV_EFFECT; |
| 302 | 302 | ||
| 303 | /* Register bit array unions */ | 303 | /* Register bit array unions */ |
| 304 | 304 | ||
| 305 | typedef union DRVREG_STATUS { /* register 0x00 */ | 305 | typedef union DRVREG_STATUS { /* register 0x00 */ |
| 306 | uint8_t Byte; | 306 | uint8_t Byte; |
| 307 | struct { | 307 | struct { |
| 308 | uint8_t OC_DETECT :1; /* set to 1 when overcurrent event is detected */ | 308 | uint8_t OC_DETECT : 1; /* set to 1 when overcurrent event is detected */ |
| 309 | uint8_t OVER_TEMP :1; /* set to 1 when device exceeds temp threshold */ | 309 | uint8_t OVER_TEMP : 1; /* set to 1 when device exceeds temp threshold */ |
| 310 | uint8_t FB_STS :1; /* set to 1 when feedback controller has timed out */ | 310 | uint8_t FB_STS : 1; /* set to 1 when feedback controller has timed out */ |
| 311 | /* auto-calibration routine and diagnostic result | 311 | /* auto-calibration routine and diagnostic result |
| 312 | * result | auto-calibation | diagnostic | | 312 | * result | auto-calibation | diagnostic | |
| 313 | * 0 | passed | actuator func normal | | 313 | * 0 | passed | actuator func normal | |
| 314 | * 1 | failed | actuator func fault* | | 314 | * 1 | failed | actuator func fault* | |
| 315 | * * actuator is not present or is shorted, timing out, or giving out–of-range back-EMF */ | 315 | * * actuator is not present or is shorted, timing out, or giving out–of-range back-EMF */ |
| 316 | uint8_t DIAG_RESULT :1; | 316 | uint8_t DIAG_RESULT : 1; |
| 317 | uint8_t :1; | 317 | uint8_t : 1; |
| 318 | uint8_t DEVICE_ID :3; /* Device IDs 3: DRV2605 4: DRV2604 5: DRV2604L 6: DRV2605L */ | 318 | uint8_t DEVICE_ID : 3; /* Device IDs 3: DRV2605 4: DRV2604 5: DRV2604L 6: DRV2605L */ |
| 319 | } Bits; | 319 | } Bits; |
| 320 | } DRVREG_STATUS; | 320 | } DRVREG_STATUS; |
| 321 | 321 | ||
| 322 | typedef union DRVREG_MODE { /* register 0x01 */ | 322 | typedef union DRVREG_MODE { /* register 0x01 */ |
| 323 | uint8_t Byte; | 323 | uint8_t Byte; |
| 324 | struct { | 324 | struct { |
| 325 | uint8_t MODE :3; /* Mode setting */ | 325 | uint8_t MODE : 3; /* Mode setting */ |
| 326 | uint8_t :3; | 326 | uint8_t : 3; |
| 327 | uint8_t STANDBY :1; /* 0:standby 1:ready */ | 327 | uint8_t STANDBY : 1; /* 0:standby 1:ready */ |
| 328 | } Bits; | 328 | } Bits; |
| 329 | } DRVREG_MODE; | 329 | } DRVREG_MODE; |
| 330 | 330 | ||
| 331 | typedef union DRVREG_WAIT { | 331 | typedef union DRVREG_WAIT { |
| 332 | uint8_t Byte; | 332 | uint8_t Byte; |
| 333 | struct { | 333 | struct { |
| 334 | uint8_t WAIT_MODE :1; /* Set to 1 to interpret as wait for next 7 bits x10ms */ | 334 | uint8_t WAIT_MODE : 1; /* Set to 1 to interpret as wait for next 7 bits x10ms */ |
| 335 | uint8_t WAIT_TIME :7; | 335 | uint8_t WAIT_TIME : 7; |
| 336 | } Bits; | 336 | } Bits; |
| 337 | } DRVREG_WAIT; | 337 | } DRVREG_WAIT; |
| 338 | 338 | ||
| 339 | typedef union DRVREG_FBR{ /* register 0x1A */ | 339 | typedef union DRVREG_FBR { /* register 0x1A */ |
| 340 | uint8_t Byte; | 340 | uint8_t Byte; |
| 341 | struct { | 341 | struct { |
| 342 | uint8_t BEMF_GAIN :2; | 342 | uint8_t BEMF_GAIN : 2; |
| 343 | uint8_t LOOP_GAIN :2; | 343 | uint8_t LOOP_GAIN : 2; |
| 344 | uint8_t BRAKE_FACTOR :3; | 344 | uint8_t BRAKE_FACTOR : 3; |
| 345 | uint8_t ERM_LRA :1; | 345 | uint8_t ERM_LRA : 1; |
| 346 | } Bits; | 346 | } Bits; |
| 347 | } DRVREG_FBR; | 347 | } DRVREG_FBR; |
| 348 | 348 | ||
| 349 | typedef union DRVREG_CTRL1{ /* register 0x1B */ | 349 | typedef union DRVREG_CTRL1 { /* register 0x1B */ |
| 350 | uint8_t Byte; | 350 | uint8_t Byte; |
| 351 | struct { | 351 | struct { |
| 352 | uint8_t C1_DRIVE_TIME :5; | 352 | uint8_t C1_DRIVE_TIME : 5; |
| 353 | uint8_t C1_AC_COUPLE :1; | 353 | uint8_t C1_AC_COUPLE : 1; |
| 354 | uint8_t :1; | 354 | uint8_t : 1; |
| 355 | uint8_t C1_STARTUP_BOOST :1; | 355 | uint8_t C1_STARTUP_BOOST : 1; |
| 356 | } Bits; | 356 | } Bits; |
| 357 | } DRVREG_CTRL1; | 357 | } DRVREG_CTRL1; |
| 358 | 358 | ||
| 359 | typedef union DRVREG_CTRL2{ /* register 0x1C */ | 359 | typedef union DRVREG_CTRL2 { /* register 0x1C */ |
| 360 | uint8_t Byte; | 360 | uint8_t Byte; |
| 361 | struct { | 361 | struct { |
| 362 | uint8_t C2_IDISS_TIME :2; | 362 | uint8_t C2_IDISS_TIME : 2; |
| 363 | uint8_t C2_BLANKING_TIME :2; | 363 | uint8_t C2_BLANKING_TIME : 2; |
| 364 | uint8_t C2_SAMPLE_TIME :2; | 364 | uint8_t C2_SAMPLE_TIME : 2; |
| 365 | uint8_t C2_BRAKE_STAB :1; | 365 | uint8_t C2_BRAKE_STAB : 1; |
| 366 | uint8_t C2_BIDIR_INPUT :1; | 366 | uint8_t C2_BIDIR_INPUT : 1; |
| 367 | } Bits; | 367 | } Bits; |
| 368 | } DRVREG_CTRL2; | 368 | } DRVREG_CTRL2; |
| 369 | 369 | ||
| 370 | typedef union DRVREG_CTRL3{ /* register 0x1D */ | 370 | typedef union DRVREG_CTRL3 { /* register 0x1D */ |
| 371 | uint8_t Byte; | 371 | uint8_t Byte; |
| 372 | struct { | 372 | struct { |
| 373 | uint8_t C3_LRA_OPEN_LOOP :1; | 373 | uint8_t C3_LRA_OPEN_LOOP : 1; |
| 374 | uint8_t C3_N_PWM_ANALOG :1; | 374 | uint8_t C3_N_PWM_ANALOG : 1; |
| 375 | uint8_t C3_LRA_DRIVE_MODE :1; | 375 | uint8_t C3_LRA_DRIVE_MODE : 1; |
| 376 | uint8_t C3_DATA_FORMAT_RTO :1; | 376 | uint8_t C3_DATA_FORMAT_RTO : 1; |
| 377 | uint8_t C3_SUPPLY_COMP_DIS :1; | 377 | uint8_t C3_SUPPLY_COMP_DIS : 1; |
| 378 | uint8_t C3_ERM_OPEN_LOOP :1; | 378 | uint8_t C3_ERM_OPEN_LOOP : 1; |
| 379 | uint8_t C3_NG_THRESH :2; | 379 | uint8_t C3_NG_THRESH : 2; |
| 380 | } Bits; | 380 | } Bits; |
| 381 | } DRVREG_CTRL3; | 381 | } DRVREG_CTRL3; |
| 382 | 382 | ||
| 383 | typedef union DRVREG_CTRL4{ /* register 0x1E */ | 383 | typedef union DRVREG_CTRL4 { /* register 0x1E */ |
| 384 | uint8_t Byte; | 384 | uint8_t Byte; |
| 385 | struct { | 385 | struct { |
| 386 | uint8_t C4_OTP_PROGRAM :1; | 386 | uint8_t C4_OTP_PROGRAM : 1; |
| 387 | uint8_t :1; | 387 | uint8_t : 1; |
| 388 | uint8_t C4_OTP_STATUS :1; | 388 | uint8_t C4_OTP_STATUS : 1; |
| 389 | uint8_t :1; | 389 | uint8_t : 1; |
| 390 | uint8_t C4_AUTO_CAL_TIME :2; | 390 | uint8_t C4_AUTO_CAL_TIME : 2; |
| 391 | uint8_t C4_ZC_DET_TIME :2; | 391 | uint8_t C4_ZC_DET_TIME : 2; |
| 392 | } Bits; | 392 | } Bits; |
| 393 | } DRVREG_CTRL4; | 393 | } DRVREG_CTRL4; |
| 394 | 394 | ||
| 395 | typedef union DRVREG_CTRL5{ /* register 0x1F */ | 395 | typedef union DRVREG_CTRL5 { /* register 0x1F */ |
| 396 | uint8_t Byte; | 396 | uint8_t Byte; |
| 397 | struct { | 397 | struct { |
| 398 | uint8_t C5_IDISS_TIME :2; | 398 | uint8_t C5_IDISS_TIME : 2; |
| 399 | uint8_t C5_BLANKING_TIME :2; | 399 | uint8_t C5_BLANKING_TIME : 2; |
| 400 | uint8_t C5_PLAYBACK_INTERVAL :1; | 400 | uint8_t C5_PLAYBACK_INTERVAL : 1; |
| 401 | uint8_t C5_LRA_AUTO_OPEN_LOOP :1; | 401 | uint8_t C5_LRA_AUTO_OPEN_LOOP : 1; |
| 402 | uint8_t C5_AUTO_OL_CNT :2; | 402 | uint8_t C5_AUTO_OL_CNT : 2; |
| 403 | } Bits; | 403 | } Bits; |
| 404 | } DRVREG_CTRL5; \ No newline at end of file | 404 | } DRVREG_CTRL5; \ No newline at end of file |
diff --git a/drivers/haptic/haptic.c b/drivers/haptic/haptic.c index a94f05565..ded6d8a44 100644 --- a/drivers/haptic/haptic.c +++ b/drivers/haptic/haptic.c | |||
| @@ -19,230 +19,248 @@ | |||
| 19 | #include "progmem.h" | 19 | #include "progmem.h" |
| 20 | #include "debug.h" | 20 | #include "debug.h" |
| 21 | #ifdef DRV2605L | 21 | #ifdef DRV2605L |
| 22 | #include "DRV2605L.h" | 22 | # include "DRV2605L.h" |
| 23 | #endif | 23 | #endif |
| 24 | #ifdef SOLENOID_ENABLE | 24 | #ifdef SOLENOID_ENABLE |
| 25 | #include "solenoid.h" | 25 | # include "solenoid.h" |
| 26 | #endif | 26 | #endif |
| 27 | 27 | ||
| 28 | haptic_config_t haptic_config; | 28 | haptic_config_t haptic_config; |
| 29 | 29 | ||
| 30 | void haptic_init(void) { | 30 | void haptic_init(void) { |
| 31 | debug_enable = 1; //Debug is ON! | 31 | debug_enable = 1; // Debug is ON! |
| 32 | if (!eeconfig_is_enabled()) { | 32 | if (!eeconfig_is_enabled()) { |
| 33 | eeconfig_init(); | 33 | eeconfig_init(); |
| 34 | } | 34 | } |
| 35 | haptic_config.raw = eeconfig_read_haptic(); | 35 | haptic_config.raw = eeconfig_read_haptic(); |
| 36 | if (haptic_config.mode < 1){ | 36 | if (haptic_config.mode < 1) { |
| 37 | haptic_config.mode = 1; | 37 | haptic_config.mode = 1; |
| 38 | } | 38 | } |
| 39 | if (!haptic_config.mode){ | 39 | if (!haptic_config.mode) { |
| 40 | dprintf("No haptic config found in eeprom, setting default configs\n"); | 40 | dprintf("No haptic config found in eeprom, setting default configs\n"); |
| 41 | haptic_reset(); | 41 | haptic_reset(); |
| 42 | } | 42 | } |
| 43 | #ifdef SOLENOID_ENABLE | 43 | #ifdef SOLENOID_ENABLE |
| 44 | solenoid_setup(); | 44 | solenoid_setup(); |
| 45 | dprintf("Solenoid driver initialized\n"); | 45 | dprintf("Solenoid driver initialized\n"); |
| 46 | #endif | 46 | #endif |
| 47 | #ifdef DRV2605L | 47 | #ifdef DRV2605L |
| 48 | DRV_init(); | 48 | DRV_init(); |
| 49 | dprintf("DRV2605 driver initialized\n"); | 49 | dprintf("DRV2605 driver initialized\n"); |
| 50 | #endif | 50 | #endif |
| 51 | eeconfig_debug_haptic(); | 51 | eeconfig_debug_haptic(); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | void haptic_task(void) { | 54 | void haptic_task(void) { |
| 55 | #ifdef SOLENOID_ENABLE | 55 | #ifdef SOLENOID_ENABLE |
| 56 | solenoid_check(); | 56 | solenoid_check(); |
| 57 | #endif | 57 | #endif |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | void eeconfig_debug_haptic(void) { | 60 | void eeconfig_debug_haptic(void) { |
| 61 | dprintf("haptic_config eprom\n"); | 61 | dprintf("haptic_config eprom\n"); |
| 62 | dprintf("haptic_config.enable = %d\n", haptic_config.enable); | 62 | dprintf("haptic_config.enable = %d\n", haptic_config.enable); |
| 63 | dprintf("haptic_config.mode = %d\n", haptic_config.mode); | 63 | dprintf("haptic_config.mode = %d\n", haptic_config.mode); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | void haptic_enable(void) { | 66 | void haptic_enable(void) { |
| 67 | haptic_config.enable = 1; | 67 | haptic_config.enable = 1; |
| 68 | xprintf("haptic_config.enable = %u\n", haptic_config.enable); | 68 | xprintf("haptic_config.enable = %u\n", haptic_config.enable); |
| 69 | eeconfig_update_haptic(haptic_config.raw); | 69 | eeconfig_update_haptic(haptic_config.raw); |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | void haptic_disable(void) { | 72 | void haptic_disable(void) { |
| 73 | haptic_config.enable = 0; | 73 | haptic_config.enable = 0; |
| 74 | xprintf("haptic_config.enable = %u\n", haptic_config.enable); | 74 | xprintf("haptic_config.enable = %u\n", haptic_config.enable); |
| 75 | eeconfig_update_haptic(haptic_config.raw); | 75 | eeconfig_update_haptic(haptic_config.raw); |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | void haptic_toggle(void) { | 78 | void haptic_toggle(void) { |
| 79 | if (haptic_config.enable) { | 79 | if (haptic_config.enable) { |
| 80 | haptic_disable(); | 80 | haptic_disable(); |
| 81 | } else { | 81 | } else { |
| 82 | haptic_enable(); | 82 | haptic_enable(); |
| 83 | } | 83 | } |
| 84 | eeconfig_update_haptic(haptic_config.raw); | 84 | eeconfig_update_haptic(haptic_config.raw); |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | void haptic_feedback_toggle(void){ | 87 | void haptic_feedback_toggle(void) { |
| 88 | haptic_config.feedback++; | 88 | haptic_config.feedback++; |
| 89 | if (haptic_config.feedback >= HAPTIC_FEEDBACK_MAX) | 89 | if (haptic_config.feedback >= HAPTIC_FEEDBACK_MAX) haptic_config.feedback = KEY_PRESS; |
| 90 | haptic_config.feedback = KEY_PRESS; | 90 | xprintf("haptic_config.feedback = %u\n", !haptic_config.feedback); |
| 91 | xprintf("haptic_config.feedback = %u\n", !haptic_config.feedback); | 91 | eeconfig_update_haptic(haptic_config.raw); |
| 92 | eeconfig_update_haptic(haptic_config.raw); | ||
| 93 | } | 92 | } |
| 94 | 93 | ||
| 95 | void haptic_buzz_toggle(void) { | 94 | void haptic_buzz_toggle(void) { |
| 96 | bool buzz_stat = !haptic_config.buzz; | 95 | bool buzz_stat = !haptic_config.buzz; |
| 97 | haptic_config.buzz = buzz_stat; | 96 | haptic_config.buzz = buzz_stat; |
| 98 | haptic_set_buzz(buzz_stat); | 97 | haptic_set_buzz(buzz_stat); |
| 99 | } | 98 | } |
| 100 | 99 | ||
| 101 | void haptic_mode_increase(void) { | 100 | void haptic_mode_increase(void) { |
| 102 | uint8_t mode = haptic_config.mode + 1; | 101 | uint8_t mode = haptic_config.mode + 1; |
| 103 | #ifdef DRV2605L | 102 | #ifdef DRV2605L |
| 104 | if (haptic_config.mode >= drv_effect_max) { | 103 | if (haptic_config.mode >= drv_effect_max) { |
| 105 | mode = 1; | 104 | mode = 1; |
| 106 | } | 105 | } |
| 107 | #endif | 106 | #endif |
| 108 | haptic_set_mode(mode); | 107 | haptic_set_mode(mode); |
| 109 | } | 108 | } |
| 110 | 109 | ||
| 111 | void haptic_mode_decrease(void) { | 110 | void haptic_mode_decrease(void) { |
| 112 | uint8_t mode = haptic_config.mode -1; | 111 | uint8_t mode = haptic_config.mode - 1; |
| 113 | #ifdef DRV2605L | 112 | #ifdef DRV2605L |
| 114 | if (haptic_config.mode < 1) { | 113 | if (haptic_config.mode < 1) { |
| 115 | mode = (drv_effect_max - 1); | 114 | mode = (drv_effect_max - 1); |
| 116 | } | 115 | } |
| 117 | #endif | 116 | #endif |
| 118 | haptic_set_mode(mode); | 117 | haptic_set_mode(mode); |
| 119 | } | 118 | } |
| 120 | 119 | ||
| 121 | void haptic_dwell_increase(void) { | 120 | void haptic_dwell_increase(void) { |
| 122 | uint8_t dwell = haptic_config.dwell + 1; | 121 | uint8_t dwell = haptic_config.dwell + 1; |
| 123 | #ifdef SOLENOID_ENABLE | 122 | #ifdef SOLENOID_ENABLE |
| 124 | if (haptic_config.dwell >= SOLENOID_MAX_DWELL) { | 123 | if (haptic_config.dwell >= SOLENOID_MAX_DWELL) { |
| 125 | dwell = 1; | 124 | dwell = 1; |
| 126 | } | 125 | } |
| 127 | solenoid_set_dwell(dwell); | 126 | solenoid_set_dwell(dwell); |
| 128 | #endif | 127 | #endif |
| 129 | haptic_set_dwell(dwell); | 128 | haptic_set_dwell(dwell); |
| 130 | } | 129 | } |
| 131 | 130 | ||
| 132 | void haptic_dwell_decrease(void) { | 131 | void haptic_dwell_decrease(void) { |
| 133 | uint8_t dwell = haptic_config.dwell -1; | 132 | uint8_t dwell = haptic_config.dwell - 1; |
| 134 | #ifdef SOLENOID_ENABLE | 133 | #ifdef SOLENOID_ENABLE |
| 135 | if (haptic_config.dwell < SOLENOID_MIN_DWELL) { | 134 | if (haptic_config.dwell < SOLENOID_MIN_DWELL) { |
| 136 | dwell = SOLENOID_MAX_DWELL; | 135 | dwell = SOLENOID_MAX_DWELL; |
| 137 | } | 136 | } |
| 138 | solenoid_set_dwell(dwell); | 137 | solenoid_set_dwell(dwell); |
| 139 | #endif | 138 | #endif |
| 140 | haptic_set_dwell(dwell); | 139 | haptic_set_dwell(dwell); |
| 141 | } | 140 | } |
| 142 | 141 | ||
| 143 | void haptic_reset(void){ | 142 | void haptic_reset(void) { |
| 144 | haptic_config.enable = true; | 143 | haptic_config.enable = true; |
| 145 | uint8_t feedback = HAPTIC_FEEDBACK_DEFAULT; | 144 | uint8_t feedback = HAPTIC_FEEDBACK_DEFAULT; |
| 146 | haptic_config.feedback = feedback; | 145 | haptic_config.feedback = feedback; |
| 147 | #ifdef DRV2605L | 146 | #ifdef DRV2605L |
| 148 | uint8_t mode = HAPTIC_MODE_DEFAULT; | 147 | uint8_t mode = HAPTIC_MODE_DEFAULT; |
| 149 | haptic_config.mode = mode; | 148 | haptic_config.mode = mode; |
| 150 | #endif | 149 | #endif |
| 151 | #ifdef SOLENOID_ENABLE | 150 | #ifdef SOLENOID_ENABLE |
| 152 | uint8_t dwell = SOLENOID_DEFAULT_DWELL; | 151 | uint8_t dwell = SOLENOID_DEFAULT_DWELL; |
| 153 | haptic_config.dwell = dwell; | 152 | haptic_config.dwell = dwell; |
| 154 | #endif | 153 | #endif |
| 155 | eeconfig_update_haptic(haptic_config.raw); | 154 | eeconfig_update_haptic(haptic_config.raw); |
| 156 | xprintf("haptic_config.feedback = %u\n", haptic_config.feedback); | 155 | xprintf("haptic_config.feedback = %u\n", haptic_config.feedback); |
| 157 | xprintf("haptic_config.mode = %u\n", haptic_config.mode); | 156 | xprintf("haptic_config.mode = %u\n", haptic_config.mode); |
| 158 | } | 157 | } |
| 159 | 158 | ||
| 160 | void haptic_set_feedback(uint8_t feedback) { | 159 | void haptic_set_feedback(uint8_t feedback) { |
| 161 | haptic_config.feedback = feedback; | 160 | haptic_config.feedback = feedback; |
| 162 | eeconfig_update_haptic(haptic_config.raw); | 161 | eeconfig_update_haptic(haptic_config.raw); |
| 163 | xprintf("haptic_config.feedback = %u\n", haptic_config.feedback); | 162 | xprintf("haptic_config.feedback = %u\n", haptic_config.feedback); |
| 164 | } | 163 | } |
| 165 | 164 | ||
| 166 | void haptic_set_mode(uint8_t mode) { | 165 | void haptic_set_mode(uint8_t mode) { |
| 167 | haptic_config.mode = mode; | 166 | haptic_config.mode = mode; |
| 168 | eeconfig_update_haptic(haptic_config.raw); | 167 | eeconfig_update_haptic(haptic_config.raw); |
| 169 | xprintf("haptic_config.mode = %u\n", haptic_config.mode); | 168 | xprintf("haptic_config.mode = %u\n", haptic_config.mode); |
| 170 | } | 169 | } |
| 171 | 170 | ||
| 172 | void haptic_set_buzz(uint8_t buzz) { | 171 | void haptic_set_buzz(uint8_t buzz) { |
| 173 | haptic_config.buzz = buzz; | 172 | haptic_config.buzz = buzz; |
| 174 | eeconfig_update_haptic(haptic_config.raw); | 173 | eeconfig_update_haptic(haptic_config.raw); |
| 175 | xprintf("haptic_config.buzz = %u\n", haptic_config.buzz); | 174 | xprintf("haptic_config.buzz = %u\n", haptic_config.buzz); |
| 176 | } | 175 | } |
| 177 | 176 | ||
| 178 | void haptic_set_dwell(uint8_t dwell) { | 177 | void haptic_set_dwell(uint8_t dwell) { |
| 179 | haptic_config.dwell = dwell; | 178 | haptic_config.dwell = dwell; |
| 180 | eeconfig_update_haptic(haptic_config.raw); | 179 | eeconfig_update_haptic(haptic_config.raw); |
| 181 | xprintf("haptic_config.dwell = %u\n", haptic_config.dwell); | 180 | xprintf("haptic_config.dwell = %u\n", haptic_config.dwell); |
| 182 | } | 181 | } |
| 183 | 182 | ||
| 184 | uint8_t haptic_get_mode(void) { | 183 | uint8_t haptic_get_mode(void) { |
| 185 | if (!haptic_config.enable){ | 184 | if (!haptic_config.enable) { |
| 186 | return false; | 185 | return false; |
| 187 | } | 186 | } |
| 188 | return haptic_config.mode; | 187 | return haptic_config.mode; |
| 189 | } | 188 | } |
| 190 | 189 | ||
| 191 | uint8_t haptic_get_feedback(void) { | 190 | uint8_t haptic_get_feedback(void) { |
| 192 | if (!haptic_config.enable){ | 191 | if (!haptic_config.enable) { |
| 193 | return false; | 192 | return false; |
| 194 | } | 193 | } |
| 195 | return haptic_config.feedback; | 194 | return haptic_config.feedback; |
| 196 | } | 195 | } |
| 197 | 196 | ||
| 198 | uint8_t haptic_get_dwell(void) { | 197 | uint8_t haptic_get_dwell(void) { |
| 199 | if (!haptic_config.enable){ | 198 | if (!haptic_config.enable) { |
| 200 | return false; | 199 | return false; |
| 201 | } | 200 | } |
| 202 | return haptic_config.dwell; | 201 | return haptic_config.dwell; |
| 203 | } | 202 | } |
| 204 | 203 | ||
| 205 | void haptic_play(void) { | 204 | void haptic_play(void) { |
| 206 | #ifdef DRV2605L | 205 | #ifdef DRV2605L |
| 207 | uint8_t play_eff = 0; | 206 | uint8_t play_eff = 0; |
| 208 | play_eff = haptic_config.mode; | 207 | play_eff = haptic_config.mode; |
| 209 | DRV_pulse(play_eff); | 208 | DRV_pulse(play_eff); |
| 210 | #endif | 209 | #endif |
| 211 | #ifdef SOLENOID_ENABLE | 210 | #ifdef SOLENOID_ENABLE |
| 212 | solenoid_fire(); | 211 | solenoid_fire(); |
| 213 | #endif | 212 | #endif |
| 214 | } | 213 | } |
| 215 | 214 | ||
| 216 | bool process_haptic(uint16_t keycode, keyrecord_t *record) { | 215 | bool process_haptic(uint16_t keycode, keyrecord_t *record) { |
| 217 | if (keycode == HPT_ON && record->event.pressed) { haptic_enable(); } | 216 | if (keycode == HPT_ON && record->event.pressed) { |
| 218 | if (keycode == HPT_OFF && record->event.pressed) { haptic_disable(); } | 217 | haptic_enable(); |
| 219 | if (keycode == HPT_TOG && record->event.pressed) { haptic_toggle(); } | ||
| 220 | if (keycode == HPT_RST && record->event.pressed) { haptic_reset(); } | ||
| 221 | if (keycode == HPT_FBK && record->event.pressed) { haptic_feedback_toggle(); } | ||
| 222 | if (keycode == HPT_BUZ && record->event.pressed) { haptic_buzz_toggle(); } | ||
| 223 | if (keycode == HPT_MODI && record->event.pressed) { haptic_mode_increase(); } | ||
| 224 | if (keycode == HPT_MODD && record->event.pressed) { haptic_mode_decrease(); } | ||
| 225 | if (keycode == HPT_DWLI && record->event.pressed) { haptic_dwell_increase(); } | ||
| 226 | if (keycode == HPT_DWLD && record->event.pressed) { haptic_dwell_decrease(); } | ||
| 227 | if (haptic_config.enable) { | ||
| 228 | if ( record->event.pressed ) { | ||
| 229 | // keypress | ||
| 230 | if (haptic_config.feedback < 2) { | ||
| 231 | haptic_play(); | ||
| 232 | } | ||
| 233 | } else { | ||
| 234 | //keyrelease | ||
| 235 | if (haptic_config.feedback > 0) { | ||
| 236 | haptic_play(); | ||
| 237 | } | ||
| 238 | } | 218 | } |
| 239 | } | 219 | if (keycode == HPT_OFF && record->event.pressed) { |
| 240 | return true; | 220 | haptic_disable(); |
| 221 | } | ||
| 222 | if (keycode == HPT_TOG && record->event.pressed) { | ||
| 223 | haptic_toggle(); | ||
| 224 | } | ||
| 225 | if (keycode == HPT_RST && record->event.pressed) { | ||
| 226 | haptic_reset(); | ||
| 227 | } | ||
| 228 | if (keycode == HPT_FBK && record->event.pressed) { | ||
| 229 | haptic_feedback_toggle(); | ||
| 230 | } | ||
| 231 | if (keycode == HPT_BUZ && record->event.pressed) { | ||
| 232 | haptic_buzz_toggle(); | ||
| 233 | } | ||
| 234 | if (keycode == HPT_MODI && record->event.pressed) { | ||
| 235 | haptic_mode_increase(); | ||
| 236 | } | ||
| 237 | if (keycode == HPT_MODD && record->event.pressed) { | ||
| 238 | haptic_mode_decrease(); | ||
| 239 | } | ||
| 240 | if (keycode == HPT_DWLI && record->event.pressed) { | ||
| 241 | haptic_dwell_increase(); | ||
| 242 | } | ||
| 243 | if (keycode == HPT_DWLD && record->event.pressed) { | ||
| 244 | haptic_dwell_decrease(); | ||
| 245 | } | ||
| 246 | if (haptic_config.enable) { | ||
| 247 | if (record->event.pressed) { | ||
| 248 | // keypress | ||
| 249 | if (haptic_config.feedback < 2) { | ||
| 250 | haptic_play(); | ||
| 251 | } | ||
| 252 | } else { | ||
| 253 | // keyrelease | ||
| 254 | if (haptic_config.feedback > 0) { | ||
| 255 | haptic_play(); | ||
| 256 | } | ||
| 257 | } | ||
| 258 | } | ||
| 259 | return true; | ||
| 241 | } | 260 | } |
| 242 | 261 | ||
| 243 | void haptic_shutdown(void) { | 262 | void haptic_shutdown(void) { |
| 244 | #ifdef SOLENOID_ENABLE | 263 | #ifdef SOLENOID_ENABLE |
| 245 | solenoid_shutdown(); | 264 | solenoid_shutdown(); |
| 246 | #endif | 265 | #endif |
| 247 | |||
| 248 | } | 266 | } |
diff --git a/drivers/haptic/haptic.h b/drivers/haptic/haptic.h index d39dc5c3b..8135d0d43 100644 --- a/drivers/haptic/haptic.h +++ b/drivers/haptic/haptic.h | |||
| @@ -20,63 +20,57 @@ | |||
| 20 | #include <stdbool.h> | 20 | #include <stdbool.h> |
| 21 | #include "quantum.h" | 21 | #include "quantum.h" |
| 22 | #ifdef DRV2605L | 22 | #ifdef DRV2605L |
| 23 | #include "DRV2605L.h" | 23 | # include "DRV2605L.h" |
| 24 | #endif | 24 | #endif |
| 25 | 25 | ||
| 26 | |||
| 27 | #ifndef HAPTIC_FEEDBACK_DEFAULT | 26 | #ifndef HAPTIC_FEEDBACK_DEFAULT |
| 28 | #define HAPTIC_FEEDBACK_DEFAULT 0 | 27 | # define HAPTIC_FEEDBACK_DEFAULT 0 |
| 29 | #endif | 28 | #endif |
| 30 | #ifndef HAPTIC_MODE_DEFAULT | 29 | #ifndef HAPTIC_MODE_DEFAULT |
| 31 | #define HAPTIC_MODE_DEFAULT DRV_MODE_DEFAULT | 30 | # define HAPTIC_MODE_DEFAULT DRV_MODE_DEFAULT |
| 32 | #endif | 31 | #endif |
| 33 | 32 | ||
| 34 | /* EEPROM config settings */ | 33 | /* EEPROM config settings */ |
| 35 | typedef union { | 34 | typedef union { |
| 36 | uint32_t raw; | 35 | uint32_t raw; |
| 37 | struct { | 36 | struct { |
| 38 | bool enable :1; | 37 | bool enable : 1; |
| 39 | uint8_t feedback :2; | 38 | uint8_t feedback : 2; |
| 40 | uint8_t mode :7; | 39 | uint8_t mode : 7; |
| 41 | bool buzz :1; | 40 | bool buzz : 1; |
| 42 | uint8_t dwell :7; | 41 | uint8_t dwell : 7; |
| 43 | uint16_t reserved :16; | 42 | uint16_t reserved : 16; |
| 44 | }; | 43 | }; |
| 45 | } haptic_config_t; | 44 | } haptic_config_t; |
| 46 | 45 | ||
| 47 | typedef enum HAPTIC_FEEDBACK{ | 46 | typedef enum HAPTIC_FEEDBACK { |
| 48 | KEY_PRESS, | 47 | KEY_PRESS, |
| 49 | KEY_PRESS_RELEASE, | 48 | KEY_PRESS_RELEASE, |
| 50 | KEY_RELEASE, | 49 | KEY_RELEASE, |
| 51 | HAPTIC_FEEDBACK_MAX, | 50 | HAPTIC_FEEDBACK_MAX, |
| 52 | } HAPTIC_FEEDBACK; | 51 | } HAPTIC_FEEDBACK; |
| 53 | 52 | ||
| 54 | bool process_haptic(uint16_t keycode, keyrecord_t *record); | 53 | bool process_haptic(uint16_t keycode, keyrecord_t *record); |
| 55 | void haptic_init(void); | 54 | void haptic_init(void); |
| 56 | void haptic_task(void); | 55 | void haptic_task(void); |
| 57 | void eeconfig_debug_haptic(void); | 56 | void eeconfig_debug_haptic(void); |
| 58 | void haptic_enable(void); | 57 | void haptic_enable(void); |
| 59 | void haptic_disable(void); | 58 | void haptic_disable(void); |
| 60 | void haptic_toggle(void); | 59 | void haptic_toggle(void); |
| 61 | void haptic_feedback_toggle(void); | 60 | void haptic_feedback_toggle(void); |
| 62 | void haptic_mode_increase(void); | 61 | void haptic_mode_increase(void); |
| 63 | void haptic_mode_decrease(void); | 62 | void haptic_mode_decrease(void); |
| 64 | void haptic_mode(uint8_t mode); | 63 | void haptic_mode(uint8_t mode); |
| 65 | void haptic_reset(void); | 64 | void haptic_reset(void); |
| 66 | void haptic_set_feedback(uint8_t feedback); | 65 | void haptic_set_feedback(uint8_t feedback); |
| 67 | void haptic_set_mode(uint8_t mode); | 66 | void haptic_set_mode(uint8_t mode); |
| 68 | void haptic_set_dwell(uint8_t dwell); | 67 | void haptic_set_dwell(uint8_t dwell); |
| 69 | void haptic_set_buzz(uint8_t buzz); | 68 | void haptic_set_buzz(uint8_t buzz); |
| 70 | void haptic_buzz_toggle(void); | 69 | void haptic_buzz_toggle(void); |
| 71 | uint8_t haptic_get_mode(void); | 70 | uint8_t haptic_get_mode(void); |
| 72 | uint8_t haptic_get_feedback(void); | 71 | uint8_t haptic_get_feedback(void); |
| 73 | void haptic_dwell_increase(void); | 72 | void haptic_dwell_increase(void); |
| 74 | void haptic_dwell_decrease(void); | 73 | void haptic_dwell_decrease(void); |
| 75 | 74 | ||
| 76 | void haptic_play(void); | 75 | void haptic_play(void); |
| 77 | void haptic_shutdown(void); | 76 | void haptic_shutdown(void); |
| 78 | |||
| 79 | |||
| 80 | |||
| 81 | |||
| 82 | |||
diff --git a/drivers/haptic/solenoid.c b/drivers/haptic/solenoid.c index 2d39dbc17..d645c379a 100644 --- a/drivers/haptic/solenoid.c +++ b/drivers/haptic/solenoid.c | |||
| @@ -19,91 +19,77 @@ | |||
| 19 | #include "solenoid.h" | 19 | #include "solenoid.h" |
| 20 | #include "haptic.h" | 20 | #include "haptic.h" |
| 21 | 21 | ||
| 22 | bool solenoid_on = false; | 22 | bool solenoid_on = false; |
| 23 | bool solenoid_buzzing = false; | 23 | bool solenoid_buzzing = false; |
| 24 | uint16_t solenoid_start = 0; | 24 | uint16_t solenoid_start = 0; |
| 25 | uint8_t solenoid_dwell = SOLENOID_DEFAULT_DWELL; | 25 | uint8_t solenoid_dwell = SOLENOID_DEFAULT_DWELL; |
| 26 | 26 | ||
| 27 | extern haptic_config_t haptic_config; | 27 | extern haptic_config_t haptic_config; |
| 28 | 28 | ||
| 29 | void solenoid_buzz_on(void) { haptic_set_buzz(1); } | ||
| 29 | 30 | ||
| 30 | void solenoid_buzz_on(void) { | 31 | void solenoid_buzz_off(void) { haptic_set_buzz(0); } |
| 31 | haptic_set_buzz(1); | ||
| 32 | } | ||
| 33 | |||
| 34 | void solenoid_buzz_off(void) { | ||
| 35 | haptic_set_buzz(0); | ||
| 36 | } | ||
| 37 | |||
| 38 | void solenoid_set_buzz(int buzz) { | ||
| 39 | haptic_set_buzz(buzz); | ||
| 40 | } | ||
| 41 | 32 | ||
| 33 | void solenoid_set_buzz(int buzz) { haptic_set_buzz(buzz); } | ||
| 42 | 34 | ||
| 43 | void solenoid_dwell_minus(uint8_t solenoid_dwell) { | 35 | void solenoid_dwell_minus(uint8_t solenoid_dwell) { |
| 44 | if (solenoid_dwell > 0) solenoid_dwell--; | 36 | if (solenoid_dwell > 0) solenoid_dwell--; |
| 45 | } | 37 | } |
| 46 | 38 | ||
| 47 | void solenoid_dwell_plus(uint8_t solenoid_dwell) { | 39 | void solenoid_dwell_plus(uint8_t solenoid_dwell) { |
| 48 | if (solenoid_dwell < SOLENOID_MAX_DWELL) solenoid_dwell++; | 40 | if (solenoid_dwell < SOLENOID_MAX_DWELL) solenoid_dwell++; |
| 49 | } | 41 | } |
| 50 | 42 | ||
| 51 | void solenoid_set_dwell(uint8_t dwell) { | 43 | void solenoid_set_dwell(uint8_t dwell) { solenoid_dwell = dwell; } |
| 52 | solenoid_dwell = dwell; | ||
| 53 | } | ||
| 54 | 44 | ||
| 55 | void solenoid_stop(void) { | 45 | void solenoid_stop(void) { |
| 56 | writePinLow(SOLENOID_PIN); | 46 | writePinLow(SOLENOID_PIN); |
| 57 | solenoid_on = false; | 47 | solenoid_on = false; |
| 58 | solenoid_buzzing = false; | 48 | solenoid_buzzing = false; |
| 59 | } | 49 | } |
| 60 | 50 | ||
| 61 | void solenoid_fire(void) { | 51 | void solenoid_fire(void) { |
| 62 | if (!haptic_config.buzz && solenoid_on) return; | 52 | if (!haptic_config.buzz && solenoid_on) return; |
| 63 | if (haptic_config.buzz && solenoid_buzzing) return; | 53 | if (haptic_config.buzz && solenoid_buzzing) return; |
| 64 | 54 | ||
| 65 | solenoid_on = true; | 55 | solenoid_on = true; |
| 66 | solenoid_buzzing = true; | 56 | solenoid_buzzing = true; |
| 67 | solenoid_start = timer_read(); | 57 | solenoid_start = timer_read(); |
| 68 | writePinHigh(SOLENOID_PIN); | 58 | writePinHigh(SOLENOID_PIN); |
| 69 | } | 59 | } |
| 70 | 60 | ||
| 71 | void solenoid_check(void) { | 61 | void solenoid_check(void) { |
| 72 | uint16_t elapsed = 0; | 62 | uint16_t elapsed = 0; |
| 73 | |||
| 74 | if (!solenoid_on) return; | ||
| 75 | 63 | ||
| 76 | elapsed = timer_elapsed(solenoid_start); | 64 | if (!solenoid_on) return; |
| 77 | 65 | ||
| 78 | //Check if it's time to finish this solenoid click cycle | 66 | elapsed = timer_elapsed(solenoid_start); |
| 79 | if (elapsed > solenoid_dwell) { | ||
| 80 | solenoid_stop(); | ||
| 81 | return; | ||
| 82 | } | ||
| 83 | 67 | ||
| 84 | //Check whether to buzz the solenoid on and off | 68 | // Check if it's time to finish this solenoid click cycle |
| 85 | if (haptic_config.buzz) { | 69 | if (elapsed > solenoid_dwell) { |
| 86 | if (elapsed / SOLENOID_MIN_DWELL % 2 == 0){ | 70 | solenoid_stop(); |
| 87 | if (!solenoid_buzzing) { | 71 | return; |
| 88 | solenoid_buzzing = true; | ||
| 89 | writePinHigh(SOLENOID_PIN); | ||
| 90 | } | ||
| 91 | } | 72 | } |
| 92 | else { | 73 | |
| 93 | if (solenoid_buzzing) { | 74 | // Check whether to buzz the solenoid on and off |
| 94 | solenoid_buzzing = false; | 75 | if (haptic_config.buzz) { |
| 95 | writePinLow(SOLENOID_PIN); | 76 | if (elapsed / SOLENOID_MIN_DWELL % 2 == 0) { |
| 96 | } | 77 | if (!solenoid_buzzing) { |
| 78 | solenoid_buzzing = true; | ||
| 79 | writePinHigh(SOLENOID_PIN); | ||
| 80 | } | ||
| 81 | } else { | ||
| 82 | if (solenoid_buzzing) { | ||
| 83 | solenoid_buzzing = false; | ||
| 84 | writePinLow(SOLENOID_PIN); | ||
| 85 | } | ||
| 86 | } | ||
| 97 | } | 87 | } |
| 98 | } | ||
| 99 | } | 88 | } |
| 100 | 89 | ||
| 101 | void solenoid_setup(void) { | 90 | void solenoid_setup(void) { |
| 102 | setPinOutput(SOLENOID_PIN); | 91 | setPinOutput(SOLENOID_PIN); |
| 103 | solenoid_fire(); | 92 | solenoid_fire(); |
| 104 | } | 93 | } |
| 105 | 94 | ||
| 106 | void solenoid_shutdown(void) { | 95 | void solenoid_shutdown(void) { writePinLow(SOLENOID_PIN); } |
| 107 | writePinLow(SOLENOID_PIN); | ||
| 108 | |||
| 109 | } | ||
diff --git a/drivers/haptic/solenoid.h b/drivers/haptic/solenoid.h index a08f62a11..53dc626e3 100644 --- a/drivers/haptic/solenoid.h +++ b/drivers/haptic/solenoid.h | |||
| @@ -18,23 +18,23 @@ | |||
| 18 | #pragma once | 18 | #pragma once |
| 19 | 19 | ||
| 20 | #ifndef SOLENOID_DEFAULT_DWELL | 20 | #ifndef SOLENOID_DEFAULT_DWELL |
| 21 | #define SOLENOID_DEFAULT_DWELL 12 | 21 | # define SOLENOID_DEFAULT_DWELL 12 |
| 22 | #endif | 22 | #endif |
| 23 | 23 | ||
| 24 | #ifndef SOLENOID_MAX_DWELL | 24 | #ifndef SOLENOID_MAX_DWELL |
| 25 | #define SOLENOID_MAX_DWELL 100 | 25 | # define SOLENOID_MAX_DWELL 100 |
| 26 | #endif | 26 | #endif |
| 27 | 27 | ||
| 28 | #ifndef SOLENOID_MIN_DWELL | 28 | #ifndef SOLENOID_MIN_DWELL |
| 29 | #define SOLENOID_MIN_DWELL 4 | 29 | # define SOLENOID_MIN_DWELL 4 |
| 30 | #endif | 30 | #endif |
| 31 | 31 | ||
| 32 | #ifndef SOLENOID_ACTIVE | 32 | #ifndef SOLENOID_ACTIVE |
| 33 | #define SOLENOID_ACTIVE false | 33 | # define SOLENOID_ACTIVE false |
| 34 | #endif | 34 | #endif |
| 35 | 35 | ||
| 36 | #ifndef SOLENOID_PIN | 36 | #ifndef SOLENOID_PIN |
| 37 | #define SOLENOID_PIN F6 | 37 | # define SOLENOID_PIN F6 |
| 38 | #endif | 38 | #endif |
| 39 | 39 | ||
| 40 | void solenoid_buzz_on(void); | 40 | void solenoid_buzz_on(void); |
diff --git a/drivers/issi/is31fl3218.c b/drivers/issi/is31fl3218.c index db44f7256..d43863ac4 100644 --- a/drivers/issi/is31fl3218.c +++ b/drivers/issi/is31fl3218.c | |||
| @@ -35,68 +35,62 @@ uint8_t g_twi_transfer_buffer[20]; | |||
| 35 | // IS31FL3218 has 18 PWM outputs and a fixed I2C address, so no chaining. | 35 | // IS31FL3218 has 18 PWM outputs and a fixed I2C address, so no chaining. |
| 36 | // If used as RGB LED driver, LEDs are assigned RGB,RGB,RGB,RGB,RGB,RGB | 36 | // If used as RGB LED driver, LEDs are assigned RGB,RGB,RGB,RGB,RGB,RGB |
| 37 | uint8_t g_pwm_buffer[18]; | 37 | uint8_t g_pwm_buffer[18]; |
| 38 | bool g_pwm_buffer_update_required = false; | 38 | bool g_pwm_buffer_update_required = false; |
| 39 | 39 | ||
| 40 | void IS31FL3218_write_register( uint8_t reg, uint8_t data ) | 40 | void IS31FL3218_write_register(uint8_t reg, uint8_t data) { |
| 41 | { | 41 | g_twi_transfer_buffer[0] = reg; |
| 42 | g_twi_transfer_buffer[0] = reg; | 42 | g_twi_transfer_buffer[1] = data; |
| 43 | g_twi_transfer_buffer[1] = data; | 43 | i2c_transmit(ISSI_ADDRESS, g_twi_transfer_buffer, 2, ISSI_TIMEOUT); |
| 44 | i2c_transmit( ISSI_ADDRESS, g_twi_transfer_buffer, 2, ISSI_TIMEOUT); | ||
| 45 | } | 44 | } |
| 46 | 45 | ||
| 47 | void IS31FL3218_write_pwm_buffer( uint8_t *pwm_buffer ) | 46 | void IS31FL3218_write_pwm_buffer(uint8_t *pwm_buffer) { |
| 48 | { | 47 | g_twi_transfer_buffer[0] = ISSI_REG_PWM; |
| 49 | g_twi_transfer_buffer[0] = ISSI_REG_PWM; | 48 | for (int i = 0; i < 18; i++) { |
| 50 | for ( int i=0; i<18; i++ ) { | 49 | g_twi_transfer_buffer[1 + i] = pwm_buffer[i]; |
| 51 | g_twi_transfer_buffer[1+i] = pwm_buffer[i]; | 50 | } |
| 52 | } | 51 | |
| 53 | 52 | i2c_transmit(ISSI_ADDRESS, g_twi_transfer_buffer, 19, ISSI_TIMEOUT); | |
| 54 | i2c_transmit( ISSI_ADDRESS, g_twi_transfer_buffer, 19, ISSI_TIMEOUT); | ||
| 55 | } | 53 | } |
| 56 | 54 | ||
| 57 | void IS31FL3218_init(void) | 55 | void IS31FL3218_init(void) { |
| 58 | { | 56 | // In case we ever want to reinitialize (?) |
| 59 | // In case we ever want to reinitialize (?) | 57 | IS31FL3218_write_register(ISSI_REG_RESET, 0x00); |
| 60 | IS31FL3218_write_register( ISSI_REG_RESET, 0x00 ); | 58 | |
| 61 | 59 | // Turn off software shutdown | |
| 62 | // Turn off software shutdown | 60 | IS31FL3218_write_register(ISSI_REG_SHUTDOWN, 0x01); |
| 63 | IS31FL3218_write_register( ISSI_REG_SHUTDOWN, 0x01 ); | 61 | |
| 64 | 62 | // Set all PWM values to zero | |
| 65 | // Set all PWM values to zero | 63 | for (uint8_t i = 0; i < 18; i++) { |
| 66 | for ( uint8_t i = 0; i < 18; i++ ) { | 64 | IS31FL3218_write_register(ISSI_REG_PWM + i, 0x00); |
| 67 | IS31FL3218_write_register( ISSI_REG_PWM+i, 0x00 ); | 65 | } |
| 68 | } | 66 | |
| 69 | 67 | // Enable all channels | |
| 70 | // Enable all channels | 68 | for (uint8_t i = 0; i < 3; i++) { |
| 71 | for ( uint8_t i = 0; i < 3; i++ ) { | 69 | IS31FL3218_write_register(ISSI_REG_CONTROL + i, 0b00111111); |
| 72 | IS31FL3218_write_register( ISSI_REG_CONTROL+i, 0b00111111 ); | 70 | } |
| 73 | } | 71 | |
| 74 | 72 | // Load PWM registers and LED Control register data | |
| 75 | // Load PWM registers and LED Control register data | 73 | IS31FL3218_write_register(ISSI_REG_UPDATE, 0x01); |
| 76 | IS31FL3218_write_register( ISSI_REG_UPDATE, 0x01 ); | ||
| 77 | } | 74 | } |
| 78 | 75 | ||
| 79 | void IS31FL3218_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ) | 76 | void IS31FL3218_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { |
| 80 | { | 77 | g_pwm_buffer[index * 3 + 0] = red; |
| 81 | g_pwm_buffer[index * 3 + 0] = red; | 78 | g_pwm_buffer[index * 3 + 1] = green; |
| 82 | g_pwm_buffer[index * 3 + 1] = green; | 79 | g_pwm_buffer[index * 3 + 2] = blue; |
| 83 | g_pwm_buffer[index * 3 + 2] = blue; | 80 | g_pwm_buffer_update_required = true; |
| 84 | g_pwm_buffer_update_required = true; | ||
| 85 | } | 81 | } |
| 86 | 82 | ||
| 87 | void IS31FL3218_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) | 83 | void IS31FL3218_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { |
| 88 | { | 84 | for (int i = 0; i < 6; i++) { |
| 89 | for ( int i = 0; i < 6; i++ ) { | 85 | IS31FL3218_set_color(i, red, green, blue); |
| 90 | IS31FL3218_set_color( i, red, green, blue ); | 86 | } |
| 91 | } | ||
| 92 | } | 87 | } |
| 93 | 88 | ||
| 94 | void IS31FL3218_update_pwm_buffers(void) | 89 | void IS31FL3218_update_pwm_buffers(void) { |
| 95 | { | 90 | if (g_pwm_buffer_update_required) { |
| 96 | if ( g_pwm_buffer_update_required ) { | 91 | IS31FL3218_write_pwm_buffer(g_pwm_buffer); |
| 97 | IS31FL3218_write_pwm_buffer( g_pwm_buffer ); | 92 | // Load PWM registers and LED Control register data |
| 98 | // Load PWM registers and LED Control register data | 93 | IS31FL3218_write_register(ISSI_REG_UPDATE, 0x01); |
| 99 | IS31FL3218_write_register( ISSI_REG_UPDATE, 0x01 ); | 94 | } |
| 100 | } | 95 | g_pwm_buffer_update_required = false; |
| 101 | g_pwm_buffer_update_required = false; | ||
| 102 | } | 96 | } |
diff --git a/drivers/issi/is31fl3218.h b/drivers/issi/is31fl3218.h index 2d24e5146..a70cc1e79 100644 --- a/drivers/issi/is31fl3218.h +++ b/drivers/issi/is31fl3218.h | |||
| @@ -19,6 +19,6 @@ | |||
| 19 | #include <stdbool.h> | 19 | #include <stdbool.h> |
| 20 | 20 | ||
| 21 | void IS31FL3218_init(void); | 21 | void IS31FL3218_init(void); |
| 22 | void IS31FL3218_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ); | 22 | void IS31FL3218_set_color(int index, uint8_t red, uint8_t green, uint8_t blue); |
| 23 | void IS31FL3218_set_color_all( uint8_t red, uint8_t green, uint8_t blue ); | 23 | void IS31FL3218_set_color_all(uint8_t red, uint8_t green, uint8_t blue); |
| 24 | void IS31FL3218_update_pwm_buffers(void); | 24 | void IS31FL3218_update_pwm_buffers(void); |
diff --git a/drivers/issi/is31fl3731-simple.c b/drivers/issi/is31fl3731-simple.c index a7faa9c38..fad4676de 100644 --- a/drivers/issi/is31fl3731-simple.c +++ b/drivers/issi/is31fl3731-simple.c | |||
| @@ -17,11 +17,11 @@ | |||
| 17 | */ | 17 | */ |
| 18 | 18 | ||
| 19 | #ifdef __AVR__ | 19 | #ifdef __AVR__ |
| 20 | #include <avr/interrupt.h> | 20 | # include <avr/interrupt.h> |
| 21 | #include <avr/io.h> | 21 | # include <avr/io.h> |
| 22 | #include <util/delay.h> | 22 | # include <util/delay.h> |
| 23 | #else | 23 | #else |
| 24 | #include "wait.h" | 24 | # include "wait.h" |
| 25 | #endif | 25 | #endif |
| 26 | 26 | ||
| 27 | #include <stdint.h> | 27 | #include <stdint.h> |
| @@ -41,7 +41,7 @@ | |||
| 41 | // 0b1110110 AD <-> SDA | 41 | // 0b1110110 AD <-> SDA |
| 42 | #define ISSI_ADDR_DEFAULT 0x74 | 42 | #define ISSI_ADDR_DEFAULT 0x74 |
| 43 | 43 | ||
| 44 | #define ISSI_REG_CONFIG 0x00 | 44 | #define ISSI_REG_CONFIG 0x00 |
| 45 | #define ISSI_REG_CONFIG_PICTUREMODE 0x00 | 45 | #define ISSI_REG_CONFIG_PICTUREMODE 0x00 |
| 46 | #define ISSI_REG_CONFIG_AUTOPLAYMODE 0x08 | 46 | #define ISSI_REG_CONFIG_AUTOPLAYMODE 0x08 |
| 47 | #define ISSI_REG_CONFIG_AUDIOPLAYMODE 0x18 | 47 | #define ISSI_REG_CONFIG_AUDIOPLAYMODE 0x18 |
| @@ -50,20 +50,20 @@ | |||
| 50 | #define ISSI_CONF_AUTOFRAMEMODE 0x04 | 50 | #define ISSI_CONF_AUTOFRAMEMODE 0x04 |
| 51 | #define ISSI_CONF_AUDIOMODE 0x08 | 51 | #define ISSI_CONF_AUDIOMODE 0x08 |
| 52 | 52 | ||
| 53 | #define ISSI_REG_PICTUREFRAME 0x01 | 53 | #define ISSI_REG_PICTUREFRAME 0x01 |
| 54 | 54 | ||
| 55 | #define ISSI_REG_SHUTDOWN 0x0A | 55 | #define ISSI_REG_SHUTDOWN 0x0A |
| 56 | #define ISSI_REG_AUDIOSYNC 0x06 | 56 | #define ISSI_REG_AUDIOSYNC 0x06 |
| 57 | 57 | ||
| 58 | #define ISSI_COMMANDREGISTER 0xFD | 58 | #define ISSI_COMMANDREGISTER 0xFD |
| 59 | #define ISSI_BANK_FUNCTIONREG 0x0B // helpfully called 'page nine' | 59 | #define ISSI_BANK_FUNCTIONREG 0x0B // helpfully called 'page nine' |
| 60 | 60 | ||
| 61 | #ifndef ISSI_TIMEOUT | 61 | #ifndef ISSI_TIMEOUT |
| 62 | #define ISSI_TIMEOUT 100 | 62 | # define ISSI_TIMEOUT 100 |
| 63 | #endif | 63 | #endif |
| 64 | 64 | ||
| 65 | #ifndef ISSI_PERSISTENCE | 65 | #ifndef ISSI_PERSISTENCE |
| 66 | #define ISSI_PERSISTENCE 0 | 66 | # define ISSI_PERSISTENCE 0 |
| 67 | #endif | 67 | #endif |
| 68 | 68 | ||
| 69 | // Transfer buffer for TWITransmitData() | 69 | // Transfer buffer for TWITransmitData() |
| @@ -75,17 +75,17 @@ uint8_t g_twi_transfer_buffer[20]; | |||
| 75 | // buffers and the transfers in IS31FL3731_write_pwm_buffer() but it's | 75 | // buffers and the transfers in IS31FL3731_write_pwm_buffer() but it's |
| 76 | // probably not worth the extra complexity. | 76 | // probably not worth the extra complexity. |
| 77 | uint8_t g_pwm_buffer[LED_DRIVER_COUNT][144]; | 77 | uint8_t g_pwm_buffer[LED_DRIVER_COUNT][144]; |
| 78 | bool g_pwm_buffer_update_required = false; | 78 | bool g_pwm_buffer_update_required = false; |
| 79 | 79 | ||
| 80 | /* There's probably a better way to init this... */ | 80 | /* There's probably a better way to init this... */ |
| 81 | #if LED_DRIVER_COUNT == 1 | 81 | #if LED_DRIVER_COUNT == 1 |
| 82 | uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}}; | 82 | uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}}; |
| 83 | #elif LED_DRIVER_COUNT == 2 | 83 | #elif LED_DRIVER_COUNT == 2 |
| 84 | uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}, {0}}; | 84 | uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}, {0}}; |
| 85 | #elif LED_DRIVER_COUNT == 3 | 85 | #elif LED_DRIVER_COUNT == 3 |
| 86 | uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}, {0}, {0}}; | 86 | uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}, {0}, {0}}; |
| 87 | #elif LED_DRIVER_COUNT == 4 | 87 | #elif LED_DRIVER_COUNT == 4 |
| 88 | uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}, {0}, {0}, {0}}; | 88 | uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}, {0}, {0}, {0}}; |
| 89 | #endif | 89 | #endif |
| 90 | bool g_led_control_registers_update_required = false; | 90 | bool g_led_control_registers_update_required = false; |
| 91 | 91 | ||
| @@ -103,20 +103,19 @@ bool g_led_control_registers_update_required = false; | |||
| 103 | // 0x0E - R17,G15,G14,G13,G12,G11,G10,G09 | 103 | // 0x0E - R17,G15,G14,G13,G12,G11,G10,G09 |
| 104 | // 0x10 - R16,R15,R14,R13,R12,R11,R10,R09 | 104 | // 0x10 - R16,R15,R14,R13,R12,R11,R10,R09 |
| 105 | 105 | ||
| 106 | |||
| 107 | void IS31FL3731_write_register(uint8_t addr, uint8_t reg, uint8_t data) { | 106 | void IS31FL3731_write_register(uint8_t addr, uint8_t reg, uint8_t data) { |
| 108 | g_twi_transfer_buffer[0] = reg; | 107 | g_twi_transfer_buffer[0] = reg; |
| 109 | g_twi_transfer_buffer[1] = data; | 108 | g_twi_transfer_buffer[1] = data; |
| 110 | 109 | ||
| 111 | #if ISSI_PERSISTENCE > 0 | 110 | #if ISSI_PERSISTENCE > 0 |
| 112 | for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) { | 111 | for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) { |
| 113 | if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0) { | 112 | if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0) { |
| 114 | break; | 113 | break; |
| 115 | } | ||
| 116 | } | 114 | } |
| 117 | #else | 115 | } |
| 118 | i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT); | 116 | #else |
| 119 | #endif | 117 | i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT); |
| 118 | #endif | ||
| 120 | } | 119 | } |
| 121 | 120 | ||
| 122 | void IS31FL3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { | 121 | void IS31FL3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { |
| @@ -136,14 +135,13 @@ void IS31FL3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { | |||
| 136 | g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j]; | 135 | g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j]; |
| 137 | } | 136 | } |
| 138 | 137 | ||
| 139 | #if ISSI_PERSISTENCE > 0 | 138 | #if ISSI_PERSISTENCE > 0 |
| 140 | for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) { | 139 | for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) { |
| 141 | if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0) | 140 | if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0) break; |
| 142 | break; | 141 | } |
| 143 | } | 142 | #else |
| 144 | #else | 143 | i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT); |
| 145 | i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT); | 144 | #endif |
| 146 | #endif | ||
| 147 | } | 145 | } |
| 148 | } | 146 | } |
| 149 | 147 | ||
| @@ -196,7 +194,6 @@ void IS31FL3731_init(uint8_t addr) { | |||
| 196 | // most usage after initialization is just writing PWM buffers in bank 0 | 194 | // most usage after initialization is just writing PWM buffers in bank 0 |
| 197 | // as there's not much point in double-buffering | 195 | // as there's not much point in double-buffering |
| 198 | IS31FL3731_write_register(addr, ISSI_COMMANDREGISTER, 0); | 196 | IS31FL3731_write_register(addr, ISSI_COMMANDREGISTER, 0); |
| 199 | |||
| 200 | } | 197 | } |
| 201 | 198 | ||
| 202 | void IS31FL3731_set_value(int index, uint8_t value) { | 199 | void IS31FL3731_set_value(int index, uint8_t value) { |
| @@ -205,7 +202,7 @@ void IS31FL3731_set_value(int index, uint8_t value) { | |||
| 205 | 202 | ||
| 206 | // Subtract 0x24 to get the second index of g_pwm_buffer | 203 | // Subtract 0x24 to get the second index of g_pwm_buffer |
| 207 | g_pwm_buffer[led.driver][led.v - 0x24] = value; | 204 | g_pwm_buffer[led.driver][led.v - 0x24] = value; |
| 208 | g_pwm_buffer_update_required = true; | 205 | g_pwm_buffer_update_required = true; |
| 209 | } | 206 | } |
| 210 | } | 207 | } |
| 211 | 208 | ||
| @@ -216,10 +213,10 @@ void IS31FL3731_set_value_all(uint8_t value) { | |||
| 216 | } | 213 | } |
| 217 | 214 | ||
| 218 | void IS31FL3731_set_led_control_register(uint8_t index, bool value) { | 215 | void IS31FL3731_set_led_control_register(uint8_t index, bool value) { |
| 219 | is31_led led = g_is31_leds[index]; | 216 | is31_led led = g_is31_leds[index]; |
| 220 | 217 | ||
| 221 | uint8_t control_register = (led.v - 0x24) / 8; | 218 | uint8_t control_register = (led.v - 0x24) / 8; |
| 222 | uint8_t bit_value = (led.v - 0x24) % 8; | 219 | uint8_t bit_value = (led.v - 0x24) % 8; |
| 223 | 220 | ||
| 224 | if (value) { | 221 | if (value) { |
| 225 | g_led_control_registers[led.driver][control_register] |= (1 << bit_value); | 222 | g_led_control_registers[led.driver][control_register] |= (1 << bit_value); |
| @@ -239,7 +236,7 @@ void IS31FL3731_update_pwm_buffers(uint8_t addr, uint8_t index) { | |||
| 239 | 236 | ||
| 240 | void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index) { | 237 | void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index) { |
| 241 | if (g_led_control_registers_update_required) { | 238 | if (g_led_control_registers_update_required) { |
| 242 | for (int i=0; i<18; i++) { | 239 | for (int i = 0; i < 18; i++) { |
| 243 | IS31FL3731_write_register(addr, i, g_led_control_registers[index][i]); | 240 | IS31FL3731_write_register(addr, i, g_led_control_registers[index][i]); |
| 244 | } | 241 | } |
| 245 | } | 242 | } |
diff --git a/drivers/issi/is31fl3731-simple.h b/drivers/issi/is31fl3731-simple.h index dbe498281..a223c351e 100644 --- a/drivers/issi/is31fl3731-simple.h +++ b/drivers/issi/is31fl3731-simple.h | |||
| @@ -16,14 +16,12 @@ | |||
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ | 17 | */ |
| 18 | 18 | ||
| 19 | |||
| 20 | #ifndef IS31FL3731_DRIVER_H | 19 | #ifndef IS31FL3731_DRIVER_H |
| 21 | #define IS31FL3731_DRIVER_H | 20 | #define IS31FL3731_DRIVER_H |
| 22 | 21 | ||
| 23 | |||
| 24 | typedef struct is31_led { | 22 | typedef struct is31_led { |
| 25 | uint8_t driver:2; | 23 | uint8_t driver : 2; |
| 26 | uint8_t v; | 24 | uint8_t v; |
| 27 | } __attribute__((packed)) is31_led; | 25 | } __attribute__((packed)) is31_led; |
| 28 | 26 | ||
| 29 | extern const is31_led g_is31_leds[LED_DRIVER_LED_COUNT]; | 27 | extern const is31_led g_is31_leds[LED_DRIVER_LED_COUNT]; |
| @@ -44,16 +42,16 @@ void IS31FL3731_set_led_control_register(uint8_t index, bool value); | |||
| 44 | void IS31FL3731_update_pwm_buffers(uint8_t addr, uint8_t index); | 42 | void IS31FL3731_update_pwm_buffers(uint8_t addr, uint8_t index); |
| 45 | void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index); | 43 | void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index); |
| 46 | 44 | ||
| 47 | #define C1_1 0x24 | 45 | #define C1_1 0x24 |
| 48 | #define C1_2 0x25 | 46 | #define C1_2 0x25 |
| 49 | #define C1_3 0x26 | 47 | #define C1_3 0x26 |
| 50 | #define C1_4 0x27 | 48 | #define C1_4 0x27 |
| 51 | #define C1_5 0x28 | 49 | #define C1_5 0x28 |
| 52 | #define C1_6 0x29 | 50 | #define C1_6 0x29 |
| 53 | #define C1_7 0x2A | 51 | #define C1_7 0x2A |
| 54 | #define C1_8 0x2B | 52 | #define C1_8 0x2B |
| 55 | 53 | ||
| 56 | #define C1_9 0x2C | 54 | #define C1_9 0x2C |
| 57 | #define C1_10 0x2D | 55 | #define C1_10 0x2D |
| 58 | #define C1_11 0x2E | 56 | #define C1_11 0x2E |
| 59 | #define C1_12 0x2F | 57 | #define C1_12 0x2F |
| @@ -62,16 +60,16 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index); | |||
| 62 | #define C1_15 0x32 | 60 | #define C1_15 0x32 |
| 63 | #define C1_16 0x33 | 61 | #define C1_16 0x33 |
| 64 | 62 | ||
| 65 | #define C2_1 0x34 | 63 | #define C2_1 0x34 |
| 66 | #define C2_2 0x35 | 64 | #define C2_2 0x35 |
| 67 | #define C2_3 0x36 | 65 | #define C2_3 0x36 |
| 68 | #define C2_4 0x37 | 66 | #define C2_4 0x37 |
| 69 | #define C2_5 0x38 | 67 | #define C2_5 0x38 |
| 70 | #define C2_6 0x39 | 68 | #define C2_6 0x39 |
| 71 | #define C2_7 0x3A | 69 | #define C2_7 0x3A |
| 72 | #define C2_8 0x3B | 70 | #define C2_8 0x3B |
| 73 | 71 | ||
| 74 | #define C2_9 0x3C | 72 | #define C2_9 0x3C |
| 75 | #define C2_10 0x3D | 73 | #define C2_10 0x3D |
| 76 | #define C2_11 0x3E | 74 | #define C2_11 0x3E |
| 77 | #define C2_12 0x3F | 75 | #define C2_12 0x3F |
| @@ -80,16 +78,16 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index); | |||
| 80 | #define C2_15 0x42 | 78 | #define C2_15 0x42 |
| 81 | #define C2_16 0x43 | 79 | #define C2_16 0x43 |
| 82 | 80 | ||
| 83 | #define C3_1 0x44 | 81 | #define C3_1 0x44 |
| 84 | #define C3_2 0x45 | 82 | #define C3_2 0x45 |
| 85 | #define C3_3 0x46 | 83 | #define C3_3 0x46 |
| 86 | #define C3_4 0x47 | 84 | #define C3_4 0x47 |
| 87 | #define C3_5 0x48 | 85 | #define C3_5 0x48 |
| 88 | #define C3_6 0x49 | 86 | #define C3_6 0x49 |
| 89 | #define C3_7 0x4A | 87 | #define C3_7 0x4A |
| 90 | #define C3_8 0x4B | 88 | #define C3_8 0x4B |
| 91 | 89 | ||
| 92 | #define C3_9 0x4C | 90 | #define C3_9 0x4C |
| 93 | #define C3_10 0x4D | 91 | #define C3_10 0x4D |
| 94 | #define C3_11 0x4E | 92 | #define C3_11 0x4E |
| 95 | #define C3_12 0x4F | 93 | #define C3_12 0x4F |
| @@ -98,16 +96,16 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index); | |||
| 98 | #define C3_15 0x52 | 96 | #define C3_15 0x52 |
| 99 | #define C3_16 0x53 | 97 | #define C3_16 0x53 |
| 100 | 98 | ||
| 101 | #define C4_1 0x54 | 99 | #define C4_1 0x54 |
| 102 | #define C4_2 0x55 | 100 | #define C4_2 0x55 |
| 103 | #define C4_3 0x56 | 101 | #define C4_3 0x56 |
| 104 | #define C4_4 0x57 | 102 | #define C4_4 0x57 |
| 105 | #define C4_5 0x58 | 103 | #define C4_5 0x58 |
| 106 | #define C4_6 0x59 | 104 | #define C4_6 0x59 |
| 107 | #define C4_7 0x5A | 105 | #define C4_7 0x5A |
| 108 | #define C4_8 0x5B | 106 | #define C4_8 0x5B |
| 109 | 107 | ||
| 110 | #define C4_9 0x5C | 108 | #define C4_9 0x5C |
| 111 | #define C4_10 0x5D | 109 | #define C4_10 0x5D |
| 112 | #define C4_11 0x5E | 110 | #define C4_11 0x5E |
| 113 | #define C4_12 0x5F | 111 | #define C4_12 0x5F |
| @@ -116,16 +114,16 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index); | |||
| 116 | #define C4_15 0x62 | 114 | #define C4_15 0x62 |
| 117 | #define C4_16 0x63 | 115 | #define C4_16 0x63 |
| 118 | 116 | ||
| 119 | #define C5_1 0x64 | 117 | #define C5_1 0x64 |
| 120 | #define C5_2 0x65 | 118 | #define C5_2 0x65 |
| 121 | #define C5_3 0x66 | 119 | #define C5_3 0x66 |
| 122 | #define C5_4 0x67 | 120 | #define C5_4 0x67 |
| 123 | #define C5_5 0x68 | 121 | #define C5_5 0x68 |
| 124 | #define C5_6 0x69 | 122 | #define C5_6 0x69 |
| 125 | #define C5_7 0x6A | 123 | #define C5_7 0x6A |
| 126 | #define C5_8 0x6B | 124 | #define C5_8 0x6B |
| 127 | 125 | ||
| 128 | #define C5_9 0x6C | 126 | #define C5_9 0x6C |
| 129 | #define C5_10 0x6D | 127 | #define C5_10 0x6D |
| 130 | #define C5_11 0x6E | 128 | #define C5_11 0x6E |
| 131 | #define C5_12 0x6F | 129 | #define C5_12 0x6F |
| @@ -134,16 +132,16 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index); | |||
| 134 | #define C5_15 0x72 | 132 | #define C5_15 0x72 |
| 135 | #define C5_16 0x73 | 133 | #define C5_16 0x73 |
| 136 | 134 | ||
| 137 | #define C6_1 0x74 | 135 | #define C6_1 0x74 |
| 138 | #define C6_2 0x75 | 136 | #define C6_2 0x75 |
| 139 | #define C6_3 0x76 | 137 | #define C6_3 0x76 |
| 140 | #define C6_4 0x77 | 138 | #define C6_4 0x77 |
| 141 | #define C6_5 0x78 | 139 | #define C6_5 0x78 |
| 142 | #define C6_6 0x79 | 140 | #define C6_6 0x79 |
| 143 | #define C6_7 0x7A | 141 | #define C6_7 0x7A |
| 144 | #define C6_8 0x7B | 142 | #define C6_8 0x7B |
| 145 | 143 | ||
| 146 | #define C6_9 0x7C | 144 | #define C6_9 0x7C |
| 147 | #define C6_10 0x7D | 145 | #define C6_10 0x7D |
| 148 | #define C6_11 0x7E | 146 | #define C6_11 0x7E |
| 149 | #define C6_12 0x7F | 147 | #define C6_12 0x7F |
| @@ -152,16 +150,16 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index); | |||
| 152 | #define C6_15 0x82 | 150 | #define C6_15 0x82 |
| 153 | #define C6_16 0x83 | 151 | #define C6_16 0x83 |
| 154 | 152 | ||
| 155 | #define C7_1 0x84 | 153 | #define C7_1 0x84 |
| 156 | #define C7_2 0x85 | 154 | #define C7_2 0x85 |
| 157 | #define C7_3 0x86 | 155 | #define C7_3 0x86 |
| 158 | #define C7_4 0x87 | 156 | #define C7_4 0x87 |
| 159 | #define C7_5 0x88 | 157 | #define C7_5 0x88 |
| 160 | #define C7_6 0x89 | 158 | #define C7_6 0x89 |
| 161 | #define C7_7 0x8A | 159 | #define C7_7 0x8A |
| 162 | #define C7_8 0x8B | 160 | #define C7_8 0x8B |
| 163 | 161 | ||
| 164 | #define C7_9 0x8C | 162 | #define C7_9 0x8C |
| 165 | #define C7_10 0x8D | 163 | #define C7_10 0x8D |
| 166 | #define C7_11 0x8E | 164 | #define C7_11 0x8E |
| 167 | #define C7_12 0x8F | 165 | #define C7_12 0x8F |
| @@ -170,16 +168,16 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index); | |||
| 170 | #define C7_15 0x92 | 168 | #define C7_15 0x92 |
| 171 | #define C7_16 0x93 | 169 | #define C7_16 0x93 |
| 172 | 170 | ||
| 173 | #define C8_1 0x94 | 171 | #define C8_1 0x94 |
| 174 | #define C8_2 0x95 | 172 | #define C8_2 0x95 |
| 175 | #define C8_3 0x96 | 173 | #define C8_3 0x96 |
| 176 | #define C8_4 0x97 | 174 | #define C8_4 0x97 |
| 177 | #define C8_5 0x98 | 175 | #define C8_5 0x98 |
| 178 | #define C8_6 0x99 | 176 | #define C8_6 0x99 |
| 179 | #define C8_7 0x9A | 177 | #define C8_7 0x9A |
| 180 | #define C8_8 0x9B | 178 | #define C8_8 0x9B |
| 181 | 179 | ||
| 182 | #define C8_9 0x9C | 180 | #define C8_9 0x9C |
| 183 | #define C8_10 0x9D | 181 | #define C8_10 0x9D |
| 184 | #define C8_11 0x9E | 182 | #define C8_11 0x9E |
| 185 | #define C8_12 0x9F | 183 | #define C8_12 0x9F |
| @@ -188,16 +186,16 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index); | |||
| 188 | #define C8_15 0xA2 | 186 | #define C8_15 0xA2 |
| 189 | #define C8_16 0xA3 | 187 | #define C8_16 0xA3 |
| 190 | 188 | ||
| 191 | #define C9_1 0xA4 | 189 | #define C9_1 0xA4 |
| 192 | #define C9_2 0xA5 | 190 | #define C9_2 0xA5 |
| 193 | #define C9_3 0xA6 | 191 | #define C9_3 0xA6 |
| 194 | #define C9_4 0xA7 | 192 | #define C9_4 0xA7 |
| 195 | #define C9_5 0xA8 | 193 | #define C9_5 0xA8 |
| 196 | #define C9_6 0xA9 | 194 | #define C9_6 0xA9 |
| 197 | #define C9_7 0xAA | 195 | #define C9_7 0xAA |
| 198 | #define C9_8 0xAB | 196 | #define C9_8 0xAB |
| 199 | 197 | ||
| 200 | #define C9_9 0xAC | 198 | #define C9_9 0xAC |
| 201 | #define C9_10 0xAD | 199 | #define C9_10 0xAD |
| 202 | #define C9_11 0xAE | 200 | #define C9_11 0xAE |
| 203 | #define C9_12 0xAF | 201 | #define C9_12 0xAF |
| @@ -206,5 +204,4 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index); | |||
| 206 | #define C9_15 0xB2 | 204 | #define C9_15 0xB2 |
| 207 | #define C9_16 0xB3 | 205 | #define C9_16 0xB3 |
| 208 | 206 | ||
| 209 | 207 | #endif // IS31FL3731_DRIVER_H | |
| 210 | #endif // IS31FL3731_DRIVER_H | ||
diff --git a/drivers/issi/is31fl3731.c b/drivers/issi/is31fl3731.c index 30c7dd053..0b6f3e985 100644 --- a/drivers/issi/is31fl3731.c +++ b/drivers/issi/is31fl3731.c | |||
| @@ -16,11 +16,11 @@ | |||
| 16 | */ | 16 | */ |
| 17 | 17 | ||
| 18 | #ifdef __AVR__ | 18 | #ifdef __AVR__ |
| 19 | #include <avr/interrupt.h> | 19 | # include <avr/interrupt.h> |
| 20 | #include <avr/io.h> | 20 | # include <avr/io.h> |
| 21 | #include <util/delay.h> | 21 | # include <util/delay.h> |
| 22 | #else | 22 | #else |
| 23 | #include "wait.h" | 23 | # include "wait.h" |
| 24 | #endif | 24 | #endif |
| 25 | 25 | ||
| 26 | #include "is31fl3731.h" | 26 | #include "is31fl3731.h" |
| @@ -37,7 +37,7 @@ | |||
| 37 | // 0b1110110 AD <-> SDA | 37 | // 0b1110110 AD <-> SDA |
| 38 | #define ISSI_ADDR_DEFAULT 0x74 | 38 | #define ISSI_ADDR_DEFAULT 0x74 |
| 39 | 39 | ||
| 40 | #define ISSI_REG_CONFIG 0x00 | 40 | #define ISSI_REG_CONFIG 0x00 |
| 41 | #define ISSI_REG_CONFIG_PICTUREMODE 0x00 | 41 | #define ISSI_REG_CONFIG_PICTUREMODE 0x00 |
| 42 | #define ISSI_REG_CONFIG_AUTOPLAYMODE 0x08 | 42 | #define ISSI_REG_CONFIG_AUTOPLAYMODE 0x08 |
| 43 | #define ISSI_REG_CONFIG_AUDIOPLAYMODE 0x18 | 43 | #define ISSI_REG_CONFIG_AUDIOPLAYMODE 0x18 |
| @@ -46,20 +46,20 @@ | |||
| 46 | #define ISSI_CONF_AUTOFRAMEMODE 0x04 | 46 | #define ISSI_CONF_AUTOFRAMEMODE 0x04 |
| 47 | #define ISSI_CONF_AUDIOMODE 0x08 | 47 | #define ISSI_CONF_AUDIOMODE 0x08 |
| 48 | 48 | ||
| 49 | #define ISSI_REG_PICTUREFRAME 0x01 | 49 | #define ISSI_REG_PICTUREFRAME 0x01 |
| 50 | 50 | ||
| 51 | #define ISSI_REG_SHUTDOWN 0x0A | 51 | #define ISSI_REG_SHUTDOWN 0x0A |
| 52 | #define ISSI_REG_AUDIOSYNC 0x06 | 52 | #define ISSI_REG_AUDIOSYNC 0x06 |
| 53 | 53 | ||
| 54 | #define ISSI_COMMANDREGISTER 0xFD | 54 | #define ISSI_COMMANDREGISTER 0xFD |
| 55 | #define ISSI_BANK_FUNCTIONREG 0x0B // helpfully called 'page nine' | 55 | #define ISSI_BANK_FUNCTIONREG 0x0B // helpfully called 'page nine' |
| 56 | 56 | ||
| 57 | #ifndef ISSI_TIMEOUT | 57 | #ifndef ISSI_TIMEOUT |
| 58 | #define ISSI_TIMEOUT 100 | 58 | # define ISSI_TIMEOUT 100 |
| 59 | #endif | 59 | #endif |
| 60 | 60 | ||
| 61 | #ifndef ISSI_PERSISTENCE | 61 | #ifndef ISSI_PERSISTENCE |
| 62 | #define ISSI_PERSISTENCE 0 | 62 | # define ISSI_PERSISTENCE 0 |
| 63 | #endif | 63 | #endif |
| 64 | 64 | ||
| 65 | // Transfer buffer for TWITransmitData() | 65 | // Transfer buffer for TWITransmitData() |
| @@ -71,10 +71,10 @@ uint8_t g_twi_transfer_buffer[20]; | |||
| 71 | // buffers and the transfers in IS31FL3731_write_pwm_buffer() but it's | 71 | // buffers and the transfers in IS31FL3731_write_pwm_buffer() but it's |
| 72 | // probably not worth the extra complexity. | 72 | // probably not worth the extra complexity. |
| 73 | uint8_t g_pwm_buffer[DRIVER_COUNT][144]; | 73 | uint8_t g_pwm_buffer[DRIVER_COUNT][144]; |
| 74 | bool g_pwm_buffer_update_required[DRIVER_COUNT] = { false }; | 74 | bool g_pwm_buffer_update_required[DRIVER_COUNT] = {false}; |
| 75 | 75 | ||
| 76 | uint8_t g_led_control_registers[DRIVER_COUNT][18] = { { 0 }, { 0 } }; | 76 | uint8_t g_led_control_registers[DRIVER_COUNT][18] = {{0}, {0}}; |
| 77 | bool g_led_control_registers_update_required[DRIVER_COUNT] = { false }; | 77 | bool g_led_control_registers_update_required[DRIVER_COUNT] = {false}; |
| 78 | 78 | ||
| 79 | // This is the bit pattern in the LED control registers | 79 | // This is the bit pattern in the LED control registers |
| 80 | // (for matrix A, add one to register for matrix B) | 80 | // (for matrix A, add one to register for matrix B) |
| @@ -90,179 +90,159 @@ bool g_led_control_registers_update_required[DRIVER_COUNT] = { false }; | |||
| 90 | // 0x0E - R17,G15,G14,G13,G12,G11,G10,G09 | 90 | // 0x0E - R17,G15,G14,G13,G12,G11,G10,G09 |
| 91 | // 0x10 - R16,R15,R14,R13,R12,R11,R10,R09 | 91 | // 0x10 - R16,R15,R14,R13,R12,R11,R10,R09 |
| 92 | 92 | ||
| 93 | 93 | void IS31FL3731_write_register(uint8_t addr, uint8_t reg, uint8_t data) { | |
| 94 | void IS31FL3731_write_register( uint8_t addr, uint8_t reg, uint8_t data ) | ||
| 95 | { | ||
| 96 | g_twi_transfer_buffer[0] = reg; | 94 | g_twi_transfer_buffer[0] = reg; |
| 97 | g_twi_transfer_buffer[1] = data; | 95 | g_twi_transfer_buffer[1] = data; |
| 98 | 96 | ||
| 99 | #if ISSI_PERSISTENCE > 0 | 97 | #if ISSI_PERSISTENCE > 0 |
| 100 | for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) { | 98 | for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) { |
| 101 | if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0) | 99 | if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0) break; |
| 102 | break; | ||
| 103 | } | 100 | } |
| 104 | #else | 101 | #else |
| 105 | i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT); | 102 | i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT); |
| 106 | #endif | 103 | #endif |
| 107 | } | 104 | } |
| 108 | 105 | ||
| 109 | void IS31FL3731_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer ) | 106 | void IS31FL3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { |
| 110 | { | ||
| 111 | // assumes bank is already selected | 107 | // assumes bank is already selected |
| 112 | 108 | ||
| 113 | // transmit PWM registers in 9 transfers of 16 bytes | 109 | // transmit PWM registers in 9 transfers of 16 bytes |
| 114 | // g_twi_transfer_buffer[] is 20 bytes | 110 | // g_twi_transfer_buffer[] is 20 bytes |
| 115 | 111 | ||
| 116 | // iterate over the pwm_buffer contents at 16 byte intervals | 112 | // iterate over the pwm_buffer contents at 16 byte intervals |
| 117 | for ( int i = 0; i < 144; i += 16 ) { | 113 | for (int i = 0; i < 144; i += 16) { |
| 118 | // set the first register, e.g. 0x24, 0x34, 0x44, etc. | 114 | // set the first register, e.g. 0x24, 0x34, 0x44, etc. |
| 119 | g_twi_transfer_buffer[0] = 0x24 + i; | 115 | g_twi_transfer_buffer[0] = 0x24 + i; |
| 120 | // copy the data from i to i+15 | 116 | // copy the data from i to i+15 |
| 121 | // device will auto-increment register for data after the first byte | 117 | // device will auto-increment register for data after the first byte |
| 122 | // thus this sets registers 0x24-0x33, 0x34-0x43, etc. in one transfer | 118 | // thus this sets registers 0x24-0x33, 0x34-0x43, etc. in one transfer |
| 123 | for ( int j = 0; j < 16; j++ ) { | 119 | for (int j = 0; j < 16; j++) { |
| 124 | g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j]; | 120 | g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j]; |
| 125 | } | 121 | } |
| 126 | 122 | ||
| 127 | #if ISSI_PERSISTENCE > 0 | 123 | #if ISSI_PERSISTENCE > 0 |
| 128 | for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) { | 124 | for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) { |
| 129 | if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0) | 125 | if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0) break; |
| 130 | break; | 126 | } |
| 131 | } | 127 | #else |
| 132 | #else | 128 | i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT); |
| 133 | i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT); | 129 | #endif |
| 134 | #endif | ||
| 135 | } | 130 | } |
| 136 | } | 131 | } |
| 137 | 132 | ||
| 138 | void IS31FL3731_init( uint8_t addr ) | 133 | void IS31FL3731_init(uint8_t addr) { |
| 139 | { | ||
| 140 | // In order to avoid the LEDs being driven with garbage data | 134 | // In order to avoid the LEDs being driven with garbage data |
| 141 | // in the LED driver's PWM registers, first enable software shutdown, | 135 | // in the LED driver's PWM registers, first enable software shutdown, |
| 142 | // then set up the mode and other settings, clear the PWM registers, | 136 | // then set up the mode and other settings, clear the PWM registers, |
| 143 | // then disable software shutdown. | 137 | // then disable software shutdown. |
| 144 | 138 | ||
| 145 | // select "function register" bank | 139 | // select "function register" bank |
| 146 | IS31FL3731_write_register( addr, ISSI_COMMANDREGISTER, ISSI_BANK_FUNCTIONREG ); | 140 | IS31FL3731_write_register(addr, ISSI_COMMANDREGISTER, ISSI_BANK_FUNCTIONREG); |
| 147 | 141 | ||
| 148 | // enable software shutdown | 142 | // enable software shutdown |
| 149 | IS31FL3731_write_register( addr, ISSI_REG_SHUTDOWN, 0x00 ); | 143 | IS31FL3731_write_register(addr, ISSI_REG_SHUTDOWN, 0x00); |
| 150 | // this delay was copied from other drivers, might not be needed | 144 | // this delay was copied from other drivers, might not be needed |
| 151 | #ifdef __AVR__ | 145 | #ifdef __AVR__ |
| 152 | _delay_ms( 10 ); | 146 | _delay_ms(10); |
| 153 | #else | 147 | #else |
| 154 | wait_ms(10); | 148 | wait_ms(10); |
| 155 | #endif | 149 | #endif |
| 156 | 150 | ||
| 157 | // picture mode | 151 | // picture mode |
| 158 | IS31FL3731_write_register( addr, ISSI_REG_CONFIG, ISSI_REG_CONFIG_PICTUREMODE ); | 152 | IS31FL3731_write_register(addr, ISSI_REG_CONFIG, ISSI_REG_CONFIG_PICTUREMODE); |
| 159 | // display frame 0 | 153 | // display frame 0 |
| 160 | IS31FL3731_write_register( addr, ISSI_REG_PICTUREFRAME, 0x00 ); | 154 | IS31FL3731_write_register(addr, ISSI_REG_PICTUREFRAME, 0x00); |
| 161 | // audio sync off | 155 | // audio sync off |
| 162 | IS31FL3731_write_register( addr, ISSI_REG_AUDIOSYNC, 0x00 ); | 156 | IS31FL3731_write_register(addr, ISSI_REG_AUDIOSYNC, 0x00); |
| 163 | 157 | ||
| 164 | // select bank 0 | 158 | // select bank 0 |
| 165 | IS31FL3731_write_register( addr, ISSI_COMMANDREGISTER, 0 ); | 159 | IS31FL3731_write_register(addr, ISSI_COMMANDREGISTER, 0); |
| 166 | 160 | ||
| 167 | // turn off all LEDs in the LED control register | 161 | // turn off all LEDs in the LED control register |
| 168 | for ( int i = 0x00; i <= 0x11; i++ ) | 162 | for (int i = 0x00; i <= 0x11; i++) { |
| 169 | { | 163 | IS31FL3731_write_register(addr, i, 0x00); |
| 170 | IS31FL3731_write_register( addr, i, 0x00 ); | ||
| 171 | } | 164 | } |
| 172 | 165 | ||
| 173 | // turn off all LEDs in the blink control register (not really needed) | 166 | // turn off all LEDs in the blink control register (not really needed) |
| 174 | for ( int i = 0x12; i <= 0x23; i++ ) | 167 | for (int i = 0x12; i <= 0x23; i++) { |
| 175 | { | 168 | IS31FL3731_write_register(addr, i, 0x00); |
| 176 | IS31FL3731_write_register( addr, i, 0x00 ); | ||
| 177 | } | 169 | } |
| 178 | 170 | ||
| 179 | // set PWM on all LEDs to 0 | 171 | // set PWM on all LEDs to 0 |
| 180 | for ( int i = 0x24; i <= 0xB3; i++ ) | 172 | for (int i = 0x24; i <= 0xB3; i++) { |
| 181 | { | 173 | IS31FL3731_write_register(addr, i, 0x00); |
| 182 | IS31FL3731_write_register( addr, i, 0x00 ); | ||
| 183 | } | 174 | } |
| 184 | 175 | ||
| 185 | // select "function register" bank | 176 | // select "function register" bank |
| 186 | IS31FL3731_write_register( addr, ISSI_COMMANDREGISTER, ISSI_BANK_FUNCTIONREG ); | 177 | IS31FL3731_write_register(addr, ISSI_COMMANDREGISTER, ISSI_BANK_FUNCTIONREG); |
| 187 | 178 | ||
| 188 | // disable software shutdown | 179 | // disable software shutdown |
| 189 | IS31FL3731_write_register( addr, ISSI_REG_SHUTDOWN, 0x01 ); | 180 | IS31FL3731_write_register(addr, ISSI_REG_SHUTDOWN, 0x01); |
| 190 | 181 | ||
| 191 | // select bank 0 and leave it selected. | 182 | // select bank 0 and leave it selected. |
| 192 | // most usage after initialization is just writing PWM buffers in bank 0 | 183 | // most usage after initialization is just writing PWM buffers in bank 0 |
| 193 | // as there's not much point in double-buffering | 184 | // as there's not much point in double-buffering |
| 194 | IS31FL3731_write_register( addr, ISSI_COMMANDREGISTER, 0 ); | 185 | IS31FL3731_write_register(addr, ISSI_COMMANDREGISTER, 0); |
| 195 | |||
| 196 | } | 186 | } |
| 197 | 187 | ||
| 198 | void IS31FL3731_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ) | 188 | void IS31FL3731_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { |
| 199 | { | 189 | if (index >= 0 && index < DRIVER_LED_TOTAL) { |
| 200 | if ( index >= 0 && index < DRIVER_LED_TOTAL ) { | ||
| 201 | is31_led led = g_is31_leds[index]; | 190 | is31_led led = g_is31_leds[index]; |
| 202 | 191 | ||
| 203 | // Subtract 0x24 to get the second index of g_pwm_buffer | 192 | // Subtract 0x24 to get the second index of g_pwm_buffer |
| 204 | g_pwm_buffer[led.driver][led.r - 0x24] = red; | 193 | g_pwm_buffer[led.driver][led.r - 0x24] = red; |
| 205 | g_pwm_buffer[led.driver][led.g - 0x24] = green; | 194 | g_pwm_buffer[led.driver][led.g - 0x24] = green; |
| 206 | g_pwm_buffer[led.driver][led.b - 0x24] = blue; | 195 | g_pwm_buffer[led.driver][led.b - 0x24] = blue; |
| 207 | g_pwm_buffer_update_required[led.driver] = true; | 196 | g_pwm_buffer_update_required[led.driver] = true; |
| 208 | } | 197 | } |
| 209 | } | 198 | } |
| 210 | 199 | ||
| 211 | void IS31FL3731_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) | 200 | void IS31FL3731_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { |
| 212 | { | 201 | for (int i = 0; i < DRIVER_LED_TOTAL; i++) { |
| 213 | for ( int i = 0; i < DRIVER_LED_TOTAL; i++ ) | 202 | IS31FL3731_set_color(i, red, green, blue); |
| 214 | { | ||
| 215 | IS31FL3731_set_color( i, red, green, blue ); | ||
| 216 | } | 203 | } |
| 217 | } | 204 | } |
| 218 | 205 | ||
| 219 | void IS31FL3731_set_led_control_register( uint8_t index, bool red, bool green, bool blue ) | 206 | void IS31FL3731_set_led_control_register(uint8_t index, bool red, bool green, bool blue) { |
| 220 | { | ||
| 221 | is31_led led = g_is31_leds[index]; | 207 | is31_led led = g_is31_leds[index]; |
| 222 | 208 | ||
| 223 | uint8_t control_register_r = (led.r - 0x24) / 8; | 209 | uint8_t control_register_r = (led.r - 0x24) / 8; |
| 224 | uint8_t control_register_g = (led.g - 0x24) / 8; | 210 | uint8_t control_register_g = (led.g - 0x24) / 8; |
| 225 | uint8_t control_register_b = (led.b - 0x24) / 8; | 211 | uint8_t control_register_b = (led.b - 0x24) / 8; |
| 226 | uint8_t bit_r = (led.r - 0x24) % 8; | 212 | uint8_t bit_r = (led.r - 0x24) % 8; |
| 227 | uint8_t bit_g = (led.g - 0x24) % 8; | 213 | uint8_t bit_g = (led.g - 0x24) % 8; |
| 228 | uint8_t bit_b = (led.b - 0x24) % 8; | 214 | uint8_t bit_b = (led.b - 0x24) % 8; |
| 229 | 215 | ||
| 230 | if ( red ) { | 216 | if (red) { |
| 231 | g_led_control_registers[led.driver][control_register_r] |= (1 << bit_r); | 217 | g_led_control_registers[led.driver][control_register_r] |= (1 << bit_r); |
| 232 | } else { | 218 | } else { |
| 233 | g_led_control_registers[led.driver][control_register_r] &= ~(1 << bit_r); | 219 | g_led_control_registers[led.driver][control_register_r] &= ~(1 << bit_r); |
| 234 | } | 220 | } |
| 235 | if ( green ) { | 221 | if (green) { |
| 236 | g_led_control_registers[led.driver][control_register_g] |= (1 << bit_g); | 222 | g_led_control_registers[led.driver][control_register_g] |= (1 << bit_g); |
| 237 | } else { | 223 | } else { |
| 238 | g_led_control_registers[led.driver][control_register_g] &= ~(1 << bit_g); | 224 | g_led_control_registers[led.driver][control_register_g] &= ~(1 << bit_g); |
| 239 | } | 225 | } |
| 240 | if ( blue ) { | 226 | if (blue) { |
| 241 | g_led_control_registers[led.driver][control_register_b] |= (1 << bit_b); | 227 | g_led_control_registers[led.driver][control_register_b] |= (1 << bit_b); |
| 242 | } else { | 228 | } else { |
| 243 | g_led_control_registers[led.driver][control_register_b] &= ~(1 << bit_b); | 229 | g_led_control_registers[led.driver][control_register_b] &= ~(1 << bit_b); |
| 244 | } | 230 | } |
| 245 | 231 | ||
| 246 | g_led_control_registers_update_required[led.driver] = true; | 232 | g_led_control_registers_update_required[led.driver] = true; |
| 247 | |||
| 248 | } | 233 | } |
| 249 | 234 | ||
| 250 | void IS31FL3731_update_pwm_buffers( uint8_t addr, uint8_t index ) | 235 | void IS31FL3731_update_pwm_buffers(uint8_t addr, uint8_t index) { |
| 251 | { | 236 | if (g_pwm_buffer_update_required[index]) { |
| 252 | if ( g_pwm_buffer_update_required[index] ) | 237 | IS31FL3731_write_pwm_buffer(addr, g_pwm_buffer[index]); |
| 253 | { | ||
| 254 | IS31FL3731_write_pwm_buffer( addr, g_pwm_buffer[index] ); | ||
| 255 | } | 238 | } |
| 256 | g_pwm_buffer_update_required[index] = false; | 239 | g_pwm_buffer_update_required[index] = false; |
| 257 | } | 240 | } |
| 258 | 241 | ||
| 259 | void IS31FL3731_update_led_control_registers( uint8_t addr, uint8_t index ) | 242 | void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index) { |
| 260 | { | 243 | if (g_led_control_registers_update_required[index]) { |
| 261 | if ( g_led_control_registers_update_required[index] ) | 244 | for (int i = 0; i < 18; i++) { |
| 262 | { | 245 | IS31FL3731_write_register(addr, i, g_led_control_registers[index][i]); |
| 263 | for ( int i=0; i<18; i++ ) | ||
| 264 | { | ||
| 265 | IS31FL3731_write_register( addr, i, g_led_control_registers[index][i] ); | ||
| 266 | } | 246 | } |
| 267 | } | 247 | } |
| 268 | } | 248 | } |
diff --git a/drivers/issi/is31fl3731.h b/drivers/issi/is31fl3731.h index 968638f86..6a7a45d8f 100644 --- a/drivers/issi/is31fl3731.h +++ b/drivers/issi/is31fl3731.h | |||
| @@ -15,7 +15,6 @@ | |||
| 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ | 16 | */ |
| 17 | 17 | ||
| 18 | |||
| 19 | #ifndef IS31FL3731_DRIVER_H | 18 | #ifndef IS31FL3731_DRIVER_H |
| 20 | #define IS31FL3731_DRIVER_H | 19 | #define IS31FL3731_DRIVER_H |
| 21 | 20 | ||
| @@ -23,40 +22,40 @@ | |||
| 23 | #include <stdbool.h> | 22 | #include <stdbool.h> |
| 24 | 23 | ||
| 25 | typedef struct is31_led { | 24 | typedef struct is31_led { |
| 26 | uint8_t driver:2; | 25 | uint8_t driver : 2; |
| 27 | uint8_t r; | 26 | uint8_t r; |
| 28 | uint8_t g; | 27 | uint8_t g; |
| 29 | uint8_t b; | 28 | uint8_t b; |
| 30 | } __attribute__((packed)) is31_led; | 29 | } __attribute__((packed)) is31_led; |
| 31 | 30 | ||
| 32 | extern const is31_led g_is31_leds[DRIVER_LED_TOTAL]; | 31 | extern const is31_led g_is31_leds[DRIVER_LED_TOTAL]; |
| 33 | 32 | ||
| 34 | void IS31FL3731_init( uint8_t addr ); | 33 | void IS31FL3731_init(uint8_t addr); |
| 35 | void IS31FL3731_write_register( uint8_t addr, uint8_t reg, uint8_t data ); | 34 | void IS31FL3731_write_register(uint8_t addr, uint8_t reg, uint8_t data); |
| 36 | void IS31FL3731_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer ); | 35 | void IS31FL3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer); |
| 37 | 36 | ||
| 38 | void IS31FL3731_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ); | 37 | void IS31FL3731_set_color(int index, uint8_t red, uint8_t green, uint8_t blue); |
| 39 | void IS31FL3731_set_color_all( uint8_t red, uint8_t green, uint8_t blue ); | 38 | void IS31FL3731_set_color_all(uint8_t red, uint8_t green, uint8_t blue); |
| 40 | 39 | ||
| 41 | void IS31FL3731_set_led_control_register( uint8_t index, bool red, bool green, bool blue ); | 40 | void IS31FL3731_set_led_control_register(uint8_t index, bool red, bool green, bool blue); |
| 42 | 41 | ||
| 43 | // This should not be called from an interrupt | 42 | // This should not be called from an interrupt |
| 44 | // (eg. from a timer interrupt). | 43 | // (eg. from a timer interrupt). |
| 45 | // Call this while idle (in between matrix scans). | 44 | // Call this while idle (in between matrix scans). |
| 46 | // If the buffer is dirty, it will update the driver with the buffer. | 45 | // If the buffer is dirty, it will update the driver with the buffer. |
| 47 | void IS31FL3731_update_pwm_buffers( uint8_t addr, uint8_t index ); | 46 | void IS31FL3731_update_pwm_buffers(uint8_t addr, uint8_t index); |
| 48 | void IS31FL3731_update_led_control_registers( uint8_t addr, uint8_t index ); | 47 | void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index); |
| 49 | 48 | ||
| 50 | #define C1_1 0x24 | 49 | #define C1_1 0x24 |
| 51 | #define C1_2 0x25 | 50 | #define C1_2 0x25 |
| 52 | #define C1_3 0x26 | 51 | #define C1_3 0x26 |
| 53 | #define C1_4 0x27 | 52 | #define C1_4 0x27 |
| 54 | #define C1_5 0x28 | 53 | #define C1_5 0x28 |
| 55 | #define C1_6 0x29 | 54 | #define C1_6 0x29 |
| 56 | #define C1_7 0x2A | 55 | #define C1_7 0x2A |
| 57 | #define C1_8 0x2B | 56 | #define C1_8 0x2B |
| 58 | 57 | ||
| 59 | #define C1_9 0x2C | 58 | #define C1_9 0x2C |
| 60 | #define C1_10 0x2D | 59 | #define C1_10 0x2D |
| 61 | #define C1_11 0x2E | 60 | #define C1_11 0x2E |
| 62 | #define C1_12 0x2F | 61 | #define C1_12 0x2F |
| @@ -65,16 +64,16 @@ void IS31FL3731_update_led_control_registers( uint8_t addr, uint8_t index ); | |||
| 65 | #define C1_15 0x32 | 64 | #define C1_15 0x32 |
| 66 | #define C1_16 0x33 | 65 | #define C1_16 0x33 |
| 67 | 66 | ||
| 68 | #define C2_1 0x34 | 67 | #define C2_1 0x34 |
| 69 | #define C2_2 0x35 | 68 | #define C2_2 0x35 |
| 70 | #define C2_3 0x36 | 69 | #define C2_3 0x36 |
| 71 | #define C2_4 0x37 | 70 | #define C2_4 0x37 |
| 72 | #define C2_5 0x38 | 71 | #define C2_5 0x38 |
| 73 | #define C2_6 0x39 | 72 | #define C2_6 0x39 |
| 74 | #define C2_7 0x3A | 73 | #define C2_7 0x3A |
| 75 | #define C2_8 0x3B | 74 | #define C2_8 0x3B |
| 76 | 75 | ||
| 77 | #define C2_9 0x3C | 76 | #define C2_9 0x3C |
| 78 | #define C2_10 0x3D | 77 | #define C2_10 0x3D |
| 79 | #define C2_11 0x3E | 78 | #define C2_11 0x3E |
| 80 | #define C2_12 0x3F | 79 | #define C2_12 0x3F |
| @@ -83,16 +82,16 @@ void IS31FL3731_update_led_control_registers( uint8_t addr, uint8_t index ); | |||
| 83 | #define C2_15 0x42 | 82 | #define C2_15 0x42 |
| 84 | #define C2_16 0x43 | 83 | #define C2_16 0x43 |
| 85 | 84 | ||
| 86 | #define C3_1 0x44 | 85 | #define C3_1 0x44 |
| 87 | #define C3_2 0x45 | 86 | #define C3_2 0x45 |
| 88 | #define C3_3 0x46 | 87 | #define C3_3 0x46 |
| 89 | #define C3_4 0x47 | 88 | #define C3_4 0x47 |
| 90 | #define C3_5 0x48 | 89 | #define C3_5 0x48 |
| 91 | #define C3_6 0x49 | 90 | #define C3_6 0x49 |
| 92 | #define C3_7 0x4A | 91 | #define C3_7 0x4A |
| 93 | #define C3_8 0x4B | 92 | #define C3_8 0x4B |
| 94 | 93 | ||
| 95 | #define C3_9 0x4C | 94 | #define C3_9 0x4C |
| 96 | #define C3_10 0x4D | 95 | #define C3_10 0x4D |
| 97 | #define C3_11 0x4E | 96 | #define C3_11 0x4E |
| 98 | #define C3_12 0x4F | 97 | #define C3_12 0x4F |
| @@ -101,16 +100,16 @@ void IS31FL3731_update_led_control_registers( uint8_t addr, uint8_t index ); | |||
| 101 | #define C3_15 0x52 | 100 | #define C3_15 0x52 |
| 102 | #define C3_16 0x53 | 101 | #define C3_16 0x53 |
| 103 | 102 | ||
| 104 | #define C4_1 0x54 | 103 | #define C4_1 0x54 |
| 105 | #define C4_2 0x55 | 104 | #define C4_2 0x55 |
| 106 | #define C4_3 0x56 | 105 | #define C4_3 0x56 |
| 107 | #define C4_4 0x57 | 106 | #define C4_4 0x57 |
| 108 | #define C4_5 0x58 | 107 | #define C4_5 0x58 |
| 109 | #define C4_6 0x59 | 108 | #define C4_6 0x59 |
| 110 | #define C4_7 0x5A | 109 | #define C4_7 0x5A |
| 111 | #define C4_8 0x5B | 110 | #define C4_8 0x5B |
| 112 | 111 | ||
| 113 | #define C4_9 0x5C | 112 | #define C4_9 0x5C |
| 114 | #define C4_10 0x5D | 113 | #define C4_10 0x5D |
| 115 | #define C4_11 0x5E | 114 | #define C4_11 0x5E |
| 116 | #define C4_12 0x5F | 115 | #define C4_12 0x5F |
| @@ -119,16 +118,16 @@ void IS31FL3731_update_led_control_registers( uint8_t addr, uint8_t index ); | |||
| 119 | #define C4_15 0x62 | 118 | #define C4_15 0x62 |
| 120 | #define C4_16 0x63 | 119 | #define C4_16 0x63 |
| 121 | 120 | ||
| 122 | #define C5_1 0x64 | 121 | #define C5_1 0x64 |
| 123 | #define C5_2 0x65 | 122 | #define C5_2 0x65 |
| 124 | #define C5_3 0x66 | 123 | #define C5_3 0x66 |
| 125 | #define C5_4 0x67 | 124 | #define C5_4 0x67 |
| 126 | #define C5_5 0x68 | 125 | #define C5_5 0x68 |
| 127 | #define C5_6 0x69 | 126 | #define C5_6 0x69 |
| 128 | #define C5_7 0x6A | 127 | #define C5_7 0x6A |
| 129 | #define C5_8 0x6B | 128 | #define C5_8 0x6B |
| 130 | 129 | ||
| 131 | #define C5_9 0x6C | 130 | #define C5_9 0x6C |
| 132 | #define C5_10 0x6D | 131 | #define C5_10 0x6D |
| 133 | #define C5_11 0x6E | 132 | #define C5_11 0x6E |
| 134 | #define C5_12 0x6F | 133 | #define C5_12 0x6F |
| @@ -137,16 +136,16 @@ void IS31FL3731_update_led_control_registers( uint8_t addr, uint8_t index ); | |||
| 137 | #define C5_15 0x72 | 136 | #define C5_15 0x72 |
| 138 | #define C5_16 0x73 | 137 | #define C5_16 0x73 |
| 139 | 138 | ||
| 140 | #define C6_1 0x74 | 139 | #define C6_1 0x74 |
| 141 | #define C6_2 0x75 | 140 | #define C6_2 0x75 |
| 142 | #define C6_3 0x76 | 141 | #define C6_3 0x76 |
| 143 | #define C6_4 0x77 | 142 | #define C6_4 0x77 |
| 144 | #define C6_5 0x78 | 143 | #define C6_5 0x78 |
| 145 | #define C6_6 0x79 | 144 | #define C6_6 0x79 |
| 146 | #define C6_7 0x7A | 145 | #define C6_7 0x7A |
| 147 | #define C6_8 0x7B | 146 | #define C6_8 0x7B |
| 148 | 147 | ||
| 149 | #define C6_9 0x7C | 148 | #define C6_9 0x7C |
| 150 | #define C6_10 0x7D | 149 | #define C6_10 0x7D |
| 151 | #define C6_11 0x7E | 150 | #define C6_11 0x7E |
| 152 | #define C6_12 0x7F | 151 | #define C6_12 0x7F |
| @@ -155,16 +154,16 @@ void IS31FL3731_update_led_control_registers( uint8_t addr, uint8_t index ); | |||
| 155 | #define C6_15 0x82 | 154 | #define C6_15 0x82 |
| 156 | #define C6_16 0x83 | 155 | #define C6_16 0x83 |
| 157 | 156 | ||
| 158 | #define C7_1 0x84 | 157 | #define C7_1 0x84 |
| 159 | #define C7_2 0x85 | 158 | #define C7_2 0x85 |
| 160 | #define C7_3 0x86 | 159 | #define C7_3 0x86 |
| 161 | #define C7_4 0x87 | 160 | #define C7_4 0x87 |
| 162 | #define C7_5 0x88 | 161 | #define C7_5 0x88 |
| 163 | #define C7_6 0x89 | 162 | #define C7_6 0x89 |
| 164 | #define C7_7 0x8A | 163 | #define C7_7 0x8A |
| 165 | #define C7_8 0x8B | 164 | #define C7_8 0x8B |
| 166 | 165 | ||
| 167 | #define C7_9 0x8C | 166 | #define C7_9 0x8C |
| 168 | #define C7_10 0x8D | 167 | #define C7_10 0x8D |
| 169 | #define C7_11 0x8E | 168 | #define C7_11 0x8E |
| 170 | #define C7_12 0x8F | 169 | #define C7_12 0x8F |
| @@ -173,16 +172,16 @@ void IS31FL3731_update_led_control_registers( uint8_t addr, uint8_t index ); | |||
| 173 | #define C7_15 0x92 | 172 | #define C7_15 0x92 |
| 174 | #define C7_16 0x93 | 173 | #define C7_16 0x93 |
| 175 | 174 | ||
| 176 | #define C8_1 0x94 | 175 | #define C8_1 0x94 |
| 177 | #define C8_2 0x95 | 176 | #define C8_2 0x95 |
| 178 | #define C8_3 0x96 | 177 | #define C8_3 0x96 |
| 179 | #define C8_4 0x97 | 178 | #define C8_4 0x97 |
| 180 | #define C8_5 0x98 | 179 | #define C8_5 0x98 |
| 181 | #define C8_6 0x99 | 180 | #define C8_6 0x99 |
| 182 | #define C8_7 0x9A | 181 | #define C8_7 0x9A |
| 183 | #define C8_8 0x9B | 182 | #define C8_8 0x9B |
| 184 | 183 | ||
| 185 | #define C8_9 0x9C | 184 | #define C8_9 0x9C |
| 186 | #define C8_10 0x9D | 185 | #define C8_10 0x9D |
| 187 | #define C8_11 0x9E | 186 | #define C8_11 0x9E |
| 188 | #define C8_12 0x9F | 187 | #define C8_12 0x9F |
| @@ -191,16 +190,16 @@ void IS31FL3731_update_led_control_registers( uint8_t addr, uint8_t index ); | |||
| 191 | #define C8_15 0xA2 | 190 | #define C8_15 0xA2 |
| 192 | #define C8_16 0xA3 | 191 | #define C8_16 0xA3 |
| 193 | 192 | ||
| 194 | #define C9_1 0xA4 | 193 | #define C9_1 0xA4 |
| 195 | #define C9_2 0xA5 | 194 | #define C9_2 0xA5 |
| 196 | #define C9_3 0xA6 | 195 | #define C9_3 0xA6 |
| 197 | #define C9_4 0xA7 | 196 | #define C9_4 0xA7 |
| 198 | #define C9_5 0xA8 | 197 | #define C9_5 0xA8 |
| 199 | #define C9_6 0xA9 | 198 | #define C9_6 0xA9 |
| 200 | #define C9_7 0xAA | 199 | #define C9_7 0xAA |
| 201 | #define C9_8 0xAB | 200 | #define C9_8 0xAB |
| 202 | 201 | ||
| 203 | #define C9_9 0xAC | 202 | #define C9_9 0xAC |
| 204 | #define C9_10 0xAD | 203 | #define C9_10 0xAD |
| 205 | #define C9_11 0xAE | 204 | #define C9_11 0xAE |
| 206 | #define C9_12 0xAF | 205 | #define C9_12 0xAF |
| @@ -209,6 +208,4 @@ void IS31FL3731_update_led_control_registers( uint8_t addr, uint8_t index ); | |||
| 209 | #define C9_15 0xB2 | 208 | #define C9_15 0xB2 |
| 210 | #define C9_16 0xB3 | 209 | #define C9_16 0xB3 |
| 211 | 210 | ||
| 212 | 211 | #endif // IS31FL3731_DRIVER_H | |
| 213 | |||
| 214 | #endif // IS31FL3731_DRIVER_H | ||
diff --git a/drivers/issi/is31fl3733.c b/drivers/issi/is31fl3733.c index aa247f4e8..968f072de 100644 --- a/drivers/issi/is31fl3733.c +++ b/drivers/issi/is31fl3733.c | |||
| @@ -17,11 +17,11 @@ | |||
| 17 | */ | 17 | */ |
| 18 | 18 | ||
| 19 | #ifdef __AVR__ | 19 | #ifdef __AVR__ |
| 20 | #include <avr/interrupt.h> | 20 | # include <avr/interrupt.h> |
| 21 | #include <avr/io.h> | 21 | # include <avr/io.h> |
| 22 | #include <util/delay.h> | 22 | # include <util/delay.h> |
| 23 | #else | 23 | #else |
| 24 | #include "wait.h" | 24 | # include "wait.h" |
| 25 | #endif | 25 | #endif |
| 26 | 26 | ||
| 27 | #include "is31fl3733.h" | 27 | #include "is31fl3733.h" |
| @@ -46,23 +46,23 @@ | |||
| 46 | #define ISSI_INTERRUPTMASKREGISTER 0xF0 | 46 | #define ISSI_INTERRUPTMASKREGISTER 0xF0 |
| 47 | #define ISSI_INTERRUPTSTATUSREGISTER 0xF1 | 47 | #define ISSI_INTERRUPTSTATUSREGISTER 0xF1 |
| 48 | 48 | ||
| 49 | #define ISSI_PAGE_LEDCONTROL 0x00 //PG0 | 49 | #define ISSI_PAGE_LEDCONTROL 0x00 // PG0 |
| 50 | #define ISSI_PAGE_PWM 0x01 //PG1 | 50 | #define ISSI_PAGE_PWM 0x01 // PG1 |
| 51 | #define ISSI_PAGE_AUTOBREATH 0x02 //PG2 | 51 | #define ISSI_PAGE_AUTOBREATH 0x02 // PG2 |
| 52 | #define ISSI_PAGE_FUNCTION 0x03 //PG3 | 52 | #define ISSI_PAGE_FUNCTION 0x03 // PG3 |
| 53 | 53 | ||
| 54 | #define ISSI_REG_CONFIGURATION 0x00 //PG3 | 54 | #define ISSI_REG_CONFIGURATION 0x00 // PG3 |
| 55 | #define ISSI_REG_GLOBALCURRENT 0x01 //PG3 | 55 | #define ISSI_REG_GLOBALCURRENT 0x01 // PG3 |
| 56 | #define ISSI_REG_RESET 0x11// PG3 | 56 | #define ISSI_REG_RESET 0x11 // PG3 |
| 57 | #define ISSI_REG_SWPULLUP 0x0F //PG3 | 57 | #define ISSI_REG_SWPULLUP 0x0F // PG3 |
| 58 | #define ISSI_REG_CSPULLUP 0x10 //PG3 | 58 | #define ISSI_REG_CSPULLUP 0x10 // PG3 |
| 59 | 59 | ||
| 60 | #ifndef ISSI_TIMEOUT | 60 | #ifndef ISSI_TIMEOUT |
| 61 | #define ISSI_TIMEOUT 100 | 61 | # define ISSI_TIMEOUT 100 |
| 62 | #endif | 62 | #endif |
| 63 | 63 | ||
| 64 | #ifndef ISSI_PERSISTENCE | 64 | #ifndef ISSI_PERSISTENCE |
| 65 | #define ISSI_PERSISTENCE 0 | 65 | # define ISSI_PERSISTENCE 0 |
| 66 | #endif | 66 | #endif |
| 67 | 67 | ||
| 68 | // Transfer buffer for TWITransmitData() | 68 | // Transfer buffer for TWITransmitData() |
| @@ -75,56 +75,51 @@ uint8_t g_twi_transfer_buffer[20]; | |||
| 75 | // buffers and the transfers in IS31FL3733_write_pwm_buffer() but it's | 75 | // buffers and the transfers in IS31FL3733_write_pwm_buffer() but it's |
| 76 | // probably not worth the extra complexity. | 76 | // probably not worth the extra complexity. |
| 77 | uint8_t g_pwm_buffer[DRIVER_COUNT][192]; | 77 | uint8_t g_pwm_buffer[DRIVER_COUNT][192]; |
| 78 | bool g_pwm_buffer_update_required[DRIVER_COUNT] = { false }; | 78 | bool g_pwm_buffer_update_required[DRIVER_COUNT] = {false}; |
| 79 | 79 | ||
| 80 | uint8_t g_led_control_registers[DRIVER_COUNT][24] = { { 0 }, { 0 } }; | 80 | uint8_t g_led_control_registers[DRIVER_COUNT][24] = {{0}, {0}}; |
| 81 | bool g_led_control_registers_update_required[DRIVER_COUNT] = { false }; | 81 | bool g_led_control_registers_update_required[DRIVER_COUNT] = {false}; |
| 82 | 82 | ||
| 83 | void IS31FL3733_write_register( uint8_t addr, uint8_t reg, uint8_t data ) | 83 | void IS31FL3733_write_register(uint8_t addr, uint8_t reg, uint8_t data) { |
| 84 | { | ||
| 85 | g_twi_transfer_buffer[0] = reg; | 84 | g_twi_transfer_buffer[0] = reg; |
| 86 | g_twi_transfer_buffer[1] = data; | 85 | g_twi_transfer_buffer[1] = data; |
| 87 | 86 | ||
| 88 | #if ISSI_PERSISTENCE > 0 | 87 | #if ISSI_PERSISTENCE > 0 |
| 89 | for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) { | 88 | for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) { |
| 90 | if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0) | 89 | if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0) break; |
| 91 | break; | ||
| 92 | } | 90 | } |
| 93 | #else | 91 | #else |
| 94 | i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT); | 92 | i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT); |
| 95 | #endif | 93 | #endif |
| 96 | } | 94 | } |
| 97 | 95 | ||
| 98 | void IS31FL3733_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer ) | 96 | void IS31FL3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { |
| 99 | { | ||
| 100 | // assumes PG1 is already selected | 97 | // assumes PG1 is already selected |
| 101 | 98 | ||
| 102 | // transmit PWM registers in 12 transfers of 16 bytes | 99 | // transmit PWM registers in 12 transfers of 16 bytes |
| 103 | // g_twi_transfer_buffer[] is 20 bytes | 100 | // g_twi_transfer_buffer[] is 20 bytes |
| 104 | 101 | ||
| 105 | // iterate over the pwm_buffer contents at 16 byte intervals | 102 | // iterate over the pwm_buffer contents at 16 byte intervals |
| 106 | for ( int i = 0; i < 192; i += 16 ) { | 103 | for (int i = 0; i < 192; i += 16) { |
| 107 | g_twi_transfer_buffer[0] = i; | 104 | g_twi_transfer_buffer[0] = i; |
| 108 | // copy the data from i to i+15 | 105 | // copy the data from i to i+15 |
| 109 | // device will auto-increment register for data after the first byte | 106 | // device will auto-increment register for data after the first byte |
| 110 | // thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer | 107 | // thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer |
| 111 | for ( int j = 0; j < 16; j++ ) { | 108 | for (int j = 0; j < 16; j++) { |
| 112 | g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j]; | 109 | g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j]; |
| 113 | } | 110 | } |
| 114 | 111 | ||
| 115 | #if ISSI_PERSISTENCE > 0 | 112 | #if ISSI_PERSISTENCE > 0 |
| 116 | for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) { | 113 | for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) { |
| 117 | if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0) | 114 | if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0) break; |
| 118 | break; | 115 | } |
| 119 | } | 116 | #else |
| 120 | #else | 117 | i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT); |
| 121 | i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT); | 118 | #endif |
| 122 | #endif | ||
| 123 | } | 119 | } |
| 124 | } | 120 | } |
| 125 | 121 | ||
| 126 | void IS31FL3733_init( uint8_t addr, uint8_t sync) | 122 | void IS31FL3733_init(uint8_t addr, uint8_t sync) { |
| 127 | { | ||
| 128 | // In order to avoid the LEDs being driven with garbage data | 123 | // In order to avoid the LEDs being driven with garbage data |
| 129 | // in the LED driver's PWM registers, shutdown is enabled last. | 124 | // in the LED driver's PWM registers, shutdown is enabled last. |
| 130 | // Set up the mode and other settings, clear the PWM registers, | 125 | // Set up the mode and other settings, clear the PWM registers, |
| @@ -132,120 +127,108 @@ void IS31FL3733_init( uint8_t addr, uint8_t sync) | |||
| 132 | // Sync is passed so set it according to the datasheet. | 127 | // Sync is passed so set it according to the datasheet. |
| 133 | 128 | ||
| 134 | // Unlock the command register. | 129 | // Unlock the command register. |
| 135 | IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 ); | 130 | IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5); |
| 136 | 131 | ||
| 137 | // Select PG0 | 132 | // Select PG0 |
| 138 | IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL ); | 133 | IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL); |
| 139 | // Turn off all LEDs. | 134 | // Turn off all LEDs. |
| 140 | for ( int i = 0x00; i <= 0x17; i++ ) | 135 | for (int i = 0x00; i <= 0x17; i++) { |
| 141 | { | 136 | IS31FL3733_write_register(addr, i, 0x00); |
| 142 | IS31FL3733_write_register( addr, i, 0x00 ); | ||
| 143 | } | 137 | } |
| 144 | 138 | ||
| 145 | // Unlock the command register. | 139 | // Unlock the command register. |
| 146 | IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 ); | 140 | IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5); |
| 147 | 141 | ||
| 148 | // Select PG1 | 142 | // Select PG1 |
| 149 | IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM ); | 143 | IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM); |
| 150 | // Set PWM on all LEDs to 0 | 144 | // Set PWM on all LEDs to 0 |
| 151 | // No need to setup Breath registers to PWM as that is the default. | 145 | // No need to setup Breath registers to PWM as that is the default. |
| 152 | for ( int i = 0x00; i <= 0xBF; i++ ) | 146 | for (int i = 0x00; i <= 0xBF; i++) { |
| 153 | { | 147 | IS31FL3733_write_register(addr, i, 0x00); |
| 154 | IS31FL3733_write_register( addr, i, 0x00 ); | ||
| 155 | } | 148 | } |
| 156 | 149 | ||
| 157 | // Unlock the command register. | 150 | // Unlock the command register. |
| 158 | IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 ); | 151 | IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5); |
| 159 | 152 | ||
| 160 | // Select PG3 | 153 | // Select PG3 |
| 161 | IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_FUNCTION ); | 154 | IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_FUNCTION); |
| 162 | // Set global current to maximum. | 155 | // Set global current to maximum. |
| 163 | IS31FL3733_write_register( addr, ISSI_REG_GLOBALCURRENT, 0xFF ); | 156 | IS31FL3733_write_register(addr, ISSI_REG_GLOBALCURRENT, 0xFF); |
| 164 | // Disable software shutdown. | 157 | // Disable software shutdown. |
| 165 | IS31FL3733_write_register( addr, ISSI_REG_CONFIGURATION, (sync << 6) | 0x01 ); | 158 | IS31FL3733_write_register(addr, ISSI_REG_CONFIGURATION, (sync << 6) | 0x01); |
| 166 | 159 | ||
| 167 | // Wait 10ms to ensure the device has woken up. | 160 | // Wait 10ms to ensure the device has woken up. |
| 168 | #ifdef __AVR__ | 161 | #ifdef __AVR__ |
| 169 | _delay_ms( 10 ); | 162 | _delay_ms(10); |
| 170 | #else | 163 | #else |
| 171 | wait_ms(10); | 164 | wait_ms(10); |
| 172 | #endif | 165 | #endif |
| 173 | } | 166 | } |
| 174 | 167 | ||
| 175 | void IS31FL3733_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ) | 168 | void IS31FL3733_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { |
| 176 | { | 169 | if (index >= 0 && index < DRIVER_LED_TOTAL) { |
| 177 | if ( index >= 0 && index < DRIVER_LED_TOTAL ) { | ||
| 178 | is31_led led = g_is31_leds[index]; | 170 | is31_led led = g_is31_leds[index]; |
| 179 | 171 | ||
| 180 | g_pwm_buffer[led.driver][led.r] = red; | 172 | g_pwm_buffer[led.driver][led.r] = red; |
| 181 | g_pwm_buffer[led.driver][led.g] = green; | 173 | g_pwm_buffer[led.driver][led.g] = green; |
| 182 | g_pwm_buffer[led.driver][led.b] = blue; | 174 | g_pwm_buffer[led.driver][led.b] = blue; |
| 183 | g_pwm_buffer_update_required[led.driver] = true; | 175 | g_pwm_buffer_update_required[led.driver] = true; |
| 184 | } | 176 | } |
| 185 | } | 177 | } |
| 186 | 178 | ||
| 187 | void IS31FL3733_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) | 179 | void IS31FL3733_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { |
| 188 | { | 180 | for (int i = 0; i < DRIVER_LED_TOTAL; i++) { |
| 189 | for ( int i = 0; i < DRIVER_LED_TOTAL; i++ ) | 181 | IS31FL3733_set_color(i, red, green, blue); |
| 190 | { | ||
| 191 | IS31FL3733_set_color( i, red, green, blue ); | ||
| 192 | } | 182 | } |
| 193 | } | 183 | } |
| 194 | 184 | ||
| 195 | void IS31FL3733_set_led_control_register( uint8_t index, bool red, bool green, bool blue ) | 185 | void IS31FL3733_set_led_control_register(uint8_t index, bool red, bool green, bool blue) { |
| 196 | { | ||
| 197 | is31_led led = g_is31_leds[index]; | 186 | is31_led led = g_is31_leds[index]; |
| 198 | 187 | ||
| 199 | uint8_t control_register_r = led.r / 8; | 188 | uint8_t control_register_r = led.r / 8; |
| 200 | uint8_t control_register_g = led.g / 8; | 189 | uint8_t control_register_g = led.g / 8; |
| 201 | uint8_t control_register_b = led.b / 8; | 190 | uint8_t control_register_b = led.b / 8; |
| 202 | uint8_t bit_r = led.r % 8; | 191 | uint8_t bit_r = led.r % 8; |
| 203 | uint8_t bit_g = led.g % 8; | 192 | uint8_t bit_g = led.g % 8; |
| 204 | uint8_t bit_b = led.b % 8; | 193 | uint8_t bit_b = led.b % 8; |
| 205 | 194 | ||
| 206 | if ( red ) { | 195 | if (red) { |
| 207 | g_led_control_registers[led.driver][control_register_r] |= (1 << bit_r); | 196 | g_led_control_registers[led.driver][control_register_r] |= (1 << bit_r); |
| 208 | } else { | 197 | } else { |
| 209 | g_led_control_registers[led.driver][control_register_r] &= ~(1 << bit_r); | 198 | g_led_control_registers[led.driver][control_register_r] &= ~(1 << bit_r); |
| 210 | } | 199 | } |
| 211 | if ( green ) { | 200 | if (green) { |
| 212 | g_led_control_registers[led.driver][control_register_g] |= (1 << bit_g); | 201 | g_led_control_registers[led.driver][control_register_g] |= (1 << bit_g); |
| 213 | } else { | 202 | } else { |
| 214 | g_led_control_registers[led.driver][control_register_g] &= ~(1 << bit_g); | 203 | g_led_control_registers[led.driver][control_register_g] &= ~(1 << bit_g); |
| 215 | } | 204 | } |
| 216 | if ( blue ) { | 205 | if (blue) { |
| 217 | g_led_control_registers[led.driver][control_register_b] |= (1 << bit_b); | 206 | g_led_control_registers[led.driver][control_register_b] |= (1 << bit_b); |
| 218 | } else { | 207 | } else { |
| 219 | g_led_control_registers[led.driver][control_register_b] &= ~(1 << bit_b); | 208 | g_led_control_registers[led.driver][control_register_b] &= ~(1 << bit_b); |
| 220 | } | 209 | } |
| 221 | 210 | ||
| 222 | g_led_control_registers_update_required[led.driver] = true; | 211 | g_led_control_registers_update_required[led.driver] = true; |
| 223 | |||
| 224 | } | 212 | } |
| 225 | 213 | ||
| 226 | void IS31FL3733_update_pwm_buffers( uint8_t addr, uint8_t index ) | 214 | void IS31FL3733_update_pwm_buffers(uint8_t addr, uint8_t index) { |
| 227 | { | 215 | if (g_pwm_buffer_update_required[index]) { |
| 228 | if ( g_pwm_buffer_update_required[index] ) | ||
| 229 | { | ||
| 230 | // Firstly we need to unlock the command register and select PG1 | 216 | // Firstly we need to unlock the command register and select PG1 |
| 231 | IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 ); | 217 | IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5); |
| 232 | IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM ); | 218 | IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM); |
| 233 | 219 | ||
| 234 | IS31FL3733_write_pwm_buffer( addr, g_pwm_buffer[index] ); | 220 | IS31FL3733_write_pwm_buffer(addr, g_pwm_buffer[index]); |
| 235 | } | 221 | } |
| 236 | g_pwm_buffer_update_required[index] = false; | 222 | g_pwm_buffer_update_required[index] = false; |
| 237 | } | 223 | } |
| 238 | 224 | ||
| 239 | void IS31FL3733_update_led_control_registers( uint8_t addr, uint8_t index ) | 225 | void IS31FL3733_update_led_control_registers(uint8_t addr, uint8_t index) { |
| 240 | { | 226 | if (g_led_control_registers_update_required[index]) { |
| 241 | if ( g_led_control_registers_update_required[index] ) | ||
| 242 | { | ||
| 243 | // Firstly we need to unlock the command register and select PG0 | 227 | // Firstly we need to unlock the command register and select PG0 |
| 244 | IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 ); | 228 | IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5); |
| 245 | IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL ); | 229 | IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL); |
| 246 | for ( int i=0; i<24; i++ ) | 230 | for (int i = 0; i < 24; i++) { |
| 247 | { | 231 | IS31FL3733_write_register(addr, i, g_led_control_registers[index][i]); |
| 248 | IS31FL3733_write_register(addr, i, g_led_control_registers[index][i] ); | ||
| 249 | } | 232 | } |
| 250 | } | 233 | } |
| 251 | g_led_control_registers_update_required[index] = false; | 234 | g_led_control_registers_update_required[index] = false; |
diff --git a/drivers/issi/is31fl3733.h b/drivers/issi/is31fl3733.h index e117b2546..5b3283e03 100644 --- a/drivers/issi/is31fl3733.h +++ b/drivers/issi/is31fl3733.h | |||
| @@ -16,7 +16,6 @@ | |||
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ | 17 | */ |
| 18 | 18 | ||
| 19 | |||
| 20 | #ifndef IS31FL3733_DRIVER_H | 19 | #ifndef IS31FL3733_DRIVER_H |
| 21 | #define IS31FL3733_DRIVER_H | 20 | #define IS31FL3733_DRIVER_H |
| 22 | 21 | ||
| @@ -24,232 +23,232 @@ | |||
| 24 | #include <stdbool.h> | 23 | #include <stdbool.h> |
| 25 | 24 | ||
| 26 | typedef struct is31_led { | 25 | typedef struct is31_led { |
| 27 | uint8_t driver:2; | 26 | uint8_t driver : 2; |
| 28 | uint8_t r; | 27 | uint8_t r; |
| 29 | uint8_t g; | 28 | uint8_t g; |
| 30 | uint8_t b; | 29 | uint8_t b; |
| 31 | } __attribute__((packed)) is31_led; | 30 | } __attribute__((packed)) is31_led; |
| 32 | 31 | ||
| 33 | extern const is31_led g_is31_leds[DRIVER_LED_TOTAL]; | 32 | extern const is31_led g_is31_leds[DRIVER_LED_TOTAL]; |
| 34 | 33 | ||
| 35 | void IS31FL3733_init( uint8_t addr, uint8_t sync ); | 34 | void IS31FL3733_init(uint8_t addr, uint8_t sync); |
| 36 | void IS31FL3733_write_register( uint8_t addr, uint8_t reg, uint8_t data ); | 35 | void IS31FL3733_write_register(uint8_t addr, uint8_t reg, uint8_t data); |
| 37 | void IS31FL3733_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer ); | 36 | void IS31FL3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer); |
| 38 | 37 | ||
| 39 | void IS31FL3733_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ); | 38 | void IS31FL3733_set_color(int index, uint8_t red, uint8_t green, uint8_t blue); |
| 40 | void IS31FL3733_set_color_all( uint8_t red, uint8_t green, uint8_t blue ); | 39 | void IS31FL3733_set_color_all(uint8_t red, uint8_t green, uint8_t blue); |
| 41 | 40 | ||
| 42 | void IS31FL3733_set_led_control_register( uint8_t index, bool red, bool green, bool blue ); | 41 | void IS31FL3733_set_led_control_register(uint8_t index, bool red, bool green, bool blue); |
| 43 | 42 | ||
| 44 | // This should not be called from an interrupt | 43 | // This should not be called from an interrupt |
| 45 | // (eg. from a timer interrupt). | 44 | // (eg. from a timer interrupt). |
| 46 | // Call this while idle (in between matrix scans). | 45 | // Call this while idle (in between matrix scans). |
| 47 | // If the buffer is dirty, it will update the driver with the buffer. | 46 | // If the buffer is dirty, it will update the driver with the buffer. |
| 48 | void IS31FL3733_update_pwm_buffers( uint8_t addr, uint8_t index ); | 47 | void IS31FL3733_update_pwm_buffers(uint8_t addr, uint8_t index); |
| 49 | void IS31FL3733_update_led_control_registers( uint8_t addr, uint8_t index ); | 48 | void IS31FL3733_update_led_control_registers(uint8_t addr, uint8_t index); |
| 50 | 49 | ||
| 51 | #define A_1 0x00 | 50 | #define A_1 0x00 |
| 52 | #define A_2 0x01 | 51 | #define A_2 0x01 |
| 53 | #define A_3 0x02 | 52 | #define A_3 0x02 |
| 54 | #define A_4 0x03 | 53 | #define A_4 0x03 |
| 55 | #define A_5 0x04 | 54 | #define A_5 0x04 |
| 56 | #define A_6 0x05 | 55 | #define A_6 0x05 |
| 57 | #define A_7 0x06 | 56 | #define A_7 0x06 |
| 58 | #define A_8 0x07 | 57 | #define A_8 0x07 |
| 59 | #define A_9 0x08 | 58 | #define A_9 0x08 |
| 60 | #define A_10 0x09 | 59 | #define A_10 0x09 |
| 61 | #define A_11 0x0A | 60 | #define A_11 0x0A |
| 62 | #define A_12 0x0B | 61 | #define A_12 0x0B |
| 63 | #define A_13 0x0C | 62 | #define A_13 0x0C |
| 64 | #define A_14 0x0D | 63 | #define A_14 0x0D |
| 65 | #define A_15 0x0E | 64 | #define A_15 0x0E |
| 66 | #define A_16 0x0F | 65 | #define A_16 0x0F |
| 67 | 66 | ||
| 68 | #define B_1 0x10 | 67 | #define B_1 0x10 |
| 69 | #define B_2 0x11 | 68 | #define B_2 0x11 |
| 70 | #define B_3 0x12 | 69 | #define B_3 0x12 |
| 71 | #define B_4 0x13 | 70 | #define B_4 0x13 |
| 72 | #define B_5 0x14 | 71 | #define B_5 0x14 |
| 73 | #define B_6 0x15 | 72 | #define B_6 0x15 |
| 74 | #define B_7 0x16 | 73 | #define B_7 0x16 |
| 75 | #define B_8 0x17 | 74 | #define B_8 0x17 |
| 76 | #define B_9 0x18 | 75 | #define B_9 0x18 |
| 77 | #define B_10 0x19 | 76 | #define B_10 0x19 |
| 78 | #define B_11 0x1A | 77 | #define B_11 0x1A |
| 79 | #define B_12 0x1B | 78 | #define B_12 0x1B |
| 80 | #define B_13 0x1C | 79 | #define B_13 0x1C |
| 81 | #define B_14 0x1D | 80 | #define B_14 0x1D |
| 82 | #define B_15 0x1E | 81 | #define B_15 0x1E |
| 83 | #define B_16 0x1F | 82 | #define B_16 0x1F |
| 84 | 83 | ||
| 85 | #define C_1 0x20 | 84 | #define C_1 0x20 |
| 86 | #define C_2 0x21 | 85 | #define C_2 0x21 |
| 87 | #define C_3 0x22 | 86 | #define C_3 0x22 |
| 88 | #define C_4 0x23 | 87 | #define C_4 0x23 |
| 89 | #define C_5 0x24 | 88 | #define C_5 0x24 |
| 90 | #define C_6 0x25 | 89 | #define C_6 0x25 |
| 91 | #define C_7 0x26 | 90 | #define C_7 0x26 |
| 92 | #define C_8 0x27 | 91 | #define C_8 0x27 |
| 93 | #define C_9 0x28 | 92 | #define C_9 0x28 |
| 94 | #define C_10 0x29 | 93 | #define C_10 0x29 |
| 95 | #define C_11 0x2A | 94 | #define C_11 0x2A |
| 96 | #define C_12 0x2B | 95 | #define C_12 0x2B |
| 97 | #define C_13 0x2C | 96 | #define C_13 0x2C |
| 98 | #define C_14 0x2D | 97 | #define C_14 0x2D |
| 99 | #define C_15 0x2E | 98 | #define C_15 0x2E |
| 100 | #define C_16 0x2F | 99 | #define C_16 0x2F |
| 101 | 100 | ||
| 102 | #define D_1 0x30 | 101 | #define D_1 0x30 |
| 103 | #define D_2 0x31 | 102 | #define D_2 0x31 |
| 104 | #define D_3 0x32 | 103 | #define D_3 0x32 |
| 105 | #define D_4 0x33 | 104 | #define D_4 0x33 |
| 106 | #define D_5 0x34 | 105 | #define D_5 0x34 |
| 107 | #define D_6 0x35 | 106 | #define D_6 0x35 |
| 108 | #define D_7 0x36 | 107 | #define D_7 0x36 |
| 109 | #define D_8 0x37 | 108 | #define D_8 0x37 |
| 110 | #define D_9 0x38 | 109 | #define D_9 0x38 |
| 111 | #define D_10 0x39 | 110 | #define D_10 0x39 |
| 112 | #define D_11 0x3A | 111 | #define D_11 0x3A |
| 113 | #define D_12 0x3B | 112 | #define D_12 0x3B |
| 114 | #define D_13 0x3C | 113 | #define D_13 0x3C |
| 115 | #define D_14 0x3D | 114 | #define D_14 0x3D |
| 116 | #define D_15 0x3E | 115 | #define D_15 0x3E |
| 117 | #define D_16 0x3F | 116 | #define D_16 0x3F |
| 118 | 117 | ||
| 119 | #define E_1 0x40 | 118 | #define E_1 0x40 |
| 120 | #define E_2 0x41 | 119 | #define E_2 0x41 |
| 121 | #define E_3 0x42 | 120 | #define E_3 0x42 |
| 122 | #define E_4 0x43 | 121 | #define E_4 0x43 |
| 123 | #define E_5 0x44 | 122 | #define E_5 0x44 |
| 124 | #define E_6 0x45 | 123 | #define E_6 0x45 |
| 125 | #define E_7 0x46 | 124 | #define E_7 0x46 |
| 126 | #define E_8 0x47 | 125 | #define E_8 0x47 |
| 127 | #define E_9 0x48 | 126 | #define E_9 0x48 |
| 128 | #define E_10 0x49 | 127 | #define E_10 0x49 |
| 129 | #define E_11 0x4A | 128 | #define E_11 0x4A |
| 130 | #define E_12 0x4B | 129 | #define E_12 0x4B |
| 131 | #define E_13 0x4C | 130 | #define E_13 0x4C |
| 132 | #define E_14 0x4D | 131 | #define E_14 0x4D |
| 133 | #define E_15 0x4E | 132 | #define E_15 0x4E |
| 134 | #define E_16 0x4F | 133 | #define E_16 0x4F |
| 135 | 134 | ||
| 136 | #define F_1 0x50 | 135 | #define F_1 0x50 |
| 137 | #define F_2 0x51 | 136 | #define F_2 0x51 |
| 138 | #define F_3 0x52 | 137 | #define F_3 0x52 |
| 139 | #define F_4 0x53 | 138 | #define F_4 0x53 |
| 140 | #define F_5 0x54 | 139 | #define F_5 0x54 |
| 141 | #define F_6 0x55 | 140 | #define F_6 0x55 |
| 142 | #define F_7 0x56 | 141 | #define F_7 0x56 |
| 143 | #define F_8 0x57 | 142 | #define F_8 0x57 |
| 144 | #define F_9 0x58 | 143 | #define F_9 0x58 |
| 145 | #define F_10 0x59 | 144 | #define F_10 0x59 |
| 146 | #define F_11 0x5A | 145 | #define F_11 0x5A |
| 147 | #define F_12 0x5B | 146 | #define F_12 0x5B |
| 148 | #define F_13 0x5C | 147 | #define F_13 0x5C |
| 149 | #define F_14 0x5D | 148 | #define F_14 0x5D |
| 150 | #define F_15 0x5E | 149 | #define F_15 0x5E |
| 151 | #define F_16 0x5F | 150 | #define F_16 0x5F |
| 152 | 151 | ||
| 153 | #define G_1 0x60 | 152 | #define G_1 0x60 |
| 154 | #define G_2 0x61 | 153 | #define G_2 0x61 |
| 155 | #define G_3 0x62 | 154 | #define G_3 0x62 |
| 156 | #define G_4 0x63 | 155 | #define G_4 0x63 |
| 157 | #define G_5 0x64 | 156 | #define G_5 0x64 |
| 158 | #define G_6 0x65 | 157 | #define G_6 0x65 |
| 159 | #define G_7 0x66 | 158 | #define G_7 0x66 |
| 160 | #define G_8 0x67 | 159 | #define G_8 0x67 |
| 161 | #define G_9 0x68 | 160 | #define G_9 0x68 |
| 162 | #define G_10 0x69 | 161 | #define G_10 0x69 |
| 163 | #define G_11 0x6A | 162 | #define G_11 0x6A |
| 164 | #define G_12 0x6B | 163 | #define G_12 0x6B |
| 165 | #define G_13 0x6C | 164 | #define G_13 0x6C |
| 166 | #define G_14 0x6D | 165 | #define G_14 0x6D |
| 167 | #define G_15 0x6E | 166 | #define G_15 0x6E |
| 168 | #define G_16 0x6F | 167 | #define G_16 0x6F |
| 169 | 168 | ||
| 170 | #define H_1 0x70 | 169 | #define H_1 0x70 |
| 171 | #define H_2 0x71 | 170 | #define H_2 0x71 |
| 172 | #define H_3 0x72 | 171 | #define H_3 0x72 |
| 173 | #define H_4 0x73 | 172 | #define H_4 0x73 |
| 174 | #define H_5 0x74 | 173 | #define H_5 0x74 |
| 175 | #define H_6 0x75 | 174 | #define H_6 0x75 |
| 176 | #define H_7 0x76 | 175 | #define H_7 0x76 |
| 177 | #define H_8 0x77 | 176 | #define H_8 0x77 |
| 178 | #define H_9 0x78 | 177 | #define H_9 0x78 |
| 179 | #define H_10 0x79 | 178 | #define H_10 0x79 |
| 180 | #define H_11 0x7A | 179 | #define H_11 0x7A |
| 181 | #define H_12 0x7B | 180 | #define H_12 0x7B |
| 182 | #define H_13 0x7C | 181 | #define H_13 0x7C |
| 183 | #define H_14 0x7D | 182 | #define H_14 0x7D |
| 184 | #define H_15 0x7E | 183 | #define H_15 0x7E |
| 185 | #define H_16 0x7F | 184 | #define H_16 0x7F |
| 186 | 185 | ||
| 187 | #define I_1 0x80 | 186 | #define I_1 0x80 |
| 188 | #define I_2 0x81 | 187 | #define I_2 0x81 |
| 189 | #define I_3 0x82 | 188 | #define I_3 0x82 |
| 190 | #define I_4 0x83 | 189 | #define I_4 0x83 |
| 191 | #define I_5 0x84 | 190 | #define I_5 0x84 |
| 192 | #define I_6 0x85 | 191 | #define I_6 0x85 |
| 193 | #define I_7 0x86 | 192 | #define I_7 0x86 |
| 194 | #define I_8 0x87 | 193 | #define I_8 0x87 |
| 195 | #define I_9 0x88 | 194 | #define I_9 0x88 |
| 196 | #define I_10 0x89 | 195 | #define I_10 0x89 |
| 197 | #define I_11 0x8A | 196 | #define I_11 0x8A |
| 198 | #define I_12 0x8B | 197 | #define I_12 0x8B |
| 199 | #define I_13 0x8C | 198 | #define I_13 0x8C |
| 200 | #define I_14 0x8D | 199 | #define I_14 0x8D |
| 201 | #define I_15 0x8E | 200 | #define I_15 0x8E |
| 202 | #define I_16 0x8F | 201 | #define I_16 0x8F |
| 203 | 202 | ||
| 204 | #define J_1 0x90 | 203 | #define J_1 0x90 |
| 205 | #define J_2 0x91 | 204 | #define J_2 0x91 |
| 206 | #define J_3 0x92 | 205 | #define J_3 0x92 |
| 207 | #define J_4 0x93 | 206 | #define J_4 0x93 |
| 208 | #define J_5 0x94 | 207 | #define J_5 0x94 |
| 209 | #define J_6 0x95 | 208 | #define J_6 0x95 |
| 210 | #define J_7 0x96 | 209 | #define J_7 0x96 |
| 211 | #define J_8 0x97 | 210 | #define J_8 0x97 |
| 212 | #define J_9 0x98 | 211 | #define J_9 0x98 |
| 213 | #define J_10 0x99 | 212 | #define J_10 0x99 |
| 214 | #define J_11 0x9A | 213 | #define J_11 0x9A |
| 215 | #define J_12 0x9B | 214 | #define J_12 0x9B |
| 216 | #define J_13 0x9C | 215 | #define J_13 0x9C |
| 217 | #define J_14 0x9D | 216 | #define J_14 0x9D |
| 218 | #define J_15 0x9E | 217 | #define J_15 0x9E |
| 219 | #define J_16 0x9F | 218 | #define J_16 0x9F |
| 220 | 219 | ||
| 221 | #define K_1 0xA0 | 220 | #define K_1 0xA0 |
| 222 | #define K_2 0xA1 | 221 | #define K_2 0xA1 |
| 223 | #define K_3 0xA2 | 222 | #define K_3 0xA2 |
| 224 | #define K_4 0xA3 | 223 | #define K_4 0xA3 |
| 225 | #define K_5 0xA4 | 224 | #define K_5 0xA4 |
| 226 | #define K_6 0xA5 | 225 | #define K_6 0xA5 |
| 227 | #define K_7 0xA6 | 226 | #define K_7 0xA6 |
| 228 | #define K_8 0xA7 | 227 | #define K_8 0xA7 |
| 229 | #define K_9 0xA8 | 228 | #define K_9 0xA8 |
| 230 | #define K_10 0xA9 | 229 | #define K_10 0xA9 |
| 231 | #define K_11 0xAA | 230 | #define K_11 0xAA |
| 232 | #define K_12 0xAB | 231 | #define K_12 0xAB |
| 233 | #define K_13 0xAC | 232 | #define K_13 0xAC |
| 234 | #define K_14 0xAD | 233 | #define K_14 0xAD |
| 235 | #define K_15 0xAE | 234 | #define K_15 0xAE |
| 236 | #define K_16 0xAF | 235 | #define K_16 0xAF |
| 237 | 236 | ||
| 238 | #define L_1 0xB0 | 237 | #define L_1 0xB0 |
| 239 | #define L_2 0xB1 | 238 | #define L_2 0xB1 |
| 240 | #define L_3 0xB2 | 239 | #define L_3 0xB2 |
| 241 | #define L_4 0xB3 | 240 | #define L_4 0xB3 |
| 242 | #define L_5 0xB4 | 241 | #define L_5 0xB4 |
| 243 | #define L_6 0xB5 | 242 | #define L_6 0xB5 |
| 244 | #define L_7 0xB6 | 243 | #define L_7 0xB6 |
| 245 | #define L_8 0xB7 | 244 | #define L_8 0xB7 |
| 246 | #define L_9 0xB8 | 245 | #define L_9 0xB8 |
| 247 | #define L_10 0xB9 | 246 | #define L_10 0xB9 |
| 248 | #define L_11 0xBA | 247 | #define L_11 0xBA |
| 249 | #define L_12 0xBB | 248 | #define L_12 0xBB |
| 250 | #define L_13 0xBC | 249 | #define L_13 0xBC |
| 251 | #define L_14 0xBD | 250 | #define L_14 0xBD |
| 252 | #define L_15 0xBE | 251 | #define L_15 0xBE |
| 253 | #define L_16 0xBF | 252 | #define L_16 0xBF |
| 254 | 253 | ||
| 255 | #endif // IS31FL3733_DRIVER_H | 254 | #endif // IS31FL3733_DRIVER_H |
diff --git a/drivers/issi/is31fl3736.c b/drivers/issi/is31fl3736.c index c5d431097..754292425 100644 --- a/drivers/issi/is31fl3736.c +++ b/drivers/issi/is31fl3736.c | |||
| @@ -14,13 +14,12 @@ | |||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | |||
| 18 | #ifdef __AVR__ | 17 | #ifdef __AVR__ |
| 19 | #include <avr/interrupt.h> | 18 | # include <avr/interrupt.h> |
| 20 | #include <avr/io.h> | 19 | # include <avr/io.h> |
| 21 | #include <util/delay.h> | 20 | # include <util/delay.h> |
| 22 | #else | 21 | #else |
| 23 | #include "wait.h" | 22 | # include "wait.h" |
| 24 | #endif | 23 | #endif |
| 25 | 24 | ||
| 26 | #include "is31fl3736.h" | 25 | #include "is31fl3736.h" |
| @@ -28,8 +27,6 @@ | |||
| 28 | #include "i2c_master.h" | 27 | #include "i2c_master.h" |
| 29 | #include "progmem.h" | 28 | #include "progmem.h" |
| 30 | 29 | ||
| 31 | |||
| 32 | |||
| 33 | // This is a 7-bit address, that gets left-shifted and bit 0 | 30 | // This is a 7-bit address, that gets left-shifted and bit 0 |
| 34 | // set to 0 for write, 1 for read (as per I2C protocol) | 31 | // set to 0 for write, 1 for read (as per I2C protocol) |
| 35 | // The address will vary depending on your wiring: | 32 | // The address will vary depending on your wiring: |
| @@ -47,23 +44,23 @@ | |||
| 47 | #define ISSI_INTERRUPTMASKREGISTER 0xF0 | 44 | #define ISSI_INTERRUPTMASKREGISTER 0xF0 |
| 48 | #define ISSI_INTERRUPTSTATUSREGISTER 0xF1 | 45 | #define ISSI_INTERRUPTSTATUSREGISTER 0xF1 |
| 49 | 46 | ||
| 50 | #define ISSI_PAGE_LEDCONTROL 0x00 //PG0 | 47 | #define ISSI_PAGE_LEDCONTROL 0x00 // PG0 |
| 51 | #define ISSI_PAGE_PWM 0x01 //PG1 | 48 | #define ISSI_PAGE_PWM 0x01 // PG1 |
| 52 | #define ISSI_PAGE_AUTOBREATH 0x02 //PG2 | 49 | #define ISSI_PAGE_AUTOBREATH 0x02 // PG2 |
| 53 | #define ISSI_PAGE_FUNCTION 0x03 //PG3 | 50 | #define ISSI_PAGE_FUNCTION 0x03 // PG3 |
| 54 | 51 | ||
| 55 | #define ISSI_REG_CONFIGURATION 0x00 //PG3 | 52 | #define ISSI_REG_CONFIGURATION 0x00 // PG3 |
| 56 | #define ISSI_REG_GLOBALCURRENT 0x01 //PG3 | 53 | #define ISSI_REG_GLOBALCURRENT 0x01 // PG3 |
| 57 | #define ISSI_REG_RESET 0x11// PG3 | 54 | #define ISSI_REG_RESET 0x11 // PG3 |
| 58 | #define ISSI_REG_SWPULLUP 0x0F //PG3 | 55 | #define ISSI_REG_SWPULLUP 0x0F // PG3 |
| 59 | #define ISSI_REG_CSPULLUP 0x10 //PG3 | 56 | #define ISSI_REG_CSPULLUP 0x10 // PG3 |
| 60 | 57 | ||
| 61 | #ifndef ISSI_TIMEOUT | 58 | #ifndef ISSI_TIMEOUT |
| 62 | #define ISSI_TIMEOUT 100 | 59 | # define ISSI_TIMEOUT 100 |
| 63 | #endif | 60 | #endif |
| 64 | 61 | ||
| 65 | #ifndef ISSI_PERSISTENCE | 62 | #ifndef ISSI_PERSISTENCE |
| 66 | #define ISSI_PERSISTENCE 0 | 63 | # define ISSI_PERSISTENCE 0 |
| 67 | #endif | 64 | #endif |
| 68 | 65 | ||
| 69 | // Transfer buffer for TWITransmitData() | 66 | // Transfer buffer for TWITransmitData() |
| @@ -76,124 +73,113 @@ uint8_t g_twi_transfer_buffer[20]; | |||
| 76 | // buffers and the transfers in IS31FL3736_write_pwm_buffer() but it's | 73 | // buffers and the transfers in IS31FL3736_write_pwm_buffer() but it's |
| 77 | // probably not worth the extra complexity. | 74 | // probably not worth the extra complexity. |
| 78 | uint8_t g_pwm_buffer[DRIVER_COUNT][192]; | 75 | uint8_t g_pwm_buffer[DRIVER_COUNT][192]; |
| 79 | bool g_pwm_buffer_update_required = false; | 76 | bool g_pwm_buffer_update_required = false; |
| 80 | 77 | ||
| 81 | uint8_t g_led_control_registers[DRIVER_COUNT][24] = { { 0 }, { 0 } }; | 78 | uint8_t g_led_control_registers[DRIVER_COUNT][24] = {{0}, {0}}; |
| 82 | bool g_led_control_registers_update_required = false; | 79 | bool g_led_control_registers_update_required = false; |
| 83 | 80 | ||
| 84 | void IS31FL3736_write_register( uint8_t addr, uint8_t reg, uint8_t data ) | 81 | void IS31FL3736_write_register(uint8_t addr, uint8_t reg, uint8_t data) { |
| 85 | { | ||
| 86 | g_twi_transfer_buffer[0] = reg; | 82 | g_twi_transfer_buffer[0] = reg; |
| 87 | g_twi_transfer_buffer[1] = data; | 83 | g_twi_transfer_buffer[1] = data; |
| 88 | 84 | ||
| 89 | #if ISSI_PERSISTENCE > 0 | 85 | #if ISSI_PERSISTENCE > 0 |
| 90 | for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) { | 86 | for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) { |
| 91 | if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0) | 87 | if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0) break; |
| 92 | break; | ||
| 93 | } | 88 | } |
| 94 | #else | 89 | #else |
| 95 | i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT); | 90 | i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT); |
| 96 | #endif | 91 | #endif |
| 97 | } | 92 | } |
| 98 | 93 | ||
| 99 | void IS31FL3736_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer ) | 94 | void IS31FL3736_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { |
| 100 | { | ||
| 101 | // assumes PG1 is already selected | 95 | // assumes PG1 is already selected |
| 102 | 96 | ||
| 103 | // transmit PWM registers in 12 transfers of 16 bytes | 97 | // transmit PWM registers in 12 transfers of 16 bytes |
| 104 | // g_twi_transfer_buffer[] is 20 bytes | 98 | // g_twi_transfer_buffer[] is 20 bytes |
| 105 | 99 | ||
| 106 | // iterate over the pwm_buffer contents at 16 byte intervals | 100 | // iterate over the pwm_buffer contents at 16 byte intervals |
| 107 | for ( int i = 0; i < 192; i += 16 ) { | 101 | for (int i = 0; i < 192; i += 16) { |
| 108 | g_twi_transfer_buffer[0] = i; | 102 | g_twi_transfer_buffer[0] = i; |
| 109 | // copy the data from i to i+15 | 103 | // copy the data from i to i+15 |
| 110 | // device will auto-increment register for data after the first byte | 104 | // device will auto-increment register for data after the first byte |
| 111 | // thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer | 105 | // thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer |
| 112 | for ( int j = 0; j < 16; j++ ) { | 106 | for (int j = 0; j < 16; j++) { |
| 113 | g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j]; | 107 | g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j]; |
| 114 | } | 108 | } |
| 115 | 109 | ||
| 116 | #if ISSI_PERSISTENCE > 0 | 110 | #if ISSI_PERSISTENCE > 0 |
| 117 | for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) { | 111 | for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) { |
| 118 | if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0) | 112 | if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0) break; |
| 119 | break; | 113 | } |
| 120 | } | 114 | #else |
| 121 | #else | 115 | i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT); |
| 122 | i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT); | 116 | #endif |
| 123 | #endif | ||
| 124 | } | 117 | } |
| 125 | } | 118 | } |
| 126 | 119 | ||
| 127 | void IS31FL3736_init( uint8_t addr ) | 120 | void IS31FL3736_init(uint8_t addr) { |
| 128 | { | ||
| 129 | // In order to avoid the LEDs being driven with garbage data | 121 | // In order to avoid the LEDs being driven with garbage data |
| 130 | // in the LED driver's PWM registers, shutdown is enabled last. | 122 | // in the LED driver's PWM registers, shutdown is enabled last. |
| 131 | // Set up the mode and other settings, clear the PWM registers, | 123 | // Set up the mode and other settings, clear the PWM registers, |
| 132 | // then disable software shutdown. | 124 | // then disable software shutdown. |
| 133 | 125 | ||
| 134 | // Unlock the command register. | 126 | // Unlock the command register. |
| 135 | IS31FL3736_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 ); | 127 | IS31FL3736_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5); |
| 136 | 128 | ||
| 137 | // Select PG0 | 129 | // Select PG0 |
| 138 | IS31FL3736_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL ); | 130 | IS31FL3736_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL); |
| 139 | // Turn off all LEDs. | 131 | // Turn off all LEDs. |
| 140 | for ( int i = 0x00; i <= 0x17; i++ ) | 132 | for (int i = 0x00; i <= 0x17; i++) { |
| 141 | { | 133 | IS31FL3736_write_register(addr, i, 0x00); |
| 142 | IS31FL3736_write_register( addr, i, 0x00 ); | ||
| 143 | } | 134 | } |
| 144 | 135 | ||
| 145 | // Unlock the command register. | 136 | // Unlock the command register. |
| 146 | IS31FL3736_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 ); | 137 | IS31FL3736_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5); |
| 147 | 138 | ||
| 148 | // Select PG1 | 139 | // Select PG1 |
| 149 | IS31FL3736_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM ); | 140 | IS31FL3736_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM); |
| 150 | // Set PWM on all LEDs to 0 | 141 | // Set PWM on all LEDs to 0 |
| 151 | // No need to setup Breath registers to PWM as that is the default. | 142 | // No need to setup Breath registers to PWM as that is the default. |
| 152 | for ( int i = 0x00; i <= 0xBF; i++ ) | 143 | for (int i = 0x00; i <= 0xBF; i++) { |
| 153 | { | 144 | IS31FL3736_write_register(addr, i, 0x00); |
| 154 | IS31FL3736_write_register( addr, i, 0x00 ); | ||
| 155 | } | 145 | } |
| 156 | 146 | ||
| 157 | // Unlock the command register. | 147 | // Unlock the command register. |
| 158 | IS31FL3736_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 ); | 148 | IS31FL3736_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5); |
| 159 | 149 | ||
| 160 | // Select PG3 | 150 | // Select PG3 |
| 161 | IS31FL3736_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_FUNCTION ); | 151 | IS31FL3736_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_FUNCTION); |
| 162 | // Set global current to maximum. | 152 | // Set global current to maximum. |
| 163 | IS31FL3736_write_register( addr, ISSI_REG_GLOBALCURRENT, 0xFF ); | 153 | IS31FL3736_write_register(addr, ISSI_REG_GLOBALCURRENT, 0xFF); |
| 164 | // Disable software shutdown. | 154 | // Disable software shutdown. |
| 165 | IS31FL3736_write_register( addr, ISSI_REG_CONFIGURATION, 0x01 ); | 155 | IS31FL3736_write_register(addr, ISSI_REG_CONFIGURATION, 0x01); |
| 166 | 156 | ||
| 167 | // Wait 10ms to ensure the device has woken up. | 157 | // Wait 10ms to ensure the device has woken up. |
| 168 | #ifdef __AVR__ | 158 | #ifdef __AVR__ |
| 169 | _delay_ms( 10 ); | 159 | _delay_ms(10); |
| 170 | #else | 160 | #else |
| 171 | wait_ms(10); | 161 | wait_ms(10); |
| 172 | #endif | 162 | #endif |
| 173 | } | 163 | } |
| 174 | 164 | ||
| 175 | void IS31FL3736_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ) | 165 | void IS31FL3736_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { |
| 176 | { | 166 | if (index >= 0 && index < DRIVER_LED_TOTAL) { |
| 177 | if ( index >= 0 && index < DRIVER_LED_TOTAL ) { | ||
| 178 | is31_led led = g_is31_leds[index]; | 167 | is31_led led = g_is31_leds[index]; |
| 179 | 168 | ||
| 180 | g_pwm_buffer[led.driver][led.r] = red; | 169 | g_pwm_buffer[led.driver][led.r] = red; |
| 181 | g_pwm_buffer[led.driver][led.g] = green; | 170 | g_pwm_buffer[led.driver][led.g] = green; |
| 182 | g_pwm_buffer[led.driver][led.b] = blue; | 171 | g_pwm_buffer[led.driver][led.b] = blue; |
| 183 | g_pwm_buffer_update_required = true; | 172 | g_pwm_buffer_update_required = true; |
| 184 | } | 173 | } |
| 185 | } | 174 | } |
| 186 | 175 | ||
| 187 | void IS31FL3736_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) | 176 | void IS31FL3736_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { |
| 188 | { | 177 | for (int i = 0; i < DRIVER_LED_TOTAL; i++) { |
| 189 | for ( int i = 0; i < DRIVER_LED_TOTAL; i++ ) | 178 | IS31FL3736_set_color(i, red, green, blue); |
| 190 | { | ||
| 191 | IS31FL3736_set_color( i, red, green, blue ); | ||
| 192 | } | 179 | } |
| 193 | } | 180 | } |
| 194 | 181 | ||
| 195 | void IS31FL3736_set_led_control_register( uint8_t index, bool red, bool green, bool blue ) | 182 | void IS31FL3736_set_led_control_register(uint8_t index, bool red, bool green, bool blue) { |
| 196 | { | ||
| 197 | is31_led led = g_is31_leds[index]; | 183 | is31_led led = g_is31_leds[index]; |
| 198 | 184 | ||
| 199 | // IS31FL3733 | 185 | // IS31FL3733 |
| @@ -209,64 +195,59 @@ void IS31FL3736_set_led_control_register( uint8_t index, bool red, bool green, b | |||
| 209 | // A1-A4=0x00 A5-A8=0x01 | 195 | // A1-A4=0x00 A5-A8=0x01 |
| 210 | // So, the same math applies. | 196 | // So, the same math applies. |
| 211 | 197 | ||
| 212 | uint8_t control_register_r = led.r / 8; | 198 | uint8_t control_register_r = led.r / 8; |
| 213 | uint8_t control_register_g = led.g / 8; | 199 | uint8_t control_register_g = led.g / 8; |
| 214 | uint8_t control_register_b = led.b / 8; | 200 | uint8_t control_register_b = led.b / 8; |
| 215 | 201 | ||
| 216 | uint8_t bit_r = led.r % 8; | 202 | uint8_t bit_r = led.r % 8; |
| 217 | uint8_t bit_g = led.g % 8; | 203 | uint8_t bit_g = led.g % 8; |
| 218 | uint8_t bit_b = led.b % 8; | 204 | uint8_t bit_b = led.b % 8; |
| 219 | 205 | ||
| 220 | if ( red ) { | 206 | if (red) { |
| 221 | g_led_control_registers[led.driver][control_register_r] |= (1 << bit_r); | 207 | g_led_control_registers[led.driver][control_register_r] |= (1 << bit_r); |
| 222 | } else { | 208 | } else { |
| 223 | g_led_control_registers[led.driver][control_register_r] &= ~(1 << bit_r); | 209 | g_led_control_registers[led.driver][control_register_r] &= ~(1 << bit_r); |
| 224 | } | 210 | } |
| 225 | if ( green ) { | 211 | if (green) { |
| 226 | g_led_control_registers[led.driver][control_register_g] |= (1 << bit_g); | 212 | g_led_control_registers[led.driver][control_register_g] |= (1 << bit_g); |
| 227 | } else { | 213 | } else { |
| 228 | g_led_control_registers[led.driver][control_register_g] &= ~(1 << bit_g); | 214 | g_led_control_registers[led.driver][control_register_g] &= ~(1 << bit_g); |
| 229 | } | 215 | } |
| 230 | if ( blue ) { | 216 | if (blue) { |
| 231 | g_led_control_registers[led.driver][control_register_b] |= (1 << bit_b); | 217 | g_led_control_registers[led.driver][control_register_b] |= (1 << bit_b); |
| 232 | } else { | 218 | } else { |
| 233 | g_led_control_registers[led.driver][control_register_b] &= ~(1 << bit_b); | 219 | g_led_control_registers[led.driver][control_register_b] &= ~(1 << bit_b); |
| 234 | } | 220 | } |
| 235 | 221 | ||
| 236 | g_led_control_registers_update_required = true; | 222 | g_led_control_registers_update_required = true; |
| 237 | |||
| 238 | } | 223 | } |
| 239 | 224 | ||
| 240 | void IS31FL3736_mono_set_brightness( int index, uint8_t value ) | 225 | void IS31FL3736_mono_set_brightness(int index, uint8_t value) { |
| 241 | { | 226 | if (index >= 0 && index < 96) { |
| 242 | if ( index >= 0 && index < 96 ) { | 227 | // Index in range 0..95 -> A1..A8, B1..B8, etc. |
| 243 | // Index in range 0..95 -> A1..A8, B1..B8, etc. | 228 | // Map index 0..95 to registers 0x00..0xBE (interleaved) |
| 244 | // Map index 0..95 to registers 0x00..0xBE (interleaved) | 229 | uint8_t pwm_register = index * 2; |
| 245 | uint8_t pwm_register = index * 2; | ||
| 246 | g_pwm_buffer[0][pwm_register] = value; | 230 | g_pwm_buffer[0][pwm_register] = value; |
| 247 | g_pwm_buffer_update_required = true; | 231 | g_pwm_buffer_update_required = true; |
| 248 | } | 232 | } |
| 249 | } | 233 | } |
| 250 | 234 | ||
| 251 | void IS31FL3736_mono_set_brightness_all( uint8_t value ) | 235 | void IS31FL3736_mono_set_brightness_all(uint8_t value) { |
| 252 | { | 236 | for (int i = 0; i < 96; i++) { |
| 253 | for ( int i = 0; i < 96; i++ ) | 237 | IS31FL3736_mono_set_brightness(i, value); |
| 254 | { | ||
| 255 | IS31FL3736_mono_set_brightness( i, value ); | ||
| 256 | } | 238 | } |
| 257 | } | 239 | } |
| 258 | 240 | ||
| 259 | void IS31FL3736_mono_set_led_control_register( uint8_t index, bool enabled ) | 241 | void IS31FL3736_mono_set_led_control_register(uint8_t index, bool enabled) { |
| 260 | { | 242 | // Index in range 0..95 -> A1..A8, B1..B8, etc. |
| 261 | // Index in range 0..95 -> A1..A8, B1..B8, etc. | ||
| 262 | 243 | ||
| 263 | // Map index 0..95 to registers 0x00..0xBE (interleaved) | 244 | // Map index 0..95 to registers 0x00..0xBE (interleaved) |
| 264 | uint8_t pwm_register = index * 2; | 245 | uint8_t pwm_register = index * 2; |
| 265 | // Map register 0x00..0xBE (interleaved) into control register and bit | 246 | // Map register 0x00..0xBE (interleaved) into control register and bit |
| 266 | uint8_t control_register = pwm_register / 8; | 247 | uint8_t control_register = pwm_register / 8; |
| 267 | uint8_t bit = pwm_register % 8; | 248 | uint8_t bit = pwm_register % 8; |
| 268 | 249 | ||
| 269 | if ( enabled ) { | 250 | if (enabled) { |
| 270 | g_led_control_registers[0][control_register] |= (1 << bit); | 251 | g_led_control_registers[0][control_register] |= (1 << bit); |
| 271 | } else { | 252 | } else { |
| 272 | g_led_control_registers[0][control_register] &= ~(1 << bit); | 253 | g_led_control_registers[0][control_register] &= ~(1 << bit); |
| @@ -275,32 +256,26 @@ void IS31FL3736_mono_set_led_control_register( uint8_t index, bool enabled ) | |||
| 275 | g_led_control_registers_update_required = true; | 256 | g_led_control_registers_update_required = true; |
| 276 | } | 257 | } |
| 277 | 258 | ||
| 278 | void IS31FL3736_update_pwm_buffers( uint8_t addr1, uint8_t addr2 ) | 259 | void IS31FL3736_update_pwm_buffers(uint8_t addr1, uint8_t addr2) { |
| 279 | { | 260 | if (g_pwm_buffer_update_required) { |
| 280 | if ( g_pwm_buffer_update_required ) | ||
| 281 | { | ||
| 282 | // Firstly we need to unlock the command register and select PG1 | 261 | // Firstly we need to unlock the command register and select PG1 |
| 283 | IS31FL3736_write_register( addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 ); | 262 | IS31FL3736_write_register(addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5); |
| 284 | IS31FL3736_write_register( addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM ); | 263 | IS31FL3736_write_register(addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM); |
| 285 | 264 | ||
| 286 | IS31FL3736_write_pwm_buffer( addr1, g_pwm_buffer[0] ); | 265 | IS31FL3736_write_pwm_buffer(addr1, g_pwm_buffer[0]); |
| 287 | //IS31FL3736_write_pwm_buffer( addr2, g_pwm_buffer[1] ); | 266 | // IS31FL3736_write_pwm_buffer( addr2, g_pwm_buffer[1] ); |
| 288 | } | 267 | } |
| 289 | g_pwm_buffer_update_required = false; | 268 | g_pwm_buffer_update_required = false; |
| 290 | } | 269 | } |
| 291 | 270 | ||
| 292 | void IS31FL3736_update_led_control_registers( uint8_t addr1, uint8_t addr2 ) | 271 | void IS31FL3736_update_led_control_registers(uint8_t addr1, uint8_t addr2) { |
| 293 | { | 272 | if (g_led_control_registers_update_required) { |
| 294 | if ( g_led_control_registers_update_required ) | ||
| 295 | { | ||
| 296 | // Firstly we need to unlock the command register and select PG0 | 273 | // Firstly we need to unlock the command register and select PG0 |
| 297 | IS31FL3736_write_register( addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 ); | 274 | IS31FL3736_write_register(addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5); |
| 298 | IS31FL3736_write_register( addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL ); | 275 | IS31FL3736_write_register(addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL); |
| 299 | for ( int i=0; i<24; i++ ) | 276 | for (int i = 0; i < 24; i++) { |
| 300 | { | 277 | IS31FL3736_write_register(addr1, i, g_led_control_registers[0][i]); |
| 301 | IS31FL3736_write_register(addr1, i, g_led_control_registers[0][i] ); | 278 | // IS31FL3736_write_register(addr2, i, g_led_control_registers[1][i] ); |
| 302 | //IS31FL3736_write_register(addr2, i, g_led_control_registers[1][i] ); | ||
| 303 | } | 279 | } |
| 304 | } | 280 | } |
| 305 | } | 281 | } |
| 306 | |||
diff --git a/drivers/issi/is31fl3736.h b/drivers/issi/is31fl3736.h index cff50fd0d..e48e31c27 100644 --- a/drivers/issi/is31fl3736.h +++ b/drivers/issi/is31fl3736.h | |||
| @@ -19,154 +19,150 @@ | |||
| 19 | #include <stdint.h> | 19 | #include <stdint.h> |
| 20 | #include <stdbool.h> | 20 | #include <stdbool.h> |
| 21 | 21 | ||
| 22 | |||
| 23 | // Simple interface option. | 22 | // Simple interface option. |
| 24 | // If these aren't defined, just define them to make it compile | 23 | // If these aren't defined, just define them to make it compile |
| 25 | 24 | ||
| 26 | |||
| 27 | #ifndef DRIVER_COUNT | 25 | #ifndef DRIVER_COUNT |
| 28 | #define DRIVER_COUNT 2 | 26 | # define DRIVER_COUNT 2 |
| 29 | #endif | 27 | #endif |
| 30 | 28 | ||
| 31 | #ifndef DRIVER_LED_TOTAL | 29 | #ifndef DRIVER_LED_TOTAL |
| 32 | #define DRIVER_LED_TOTAL 96 | 30 | # define DRIVER_LED_TOTAL 96 |
| 33 | #endif | 31 | #endif |
| 34 | 32 | ||
| 35 | |||
| 36 | typedef struct is31_led { | 33 | typedef struct is31_led { |
| 37 | uint8_t driver:2; | 34 | uint8_t driver : 2; |
| 38 | uint8_t r; | 35 | uint8_t r; |
| 39 | uint8_t g; | 36 | uint8_t g; |
| 40 | uint8_t b; | 37 | uint8_t b; |
| 41 | } __attribute__((packed)) is31_led; | 38 | } __attribute__((packed)) is31_led; |
| 42 | 39 | ||
| 43 | extern const is31_led g_is31_leds[DRIVER_LED_TOTAL]; | 40 | extern const is31_led g_is31_leds[DRIVER_LED_TOTAL]; |
| 44 | 41 | ||
| 45 | void IS31FL3736_init( uint8_t addr ); | 42 | void IS31FL3736_init(uint8_t addr); |
| 46 | void IS31FL3736_write_register( uint8_t addr, uint8_t reg, uint8_t data ); | 43 | void IS31FL3736_write_register(uint8_t addr, uint8_t reg, uint8_t data); |
| 47 | void IS31FL3736_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer ); | 44 | void IS31FL3736_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer); |
| 48 | 45 | ||
| 49 | void IS31FL3736_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ); | 46 | void IS31FL3736_set_color(int index, uint8_t red, uint8_t green, uint8_t blue); |
| 50 | void IS31FL3736_set_color_all( uint8_t red, uint8_t green, uint8_t blue ); | 47 | void IS31FL3736_set_color_all(uint8_t red, uint8_t green, uint8_t blue); |
| 51 | 48 | ||
| 52 | void IS31FL3736_set_led_control_register( uint8_t index, bool red, bool green, bool blue ); | 49 | void IS31FL3736_set_led_control_register(uint8_t index, bool red, bool green, bool blue); |
| 53 | 50 | ||
| 54 | void IS31FL3736_mono_set_brightness( int index, uint8_t value ); | 51 | void IS31FL3736_mono_set_brightness(int index, uint8_t value); |
| 55 | void IS31FL3736_mono_set_brightness_all( uint8_t value ); | 52 | void IS31FL3736_mono_set_brightness_all(uint8_t value); |
| 56 | void IS31FL3736_mono_set_led_control_register( uint8_t index, bool enabled ); | 53 | void IS31FL3736_mono_set_led_control_register(uint8_t index, bool enabled); |
| 57 | 54 | ||
| 58 | // This should not be called from an interrupt | 55 | // This should not be called from an interrupt |
| 59 | // (eg. from a timer interrupt). | 56 | // (eg. from a timer interrupt). |
| 60 | // Call this while idle (in between matrix scans). | 57 | // Call this while idle (in between matrix scans). |
| 61 | // If the buffer is dirty, it will update the driver with the buffer. | 58 | // If the buffer is dirty, it will update the driver with the buffer. |
| 62 | void IS31FL3736_update_pwm_buffers( uint8_t addr1, uint8_t addr2 ); | 59 | void IS31FL3736_update_pwm_buffers(uint8_t addr1, uint8_t addr2); |
| 63 | void IS31FL3736_update_led_control_registers( uint8_t addr1, uint8_t addr2 ); | 60 | void IS31FL3736_update_led_control_registers(uint8_t addr1, uint8_t addr2); |
| 64 | 61 | ||
| 65 | #define A_1 0x00 | 62 | #define A_1 0x00 |
| 66 | #define A_2 0x02 | 63 | #define A_2 0x02 |
| 67 | #define A_3 0x04 | 64 | #define A_3 0x04 |
| 68 | #define A_4 0x06 | 65 | #define A_4 0x06 |
| 69 | #define A_5 0x08 | 66 | #define A_5 0x08 |
| 70 | #define A_6 0x0A | 67 | #define A_6 0x0A |
| 71 | #define A_7 0x0C | 68 | #define A_7 0x0C |
| 72 | #define A_8 0x0E | 69 | #define A_8 0x0E |
| 73 | 70 | ||
| 74 | #define B_1 0x10 | 71 | #define B_1 0x10 |
| 75 | #define B_2 0x12 | 72 | #define B_2 0x12 |
| 76 | #define B_3 0x14 | 73 | #define B_3 0x14 |
| 77 | #define B_4 0x16 | 74 | #define B_4 0x16 |
| 78 | #define B_5 0x18 | 75 | #define B_5 0x18 |
| 79 | #define B_6 0x1A | 76 | #define B_6 0x1A |
| 80 | #define B_7 0x1C | 77 | #define B_7 0x1C |
| 81 | #define B_8 0x1E | 78 | #define B_8 0x1E |
| 82 | 79 | ||
| 83 | #define C_1 0x20 | 80 | #define C_1 0x20 |
| 84 | #define C_2 0x22 | 81 | #define C_2 0x22 |
| 85 | #define C_3 0x24 | 82 | #define C_3 0x24 |
| 86 | #define C_4 0x26 | 83 | #define C_4 0x26 |
| 87 | #define C_5 0x28 | 84 | #define C_5 0x28 |
| 88 | #define C_6 0x2A | 85 | #define C_6 0x2A |
| 89 | #define C_7 0x2C | 86 | #define C_7 0x2C |
| 90 | #define C_8 0x2E | 87 | #define C_8 0x2E |
| 91 | 88 | ||
| 92 | #define D_1 0x30 | 89 | #define D_1 0x30 |
| 93 | #define D_2 0x32 | 90 | #define D_2 0x32 |
| 94 | #define D_3 0x34 | 91 | #define D_3 0x34 |
| 95 | #define D_4 0x36 | 92 | #define D_4 0x36 |
| 96 | #define D_5 0x38 | 93 | #define D_5 0x38 |
| 97 | #define D_6 0x3A | 94 | #define D_6 0x3A |
| 98 | #define D_7 0x3C | 95 | #define D_7 0x3C |
| 99 | #define D_8 0x3E | 96 | #define D_8 0x3E |
| 100 | 97 | ||
| 101 | #define E_1 0x40 | 98 | #define E_1 0x40 |
| 102 | #define E_2 0x42 | 99 | #define E_2 0x42 |
| 103 | #define E_3 0x44 | 100 | #define E_3 0x44 |
| 104 | #define E_4 0x46 | 101 | #define E_4 0x46 |
| 105 | #define E_5 0x48 | 102 | #define E_5 0x48 |
| 106 | #define E_6 0x4A | 103 | #define E_6 0x4A |
| 107 | #define E_7 0x4C | 104 | #define E_7 0x4C |
| 108 | #define E_8 0x4E | 105 | #define E_8 0x4E |
| 109 | 106 | ||
| 110 | #define F_1 0x50 | 107 | #define F_1 0x50 |
| 111 | #define F_2 0x52 | 108 | #define F_2 0x52 |
| 112 | #define F_3 0x54 | 109 | #define F_3 0x54 |
| 113 | #define F_4 0x56 | 110 | #define F_4 0x56 |
| 114 | #define F_5 0x58 | 111 | #define F_5 0x58 |
| 115 | #define F_6 0x5A | 112 | #define F_6 0x5A |
| 116 | #define F_7 0x5C | 113 | #define F_7 0x5C |
| 117 | #define F_8 0x5E | 114 | #define F_8 0x5E |
| 118 | 115 | ||
| 119 | #define G_1 0x60 | 116 | #define G_1 0x60 |
| 120 | #define G_2 0x62 | 117 | #define G_2 0x62 |
| 121 | #define G_3 0x64 | 118 | #define G_3 0x64 |
| 122 | #define G_4 0x66 | 119 | #define G_4 0x66 |
| 123 | #define G_5 0x68 | 120 | #define G_5 0x68 |
| 124 | #define G_6 0x6A | 121 | #define G_6 0x6A |
| 125 | #define G_7 0x6C | 122 | #define G_7 0x6C |
| 126 | #define G_8 0x6E | 123 | #define G_8 0x6E |
| 127 | 124 | ||
| 128 | #define H_1 0x70 | 125 | #define H_1 0x70 |
| 129 | #define H_2 0x72 | 126 | #define H_2 0x72 |
| 130 | #define H_3 0x74 | 127 | #define H_3 0x74 |
| 131 | #define H_4 0x76 | 128 | #define H_4 0x76 |
| 132 | #define H_5 0x78 | 129 | #define H_5 0x78 |
| 133 | #define H_6 0x7A | 130 | #define H_6 0x7A |
| 134 | #define H_7 0x7C | 131 | #define H_7 0x7C |
| 135 | #define H_8 0x7E | 132 | #define H_8 0x7E |
| 136 | 133 | ||
| 137 | #define I_1 0x80 | 134 | #define I_1 0x80 |
| 138 | #define I_2 0x82 | 135 | #define I_2 0x82 |
| 139 | #define I_3 0x84 | 136 | #define I_3 0x84 |
| 140 | #define I_4 0x86 | 137 | #define I_4 0x86 |
| 141 | #define I_5 0x88 | 138 | #define I_5 0x88 |
| 142 | #define I_6 0x8A | 139 | #define I_6 0x8A |
| 143 | #define I_7 0x8C | 140 | #define I_7 0x8C |
| 144 | #define I_8 0x8E | 141 | #define I_8 0x8E |
| 145 | 142 | ||
| 146 | #define J_1 0x90 | 143 | #define J_1 0x90 |
| 147 | #define J_2 0x92 | 144 | #define J_2 0x92 |
| 148 | #define J_3 0x94 | 145 | #define J_3 0x94 |
| 149 | #define J_4 0x96 | 146 | #define J_4 0x96 |
| 150 | #define J_5 0x98 | 147 | #define J_5 0x98 |
| 151 | #define J_6 0x9A | 148 | #define J_6 0x9A |
| 152 | #define J_7 0x9C | 149 | #define J_7 0x9C |
| 153 | #define J_8 0x9E | 150 | #define J_8 0x9E |
| 154 | 151 | ||
| 155 | #define K_1 0xA0 | 152 | #define K_1 0xA0 |
| 156 | #define K_2 0xA2 | 153 | #define K_2 0xA2 |
| 157 | #define K_3 0xA4 | 154 | #define K_3 0xA4 |
| 158 | #define K_4 0xA6 | 155 | #define K_4 0xA6 |
| 159 | #define K_5 0xA8 | 156 | #define K_5 0xA8 |
| 160 | #define K_6 0xAA | 157 | #define K_6 0xAA |
| 161 | #define K_7 0xAC | 158 | #define K_7 0xAC |
| 162 | #define K_8 0xAE | 159 | #define K_8 0xAE |
| 163 | 160 | ||
| 164 | #define L_1 0xB0 | 161 | #define L_1 0xB0 |
| 165 | #define L_2 0xB2 | 162 | #define L_2 0xB2 |
| 166 | #define L_3 0xB4 | 163 | #define L_3 0xB4 |
| 167 | #define L_4 0xB6 | 164 | #define L_4 0xB6 |
| 168 | #define L_5 0xB8 | 165 | #define L_5 0xB8 |
| 169 | #define L_6 0xBA | 166 | #define L_6 0xBA |
| 170 | #define L_7 0xBC | 167 | #define L_7 0xBC |
| 171 | #define L_8 0xBE | 168 | #define L_8 0xBE |
| 172 | |||
diff --git a/drivers/issi/is31fl3737.c b/drivers/issi/is31fl3737.c index 649104927..4cc46272e 100644 --- a/drivers/issi/is31fl3737.c +++ b/drivers/issi/is31fl3737.c | |||
| @@ -17,11 +17,11 @@ | |||
| 17 | */ | 17 | */ |
| 18 | 18 | ||
| 19 | #ifdef __AVR__ | 19 | #ifdef __AVR__ |
| 20 | #include <avr/interrupt.h> | 20 | # include <avr/interrupt.h> |
| 21 | #include <avr/io.h> | 21 | # include <avr/io.h> |
| 22 | #include <util/delay.h> | 22 | # include <util/delay.h> |
| 23 | #else | 23 | #else |
| 24 | #include "wait.h" | 24 | # include "wait.h" |
| 25 | #endif | 25 | #endif |
| 26 | 26 | ||
| 27 | #include <string.h> | 27 | #include <string.h> |
| @@ -46,23 +46,23 @@ | |||
| 46 | #define ISSI_INTERRUPTMASKREGISTER 0xF0 | 46 | #define ISSI_INTERRUPTMASKREGISTER 0xF0 |
| 47 | #define ISSI_INTERRUPTSTATUSREGISTER 0xF1 | 47 | #define ISSI_INTERRUPTSTATUSREGISTER 0xF1 |
| 48 | 48 | ||
| 49 | #define ISSI_PAGE_LEDCONTROL 0x00 //PG0 | 49 | #define ISSI_PAGE_LEDCONTROL 0x00 // PG0 |
| 50 | #define ISSI_PAGE_PWM 0x01 //PG1 | 50 | #define ISSI_PAGE_PWM 0x01 // PG1 |
| 51 | #define ISSI_PAGE_AUTOBREATH 0x02 //PG2 | 51 | #define ISSI_PAGE_AUTOBREATH 0x02 // PG2 |
| 52 | #define ISSI_PAGE_FUNCTION 0x03 //PG3 | 52 | #define ISSI_PAGE_FUNCTION 0x03 // PG3 |
| 53 | 53 | ||
| 54 | #define ISSI_REG_CONFIGURATION 0x00 //PG3 | 54 | #define ISSI_REG_CONFIGURATION 0x00 // PG3 |
| 55 | #define ISSI_REG_GLOBALCURRENT 0x01 //PG3 | 55 | #define ISSI_REG_GLOBALCURRENT 0x01 // PG3 |
| 56 | #define ISSI_REG_RESET 0x11// PG3 | 56 | #define ISSI_REG_RESET 0x11 // PG3 |
| 57 | #define ISSI_REG_SWPULLUP 0x0F //PG3 | 57 | #define ISSI_REG_SWPULLUP 0x0F // PG3 |
| 58 | #define ISSI_REG_CSPULLUP 0x10 //PG3 | 58 | #define ISSI_REG_CSPULLUP 0x10 // PG3 |
| 59 | 59 | ||
| 60 | #ifndef ISSI_TIMEOUT | 60 | #ifndef ISSI_TIMEOUT |
| 61 | #define ISSI_TIMEOUT 100 | 61 | # define ISSI_TIMEOUT 100 |
| 62 | #endif | 62 | #endif |
| 63 | 63 | ||
| 64 | #ifndef ISSI_PERSISTENCE | 64 | #ifndef ISSI_PERSISTENCE |
| 65 | #define ISSI_PERSISTENCE 0 | 65 | # define ISSI_PERSISTENCE 0 |
| 66 | #endif | 66 | #endif |
| 67 | 67 | ||
| 68 | // Transfer buffer for TWITransmitData() | 68 | // Transfer buffer for TWITransmitData() |
| @@ -75,178 +75,161 @@ uint8_t g_twi_transfer_buffer[20]; | |||
| 75 | // buffers and the transfers in IS31FL3737_write_pwm_buffer() but it's | 75 | // buffers and the transfers in IS31FL3737_write_pwm_buffer() but it's |
| 76 | // probably not worth the extra complexity. | 76 | // probably not worth the extra complexity. |
| 77 | uint8_t g_pwm_buffer[DRIVER_COUNT][192]; | 77 | uint8_t g_pwm_buffer[DRIVER_COUNT][192]; |
| 78 | bool g_pwm_buffer_update_required = false; | 78 | bool g_pwm_buffer_update_required = false; |
| 79 | 79 | ||
| 80 | uint8_t g_led_control_registers[DRIVER_COUNT][24] = { { 0 } }; | 80 | uint8_t g_led_control_registers[DRIVER_COUNT][24] = {{0}}; |
| 81 | bool g_led_control_registers_update_required = false; | 81 | bool g_led_control_registers_update_required = false; |
| 82 | 82 | ||
| 83 | void IS31FL3737_write_register( uint8_t addr, uint8_t reg, uint8_t data ) | 83 | void IS31FL3737_write_register(uint8_t addr, uint8_t reg, uint8_t data) { |
| 84 | { | ||
| 85 | g_twi_transfer_buffer[0] = reg; | 84 | g_twi_transfer_buffer[0] = reg; |
| 86 | g_twi_transfer_buffer[1] = data; | 85 | g_twi_transfer_buffer[1] = data; |
| 87 | 86 | ||
| 88 | #if ISSI_PERSISTENCE > 0 | 87 | #if ISSI_PERSISTENCE > 0 |
| 89 | for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) { | 88 | for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) { |
| 90 | if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0) | 89 | if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0) break; |
| 91 | break; | ||
| 92 | } | 90 | } |
| 93 | #else | 91 | #else |
| 94 | i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT); | 92 | i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT); |
| 95 | #endif | 93 | #endif |
| 96 | } | 94 | } |
| 97 | 95 | ||
| 98 | void IS31FL3737_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer ) | 96 | void IS31FL3737_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { |
| 99 | { | ||
| 100 | // assumes PG1 is already selected | 97 | // assumes PG1 is already selected |
| 101 | 98 | ||
| 102 | // transmit PWM registers in 12 transfers of 16 bytes | 99 | // transmit PWM registers in 12 transfers of 16 bytes |
| 103 | // g_twi_transfer_buffer[] is 20 bytes | 100 | // g_twi_transfer_buffer[] is 20 bytes |
| 104 | 101 | ||
| 105 | // iterate over the pwm_buffer contents at 16 byte intervals | 102 | // iterate over the pwm_buffer contents at 16 byte intervals |
| 106 | for ( int i = 0; i < 192; i += 16 ) { | 103 | for (int i = 0; i < 192; i += 16) { |
| 107 | g_twi_transfer_buffer[0] = i; | 104 | g_twi_transfer_buffer[0] = i; |
| 108 | // copy the data from i to i+15 | 105 | // copy the data from i to i+15 |
| 109 | // device will auto-increment register for data after the first byte | 106 | // device will auto-increment register for data after the first byte |
| 110 | // thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer | 107 | // thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer |
| 111 | for ( int j = 0; j < 16; j++ ) { | 108 | for (int j = 0; j < 16; j++) { |
| 112 | g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j]; | 109 | g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j]; |
| 113 | } | 110 | } |
| 114 | 111 | ||
| 115 | #if ISSI_PERSISTENCE > 0 | 112 | #if ISSI_PERSISTENCE > 0 |
| 116 | for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) { | 113 | for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) { |
| 117 | if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0) | 114 | if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0) break; |
| 118 | break; | 115 | } |
| 119 | } | 116 | #else |
| 120 | #else | 117 | i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT); |
| 121 | i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT); | 118 | #endif |
| 122 | #endif | ||
| 123 | } | 119 | } |
| 124 | } | 120 | } |
| 125 | 121 | ||
| 126 | void IS31FL3737_init( uint8_t addr ) | 122 | void IS31FL3737_init(uint8_t addr) { |
| 127 | { | ||
| 128 | // In order to avoid the LEDs being driven with garbage data | 123 | // In order to avoid the LEDs being driven with garbage data |
| 129 | // in the LED driver's PWM registers, shutdown is enabled last. | 124 | // in the LED driver's PWM registers, shutdown is enabled last. |
| 130 | // Set up the mode and other settings, clear the PWM registers, | 125 | // Set up the mode and other settings, clear the PWM registers, |
| 131 | // then disable software shutdown. | 126 | // then disable software shutdown. |
| 132 | 127 | ||
| 133 | // Unlock the command register. | 128 | // Unlock the command register. |
| 134 | IS31FL3737_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 ); | 129 | IS31FL3737_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5); |
| 135 | 130 | ||
| 136 | // Select PG0 | 131 | // Select PG0 |
| 137 | IS31FL3737_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL ); | 132 | IS31FL3737_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL); |
| 138 | // Turn off all LEDs. | 133 | // Turn off all LEDs. |
| 139 | for ( int i = 0x00; i <= 0x17; i++ ) | 134 | for (int i = 0x00; i <= 0x17; i++) { |
| 140 | { | 135 | IS31FL3737_write_register(addr, i, 0x00); |
| 141 | IS31FL3737_write_register( addr, i, 0x00 ); | ||
| 142 | } | 136 | } |
| 143 | 137 | ||
| 144 | // Unlock the command register. | 138 | // Unlock the command register. |
| 145 | IS31FL3737_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 ); | 139 | IS31FL3737_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5); |
| 146 | 140 | ||
| 147 | // Select PG1 | 141 | // Select PG1 |
| 148 | IS31FL3737_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM ); | 142 | IS31FL3737_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM); |
| 149 | // Set PWM on all LEDs to 0 | 143 | // Set PWM on all LEDs to 0 |
| 150 | // No need to setup Breath registers to PWM as that is the default. | 144 | // No need to setup Breath registers to PWM as that is the default. |
| 151 | for ( int i = 0x00; i <= 0xBF; i++ ) | 145 | for (int i = 0x00; i <= 0xBF; i++) { |
| 152 | { | 146 | IS31FL3737_write_register(addr, i, 0x00); |
| 153 | IS31FL3737_write_register( addr, i, 0x00 ); | ||
| 154 | } | 147 | } |
| 155 | 148 | ||
| 156 | // Unlock the command register. | 149 | // Unlock the command register. |
| 157 | IS31FL3737_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 ); | 150 | IS31FL3737_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5); |
| 158 | 151 | ||
| 159 | // Select PG3 | 152 | // Select PG3 |
| 160 | IS31FL3737_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_FUNCTION ); | 153 | IS31FL3737_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_FUNCTION); |
| 161 | // Set global current to maximum. | 154 | // Set global current to maximum. |
| 162 | IS31FL3737_write_register( addr, ISSI_REG_GLOBALCURRENT, 0xFF ); | 155 | IS31FL3737_write_register(addr, ISSI_REG_GLOBALCURRENT, 0xFF); |
| 163 | // Disable software shutdown. | 156 | // Disable software shutdown. |
| 164 | IS31FL3737_write_register( addr, ISSI_REG_CONFIGURATION, 0x01 ); | 157 | IS31FL3737_write_register(addr, ISSI_REG_CONFIGURATION, 0x01); |
| 165 | 158 | ||
| 166 | // Wait 10ms to ensure the device has woken up. | 159 | // Wait 10ms to ensure the device has woken up. |
| 167 | #ifdef __AVR__ | 160 | #ifdef __AVR__ |
| 168 | _delay_ms( 10 ); | 161 | _delay_ms(10); |
| 169 | #else | 162 | #else |
| 170 | wait_ms(10); | 163 | wait_ms(10); |
| 171 | #endif | 164 | #endif |
| 172 | } | 165 | } |
| 173 | 166 | ||
| 174 | void IS31FL3737_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ) | 167 | void IS31FL3737_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { |
| 175 | { | 168 | if (index >= 0 && index < DRIVER_LED_TOTAL) { |
| 176 | if ( index >= 0 && index < DRIVER_LED_TOTAL ) { | ||
| 177 | is31_led led = g_is31_leds[index]; | 169 | is31_led led = g_is31_leds[index]; |
| 178 | 170 | ||
| 179 | g_pwm_buffer[led.driver][led.r] = red; | 171 | g_pwm_buffer[led.driver][led.r] = red; |
| 180 | g_pwm_buffer[led.driver][led.g] = green; | 172 | g_pwm_buffer[led.driver][led.g] = green; |
| 181 | g_pwm_buffer[led.driver][led.b] = blue; | 173 | g_pwm_buffer[led.driver][led.b] = blue; |
| 182 | g_pwm_buffer_update_required = true; | 174 | g_pwm_buffer_update_required = true; |
| 183 | } | 175 | } |
| 184 | } | 176 | } |
| 185 | 177 | ||
| 186 | void IS31FL3737_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) | 178 | void IS31FL3737_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { |
| 187 | { | 179 | for (int i = 0; i < DRIVER_LED_TOTAL; i++) { |
| 188 | for ( int i = 0; i < DRIVER_LED_TOTAL; i++ ) | 180 | IS31FL3737_set_color(i, red, green, blue); |
| 189 | { | ||
| 190 | IS31FL3737_set_color( i, red, green, blue ); | ||
| 191 | } | 181 | } |
| 192 | } | 182 | } |
| 193 | 183 | ||
| 194 | void IS31FL3737_set_led_control_register( uint8_t index, bool red, bool green, bool blue ) | 184 | void IS31FL3737_set_led_control_register(uint8_t index, bool red, bool green, bool blue) { |
| 195 | { | ||
| 196 | is31_led led = g_is31_leds[index]; | 185 | is31_led led = g_is31_leds[index]; |
| 197 | 186 | ||
| 198 | uint8_t control_register_r = led.r / 8; | 187 | uint8_t control_register_r = led.r / 8; |
| 199 | uint8_t control_register_g = led.g / 8; | 188 | uint8_t control_register_g = led.g / 8; |
| 200 | uint8_t control_register_b = led.b / 8; | 189 | uint8_t control_register_b = led.b / 8; |
| 201 | uint8_t bit_r = led.r % 8; | 190 | uint8_t bit_r = led.r % 8; |
| 202 | uint8_t bit_g = led.g % 8; | 191 | uint8_t bit_g = led.g % 8; |
| 203 | uint8_t bit_b = led.b % 8; | 192 | uint8_t bit_b = led.b % 8; |
| 204 | 193 | ||
| 205 | if ( red ) { | 194 | if (red) { |
| 206 | g_led_control_registers[led.driver][control_register_r] |= (1 << bit_r); | 195 | g_led_control_registers[led.driver][control_register_r] |= (1 << bit_r); |
| 207 | } else { | 196 | } else { |
| 208 | g_led_control_registers[led.driver][control_register_r] &= ~(1 << bit_r); | 197 | g_led_control_registers[led.driver][control_register_r] &= ~(1 << bit_r); |
| 209 | } | 198 | } |
| 210 | if ( green ) { | 199 | if (green) { |
| 211 | g_led_control_registers[led.driver][control_register_g] |= (1 << bit_g); | 200 | g_led_control_registers[led.driver][control_register_g] |= (1 << bit_g); |
| 212 | } else { | 201 | } else { |
| 213 | g_led_control_registers[led.driver][control_register_g] &= ~(1 << bit_g); | 202 | g_led_control_registers[led.driver][control_register_g] &= ~(1 << bit_g); |
| 214 | } | 203 | } |
| 215 | if ( blue ) { | 204 | if (blue) { |
| 216 | g_led_control_registers[led.driver][control_register_b] |= (1 << bit_b); | 205 | g_led_control_registers[led.driver][control_register_b] |= (1 << bit_b); |
| 217 | } else { | 206 | } else { |
| 218 | g_led_control_registers[led.driver][control_register_b] &= ~(1 << bit_b); | 207 | g_led_control_registers[led.driver][control_register_b] &= ~(1 << bit_b); |
| 219 | } | 208 | } |
| 220 | 209 | ||
| 221 | g_led_control_registers_update_required = true; | 210 | g_led_control_registers_update_required = true; |
| 222 | |||
| 223 | } | 211 | } |
| 224 | 212 | ||
| 225 | void IS31FL3737_update_pwm_buffers( uint8_t addr1, uint8_t addr2 ) | 213 | void IS31FL3737_update_pwm_buffers(uint8_t addr1, uint8_t addr2) { |
| 226 | { | 214 | if (g_pwm_buffer_update_required) { |
| 227 | if ( g_pwm_buffer_update_required ) | ||
| 228 | { | ||
| 229 | // Firstly we need to unlock the command register and select PG1 | 215 | // Firstly we need to unlock the command register and select PG1 |
| 230 | IS31FL3737_write_register( addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 ); | 216 | IS31FL3737_write_register(addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5); |
| 231 | IS31FL3737_write_register( addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM ); | 217 | IS31FL3737_write_register(addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM); |
| 232 | 218 | ||
| 233 | IS31FL3737_write_pwm_buffer( addr1, g_pwm_buffer[0] ); | 219 | IS31FL3737_write_pwm_buffer(addr1, g_pwm_buffer[0]); |
| 234 | //IS31FL3737_write_pwm_buffer( addr2, g_pwm_buffer[1] ); | 220 | // IS31FL3737_write_pwm_buffer( addr2, g_pwm_buffer[1] ); |
| 235 | } | 221 | } |
| 236 | g_pwm_buffer_update_required = false; | 222 | g_pwm_buffer_update_required = false; |
| 237 | } | 223 | } |
| 238 | 224 | ||
| 239 | void IS31FL3737_update_led_control_registers( uint8_t addr1, uint8_t addr2 ) | 225 | void IS31FL3737_update_led_control_registers(uint8_t addr1, uint8_t addr2) { |
| 240 | { | 226 | if (g_led_control_registers_update_required) { |
| 241 | if ( g_led_control_registers_update_required ) | ||
| 242 | { | ||
| 243 | // Firstly we need to unlock the command register and select PG0 | 227 | // Firstly we need to unlock the command register and select PG0 |
| 244 | IS31FL3737_write_register( addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 ); | 228 | IS31FL3737_write_register(addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5); |
| 245 | IS31FL3737_write_register( addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL ); | 229 | IS31FL3737_write_register(addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL); |
| 246 | for ( int i=0; i<24; i++ ) | 230 | for (int i = 0; i < 24; i++) { |
| 247 | { | 231 | IS31FL3737_write_register(addr1, i, g_led_control_registers[0][i]); |
| 248 | IS31FL3737_write_register(addr1, i, g_led_control_registers[0][i] ); | 232 | // IS31FL3737_write_register(addr2, i, g_led_control_registers[1][i] ); |
| 249 | //IS31FL3737_write_register(addr2, i, g_led_control_registers[1][i] ); | ||
| 250 | } | 233 | } |
| 251 | } | 234 | } |
| 252 | } | 235 | } |
diff --git a/drivers/issi/is31fl3737.h b/drivers/issi/is31fl3737.h index 69c4b9b53..2c2fb1964 100644 --- a/drivers/issi/is31fl3737.h +++ b/drivers/issi/is31fl3737.h | |||
| @@ -16,7 +16,6 @@ | |||
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ | 17 | */ |
| 18 | 18 | ||
| 19 | |||
| 20 | #ifndef IS31FL3737_DRIVER_H | 19 | #ifndef IS31FL3737_DRIVER_H |
| 21 | #define IS31FL3737_DRIVER_H | 20 | #define IS31FL3737_DRIVER_H |
| 22 | 21 | ||
| @@ -24,184 +23,184 @@ | |||
| 24 | #include <stdbool.h> | 23 | #include <stdbool.h> |
| 25 | 24 | ||
| 26 | typedef struct is31_led { | 25 | typedef struct is31_led { |
| 27 | uint8_t driver:2; | 26 | uint8_t driver : 2; |
| 28 | uint8_t r; | 27 | uint8_t r; |
| 29 | uint8_t g; | 28 | uint8_t g; |
| 30 | uint8_t b; | 29 | uint8_t b; |
| 31 | } __attribute__((packed)) is31_led; | 30 | } __attribute__((packed)) is31_led; |
| 32 | 31 | ||
| 33 | extern const is31_led g_is31_leds[DRIVER_LED_TOTAL]; | 32 | extern const is31_led g_is31_leds[DRIVER_LED_TOTAL]; |
| 34 | 33 | ||
| 35 | void IS31FL3737_init( uint8_t addr ); | 34 | void IS31FL3737_init(uint8_t addr); |
| 36 | void IS31FL3737_write_register( uint8_t addr, uint8_t reg, uint8_t data ); | 35 | void IS31FL3737_write_register(uint8_t addr, uint8_t reg, uint8_t data); |
| 37 | void IS31FL3737_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer ); | 36 | void IS31FL3737_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer); |
| 38 | 37 | ||
| 39 | void IS31FL3737_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ); | 38 | void IS31FL3737_set_color(int index, uint8_t red, uint8_t green, uint8_t blue); |
| 40 | void IS31FL3737_set_color_all( uint8_t red, uint8_t green, uint8_t blue ); | 39 | void IS31FL3737_set_color_all(uint8_t red, uint8_t green, uint8_t blue); |
| 41 | 40 | ||
| 42 | void IS31FL3737_set_led_control_register( uint8_t index, bool red, bool green, bool blue ); | 41 | void IS31FL3737_set_led_control_register(uint8_t index, bool red, bool green, bool blue); |
| 43 | 42 | ||
| 44 | // This should not be called from an interrupt | 43 | // This should not be called from an interrupt |
| 45 | // (eg. from a timer interrupt). | 44 | // (eg. from a timer interrupt). |
| 46 | // Call this while idle (in between matrix scans). | 45 | // Call this while idle (in between matrix scans). |
| 47 | // If the buffer is dirty, it will update the driver with the buffer. | 46 | // If the buffer is dirty, it will update the driver with the buffer. |
| 48 | void IS31FL3737_update_pwm_buffers( uint8_t addr1, uint8_t addr2 ); | 47 | void IS31FL3737_update_pwm_buffers(uint8_t addr1, uint8_t addr2); |
| 49 | void IS31FL3737_update_led_control_registers( uint8_t addr1, uint8_t addr2 ); | 48 | void IS31FL3737_update_led_control_registers(uint8_t addr1, uint8_t addr2); |
| 50 | 49 | ||
| 51 | #define A_1 0x00 | 50 | #define A_1 0x00 |
| 52 | #define A_2 0x01 | 51 | #define A_2 0x01 |
| 53 | #define A_3 0x02 | 52 | #define A_3 0x02 |
| 54 | #define A_4 0x03 | 53 | #define A_4 0x03 |
| 55 | #define A_5 0x04 | 54 | #define A_5 0x04 |
| 56 | #define A_6 0x05 | 55 | #define A_6 0x05 |
| 57 | #define A_7 0x08 | 56 | #define A_7 0x08 |
| 58 | #define A_8 0x09 | 57 | #define A_8 0x09 |
| 59 | #define A_9 0x0A | 58 | #define A_9 0x0A |
| 60 | #define A_10 0x0B | 59 | #define A_10 0x0B |
| 61 | #define A_11 0x0C | 60 | #define A_11 0x0C |
| 62 | #define A_12 0x0D | 61 | #define A_12 0x0D |
| 63 | 62 | ||
| 64 | #define B_1 0x10 | 63 | #define B_1 0x10 |
| 65 | #define B_2 0x11 | 64 | #define B_2 0x11 |
| 66 | #define B_3 0x12 | 65 | #define B_3 0x12 |
| 67 | #define B_4 0x13 | 66 | #define B_4 0x13 |
| 68 | #define B_5 0x14 | 67 | #define B_5 0x14 |
| 69 | #define B_6 0x15 | 68 | #define B_6 0x15 |
| 70 | #define B_7 0x18 | 69 | #define B_7 0x18 |
| 71 | #define B_8 0x19 | 70 | #define B_8 0x19 |
| 72 | #define B_9 0x1A | 71 | #define B_9 0x1A |
| 73 | #define B_10 0x1B | 72 | #define B_10 0x1B |
| 74 | #define B_11 0x1C | 73 | #define B_11 0x1C |
| 75 | #define B_12 0x1D | 74 | #define B_12 0x1D |
| 76 | 75 | ||
| 77 | #define C_1 0x20 | 76 | #define C_1 0x20 |
| 78 | #define C_2 0x21 | 77 | #define C_2 0x21 |
| 79 | #define C_3 0x22 | 78 | #define C_3 0x22 |
| 80 | #define C_4 0x23 | 79 | #define C_4 0x23 |
| 81 | #define C_5 0x24 | 80 | #define C_5 0x24 |
| 82 | #define C_6 0x25 | 81 | #define C_6 0x25 |
| 83 | #define C_7 0x28 | 82 | #define C_7 0x28 |
| 84 | #define C_8 0x29 | 83 | #define C_8 0x29 |
| 85 | #define C_9 0x2A | 84 | #define C_9 0x2A |
| 86 | #define C_10 0x2B | 85 | #define C_10 0x2B |
| 87 | #define C_11 0x2C | 86 | #define C_11 0x2C |
| 88 | #define C_12 0x2D | 87 | #define C_12 0x2D |
| 89 | 88 | ||
| 90 | #define D_1 0x30 | 89 | #define D_1 0x30 |
| 91 | #define D_2 0x31 | 90 | #define D_2 0x31 |
| 92 | #define D_3 0x32 | 91 | #define D_3 0x32 |
| 93 | #define D_4 0x33 | 92 | #define D_4 0x33 |
| 94 | #define D_5 0x34 | 93 | #define D_5 0x34 |
| 95 | #define D_6 0x35 | 94 | #define D_6 0x35 |
| 96 | #define D_7 0x38 | 95 | #define D_7 0x38 |
| 97 | #define D_8 0x39 | 96 | #define D_8 0x39 |
| 98 | #define D_9 0x3A | 97 | #define D_9 0x3A |
| 99 | #define D_10 0x3B | 98 | #define D_10 0x3B |
| 100 | #define D_11 0x3C | 99 | #define D_11 0x3C |
| 101 | #define D_12 0x3D | 100 | #define D_12 0x3D |
| 102 | 101 | ||
| 103 | #define E_1 0x40 | 102 | #define E_1 0x40 |
| 104 | #define E_2 0x41 | 103 | #define E_2 0x41 |
| 105 | #define E_3 0x42 | 104 | #define E_3 0x42 |
| 106 | #define E_4 0x43 | 105 | #define E_4 0x43 |
| 107 | #define E_5 0x44 | 106 | #define E_5 0x44 |
| 108 | #define E_6 0x45 | 107 | #define E_6 0x45 |
| 109 | #define E_7 0x48 | 108 | #define E_7 0x48 |
| 110 | #define E_8 0x49 | 109 | #define E_8 0x49 |
| 111 | #define E_9 0x4A | 110 | #define E_9 0x4A |
| 112 | #define E_10 0x4B | 111 | #define E_10 0x4B |
| 113 | #define E_11 0x4C | 112 | #define E_11 0x4C |
| 114 | #define E_12 0x4D | 113 | #define E_12 0x4D |
| 115 | 114 | ||
| 116 | #define F_1 0x50 | 115 | #define F_1 0x50 |
| 117 | #define F_2 0x51 | 116 | #define F_2 0x51 |
| 118 | #define F_3 0x52 | 117 | #define F_3 0x52 |
| 119 | #define F_4 0x53 | 118 | #define F_4 0x53 |
| 120 | #define F_5 0x54 | 119 | #define F_5 0x54 |
| 121 | #define F_6 0x55 | 120 | #define F_6 0x55 |
| 122 | #define F_7 0x58 | 121 | #define F_7 0x58 |
| 123 | #define F_8 0x59 | 122 | #define F_8 0x59 |
| 124 | #define F_9 0x5A | 123 | #define F_9 0x5A |
| 125 | #define F_10 0x5B | 124 | #define F_10 0x5B |
| 126 | #define F_11 0x5C | 125 | #define F_11 0x5C |
| 127 | #define F_12 0x5D | 126 | #define F_12 0x5D |
| 128 | 127 | ||
| 129 | #define G_1 0x60 | 128 | #define G_1 0x60 |
| 130 | #define G_2 0x61 | 129 | #define G_2 0x61 |
| 131 | #define G_3 0x62 | 130 | #define G_3 0x62 |
| 132 | #define G_4 0x63 | 131 | #define G_4 0x63 |
| 133 | #define G_5 0x64 | 132 | #define G_5 0x64 |
| 134 | #define G_6 0x65 | 133 | #define G_6 0x65 |
| 135 | #define G_7 0x68 | 134 | #define G_7 0x68 |
| 136 | #define G_8 0x69 | 135 | #define G_8 0x69 |
| 137 | #define G_9 0x6A | 136 | #define G_9 0x6A |
| 138 | #define G_10 0x6B | 137 | #define G_10 0x6B |
| 139 | #define G_11 0x6C | 138 | #define G_11 0x6C |
| 140 | #define G_12 0x6D | 139 | #define G_12 0x6D |
| 141 | 140 | ||
| 142 | #define H_1 0x70 | 141 | #define H_1 0x70 |
| 143 | #define H_2 0x71 | 142 | #define H_2 0x71 |
| 144 | #define H_3 0x72 | 143 | #define H_3 0x72 |
| 145 | #define H_4 0x73 | 144 | #define H_4 0x73 |
| 146 | #define H_5 0x74 | 145 | #define H_5 0x74 |
| 147 | #define H_6 0x75 | 146 | #define H_6 0x75 |
| 148 | #define H_7 0x78 | 147 | #define H_7 0x78 |
| 149 | #define H_8 0x79 | 148 | #define H_8 0x79 |
| 150 | #define H_9 0x7A | 149 | #define H_9 0x7A |
| 151 | #define H_10 0x7B | 150 | #define H_10 0x7B |
| 152 | #define H_11 0x7C | 151 | #define H_11 0x7C |
| 153 | #define H_12 0x7D | 152 | #define H_12 0x7D |
| 154 | 153 | ||
| 155 | #define I_1 0x80 | 154 | #define I_1 0x80 |
| 156 | #define I_2 0x81 | 155 | #define I_2 0x81 |
| 157 | #define I_3 0x82 | 156 | #define I_3 0x82 |
| 158 | #define I_4 0x83 | 157 | #define I_4 0x83 |
| 159 | #define I_5 0x84 | 158 | #define I_5 0x84 |
| 160 | #define I_6 0x85 | 159 | #define I_6 0x85 |
| 161 | #define I_7 0x88 | 160 | #define I_7 0x88 |
| 162 | #define I_8 0x89 | 161 | #define I_8 0x89 |
| 163 | #define I_9 0x8A | 162 | #define I_9 0x8A |
| 164 | #define I_10 0x8B | 163 | #define I_10 0x8B |
| 165 | #define I_11 0x8C | 164 | #define I_11 0x8C |
| 166 | #define I_12 0x8D | 165 | #define I_12 0x8D |
| 167 | 166 | ||
| 168 | #define J_1 0x90 | 167 | #define J_1 0x90 |
| 169 | #define J_2 0x91 | 168 | #define J_2 0x91 |
| 170 | #define J_3 0x92 | 169 | #define J_3 0x92 |
| 171 | #define J_4 0x93 | 170 | #define J_4 0x93 |
| 172 | #define J_5 0x94 | 171 | #define J_5 0x94 |
| 173 | #define J_6 0x95 | 172 | #define J_6 0x95 |
| 174 | #define J_7 0x98 | 173 | #define J_7 0x98 |
| 175 | #define J_8 0x99 | 174 | #define J_8 0x99 |
| 176 | #define J_9 0x9A | 175 | #define J_9 0x9A |
| 177 | #define J_10 0x9B | 176 | #define J_10 0x9B |
| 178 | #define J_11 0x9C | 177 | #define J_11 0x9C |
| 179 | #define J_12 0x9D | 178 | #define J_12 0x9D |
| 180 | 179 | ||
| 181 | #define K_1 0xA0 | 180 | #define K_1 0xA0 |
| 182 | #define K_2 0xA1 | 181 | #define K_2 0xA1 |
| 183 | #define K_3 0xA2 | 182 | #define K_3 0xA2 |
| 184 | #define K_4 0xA3 | 183 | #define K_4 0xA3 |
| 185 | #define K_5 0xA4 | 184 | #define K_5 0xA4 |
| 186 | #define K_6 0xA5 | 185 | #define K_6 0xA5 |
| 187 | #define K_7 0xA8 | 186 | #define K_7 0xA8 |
| 188 | #define K_8 0xA9 | 187 | #define K_8 0xA9 |
| 189 | #define K_9 0xAA | 188 | #define K_9 0xAA |
| 190 | #define K_10 0xAB | 189 | #define K_10 0xAB |
| 191 | #define K_11 0xAC | 190 | #define K_11 0xAC |
| 192 | #define K_12 0xAD | 191 | #define K_12 0xAD |
| 193 | 192 | ||
| 194 | #define L_1 0xB0 | 193 | #define L_1 0xB0 |
| 195 | #define L_2 0xB1 | 194 | #define L_2 0xB1 |
| 196 | #define L_3 0xB2 | 195 | #define L_3 0xB2 |
| 197 | #define L_4 0xB3 | 196 | #define L_4 0xB3 |
| 198 | #define L_5 0xB4 | 197 | #define L_5 0xB4 |
| 199 | #define L_6 0xB5 | 198 | #define L_6 0xB5 |
| 200 | #define L_7 0xB8 | 199 | #define L_7 0xB8 |
| 201 | #define L_8 0xB9 | 200 | #define L_8 0xB9 |
| 202 | #define L_9 0xBA | 201 | #define L_9 0xBA |
| 203 | #define L_10 0xBB | 202 | #define L_10 0xBB |
| 204 | #define L_11 0xBC | 203 | #define L_11 0xBC |
| 205 | #define L_12 0xBD | 204 | #define L_12 0xBD |
| 206 | 205 | ||
| 207 | #endif // IS31FL3737_DRIVER_H | 206 | #endif // IS31FL3737_DRIVER_H |
diff --git a/drivers/oled/glcdfont.c b/drivers/oled/glcdfont.c index 8b969057e..95c5d2ebf 100644 --- a/drivers/oled/glcdfont.c +++ b/drivers/oled/glcdfont.c | |||
| @@ -1,240 +1,25 @@ | |||
| 1 | #pragma once | 1 | #pragma once |
| 2 | 2 | ||
| 3 | #ifdef __AVR__ | 3 | #ifdef __AVR__ |
| 4 | #include <avr/io.h> | 4 | # include <avr/io.h> |
| 5 | #include <avr/pgmspace.h> | 5 | # include <avr/pgmspace.h> |
| 6 | #elif defined(ESP8266) | 6 | #elif defined(ESP8266) |
| 7 | #include <pgmspace.h> | 7 | # include <pgmspace.h> |
| 8 | #else | 8 | #else |
| 9 | #define PROGMEM | 9 | # define PROGMEM |
| 10 | #endif | 10 | #endif |
| 11 | 11 | ||
| 12 | // Helidox 8x6 font with QMK Firmware Logo | 12 | // Helidox 8x6 font with QMK Firmware Logo |
| 13 | // Online editor: http://teripom.x0.com/ | 13 | // Online editor: http://teripom.x0.com/ |
| 14 | 14 | ||
| 15 | static const unsigned char font[] PROGMEM = { | 15 | static const unsigned char font[] PROGMEM = { |
| 16 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 16 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00, 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x00, 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x00, 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x00, 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x00, 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00, 0x00, 0x18, 0x3C, 0x18, 0x00, 0x00, 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, 0x00, 0x18, 0x24, 0x18, 0x00, 0x00, 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x00, 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x00, 0x26, 0x29, 0x79, 0x29, 0x26, 0x00, 0x40, 0x7F, 0x05, 0x05, 0x07, 0x00, 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x00, 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x00, 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x00, 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x00, 0x14, 0x22, 0x7F, 0x22, 0x14, 0x00, 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x00, 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, 0x00, 0x66, 0x89, 0x95, 0x6A, 0x00, 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x00, 0x08, 0x04, 0x7E, 0x04, 0x08, 0x00, |
| 17 | 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00, | 17 | 0x10, 0x20, 0x7E, 0x20, 0x10, 0x00, 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x00, 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x00, 0x1E, 0x10, 0x10, 0x10, 0x10, 0x00, 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x00, 0x30, 0x38, 0x3E, 0x38, 0x30, 0x00, 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00, 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00, 0x23, 0x13, 0x08, 0x64, 0x62, 0x00, 0x36, 0x49, 0x56, 0x20, 0x50, 0x00, 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, 0x00, 0x41, 0x22, 0x1C, 0x00, 0x00, 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, 0x00, 0x80, 0x70, 0x30, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00, |
| 18 | 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x00, | 18 | 0x72, 0x49, 0x49, 0x49, 0x46, 0x00, 0x21, 0x41, 0x49, 0x4D, 0x33, 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10, 0x00, 0x27, 0x45, 0x45, 0x45, 0x39, 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x00, 0x41, 0x21, 0x11, 0x09, 0x07, 0x00, 0x36, 0x49, 0x49, 0x49, 0x36, 0x00, 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x40, 0x34, 0x00, 0x00, 0x00, 0x00, 0x08, 0x14, 0x22, 0x41, 0x00, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, 0x00, 0x41, 0x22, 0x14, 0x08, 0x00, 0x02, 0x01, 0x59, 0x09, 0x06, 0x00, 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36, 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41, 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01, 0x00, 0x3E, 0x41, 0x41, 0x51, 0x73, 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00, 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, 0x00, |
| 19 | 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x00, | 19 | 0x7F, 0x08, 0x14, 0x22, 0x41, 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40, 0x00, 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06, 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46, 0x00, 0x26, 0x49, 0x49, 0x49, 0x32, 0x00, 0x03, 0x01, 0x7F, 0x01, 0x03, 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00, 0x63, 0x14, 0x08, 0x14, 0x63, 0x00, 0x03, 0x04, 0x78, 0x04, 0x03, 0x00, 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x04, 0x02, 0x01, 0x02, 0x04, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, 0x03, 0x07, 0x08, 0x00, 0x00, 0x20, 0x54, 0x54, 0x78, 0x40, 0x00, 0x7F, 0x28, 0x44, 0x44, 0x38, 0x00, 0x38, 0x44, 0x44, 0x44, 0x28, 0x00, |
| 20 | 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x00, | 20 | 0x38, 0x44, 0x44, 0x28, 0x7F, 0x00, 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, 0x00, 0x08, 0x7E, 0x09, 0x02, 0x00, 0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00, 0x00, 0x20, 0x40, 0x40, 0x3D, 0x00, 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00, 0x00, 0x7C, 0x04, 0x78, 0x04, 0x78, 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0xFC, 0x18, 0x24, 0x24, 0x18, 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC, 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08, 0x00, 0x48, 0x54, 0x54, 0x54, 0x24, 0x00, 0x04, 0x04, 0x3F, 0x44, 0x24, 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, |
| 21 | 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x00, | 21 | 0x00, 0x41, 0x36, 0x08, 0x00, 0x00, 0x02, 0x01, 0x02, 0x04, 0x02, 0x00, 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0xF0, 0xF8, 0xF8, 0xFF, 0x38, 0xFF, 0xF8, 0xF8, 0x3F, 0xF8, 0xF8, 0xFF, 0x38, 0xFF, 0xF8, 0xF8, 0xF0, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xF8, 0xFC, 0x3E, |
| 22 | 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00, | 22 | 0x1E, 0x06, 0x01, 0x00, 0x00, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0x7E, 0x5B, 0x4F, 0x5B, 0xFE, 0xC0, 0x00, 0x00, 0xC0, 0x00, 0xDC, 0xD7, 0xDE, 0xDE, 0xDE, 0xD7, 0xDC, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x49, 0x49, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xDF, 0xBF, 0xBF, 0x00, 0xBF, 0xBF, 0xDF, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0x49, 0x49, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x3F, 0x60, 0x60, 0xE0, 0xBF, 0x1F, 0x00, 0x7F, 0x7F, 0x07, 0x1E, 0x38, 0x1E, 0x07, 0x7F, 0x7F, 0x00, 0x7F, 0x7F, 0x0E, 0x1F, 0x3B, 0x71, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x0C, 0x0C, 0x0C, 0x00, 0x7E, 0x7E, 0x00, 0x7F, 0x7E, 0x03, 0x03, 0x00, 0x7F, 0x7E, 0x03, 0x03, 0x7E, 0x7E, 0x03, 0x03, 0x7F, 0x7E, 0x00, 0x0F, |
| 23 | 0x00, 0x18, 0x3C, 0x18, 0x00, 0x00, | 23 | 0x3E, 0x70, 0x3C, 0x06, 0x3C, 0x70, 0x3E, 0x0F, 0x00, 0x32, 0x7B, 0x49, 0x49, 0x3F, 0x7E, 0x00, 0x7F, 0x7E, 0x03, 0x03, 0x00, 0x1E, 0x3F, 0x69, 0x69, 0x6F, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x1F, 0x3F, 0x3C, 0x78, 0x70, 0x60, 0x00, 0x00, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x30, 0x7B, 0x7F, 0x78, 0x30, 0x20, 0x20, 0x30, 0x78, 0x7F, 0x3B, 0x00, 0x03, 0x00, 0x0F, 0x7F, 0x0F, 0x0F, 0x0F, 0x7F, 0x0F, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x07, 0x0F, 0x0F, 0x7F, 0x0F, 0x7F, 0x0F, 0x0F, 0x7E, 0x0F, 0x0F, 0x7F, 0x0F, 0x7F, 0x0F, 0x0F, 0x07, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 24 | 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, | 24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 25 | 0x00, 0x18, 0x24, 0x18, 0x00, 0x00, | ||
| 26 | 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x00, | ||
| 27 | 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x00, | ||
| 28 | 0x26, 0x29, 0x79, 0x29, 0x26, 0x00, | ||
| 29 | 0x40, 0x7F, 0x05, 0x05, 0x07, 0x00, | ||
| 30 | 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x00, | ||
| 31 | 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x00, | ||
| 32 | 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x00, | ||
| 33 | 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x00, | ||
| 34 | 0x14, 0x22, 0x7F, 0x22, 0x14, 0x00, | ||
| 35 | 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x00, | ||
| 36 | 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, | ||
| 37 | 0x00, 0x66, 0x89, 0x95, 0x6A, 0x00, | ||
| 38 | 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, | ||
| 39 | 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x00, | ||
| 40 | 0x08, 0x04, 0x7E, 0x04, 0x08, 0x00, | ||
| 41 | 0x10, 0x20, 0x7E, 0x20, 0x10, 0x00, | ||
| 42 | 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x00, | ||
| 43 | 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x00, | ||
| 44 | 0x1E, 0x10, 0x10, 0x10, 0x10, 0x00, | ||
| 45 | 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x00, | ||
| 46 | 0x30, 0x38, 0x3E, 0x38, 0x30, 0x00, | ||
| 47 | 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, | ||
| 48 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 49 | 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, | ||
| 50 | 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, | ||
| 51 | 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00, | ||
| 52 | 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00, | ||
| 53 | 0x23, 0x13, 0x08, 0x64, 0x62, 0x00, | ||
| 54 | 0x36, 0x49, 0x56, 0x20, 0x50, 0x00, | ||
| 55 | 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, | ||
| 56 | 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, | ||
| 57 | 0x00, 0x41, 0x22, 0x1C, 0x00, 0x00, | ||
| 58 | 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x00, | ||
| 59 | 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, | ||
| 60 | 0x00, 0x80, 0x70, 0x30, 0x00, 0x00, | ||
| 61 | 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, | ||
| 62 | 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, | ||
| 63 | 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, | ||
| 64 | 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, | ||
| 65 | 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00, | ||
| 66 | 0x72, 0x49, 0x49, 0x49, 0x46, 0x00, | ||
| 67 | 0x21, 0x41, 0x49, 0x4D, 0x33, 0x00, | ||
| 68 | 0x18, 0x14, 0x12, 0x7F, 0x10, 0x00, | ||
| 69 | 0x27, 0x45, 0x45, 0x45, 0x39, 0x00, | ||
| 70 | 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x00, | ||
| 71 | 0x41, 0x21, 0x11, 0x09, 0x07, 0x00, | ||
| 72 | 0x36, 0x49, 0x49, 0x49, 0x36, 0x00, | ||
| 73 | 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00, | ||
| 74 | 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, | ||
| 75 | 0x00, 0x40, 0x34, 0x00, 0x00, 0x00, | ||
| 76 | 0x00, 0x08, 0x14, 0x22, 0x41, 0x00, | ||
| 77 | 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, | ||
| 78 | 0x00, 0x41, 0x22, 0x14, 0x08, 0x00, | ||
| 79 | 0x02, 0x01, 0x59, 0x09, 0x06, 0x00, | ||
| 80 | 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x00, | ||
| 81 | 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x00, | ||
| 82 | 0x7F, 0x49, 0x49, 0x49, 0x36, 0x00, | ||
| 83 | 0x3E, 0x41, 0x41, 0x41, 0x22, 0x00, | ||
| 84 | 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x00, | ||
| 85 | 0x7F, 0x49, 0x49, 0x49, 0x41, 0x00, | ||
| 86 | 0x7F, 0x09, 0x09, 0x09, 0x01, 0x00, | ||
| 87 | 0x3E, 0x41, 0x41, 0x51, 0x73, 0x00, | ||
| 88 | 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, | ||
| 89 | 0x00, 0x41, 0x7F, 0x41, 0x00, 0x00, | ||
| 90 | 0x20, 0x40, 0x41, 0x3F, 0x01, 0x00, | ||
| 91 | 0x7F, 0x08, 0x14, 0x22, 0x41, 0x00, | ||
| 92 | 0x7F, 0x40, 0x40, 0x40, 0x40, 0x00, | ||
| 93 | 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x00, | ||
| 94 | 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, | ||
| 95 | 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, | ||
| 96 | 0x7F, 0x09, 0x09, 0x09, 0x06, 0x00, | ||
| 97 | 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00, | ||
| 98 | 0x7F, 0x09, 0x19, 0x29, 0x46, 0x00, | ||
| 99 | 0x26, 0x49, 0x49, 0x49, 0x32, 0x00, | ||
| 100 | 0x03, 0x01, 0x7F, 0x01, 0x03, 0x00, | ||
| 101 | 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00, | ||
| 102 | 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00, | ||
| 103 | 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00, | ||
| 104 | 0x63, 0x14, 0x08, 0x14, 0x63, 0x00, | ||
| 105 | 0x03, 0x04, 0x78, 0x04, 0x03, 0x00, | ||
| 106 | 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00, | ||
| 107 | 0x00, 0x7F, 0x41, 0x41, 0x41, 0x00, | ||
| 108 | 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, | ||
| 109 | 0x00, 0x41, 0x41, 0x41, 0x7F, 0x00, | ||
| 110 | 0x04, 0x02, 0x01, 0x02, 0x04, 0x00, | ||
| 111 | 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, | ||
| 112 | 0x00, 0x03, 0x07, 0x08, 0x00, 0x00, | ||
| 113 | 0x20, 0x54, 0x54, 0x78, 0x40, 0x00, | ||
| 114 | 0x7F, 0x28, 0x44, 0x44, 0x38, 0x00, | ||
| 115 | 0x38, 0x44, 0x44, 0x44, 0x28, 0x00, | ||
| 116 | 0x38, 0x44, 0x44, 0x28, 0x7F, 0x00, | ||
| 117 | 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, | ||
| 118 | 0x00, 0x08, 0x7E, 0x09, 0x02, 0x00, | ||
| 119 | 0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x00, | ||
| 120 | 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, | ||
| 121 | 0x00, 0x44, 0x7D, 0x40, 0x00, 0x00, | ||
| 122 | 0x20, 0x40, 0x40, 0x3D, 0x00, 0x00, | ||
| 123 | 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, | ||
| 124 | 0x00, 0x41, 0x7F, 0x40, 0x00, 0x00, | ||
| 125 | 0x7C, 0x04, 0x78, 0x04, 0x78, 0x00, | ||
| 126 | 0x7C, 0x08, 0x04, 0x04, 0x78, 0x00, | ||
| 127 | 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, | ||
| 128 | 0xFC, 0x18, 0x24, 0x24, 0x18, 0x00, | ||
| 129 | 0x18, 0x24, 0x24, 0x18, 0xFC, 0x00, | ||
| 130 | 0x7C, 0x08, 0x04, 0x04, 0x08, 0x00, | ||
| 131 | 0x48, 0x54, 0x54, 0x54, 0x24, 0x00, | ||
| 132 | 0x04, 0x04, 0x3F, 0x44, 0x24, 0x00, | ||
| 133 | 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00, | ||
| 134 | 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00, | ||
| 135 | 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00, | ||
| 136 | 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, | ||
| 137 | 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x00, | ||
| 138 | 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, | ||
| 139 | 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, | ||
| 140 | 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, | ||
| 141 | 0x00, 0x41, 0x36, 0x08, 0x00, 0x00, | ||
| 142 | 0x02, 0x01, 0x02, 0x04, 0x02, 0x00, | ||
| 143 | 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x00, | ||
| 144 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 145 | 0x40, 0x40, 0x40, 0xF0, 0xF8, 0xF8, | ||
| 146 | 0xFF, 0x38, 0xFF, 0xF8, 0xF8, 0x3F, | ||
| 147 | 0xF8, 0xF8, 0xFF, 0x38, 0xFF, 0xF8, | ||
| 148 | 0xF8, 0xF0, 0x40, 0x40, 0x40, 0x00, | ||
| 149 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, | ||
| 150 | 0xC0, 0xC0, 0xC0, 0x80, 0x00, 0x00, | ||
| 151 | 0xC0, 0xC0, 0x80, 0x00, 0x00, 0x00, | ||
| 152 | 0x80, 0xC0, 0xC0, 0x00, 0xC0, 0xC0, | ||
| 153 | 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x00, | ||
| 154 | 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, | ||
| 155 | 0xC0, 0xC0, 0xC0, 0x00, 0xC0, 0xC0, | ||
| 156 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 157 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 158 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 159 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 160 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 161 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 162 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 163 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 164 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 165 | 0x00, 0xC0, 0xF0, 0xF8, 0xFC, 0x3E, | ||
| 166 | 0x1E, 0x06, 0x01, 0x00, 0x00, 0x00, | ||
| 167 | 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, | ||
| 168 | 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, | ||
| 169 | 0x00, 0x80, 0xC0, 0xE0, 0x7E, 0x5B, | ||
| 170 | 0x4F, 0x5B, 0xFE, 0xC0, 0x00, 0x00, | ||
| 171 | 0xC0, 0x00, 0xDC, 0xD7, 0xDE, 0xDE, | ||
| 172 | 0xDE, 0xD7, 0xDC, 0x00, 0xC0, 0x00, | ||
| 173 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 174 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 175 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 176 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 177 | 0x49, 0x49, 0x49, 0xFF, 0xFF, 0xFF, | ||
| 178 | 0xFF, 0xE0, 0xDF, 0xBF, 0xBF, 0x00, | ||
| 179 | 0xBF, 0xBF, 0xDF, 0xE0, 0xFF, 0xFF, | ||
| 180 | 0xFF, 0xFF, 0x49, 0x49, 0x49, 0x00, | ||
| 181 | 0x00, 0x00, 0x00, 0x00, 0x1F, 0x3F, | ||
| 182 | 0x60, 0x60, 0xE0, 0xBF, 0x1F, 0x00, | ||
| 183 | 0x7F, 0x7F, 0x07, 0x1E, 0x38, 0x1E, | ||
| 184 | 0x07, 0x7F, 0x7F, 0x00, 0x7F, 0x7F, | ||
| 185 | 0x0E, 0x1F, 0x3B, 0x71, 0x60, 0x00, | ||
| 186 | 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, | ||
| 187 | 0x0C, 0x0C, 0x0C, 0x00, 0x7E, 0x7E, | ||
| 188 | 0x00, 0x7F, 0x7E, 0x03, 0x03, 0x00, | ||
| 189 | 0x7F, 0x7E, 0x03, 0x03, 0x7E, 0x7E, | ||
| 190 | 0x03, 0x03, 0x7F, 0x7E, 0x00, 0x0F, | ||
| 191 | 0x3E, 0x70, 0x3C, 0x06, 0x3C, 0x70, | ||
| 192 | 0x3E, 0x0F, 0x00, 0x32, 0x7B, 0x49, | ||
| 193 | 0x49, 0x3F, 0x7E, 0x00, 0x7F, 0x7E, | ||
| 194 | 0x03, 0x03, 0x00, 0x1E, 0x3F, 0x69, | ||
| 195 | 0x69, 0x6F, 0x26, 0x00, 0x00, 0x00, | ||
| 196 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 197 | 0x00, 0x03, 0x0F, 0x1F, 0x3F, 0x3C, | ||
| 198 | 0x78, 0x70, 0x60, 0x00, 0x00, 0x00, | ||
| 199 | 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, | ||
| 200 | 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, | ||
| 201 | 0x30, 0x7B, 0x7F, 0x78, 0x30, 0x20, | ||
| 202 | 0x20, 0x30, 0x78, 0x7F, 0x3B, 0x00, | ||
| 203 | 0x03, 0x00, 0x0F, 0x7F, 0x0F, 0x0F, | ||
| 204 | 0x0F, 0x7F, 0x0F, 0x00, 0x03, 0x00, | ||
| 205 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 206 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 207 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 208 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 209 | 0x01, 0x01, 0x01, 0x07, 0x0F, 0x0F, | ||
| 210 | 0x7F, 0x0F, 0x7F, 0x0F, 0x0F, 0x7E, | ||
| 211 | 0x0F, 0x0F, 0x7F, 0x0F, 0x7F, 0x0F, | ||
| 212 | 0x0F, 0x07, 0x01, 0x01, 0x01, 0x00, | ||
| 213 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 214 | 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, | ||
| 215 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 216 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 217 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 218 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 219 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 220 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 221 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 222 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 223 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 224 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 225 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 226 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 227 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 228 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 229 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 230 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 231 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 232 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 233 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 234 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 235 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 236 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 237 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 238 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 239 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 240 | }; | 25 | }; |
diff --git a/drivers/oled/oled_driver.c b/drivers/oled/oled_driver.c index 3dad72add..1a1b7299b 100644 --- a/drivers/oled/oled_driver.c +++ b/drivers/oled/oled_driver.c | |||
| @@ -23,64 +23,64 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 23 | #include <string.h> | 23 | #include <string.h> |
| 24 | 24 | ||
| 25 | #if defined(__AVR__) | 25 | #if defined(__AVR__) |
| 26 | #include <avr/io.h> | 26 | # include <avr/io.h> |
| 27 | #include <avr/pgmspace.h> | 27 | # include <avr/pgmspace.h> |
| 28 | #elif defined(ESP8266) | 28 | #elif defined(ESP8266) |
| 29 | #include <pgmspace.h> | 29 | # include <pgmspace.h> |
| 30 | #else // defined(ESP8266) | 30 | #else // defined(ESP8266) |
| 31 | #define PROGMEM | 31 | # define PROGMEM |
| 32 | #define memcpy_P(des, src, len) memcpy(des, src, len) | 32 | # define memcpy_P(des, src, len) memcpy(des, src, len) |
| 33 | #endif // defined(__AVR__) | 33 | #endif // defined(__AVR__) |
| 34 | 34 | ||
| 35 | // Used commands from spec sheet: https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf | 35 | // Used commands from spec sheet: https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf |
| 36 | // for SH1106: https://www.velleman.eu/downloads/29/infosheets/sh1106_datasheet.pdf | 36 | // for SH1106: https://www.velleman.eu/downloads/29/infosheets/sh1106_datasheet.pdf |
| 37 | 37 | ||
| 38 | // Fundamental Commands | 38 | // Fundamental Commands |
| 39 | #define CONTRAST 0x81 | 39 | #define CONTRAST 0x81 |
| 40 | #define DISPLAY_ALL_ON 0xA5 | 40 | #define DISPLAY_ALL_ON 0xA5 |
| 41 | #define DISPLAY_ALL_ON_RESUME 0xA4 | 41 | #define DISPLAY_ALL_ON_RESUME 0xA4 |
| 42 | #define NORMAL_DISPLAY 0xA6 | 42 | #define NORMAL_DISPLAY 0xA6 |
| 43 | #define DISPLAY_ON 0xAF | 43 | #define DISPLAY_ON 0xAF |
| 44 | #define DISPLAY_OFF 0xAE | 44 | #define DISPLAY_OFF 0xAE |
| 45 | #define NOP 0xE3 | 45 | #define NOP 0xE3 |
| 46 | 46 | ||
| 47 | // Scrolling Commands | 47 | // Scrolling Commands |
| 48 | #define ACTIVATE_SCROLL 0x2F | 48 | #define ACTIVATE_SCROLL 0x2F |
| 49 | #define DEACTIVATE_SCROLL 0x2E | 49 | #define DEACTIVATE_SCROLL 0x2E |
| 50 | #define SCROLL_RIGHT 0x26 | 50 | #define SCROLL_RIGHT 0x26 |
| 51 | #define SCROLL_LEFT 0x27 | 51 | #define SCROLL_LEFT 0x27 |
| 52 | #define SCROLL_RIGHT_UP 0x29 | 52 | #define SCROLL_RIGHT_UP 0x29 |
| 53 | #define SCROLL_LEFT_UP 0x2A | 53 | #define SCROLL_LEFT_UP 0x2A |
| 54 | 54 | ||
| 55 | // Addressing Setting Commands | 55 | // Addressing Setting Commands |
| 56 | #define MEMORY_MODE 0x20 | 56 | #define MEMORY_MODE 0x20 |
| 57 | #define COLUMN_ADDR 0x21 | 57 | #define COLUMN_ADDR 0x21 |
| 58 | #define PAGE_ADDR 0x22 | 58 | #define PAGE_ADDR 0x22 |
| 59 | #define PAM_SETCOLUMN_LSB 0x00 | 59 | #define PAM_SETCOLUMN_LSB 0x00 |
| 60 | #define PAM_SETCOLUMN_MSB 0x10 | 60 | #define PAM_SETCOLUMN_MSB 0x10 |
| 61 | #define PAM_PAGE_ADDR 0xB0 // 0xb0 -- 0xb7 | 61 | #define PAM_PAGE_ADDR 0xB0 // 0xb0 -- 0xb7 |
| 62 | 62 | ||
| 63 | // Hardware Configuration Commands | 63 | // Hardware Configuration Commands |
| 64 | #define DISPLAY_START_LINE 0x40 | 64 | #define DISPLAY_START_LINE 0x40 |
| 65 | #define SEGMENT_REMAP 0xA0 | 65 | #define SEGMENT_REMAP 0xA0 |
| 66 | #define SEGMENT_REMAP_INV 0xA1 | 66 | #define SEGMENT_REMAP_INV 0xA1 |
| 67 | #define MULTIPLEX_RATIO 0xA8 | 67 | #define MULTIPLEX_RATIO 0xA8 |
| 68 | #define COM_SCAN_INC 0xC0 | 68 | #define COM_SCAN_INC 0xC0 |
| 69 | #define COM_SCAN_DEC 0xC8 | 69 | #define COM_SCAN_DEC 0xC8 |
| 70 | #define DISPLAY_OFFSET 0xD3 | 70 | #define DISPLAY_OFFSET 0xD3 |
| 71 | #define COM_PINS 0xDA | 71 | #define COM_PINS 0xDA |
| 72 | #define COM_PINS_SEQ 0x02 | 72 | #define COM_PINS_SEQ 0x02 |
| 73 | #define COM_PINS_ALT 0x12 | 73 | #define COM_PINS_ALT 0x12 |
| 74 | #define COM_PINS_SEQ_LR 0x22 | 74 | #define COM_PINS_SEQ_LR 0x22 |
| 75 | #define COM_PINS_ALT_LR 0x32 | 75 | #define COM_PINS_ALT_LR 0x32 |
| 76 | 76 | ||
| 77 | // Timing & Driving Commands | 77 | // Timing & Driving Commands |
| 78 | #define DISPLAY_CLOCK 0xD5 | 78 | #define DISPLAY_CLOCK 0xD5 |
| 79 | #define PRE_CHARGE_PERIOD 0xD9 | 79 | #define PRE_CHARGE_PERIOD 0xD9 |
| 80 | #define VCOM_DETECT 0xDB | 80 | #define VCOM_DETECT 0xDB |
| 81 | 81 | ||
| 82 | // Charge Pump Commands | 82 | // Charge Pump Commands |
| 83 | #define CHARGE_PUMP 0x8D | 83 | #define CHARGE_PUMP 0x8D |
| 84 | 84 | ||
| 85 | // Misc defines | 85 | // Misc defines |
| 86 | #define OLED_TIMEOUT 60000 | 86 | #define OLED_TIMEOUT 60000 |
| @@ -91,12 +91,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 91 | #define I2C_CMD 0x00 | 91 | #define I2C_CMD 0x00 |
| 92 | #define I2C_DATA 0x40 | 92 | #define I2C_DATA 0x40 |
| 93 | #if defined(__AVR__) | 93 | #if defined(__AVR__) |
| 94 | // already defined on ARM | 94 | // already defined on ARM |
| 95 | #define I2C_TIMEOUT 100 | 95 | # define I2C_TIMEOUT 100 |
| 96 | #define I2C_TRANSMIT_P(data) i2c_transmit_P((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), I2C_TIMEOUT) | 96 | # define I2C_TRANSMIT_P(data) i2c_transmit_P((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), I2C_TIMEOUT) |
| 97 | #else // defined(__AVR__) | 97 | #else // defined(__AVR__) |
| 98 | #define I2C_TRANSMIT_P(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), I2C_TIMEOUT) | 98 | # define I2C_TRANSMIT_P(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), I2C_TIMEOUT) |
| 99 | #endif // defined(__AVR__) | 99 | #endif // defined(__AVR__) |
| 100 | #define I2C_TRANSMIT(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), I2C_TIMEOUT) | 100 | #define I2C_TRANSMIT(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), I2C_TIMEOUT) |
| 101 | #define I2C_WRITE_REG(mode, data, size) i2c_writeReg((OLED_DISPLAY_ADDRESS << 1), mode, data, size, I2C_TIMEOUT) | 101 | #define I2C_WRITE_REG(mode, data, size) i2c_writeReg((OLED_DISPLAY_ADDRESS << 1), mode, data, size, I2C_TIMEOUT) |
| 102 | 102 | ||
| @@ -106,19 +106,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 106 | // this is so we don't end up with rounding errors with | 106 | // this is so we don't end up with rounding errors with |
| 107 | // parts of the display unusable or don't get cleared correctly | 107 | // parts of the display unusable or don't get cleared correctly |
| 108 | // and also allows for drawing & inverting | 108 | // and also allows for drawing & inverting |
| 109 | uint8_t oled_buffer[OLED_MATRIX_SIZE]; | 109 | uint8_t oled_buffer[OLED_MATRIX_SIZE]; |
| 110 | uint8_t* oled_cursor; | 110 | uint8_t * oled_cursor; |
| 111 | OLED_BLOCK_TYPE oled_dirty = 0; | 111 | OLED_BLOCK_TYPE oled_dirty = 0; |
| 112 | bool oled_initialized = false; | 112 | bool oled_initialized = false; |
| 113 | bool oled_active = false; | 113 | bool oled_active = false; |
| 114 | bool oled_scrolling = false; | 114 | bool oled_scrolling = false; |
| 115 | uint8_t oled_rotation = 0; | 115 | uint8_t oled_rotation = 0; |
| 116 | uint8_t oled_rotation_width = 0; | 116 | uint8_t oled_rotation_width = 0; |
| 117 | #if OLED_TIMEOUT > 0 | 117 | #if OLED_TIMEOUT > 0 |
| 118 | uint32_t oled_timeout; | 118 | uint32_t oled_timeout; |
| 119 | #endif | 119 | #endif |
| 120 | #if OLED_SCROLL_TIMEOUT > 0 | 120 | #if OLED_SCROLL_TIMEOUT > 0 |
| 121 | uint32_t oled_scroll_timeout; | 121 | uint32_t oled_scroll_timeout; |
| 122 | #endif | 122 | #endif |
| 123 | 123 | ||
| 124 | // Internal variables to reduce math instructions | 124 | // Internal variables to reduce math instructions |
| @@ -126,468 +126,445 @@ uint8_t oled_rotation_width = 0; | |||
| 126 | #if defined(__AVR__) | 126 | #if defined(__AVR__) |
| 127 | // identical to i2c_transmit, but for PROGMEM since all initialization is in PROGMEM arrays currently | 127 | // identical to i2c_transmit, but for PROGMEM since all initialization is in PROGMEM arrays currently |
| 128 | // probably should move this into i2c_master... | 128 | // probably should move this into i2c_master... |
| 129 | static i2c_status_t i2c_transmit_P(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout) { | 129 | static i2c_status_t i2c_transmit_P(uint8_t address, const uint8_t *data, uint16_t length, uint16_t timeout) { |
| 130 | i2c_status_t status = i2c_start(address | I2C_WRITE, timeout); | 130 | i2c_status_t status = i2c_start(address | I2C_WRITE, timeout); |
| 131 | 131 | ||
| 132 | for (uint16_t i = 0; i < length && status >= 0; i++) { | 132 | for (uint16_t i = 0; i < length && status >= 0; i++) { |
| 133 | status = i2c_write(pgm_read_byte((const char*)data++), timeout); | 133 | status = i2c_write(pgm_read_byte((const char *)data++), timeout); |
| 134 | if (status) break; | 134 | if (status) break; |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | i2c_stop(); | 137 | i2c_stop(); |
| 138 | 138 | ||
| 139 | return status; | 139 | return status; |
| 140 | } | 140 | } |
| 141 | #endif | 141 | #endif |
| 142 | 142 | ||
| 143 | // Flips the rendering bits for a character at the current cursor position | 143 | // Flips the rendering bits for a character at the current cursor position |
| 144 | static void InvertCharacter(uint8_t *cursor) | 144 | static void InvertCharacter(uint8_t *cursor) { |
| 145 | { | 145 | const uint8_t *end = cursor + OLED_FONT_WIDTH; |
| 146 | const uint8_t *end = cursor + OLED_FONT_WIDTH; | 146 | while (cursor < end) { |
| 147 | while (cursor < end) { | 147 | *cursor = ~(*cursor); |
| 148 | *cursor = ~(*cursor); | 148 | cursor++; |
| 149 | cursor++; | 149 | } |
| 150 | } | ||
| 151 | } | 150 | } |
| 152 | 151 | ||
| 153 | bool oled_init(uint8_t rotation) { | 152 | bool oled_init(uint8_t rotation) { |
| 154 | oled_rotation = oled_init_user(rotation); | 153 | oled_rotation = oled_init_user(rotation); |
| 155 | if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { | 154 | if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { |
| 156 | oled_rotation_width = OLED_DISPLAY_WIDTH; | 155 | oled_rotation_width = OLED_DISPLAY_WIDTH; |
| 157 | } else { | 156 | } else { |
| 158 | oled_rotation_width = OLED_DISPLAY_HEIGHT; | 157 | oled_rotation_width = OLED_DISPLAY_HEIGHT; |
| 159 | } | 158 | } |
| 160 | i2c_init(); | 159 | i2c_init(); |
| 161 | 160 | ||
| 162 | static const uint8_t PROGMEM display_setup1[] = { | 161 | static const uint8_t PROGMEM display_setup1[] = { |
| 163 | I2C_CMD, | 162 | I2C_CMD, |
| 164 | DISPLAY_OFF, | 163 | DISPLAY_OFF, |
| 165 | DISPLAY_CLOCK, 0x80, | 164 | DISPLAY_CLOCK, |
| 166 | MULTIPLEX_RATIO, OLED_DISPLAY_HEIGHT - 1, | 165 | 0x80, |
| 167 | DISPLAY_OFFSET, 0x00, | 166 | MULTIPLEX_RATIO, |
| 168 | DISPLAY_START_LINE | 0x00, | 167 | OLED_DISPLAY_HEIGHT - 1, |
| 169 | CHARGE_PUMP, 0x14, | 168 | DISPLAY_OFFSET, |
| 169 | 0x00, | ||
| 170 | DISPLAY_START_LINE | 0x00, | ||
| 171 | CHARGE_PUMP, | ||
| 172 | 0x14, | ||
| 170 | #if (OLED_IC != OLED_IC_SH1106) | 173 | #if (OLED_IC != OLED_IC_SH1106) |
| 171 | // MEMORY_MODE is unsupported on SH1106 (Page Addressing only) | 174 | // MEMORY_MODE is unsupported on SH1106 (Page Addressing only) |
| 172 | MEMORY_MODE, 0x00, // Horizontal addressing mode | 175 | MEMORY_MODE, |
| 176 | 0x00, // Horizontal addressing mode | ||
| 173 | #endif | 177 | #endif |
| 174 | }; | 178 | }; |
| 175 | if (I2C_TRANSMIT_P(display_setup1) != I2C_STATUS_SUCCESS) { | 179 | if (I2C_TRANSMIT_P(display_setup1) != I2C_STATUS_SUCCESS) { |
| 176 | print("oled_init cmd set 1 failed\n"); | 180 | print("oled_init cmd set 1 failed\n"); |
| 177 | return false; | 181 | return false; |
| 178 | } | 182 | } |
| 179 | 183 | ||
| 180 | if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_180)) { | 184 | if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_180)) { |
| 181 | static const uint8_t PROGMEM display_normal[] = { | 185 | static const uint8_t PROGMEM display_normal[] = {I2C_CMD, SEGMENT_REMAP_INV, COM_SCAN_DEC}; |
| 182 | I2C_CMD, | 186 | if (I2C_TRANSMIT_P(display_normal) != I2C_STATUS_SUCCESS) { |
| 183 | SEGMENT_REMAP_INV, | 187 | print("oled_init cmd normal rotation failed\n"); |
| 184 | COM_SCAN_DEC }; | 188 | return false; |
| 185 | if (I2C_TRANSMIT_P(display_normal) != I2C_STATUS_SUCCESS) { | 189 | } |
| 186 | print("oled_init cmd normal rotation failed\n"); | 190 | } else { |
| 187 | return false; | 191 | static const uint8_t PROGMEM display_flipped[] = {I2C_CMD, SEGMENT_REMAP, COM_SCAN_INC}; |
| 188 | } | 192 | if (I2C_TRANSMIT_P(display_flipped) != I2C_STATUS_SUCCESS) { |
| 189 | } else { | 193 | print("display_flipped failed\n"); |
| 190 | static const uint8_t PROGMEM display_flipped[] = { | 194 | return false; |
| 191 | I2C_CMD, | 195 | } |
| 192 | SEGMENT_REMAP, | 196 | } |
| 193 | COM_SCAN_INC }; | 197 | |
| 194 | if (I2C_TRANSMIT_P(display_flipped) != I2C_STATUS_SUCCESS) { | 198 | static const uint8_t PROGMEM display_setup2[] = {I2C_CMD, COM_PINS, OLED_COM_PINS, CONTRAST, 0x8F, PRE_CHARGE_PERIOD, 0xF1, VCOM_DETECT, 0x40, DISPLAY_ALL_ON_RESUME, NORMAL_DISPLAY, DEACTIVATE_SCROLL, DISPLAY_ON}; |
| 195 | print("display_flipped failed\n"); | 199 | if (I2C_TRANSMIT_P(display_setup2) != I2C_STATUS_SUCCESS) { |
| 196 | return false; | 200 | print("display_setup2 failed\n"); |
| 197 | } | 201 | return false; |
| 198 | } | 202 | } |
| 199 | |||
| 200 | static const uint8_t PROGMEM display_setup2[] = { | ||
| 201 | I2C_CMD, | ||
| 202 | COM_PINS, OLED_COM_PINS, | ||
| 203 | CONTRAST, 0x8F, | ||
| 204 | PRE_CHARGE_PERIOD, 0xF1, | ||
| 205 | VCOM_DETECT, 0x40, | ||
| 206 | DISPLAY_ALL_ON_RESUME, | ||
| 207 | NORMAL_DISPLAY, | ||
| 208 | DEACTIVATE_SCROLL, | ||
| 209 | DISPLAY_ON }; | ||
| 210 | if (I2C_TRANSMIT_P(display_setup2) != I2C_STATUS_SUCCESS) { | ||
| 211 | print("display_setup2 failed\n"); | ||
| 212 | return false; | ||
| 213 | } | ||
| 214 | 203 | ||
| 215 | #if OLED_TIMEOUT > 0 | 204 | #if OLED_TIMEOUT > 0 |
| 216 | oled_timeout = timer_read32() + OLED_TIMEOUT; | 205 | oled_timeout = timer_read32() + OLED_TIMEOUT; |
| 217 | #endif | 206 | #endif |
| 218 | #if OLED_SCROLL_TIMEOUT > 0 | 207 | #if OLED_SCROLL_TIMEOUT > 0 |
| 219 | oled_scroll_timeout = timer_read32() + OLED_SCROLL_TIMEOUT; | 208 | oled_scroll_timeout = timer_read32() + OLED_SCROLL_TIMEOUT; |
| 220 | #endif | 209 | #endif |
| 221 | 210 | ||
| 222 | oled_clear(); | 211 | oled_clear(); |
| 223 | oled_initialized = true; | 212 | oled_initialized = true; |
| 224 | oled_active = true; | 213 | oled_active = true; |
| 225 | oled_scrolling = false; | 214 | oled_scrolling = false; |
| 226 | return true; | 215 | return true; |
| 227 | } | 216 | } |
| 228 | 217 | ||
| 229 | __attribute__((weak)) | 218 | __attribute__((weak)) oled_rotation_t oled_init_user(oled_rotation_t rotation) { return rotation; } |
| 230 | oled_rotation_t oled_init_user(oled_rotation_t rotation) { | ||
| 231 | return rotation; | ||
| 232 | } | ||
| 233 | 219 | ||
| 234 | void oled_clear(void) { | 220 | void oled_clear(void) { |
| 235 | memset(oled_buffer, 0, sizeof(oled_buffer)); | 221 | memset(oled_buffer, 0, sizeof(oled_buffer)); |
| 236 | oled_cursor = &oled_buffer[0]; | 222 | oled_cursor = &oled_buffer[0]; |
| 237 | oled_dirty = -1; // -1 will be max value as long as display_dirty is unsigned type | 223 | oled_dirty = -1; // -1 will be max value as long as display_dirty is unsigned type |
| 238 | } | 224 | } |
| 239 | 225 | ||
| 240 | static void calc_bounds(uint8_t update_start, uint8_t* cmd_array) | 226 | static void calc_bounds(uint8_t update_start, uint8_t *cmd_array) { |
| 241 | { | 227 | // Calculate commands to set memory addressing bounds. |
| 242 | // Calculate commands to set memory addressing bounds. | 228 | uint8_t start_page = OLED_BLOCK_SIZE * update_start / OLED_DISPLAY_WIDTH; |
| 243 | uint8_t start_page = OLED_BLOCK_SIZE * update_start / OLED_DISPLAY_WIDTH; | 229 | uint8_t start_column = OLED_BLOCK_SIZE * update_start % OLED_DISPLAY_WIDTH; |
| 244 | uint8_t start_column = OLED_BLOCK_SIZE * update_start % OLED_DISPLAY_WIDTH; | ||
| 245 | #if (OLED_IC == OLED_IC_SH1106) | 230 | #if (OLED_IC == OLED_IC_SH1106) |
| 246 | // Commands for Page Addressing Mode. Sets starting page and column; has no end bound. | 231 | // Commands for Page Addressing Mode. Sets starting page and column; has no end bound. |
| 247 | // Column value must be split into high and low nybble and sent as two commands. | 232 | // Column value must be split into high and low nybble and sent as two commands. |
| 248 | cmd_array[0] = PAM_PAGE_ADDR | start_page; | 233 | cmd_array[0] = PAM_PAGE_ADDR | start_page; |
| 249 | cmd_array[1] = PAM_SETCOLUMN_LSB | ((OLED_COLUMN_OFFSET + start_column) & 0x0f); | 234 | cmd_array[1] = PAM_SETCOLUMN_LSB | ((OLED_COLUMN_OFFSET + start_column) & 0x0f); |
| 250 | cmd_array[2] = PAM_SETCOLUMN_MSB | ((OLED_COLUMN_OFFSET + start_column) >> 4 & 0x0f); | 235 | cmd_array[2] = PAM_SETCOLUMN_MSB | ((OLED_COLUMN_OFFSET + start_column) >> 4 & 0x0f); |
| 251 | cmd_array[3] = NOP; | 236 | cmd_array[3] = NOP; |
| 252 | cmd_array[4] = NOP; | 237 | cmd_array[4] = NOP; |
| 253 | cmd_array[5] = NOP; | 238 | cmd_array[5] = NOP; |
| 254 | #else | 239 | #else |
| 255 | // Commands for use in Horizontal Addressing mode. | 240 | // Commands for use in Horizontal Addressing mode. |
| 256 | cmd_array[1] = start_column; | 241 | cmd_array[1] = start_column; |
| 257 | cmd_array[4] = start_page; | 242 | cmd_array[4] = start_page; |
| 258 | cmd_array[2] = (OLED_BLOCK_SIZE + OLED_DISPLAY_WIDTH - 1) % OLED_DISPLAY_WIDTH + cmd_array[1]; | 243 | cmd_array[2] = (OLED_BLOCK_SIZE + OLED_DISPLAY_WIDTH - 1) % OLED_DISPLAY_WIDTH + cmd_array[1]; |
| 259 | cmd_array[5] = (OLED_BLOCK_SIZE + OLED_DISPLAY_WIDTH - 1) / OLED_DISPLAY_WIDTH - 1; | 244 | cmd_array[5] = (OLED_BLOCK_SIZE + OLED_DISPLAY_WIDTH - 1) / OLED_DISPLAY_WIDTH - 1; |
| 260 | #endif | 245 | #endif |
| 261 | } | 246 | } |
| 262 | 247 | ||
| 263 | static void calc_bounds_90(uint8_t update_start, uint8_t* cmd_array) | 248 | static void calc_bounds_90(uint8_t update_start, uint8_t *cmd_array) { |
| 264 | { | 249 | cmd_array[1] = OLED_BLOCK_SIZE * update_start / OLED_DISPLAY_HEIGHT * 8; |
| 265 | cmd_array[1] = OLED_BLOCK_SIZE * update_start / OLED_DISPLAY_HEIGHT * 8; | 250 | cmd_array[4] = OLED_BLOCK_SIZE * update_start % OLED_DISPLAY_HEIGHT; |
| 266 | cmd_array[4] = OLED_BLOCK_SIZE * update_start % OLED_DISPLAY_HEIGHT; | 251 | cmd_array[2] = (OLED_BLOCK_SIZE + OLED_DISPLAY_HEIGHT - 1) / OLED_DISPLAY_HEIGHT * 8 - 1 + cmd_array[1]; |
| 267 | cmd_array[2] = (OLED_BLOCK_SIZE + OLED_DISPLAY_HEIGHT - 1) / OLED_DISPLAY_HEIGHT * 8 - 1 + cmd_array[1];; | 252 | ; |
| 268 | cmd_array[5] = (OLED_BLOCK_SIZE + OLED_DISPLAY_HEIGHT - 1) % OLED_DISPLAY_HEIGHT / 8; | 253 | cmd_array[5] = (OLED_BLOCK_SIZE + OLED_DISPLAY_HEIGHT - 1) % OLED_DISPLAY_HEIGHT / 8; |
| 269 | } | 254 | } |
| 270 | 255 | ||
| 271 | uint8_t crot(uint8_t a, int8_t n) | 256 | uint8_t crot(uint8_t a, int8_t n) { |
| 272 | { | 257 | const uint8_t mask = 0x7; |
| 273 | const uint8_t mask = 0x7; | 258 | n &= mask; |
| 274 | n &= mask; | 259 | return a << n | a >> (-n & mask); |
| 275 | return a << n | a >> (-n & mask); | ||
| 276 | } | 260 | } |
| 277 | 261 | ||
| 278 | static void rotate_90(const uint8_t* src, uint8_t* dest) | 262 | static void rotate_90(const uint8_t *src, uint8_t *dest) { |
| 279 | { | 263 | for (uint8_t i = 0, shift = 7; i < 8; ++i, --shift) { |
| 280 | for (uint8_t i = 0, shift = 7; i < 8; ++i, --shift) { | 264 | uint8_t selector = (1 << i); |
| 281 | uint8_t selector = (1 << i); | 265 | for (uint8_t j = 0; j < 8; ++j) { |
| 282 | for (uint8_t j = 0; j < 8; ++j) { | 266 | dest[i] |= crot(src[j] & selector, shift - (int8_t)j); |
| 283 | dest[i] |= crot(src[j] & selector, shift - (int8_t)j); | 267 | } |
| 284 | } | 268 | } |
| 285 | } | ||
| 286 | } | 269 | } |
| 287 | 270 | ||
| 288 | void oled_render(void) { | 271 | void oled_render(void) { |
| 289 | // Do we have work to do? | 272 | // Do we have work to do? |
| 290 | if (!oled_dirty || oled_scrolling) { | 273 | if (!oled_dirty || oled_scrolling) { |
| 291 | return; | 274 | return; |
| 292 | } | 275 | } |
| 293 | 276 | ||
| 294 | // Find first dirty block | 277 | // Find first dirty block |
| 295 | uint8_t update_start = 0; | 278 | uint8_t update_start = 0; |
| 296 | while (!(oled_dirty & (1 << update_start))) { ++update_start; } | 279 | while (!(oled_dirty & (1 << update_start))) { |
| 297 | 280 | ++update_start; | |
| 298 | // Set column & page position | 281 | } |
| 299 | static uint8_t display_start[] = { | 282 | |
| 300 | I2C_CMD, | 283 | // Set column & page position |
| 301 | COLUMN_ADDR, 0, OLED_DISPLAY_WIDTH - 1, | 284 | static uint8_t display_start[] = {I2C_CMD, COLUMN_ADDR, 0, OLED_DISPLAY_WIDTH - 1, PAGE_ADDR, 0, OLED_DISPLAY_HEIGHT / 8 - 1}; |
| 302 | PAGE_ADDR, 0, OLED_DISPLAY_HEIGHT / 8 - 1 }; | 285 | if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { |
| 303 | if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { | 286 | calc_bounds(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start |
| 304 | calc_bounds(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start | 287 | } else { |
| 305 | } else { | 288 | calc_bounds_90(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start |
| 306 | calc_bounds_90(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start | 289 | } |
| 307 | } | 290 | |
| 308 | 291 | // Send column & page position | |
| 309 | // Send column & page position | 292 | if (I2C_TRANSMIT(display_start) != I2C_STATUS_SUCCESS) { |
| 310 | if (I2C_TRANSMIT(display_start) != I2C_STATUS_SUCCESS) { | 293 | print("oled_render offset command failed\n"); |
| 311 | print("oled_render offset command failed\n"); | 294 | return; |
| 312 | return; | 295 | } |
| 313 | } | 296 | |
| 314 | 297 | if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { | |
| 315 | if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { | 298 | // Send render data chunk as is |
| 316 | // Send render data chunk as is | 299 | if (I2C_WRITE_REG(I2C_DATA, &oled_buffer[OLED_BLOCK_SIZE * update_start], OLED_BLOCK_SIZE) != I2C_STATUS_SUCCESS) { |
| 317 | if (I2C_WRITE_REG(I2C_DATA, &oled_buffer[OLED_BLOCK_SIZE * update_start], OLED_BLOCK_SIZE) != I2C_STATUS_SUCCESS) { | 300 | print("oled_render data failed\n"); |
| 318 | print("oled_render data failed\n"); | 301 | return; |
| 319 | return; | 302 | } |
| 320 | } | 303 | } else { |
| 321 | } else { | 304 | // Rotate the render chunks |
| 322 | // Rotate the render chunks | 305 | const static uint8_t source_map[] = OLED_SOURCE_MAP; |
| 323 | const static uint8_t source_map[] = OLED_SOURCE_MAP; | 306 | const static uint8_t target_map[] = OLED_TARGET_MAP; |
| 324 | const static uint8_t target_map[] = OLED_TARGET_MAP; | 307 | |
| 325 | 308 | static uint8_t temp_buffer[OLED_BLOCK_SIZE]; | |
| 326 | static uint8_t temp_buffer[OLED_BLOCK_SIZE]; | 309 | memset(temp_buffer, 0, sizeof(temp_buffer)); |
| 327 | memset(temp_buffer, 0, sizeof(temp_buffer)); | 310 | for (uint8_t i = 0; i < sizeof(source_map); ++i) { |
| 328 | for(uint8_t i = 0; i < sizeof(source_map); ++i) { | 311 | rotate_90(&oled_buffer[OLED_BLOCK_SIZE * update_start + source_map[i]], &temp_buffer[target_map[i]]); |
| 329 | rotate_90(&oled_buffer[OLED_BLOCK_SIZE * update_start + source_map[i]], &temp_buffer[target_map[i]]); | 312 | } |
| 330 | } | 313 | |
| 331 | 314 | // Send render data chunk after rotating | |
| 332 | // Send render data chunk after rotating | 315 | if (I2C_WRITE_REG(I2C_DATA, &temp_buffer[0], OLED_BLOCK_SIZE) != I2C_STATUS_SUCCESS) { |
| 333 | if (I2C_WRITE_REG(I2C_DATA, &temp_buffer[0], OLED_BLOCK_SIZE) != I2C_STATUS_SUCCESS) { | 316 | print("oled_render90 data failed\n"); |
| 334 | print("oled_render90 data failed\n"); | 317 | return; |
| 335 | return; | 318 | } |
| 336 | } | 319 | } |
| 337 | } | 320 | |
| 338 | 321 | // Turn on display if it is off | |
| 339 | // Turn on display if it is off | 322 | oled_on(); |
| 340 | oled_on(); | 323 | |
| 341 | 324 | // Clear dirty flag | |
| 342 | // Clear dirty flag | 325 | oled_dirty &= ~(1 << update_start); |
| 343 | oled_dirty &= ~(1 << update_start); | ||
| 344 | } | 326 | } |
| 345 | 327 | ||
| 346 | void oled_set_cursor(uint8_t col, uint8_t line) { | 328 | void oled_set_cursor(uint8_t col, uint8_t line) { |
| 347 | uint16_t index = line * oled_rotation_width + col * OLED_FONT_WIDTH; | 329 | uint16_t index = line * oled_rotation_width + col * OLED_FONT_WIDTH; |
| 348 | 330 | ||
| 349 | // Out of bounds? | 331 | // Out of bounds? |
| 350 | if (index >= OLED_MATRIX_SIZE) { | 332 | if (index >= OLED_MATRIX_SIZE) { |
| 351 | index = 0; | 333 | index = 0; |
| 352 | } | 334 | } |
| 353 | 335 | ||
| 354 | oled_cursor = &oled_buffer[index]; | 336 | oled_cursor = &oled_buffer[index]; |
| 355 | } | 337 | } |
| 356 | 338 | ||
| 357 | void oled_advance_page(bool clearPageRemainder) { | 339 | void oled_advance_page(bool clearPageRemainder) { |
| 358 | uint16_t index = oled_cursor - &oled_buffer[0]; | 340 | uint16_t index = oled_cursor - &oled_buffer[0]; |
| 359 | uint8_t remaining = oled_rotation_width - (index % oled_rotation_width); | 341 | uint8_t remaining = oled_rotation_width - (index % oled_rotation_width); |
| 360 | 342 | ||
| 361 | if (clearPageRemainder) { | 343 | if (clearPageRemainder) { |
| 362 | // Remaining Char count | 344 | // Remaining Char count |
| 363 | remaining = remaining / OLED_FONT_WIDTH; | 345 | remaining = remaining / OLED_FONT_WIDTH; |
| 364 | 346 | ||
| 365 | // Write empty character until next line | 347 | // Write empty character until next line |
| 366 | while (remaining--) | 348 | while (remaining--) oled_write_char(' ', false); |
| 367 | oled_write_char(' ', false); | 349 | } else { |
| 368 | } else { | 350 | // Next page index out of bounds? |
| 369 | // Next page index out of bounds? | 351 | if (index + remaining >= OLED_MATRIX_SIZE) { |
| 370 | if (index + remaining >= OLED_MATRIX_SIZE) { | 352 | index = 0; |
| 371 | index = 0; | 353 | remaining = 0; |
| 372 | remaining = 0; | 354 | } |
| 355 | |||
| 356 | oled_cursor = &oled_buffer[index + remaining]; | ||
| 373 | } | 357 | } |
| 374 | |||
| 375 | oled_cursor = &oled_buffer[index + remaining]; | ||
| 376 | } | ||
| 377 | } | 358 | } |
| 378 | 359 | ||
| 379 | void oled_advance_char(void) { | 360 | void oled_advance_char(void) { |
| 380 | uint16_t nextIndex = oled_cursor - &oled_buffer[0] + OLED_FONT_WIDTH; | 361 | uint16_t nextIndex = oled_cursor - &oled_buffer[0] + OLED_FONT_WIDTH; |
| 381 | uint8_t remainingSpace = oled_rotation_width - (nextIndex % oled_rotation_width); | 362 | uint8_t remainingSpace = oled_rotation_width - (nextIndex % oled_rotation_width); |
| 382 | 363 | ||
| 383 | // Do we have enough space on the current line for the next character | 364 | // Do we have enough space on the current line for the next character |
| 384 | if (remainingSpace < OLED_FONT_WIDTH) { | 365 | if (remainingSpace < OLED_FONT_WIDTH) { |
| 385 | nextIndex += remainingSpace; | 366 | nextIndex += remainingSpace; |
| 386 | } | 367 | } |
| 387 | 368 | ||
| 388 | // Did we go out of bounds | 369 | // Did we go out of bounds |
| 389 | if (nextIndex >= OLED_MATRIX_SIZE) { | 370 | if (nextIndex >= OLED_MATRIX_SIZE) { |
| 390 | nextIndex = 0; | 371 | nextIndex = 0; |
| 391 | } | 372 | } |
| 392 | 373 | ||
| 393 | // Update cursor position | 374 | // Update cursor position |
| 394 | oled_cursor = &oled_buffer[nextIndex]; | 375 | oled_cursor = &oled_buffer[nextIndex]; |
| 395 | } | 376 | } |
| 396 | 377 | ||
| 397 | // Main handler that writes character data to the display buffer | 378 | // Main handler that writes character data to the display buffer |
| 398 | void oled_write_char(const char data, bool invert) { | 379 | void oled_write_char(const char data, bool invert) { |
| 399 | // Advance to the next line if newline | 380 | // Advance to the next line if newline |
| 400 | if (data == '\n') { | 381 | if (data == '\n') { |
| 401 | // Old source wrote ' ' until end of line... | 382 | // Old source wrote ' ' until end of line... |
| 402 | oled_advance_page(true); | 383 | oled_advance_page(true); |
| 403 | return; | 384 | return; |
| 404 | } | 385 | } |
| 405 | 386 | ||
| 406 | if (data == '\r') { | 387 | if (data == '\r') { |
| 407 | oled_advance_page(false); | 388 | oled_advance_page(false); |
| 408 | return; | 389 | return; |
| 409 | } | 390 | } |
| 410 | 391 | ||
| 411 | // copy the current render buffer to check for dirty after | 392 | // copy the current render buffer to check for dirty after |
| 412 | static uint8_t oled_temp_buffer[OLED_FONT_WIDTH]; | 393 | static uint8_t oled_temp_buffer[OLED_FONT_WIDTH]; |
| 413 | memcpy(&oled_temp_buffer, oled_cursor, OLED_FONT_WIDTH); | 394 | memcpy(&oled_temp_buffer, oled_cursor, OLED_FONT_WIDTH); |
| 414 | 395 | ||
| 415 | // set the reder buffer data | 396 | // set the reder buffer data |
| 416 | uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index | 397 | uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index |
| 417 | if (cast_data < OLED_FONT_START || cast_data > OLED_FONT_END) { | 398 | if (cast_data < OLED_FONT_START || cast_data > OLED_FONT_END) { |
| 418 | memset(oled_cursor, 0x00, OLED_FONT_WIDTH); | 399 | memset(oled_cursor, 0x00, OLED_FONT_WIDTH); |
| 419 | } else { | 400 | } else { |
| 420 | const uint8_t *glyph = &font[(cast_data - OLED_FONT_START) * OLED_FONT_WIDTH]; | 401 | const uint8_t *glyph = &font[(cast_data - OLED_FONT_START) * OLED_FONT_WIDTH]; |
| 421 | memcpy_P(oled_cursor, glyph, OLED_FONT_WIDTH); | 402 | memcpy_P(oled_cursor, glyph, OLED_FONT_WIDTH); |
| 422 | } | 403 | } |
| 423 | 404 | ||
| 424 | // Invert if needed | 405 | // Invert if needed |
| 425 | if (invert) { | 406 | if (invert) { |
| 426 | InvertCharacter(oled_cursor); | 407 | InvertCharacter(oled_cursor); |
| 427 | } | 408 | } |
| 428 | 409 | ||
| 429 | // Dirty check | 410 | // Dirty check |
| 430 | if (memcmp(&oled_temp_buffer, oled_cursor, OLED_FONT_WIDTH)) { | 411 | if (memcmp(&oled_temp_buffer, oled_cursor, OLED_FONT_WIDTH)) { |
| 431 | uint16_t index = oled_cursor - &oled_buffer[0]; | 412 | uint16_t index = oled_cursor - &oled_buffer[0]; |
| 432 | oled_dirty |= (1 << (index / OLED_BLOCK_SIZE)); | 413 | oled_dirty |= (1 << (index / OLED_BLOCK_SIZE)); |
| 433 | // Edgecase check if the written data spans the 2 chunks | 414 | // Edgecase check if the written data spans the 2 chunks |
| 434 | oled_dirty |= (1 << ((index + OLED_FONT_WIDTH) / OLED_BLOCK_SIZE)); | 415 | oled_dirty |= (1 << ((index + OLED_FONT_WIDTH) / OLED_BLOCK_SIZE)); |
| 435 | } | 416 | } |
| 436 | 417 | ||
| 437 | // Finally move to the next char | 418 | // Finally move to the next char |
| 438 | oled_advance_char(); | 419 | oled_advance_char(); |
| 439 | } | 420 | } |
| 440 | 421 | ||
| 441 | void oled_write(const char *data, bool invert) { | 422 | void oled_write(const char *data, bool invert) { |
| 442 | const char *end = data + strlen(data); | 423 | const char *end = data + strlen(data); |
| 443 | while (data < end) { | 424 | while (data < end) { |
| 444 | oled_write_char(*data, invert); | 425 | oled_write_char(*data, invert); |
| 445 | data++; | 426 | data++; |
| 446 | } | 427 | } |
| 447 | } | 428 | } |
| 448 | 429 | ||
| 449 | void oled_write_ln(const char *data, bool invert) { | 430 | void oled_write_ln(const char *data, bool invert) { |
| 450 | oled_write(data, invert); | 431 | oled_write(data, invert); |
| 451 | oled_advance_page(true); | 432 | oled_advance_page(true); |
| 452 | } | 433 | } |
| 453 | 434 | ||
| 454 | #if defined(__AVR__) | 435 | #if defined(__AVR__) |
| 455 | void oled_write_P(const char *data, bool invert) { | 436 | void oled_write_P(const char *data, bool invert) { |
| 456 | uint8_t c = pgm_read_byte(data); | 437 | uint8_t c = pgm_read_byte(data); |
| 457 | while (c != 0) { | 438 | while (c != 0) { |
| 458 | oled_write_char(c, invert); | 439 | oled_write_char(c, invert); |
| 459 | c = pgm_read_byte(++data); | 440 | c = pgm_read_byte(++data); |
| 460 | } | 441 | } |
| 461 | } | 442 | } |
| 462 | 443 | ||
| 463 | void oled_write_ln_P(const char *data, bool invert) { | 444 | void oled_write_ln_P(const char *data, bool invert) { |
| 464 | oled_write_P(data, invert); | 445 | oled_write_P(data, invert); |
| 465 | oled_advance_page(true); | 446 | oled_advance_page(true); |
| 466 | } | 447 | } |
| 467 | #endif // defined(__AVR__) | 448 | #endif // defined(__AVR__) |
| 468 | 449 | ||
| 469 | bool oled_on(void) { | 450 | bool oled_on(void) { |
| 470 | #if OLED_TIMEOUT > 0 | 451 | #if OLED_TIMEOUT > 0 |
| 471 | oled_timeout = timer_read32() + OLED_TIMEOUT; | 452 | oled_timeout = timer_read32() + OLED_TIMEOUT; |
| 472 | #endif | 453 | #endif |
| 473 | 454 | ||
| 474 | static const uint8_t PROGMEM display_on[] = { I2C_CMD, DISPLAY_ON }; | 455 | static const uint8_t PROGMEM display_on[] = {I2C_CMD, DISPLAY_ON}; |
| 475 | if (!oled_active) { | 456 | if (!oled_active) { |
| 476 | if (I2C_TRANSMIT_P(display_on) != I2C_STATUS_SUCCESS) { | 457 | if (I2C_TRANSMIT_P(display_on) != I2C_STATUS_SUCCESS) { |
| 477 | print("oled_on cmd failed\n"); | 458 | print("oled_on cmd failed\n"); |
| 478 | return oled_active; | 459 | return oled_active; |
| 460 | } | ||
| 461 | oled_active = true; | ||
| 479 | } | 462 | } |
| 480 | oled_active = true; | 463 | return oled_active; |
| 481 | } | ||
| 482 | return oled_active; | ||
| 483 | } | 464 | } |
| 484 | 465 | ||
| 485 | bool oled_off(void) { | 466 | bool oled_off(void) { |
| 486 | static const uint8_t PROGMEM display_off[] = { I2C_CMD, DISPLAY_OFF }; | 467 | static const uint8_t PROGMEM display_off[] = {I2C_CMD, DISPLAY_OFF}; |
| 487 | if (oled_active) { | 468 | if (oled_active) { |
| 488 | if (I2C_TRANSMIT_P(display_off) != I2C_STATUS_SUCCESS) { | 469 | if (I2C_TRANSMIT_P(display_off) != I2C_STATUS_SUCCESS) { |
| 489 | print("oled_off cmd failed\n"); | 470 | print("oled_off cmd failed\n"); |
| 490 | return oled_active; | 471 | return oled_active; |
| 491 | } | 472 | } |
| 492 | oled_active = false; | 473 | oled_active = false; |
| 493 | } | 474 | } |
| 494 | return !oled_active; | 475 | return !oled_active; |
| 495 | } | 476 | } |
| 496 | 477 | ||
| 497 | bool oled_scroll_right(void) { | 478 | bool oled_scroll_right(void) { |
| 498 | // Dont enable scrolling if we need to update the display | 479 | // Dont enable scrolling if we need to update the display |
| 499 | // This prevents scrolling of bad data from starting the scroll too early after init | 480 | // This prevents scrolling of bad data from starting the scroll too early after init |
| 500 | if (!oled_dirty && !oled_scrolling) { | 481 | if (!oled_dirty && !oled_scrolling) { |
| 501 | static const uint8_t PROGMEM display_scroll_right[] = { | 482 | static const uint8_t PROGMEM display_scroll_right[] = {I2C_CMD, SCROLL_RIGHT, 0x00, 0x00, 0x00, 0x0F, 0x00, 0xFF, ACTIVATE_SCROLL}; |
| 502 | I2C_CMD, SCROLL_RIGHT, 0x00, 0x00, 0x00, 0x0F, 0x00, 0xFF, ACTIVATE_SCROLL }; | 483 | if (I2C_TRANSMIT_P(display_scroll_right) != I2C_STATUS_SUCCESS) { |
| 503 | if (I2C_TRANSMIT_P(display_scroll_right) != I2C_STATUS_SUCCESS) { | 484 | print("oled_scroll_right cmd failed\n"); |
| 504 | print("oled_scroll_right cmd failed\n"); | 485 | return oled_scrolling; |
| 505 | return oled_scrolling; | 486 | } |
| 506 | } | 487 | oled_scrolling = true; |
| 507 | oled_scrolling = true; | 488 | } |
| 508 | } | 489 | return oled_scrolling; |
| 509 | return oled_scrolling; | ||
| 510 | } | 490 | } |
| 511 | 491 | ||
| 512 | bool oled_scroll_left(void) { | 492 | bool oled_scroll_left(void) { |
| 513 | // Dont enable scrolling if we need to update the display | 493 | // Dont enable scrolling if we need to update the display |
| 514 | // This prevents scrolling of bad data from starting the scroll too early after init | 494 | // This prevents scrolling of bad data from starting the scroll too early after init |
| 515 | if (!oled_dirty && !oled_scrolling) { | 495 | if (!oled_dirty && !oled_scrolling) { |
| 516 | static const uint8_t PROGMEM display_scroll_left[] = { | 496 | static const uint8_t PROGMEM display_scroll_left[] = {I2C_CMD, SCROLL_LEFT, 0x00, 0x00, 0x00, 0x0F, 0x00, 0xFF, ACTIVATE_SCROLL}; |
| 517 | I2C_CMD, SCROLL_LEFT, 0x00, 0x00, 0x00, 0x0F, 0x00, 0xFF, ACTIVATE_SCROLL }; | 497 | if (I2C_TRANSMIT_P(display_scroll_left) != I2C_STATUS_SUCCESS) { |
| 518 | if (I2C_TRANSMIT_P(display_scroll_left) != I2C_STATUS_SUCCESS) { | 498 | print("oled_scroll_left cmd failed\n"); |
| 519 | print("oled_scroll_left cmd failed\n"); | 499 | return oled_scrolling; |
| 520 | return oled_scrolling; | 500 | } |
| 521 | } | 501 | oled_scrolling = true; |
| 522 | oled_scrolling = true; | 502 | } |
| 523 | } | 503 | return oled_scrolling; |
| 524 | return oled_scrolling; | ||
| 525 | } | 504 | } |
| 526 | 505 | ||
| 527 | bool oled_scroll_off(void) { | 506 | bool oled_scroll_off(void) { |
| 528 | if (oled_scrolling) { | 507 | if (oled_scrolling) { |
| 529 | static const uint8_t PROGMEM display_scroll_off[] = { I2C_CMD, DEACTIVATE_SCROLL }; | 508 | static const uint8_t PROGMEM display_scroll_off[] = {I2C_CMD, DEACTIVATE_SCROLL}; |
| 530 | if (I2C_TRANSMIT_P(display_scroll_off) != I2C_STATUS_SUCCESS) { | 509 | if (I2C_TRANSMIT_P(display_scroll_off) != I2C_STATUS_SUCCESS) { |
| 531 | print("oled_scroll_off cmd failed\n"); | 510 | print("oled_scroll_off cmd failed\n"); |
| 532 | return oled_scrolling; | 511 | return oled_scrolling; |
| 533 | } | 512 | } |
| 534 | oled_scrolling = false; | 513 | oled_scrolling = false; |
| 535 | oled_dirty = -1; | 514 | oled_dirty = -1; |
| 536 | } | 515 | } |
| 537 | return !oled_scrolling; | 516 | return !oled_scrolling; |
| 538 | } | 517 | } |
| 539 | 518 | ||
| 540 | uint8_t oled_max_chars(void) { | 519 | uint8_t oled_max_chars(void) { |
| 541 | if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { | 520 | if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { |
| 542 | return OLED_DISPLAY_WIDTH / OLED_FONT_WIDTH; | 521 | return OLED_DISPLAY_WIDTH / OLED_FONT_WIDTH; |
| 543 | } | 522 | } |
| 544 | return OLED_DISPLAY_HEIGHT / OLED_FONT_WIDTH; | 523 | return OLED_DISPLAY_HEIGHT / OLED_FONT_WIDTH; |
| 545 | } | 524 | } |
| 546 | 525 | ||
| 547 | uint8_t oled_max_lines(void) { | 526 | uint8_t oled_max_lines(void) { |
| 548 | if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { | 527 | if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { |
| 549 | return OLED_DISPLAY_HEIGHT / OLED_FONT_HEIGHT; | 528 | return OLED_DISPLAY_HEIGHT / OLED_FONT_HEIGHT; |
| 550 | } | 529 | } |
| 551 | return OLED_DISPLAY_WIDTH / OLED_FONT_HEIGHT; | 530 | return OLED_DISPLAY_WIDTH / OLED_FONT_HEIGHT; |
| 552 | } | 531 | } |
| 553 | 532 | ||
| 554 | void oled_task(void) { | 533 | void oled_task(void) { |
| 555 | if (!oled_initialized) { | 534 | if (!oled_initialized) { |
| 556 | return; | 535 | return; |
| 557 | } | 536 | } |
| 558 | 537 | ||
| 559 | oled_set_cursor(0, 0); | 538 | oled_set_cursor(0, 0); |
| 560 | 539 | ||
| 561 | oled_task_user(); | 540 | oled_task_user(); |
| 562 | 541 | ||
| 563 | #if OLED_SCROLL_TIMEOUT > 0 | 542 | #if OLED_SCROLL_TIMEOUT > 0 |
| 564 | if (oled_dirty && oled_scrolling) { | 543 | if (oled_dirty && oled_scrolling) { |
| 565 | oled_scroll_timeout = timer_read32() + OLED_SCROLL_TIMEOUT; | 544 | oled_scroll_timeout = timer_read32() + OLED_SCROLL_TIMEOUT; |
| 566 | oled_scroll_off(); | 545 | oled_scroll_off(); |
| 567 | } | 546 | } |
| 568 | #endif | 547 | #endif |
| 569 | 548 | ||
| 570 | // Smart render system, no need to check for dirty | 549 | // Smart render system, no need to check for dirty |
| 571 | oled_render(); | 550 | oled_render(); |
| 572 | 551 | ||
| 573 | // Display timeout check | 552 | // Display timeout check |
| 574 | #if OLED_TIMEOUT > 0 | 553 | #if OLED_TIMEOUT > 0 |
| 575 | if (oled_active && timer_expired32(timer_read32(), oled_timeout)) { | 554 | if (oled_active && timer_expired32(timer_read32(), oled_timeout)) { |
| 576 | oled_off(); | 555 | oled_off(); |
| 577 | } | 556 | } |
| 578 | #endif | 557 | #endif |
| 579 | 558 | ||
| 580 | #if OLED_SCROLL_TIMEOUT > 0 | 559 | #if OLED_SCROLL_TIMEOUT > 0 |
| 581 | if (!oled_scrolling && timer_expired32(timer_read32(), oled_scroll_timeout)) { | 560 | if (!oled_scrolling && timer_expired32(timer_read32(), oled_scroll_timeout)) { |
| 582 | #ifdef OLED_SCROLL_TIMEOUT_RIGHT | 561 | # ifdef OLED_SCROLL_TIMEOUT_RIGHT |
| 583 | oled_scroll_right(); | 562 | oled_scroll_right(); |
| 584 | #else | 563 | # else |
| 585 | oled_scroll_left(); | 564 | oled_scroll_left(); |
| 586 | #endif | 565 | # endif |
| 587 | } | 566 | } |
| 588 | #endif | 567 | #endif |
| 589 | } | 568 | } |
| 590 | 569 | ||
| 591 | __attribute__((weak)) | 570 | __attribute__((weak)) void oled_task_user(void) {} |
| 592 | void oled_task_user(void) { | ||
| 593 | } | ||
diff --git a/drivers/oled/oled_driver.h b/drivers/oled/oled_driver.h index 4f6254c98..ac8a1c765 100644 --- a/drivers/oled/oled_driver.h +++ b/drivers/oled/oled_driver.h | |||
| @@ -21,129 +21,133 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 21 | 21 | ||
| 22 | // an enumeration of the chips this driver supports | 22 | // an enumeration of the chips this driver supports |
| 23 | #define OLED_IC_SSD1306 0 | 23 | #define OLED_IC_SSD1306 0 |
| 24 | #define OLED_IC_SH1106 1 | 24 | #define OLED_IC_SH1106 1 |
| 25 | 25 | ||
| 26 | #if defined(OLED_DISPLAY_CUSTOM) | 26 | #if defined(OLED_DISPLAY_CUSTOM) |
| 27 | // Expected user to implement the necessary defines | 27 | // Expected user to implement the necessary defines |
| 28 | #elif defined(OLED_DISPLAY_128X64) | 28 | #elif defined(OLED_DISPLAY_128X64) |
| 29 | // Double height 128x64 | 29 | // Double height 128x64 |
| 30 | #ifndef OLED_DISPLAY_WIDTH | 30 | # ifndef OLED_DISPLAY_WIDTH |
| 31 | #define OLED_DISPLAY_WIDTH 128 | 31 | # define OLED_DISPLAY_WIDTH 128 |
| 32 | #endif | 32 | # endif |
| 33 | #ifndef OLED_DISPLAY_HEIGHT | 33 | # ifndef OLED_DISPLAY_HEIGHT |
| 34 | #define OLED_DISPLAY_HEIGHT 64 | 34 | # define OLED_DISPLAY_HEIGHT 64 |
| 35 | #endif | 35 | # endif |
| 36 | #ifndef OLED_MATRIX_SIZE | 36 | # ifndef OLED_MATRIX_SIZE |
| 37 | #define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 1024 (compile time mathed) | 37 | # define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 1024 (compile time mathed) |
| 38 | #endif | 38 | # endif |
| 39 | #ifndef OLED_BLOCK_TYPE | 39 | # ifndef OLED_BLOCK_TYPE |
| 40 | #define OLED_BLOCK_TYPE uint16_t | 40 | # define OLED_BLOCK_TYPE uint16_t |
| 41 | #endif | 41 | # endif |
| 42 | #ifndef OLED_BLOCK_COUNT | 42 | # ifndef OLED_BLOCK_COUNT |
| 43 | #define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 32 (compile time mathed) | 43 | # define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 32 (compile time mathed) |
| 44 | #endif | 44 | # endif |
| 45 | #ifndef OLED_BLOCK_SIZE | 45 | # ifndef OLED_BLOCK_SIZE |
| 46 | #define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed) | 46 | # define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed) |
| 47 | #endif | 47 | # endif |
| 48 | #ifndef OLED_COM_PINS | 48 | # ifndef OLED_COM_PINS |
| 49 | #define OLED_COM_PINS COM_PINS_ALT | 49 | # define OLED_COM_PINS COM_PINS_ALT |
| 50 | #endif | 50 | # endif |
| 51 | 51 | ||
| 52 | // For 90 degree rotation, we map our internal matrix to oled matrix using fixed arrays | 52 | // For 90 degree rotation, we map our internal matrix to oled matrix using fixed arrays |
| 53 | // The OLED writes to it's memory horizontally, starting top left, but our memory starts bottom left in this mode | 53 | // The OLED writes to it's memory horizontally, starting top left, but our memory starts bottom left in this mode |
| 54 | #ifndef OLED_SOURCE_MAP | 54 | # ifndef OLED_SOURCE_MAP |
| 55 | #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 } | 55 | # define OLED_SOURCE_MAP \ |
| 56 | #endif | 56 | { 0, 8, 16, 24, 32, 40, 48, 56 } |
| 57 | #ifndef OLED_TARGET_MAP | 57 | # endif |
| 58 | #define OLED_TARGET_MAP { 56, 48, 40, 32, 24, 16, 8, 0 } | 58 | # ifndef OLED_TARGET_MAP |
| 59 | #endif | 59 | # define OLED_TARGET_MAP \ |
| 60 | // If OLED_BLOCK_TYPE is uint32_t, these tables would look like: | 60 | { 56, 48, 40, 32, 24, 16, 8, 0 } |
| 61 | // #define OLED_SOURCE_MAP { 32, 40, 48, 56 } | 61 | # endif |
| 62 | // #define OLED_TARGET_MAP { 24, 16, 8, 0 } | 62 | // If OLED_BLOCK_TYPE is uint32_t, these tables would look like: |
| 63 | // If OLED_BLOCK_TYPE is uint16_t, these tables would look like: | 63 | // #define OLED_SOURCE_MAP { 32, 40, 48, 56 } |
| 64 | // #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 } | 64 | // #define OLED_TARGET_MAP { 24, 16, 8, 0 } |
| 65 | // #define OLED_TARGET_MAP { 56, 48, 40, 32, 24, 16, 8, 0 } | 65 | // If OLED_BLOCK_TYPE is uint16_t, these tables would look like: |
| 66 | // If OLED_BLOCK_TYPE is uint8_t, these tables would look like: | 66 | // #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 } |
| 67 | // #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120 } | 67 | // #define OLED_TARGET_MAP { 56, 48, 40, 32, 24, 16, 8, 0 } |
| 68 | // #define OLED_TARGET_MAP { 56, 120, 48, 112, 40, 104, 32, 96, 24, 88, 16, 80, 8, 72, 0, 64 } | 68 | // If OLED_BLOCK_TYPE is uint8_t, these tables would look like: |
| 69 | #else // defined(OLED_DISPLAY_128X64) | 69 | // #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120 } |
| 70 | // Default 128x32 | 70 | // #define OLED_TARGET_MAP { 56, 120, 48, 112, 40, 104, 32, 96, 24, 88, 16, 80, 8, 72, 0, 64 } |
| 71 | #ifndef OLED_DISPLAY_WIDTH | 71 | #else // defined(OLED_DISPLAY_128X64) |
| 72 | #define OLED_DISPLAY_WIDTH 128 | 72 | // Default 128x32 |
| 73 | #endif | 73 | # ifndef OLED_DISPLAY_WIDTH |
| 74 | #ifndef OLED_DISPLAY_HEIGHT | 74 | # define OLED_DISPLAY_WIDTH 128 |
| 75 | #define OLED_DISPLAY_HEIGHT 32 | 75 | # endif |
| 76 | #endif | 76 | # ifndef OLED_DISPLAY_HEIGHT |
| 77 | #ifndef OLED_MATRIX_SIZE | 77 | # define OLED_DISPLAY_HEIGHT 32 |
| 78 | #define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 512 (compile time mathed) | 78 | # endif |
| 79 | #endif | 79 | # ifndef OLED_MATRIX_SIZE |
| 80 | #ifndef OLED_BLOCK_TYPE | 80 | # define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 512 (compile time mathed) |
| 81 | #define OLED_BLOCK_TYPE uint16_t // Type to use for segmenting the oled display for smart rendering, use unsigned types only | 81 | # endif |
| 82 | #endif | 82 | # ifndef OLED_BLOCK_TYPE |
| 83 | #ifndef OLED_BLOCK_COUNT | 83 | # define OLED_BLOCK_TYPE uint16_t // Type to use for segmenting the oled display for smart rendering, use unsigned types only |
| 84 | #define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 16 (compile time mathed) | 84 | # endif |
| 85 | #endif | 85 | # ifndef OLED_BLOCK_COUNT |
| 86 | #ifndef OLED_BLOCK_SIZE | 86 | # define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 16 (compile time mathed) |
| 87 | #define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed) | 87 | # endif |
| 88 | #endif | 88 | # ifndef OLED_BLOCK_SIZE |
| 89 | #ifndef OLED_COM_PINS | 89 | # define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed) |
| 90 | #define OLED_COM_PINS COM_PINS_SEQ | 90 | # endif |
| 91 | #endif | 91 | # ifndef OLED_COM_PINS |
| 92 | 92 | # define OLED_COM_PINS COM_PINS_SEQ | |
| 93 | // For 90 degree rotation, we map our internal matrix to oled matrix using fixed arrays | 93 | # endif |
| 94 | // The OLED writes to it's memory horizontally, starting top left, but our memory starts bottom left in this mode | 94 | |
| 95 | #ifndef OLED_SOURCE_MAP | 95 | // For 90 degree rotation, we map our internal matrix to oled matrix using fixed arrays |
| 96 | #define OLED_SOURCE_MAP { 0, 8, 16, 24 } | 96 | // The OLED writes to it's memory horizontally, starting top left, but our memory starts bottom left in this mode |
| 97 | #endif | 97 | # ifndef OLED_SOURCE_MAP |
| 98 | #ifndef OLED_TARGET_MAP | 98 | # define OLED_SOURCE_MAP \ |
| 99 | #define OLED_TARGET_MAP { 24, 16, 8, 0 } | 99 | { 0, 8, 16, 24 } |
| 100 | #endif | 100 | # endif |
| 101 | // If OLED_BLOCK_TYPE is uint8_t, these tables would look like: | 101 | # ifndef OLED_TARGET_MAP |
| 102 | // #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 } | 102 | # define OLED_TARGET_MAP \ |
| 103 | // #define OLED_TARGET_MAP { 48, 32, 16, 0, 56, 40, 24, 8 } | 103 | { 24, 16, 8, 0 } |
| 104 | #endif // defined(OLED_DISPLAY_CUSTOM) | 104 | # endif |
| 105 | // If OLED_BLOCK_TYPE is uint8_t, these tables would look like: | ||
| 106 | // #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 } | ||
| 107 | // #define OLED_TARGET_MAP { 48, 32, 16, 0, 56, 40, 24, 8 } | ||
| 108 | #endif // defined(OLED_DISPLAY_CUSTOM) | ||
| 105 | 109 | ||
| 106 | #if !defined(OLED_IC) | 110 | #if !defined(OLED_IC) |
| 107 | #define OLED_IC OLED_IC_SSD1306 | 111 | # define OLED_IC OLED_IC_SSD1306 |
| 108 | #endif | 112 | #endif |
| 109 | 113 | ||
| 110 | // the column address corresponding to the first column in the display hardware | 114 | // the column address corresponding to the first column in the display hardware |
| 111 | #if !defined(OLED_COLUMN_OFFSET) | 115 | #if !defined(OLED_COLUMN_OFFSET) |
| 112 | #define OLED_COLUMN_OFFSET 0 | 116 | # define OLED_COLUMN_OFFSET 0 |
| 113 | #endif | 117 | #endif |
| 114 | 118 | ||
| 115 | // Address to use for the i2c oled communication | 119 | // Address to use for the i2c oled communication |
| 116 | #if !defined(OLED_DISPLAY_ADDRESS) | 120 | #if !defined(OLED_DISPLAY_ADDRESS) |
| 117 | #define OLED_DISPLAY_ADDRESS 0x3C | 121 | # define OLED_DISPLAY_ADDRESS 0x3C |
| 118 | #endif | 122 | #endif |
| 119 | 123 | ||
| 120 | // Custom font file to use | 124 | // Custom font file to use |
| 121 | #if !defined(OLED_FONT_H) | 125 | #if !defined(OLED_FONT_H) |
| 122 | #define OLED_FONT_H "glcdfont.c" | 126 | # define OLED_FONT_H "glcdfont.c" |
| 123 | #endif | 127 | #endif |
| 124 | // unsigned char value of the first character in the font file | 128 | // unsigned char value of the first character in the font file |
| 125 | #if !defined(OLED_FONT_START) | 129 | #if !defined(OLED_FONT_START) |
| 126 | #define OLED_FONT_START 0 | 130 | # define OLED_FONT_START 0 |
| 127 | #endif | 131 | #endif |
| 128 | // unsigned char value of the last character in the font file | 132 | // unsigned char value of the last character in the font file |
| 129 | #if !defined(OLED_FONT_END) | 133 | #if !defined(OLED_FONT_END) |
| 130 | #define OLED_FONT_END 224 | 134 | # define OLED_FONT_END 224 |
| 131 | #endif | 135 | #endif |
| 132 | // Font render width | 136 | // Font render width |
| 133 | #if !defined(OLED_FONT_WIDTH) | 137 | #if !defined(OLED_FONT_WIDTH) |
| 134 | #define OLED_FONT_WIDTH 6 | 138 | # define OLED_FONT_WIDTH 6 |
| 135 | #endif | 139 | #endif |
| 136 | // Font render height | 140 | // Font render height |
| 137 | #if !defined(OLED_FONT_HEIGHT) | 141 | #if !defined(OLED_FONT_HEIGHT) |
| 138 | #define OLED_FONT_HEIGHT 8 | 142 | # define OLED_FONT_HEIGHT 8 |
| 139 | #endif | 143 | #endif |
| 140 | 144 | ||
| 141 | #if !defined(OLED_TIMEOUT) | 145 | #if !defined(OLED_TIMEOUT) |
| 142 | #if defined(OLED_DISABLE_TIMEOUT) | 146 | # if defined(OLED_DISABLE_TIMEOUT) |
| 143 | #define OLED_TIMEOUT 0 | 147 | # define OLED_TIMEOUT 0 |
| 144 | #else | 148 | # else |
| 145 | #define OLED_TIMEOUT 60000 | 149 | # define OLED_TIMEOUT 60000 |
| 146 | #endif | 150 | # endif |
| 147 | #endif | 151 | #endif |
| 148 | 152 | ||
| 149 | // OLED Rotation enum values are flags | 153 | // OLED Rotation enum values are flags |
| @@ -151,7 +155,7 @@ typedef enum { | |||
| 151 | OLED_ROTATION_0 = 0, | 155 | OLED_ROTATION_0 = 0, |
| 152 | OLED_ROTATION_90 = 1, | 156 | OLED_ROTATION_90 = 1, |
| 153 | OLED_ROTATION_180 = 2, | 157 | OLED_ROTATION_180 = 2, |
| 154 | OLED_ROTATION_270 = 3, // OLED_ROTATION_90 | OLED_ROTATION_180 | 158 | OLED_ROTATION_270 = 3, // OLED_ROTATION_90 | OLED_ROTATION_180 |
| 155 | } oled_rotation_t; | 159 | } oled_rotation_t; |
| 156 | 160 | ||
| 157 | // Initialize the oled display, rotating the rendered output based on the define passed in. | 161 | // Initialize the oled display, rotating the rendered output based on the define passed in. |
| @@ -208,15 +212,15 @@ void oled_write_P(const char *data, bool invert); | |||
| 208 | // Remapped to call 'void oled_write_ln(const char *data, bool invert);' on ARM | 212 | // Remapped to call 'void oled_write_ln(const char *data, bool invert);' on ARM |
| 209 | void oled_write_ln_P(const char *data, bool invert); | 213 | void oled_write_ln_P(const char *data, bool invert); |
| 210 | #else | 214 | #else |
| 211 | // Writes a string to the buffer at current cursor position | 215 | // Writes a string to the buffer at current cursor position |
| 212 | // Advances the cursor while writing, inverts the pixels if true | 216 | // Advances the cursor while writing, inverts the pixels if true |
| 213 | #define oled_write_P(data, invert) oled_write(data, invert) | 217 | # define oled_write_P(data, invert) oled_write(data, invert) |
| 214 | 218 | ||
| 215 | // Writes a string to the buffer at current cursor position | 219 | // Writes a string to the buffer at current cursor position |
| 216 | // Advances the cursor while writing, inverts the pixels if true | 220 | // Advances the cursor while writing, inverts the pixels if true |
| 217 | // Advances the cursor to the next page, wiring ' ' to the remainder of the current page | 221 | // Advances the cursor to the next page, wiring ' ' to the remainder of the current page |
| 218 | #define oled_write_ln_P(data, invert) oled_write(data, invert) | 222 | # define oled_write_ln_P(data, invert) oled_write(data, invert) |
| 219 | #endif // defined(__AVR__) | 223 | #endif // defined(__AVR__) |
| 220 | 224 | ||
| 221 | // Can be used to manually turn on the screen if it is off | 225 | // Can be used to manually turn on the screen if it is off |
| 222 | // Returns true if the screen was on or turns on | 226 | // Returns true if the screen was on or turns on |
diff --git a/drivers/qwiic/micro_oled.c b/drivers/qwiic/micro_oled.c index 092dd551e..597810f33 100644 --- a/drivers/qwiic/micro_oled.c +++ b/drivers/qwiic/micro_oled.c | |||
| @@ -35,16 +35,21 @@ | |||
| 35 | #include "string.h" | 35 | #include "string.h" |
| 36 | 36 | ||
| 37 | #define TOTALFONTS 2 | 37 | #define TOTALFONTS 2 |
| 38 | const unsigned char * fonts_pointer[]= { font5x7, font8x16 }; | 38 | const unsigned char* fonts_pointer[] = {font5x7, font8x16}; |
| 39 | 39 | ||
| 40 | uint8_t foreColor,drawMode,fontWidth, fontHeight, fontType, fontStartChar, fontTotalChar, cursorX, cursorY; | 40 | uint8_t foreColor, drawMode, fontWidth, fontHeight, fontType, fontStartChar, fontTotalChar, cursorX, cursorY; |
| 41 | uint16_t fontMapWidth; | 41 | uint16_t fontMapWidth; |
| 42 | 42 | ||
| 43 | #define _BV(x) (1 << (x)) | 43 | #define _BV(x) (1 << (x)) |
| 44 | #define swap(a, b) { uint8_t t = a; a = b; b = t; } | 44 | #define swap(a, b) \ |
| 45 | { \ | ||
| 46 | uint8_t t = a; \ | ||
| 47 | a = b; \ | ||
| 48 | b = t; \ | ||
| 49 | } | ||
| 45 | 50 | ||
| 46 | uint8_t micro_oled_transfer_buffer[20]; | 51 | uint8_t micro_oled_transfer_buffer[20]; |
| 47 | static uint8_t micro_oled_screen_current[LCDWIDTH*LCDWIDTH/8] = { 0 }; | 52 | static uint8_t micro_oled_screen_current[LCDWIDTH * LCDWIDTH / 8] = {0}; |
| 48 | 53 | ||
| 49 | /* LCD Memory organised in 64 horizontal pixel and 6 rows of byte | 54 | /* LCD Memory organised in 64 horizontal pixel and 6 rows of byte |
| 50 | B B .............B ----- | 55 | B B .............B ----- |
| @@ -64,628 +69,399 @@ static uint8_t micro_oled_screen_current[LCDWIDTH*LCDWIDTH/8] = { 0 }; | |||
| 64 | */ | 69 | */ |
| 65 | 70 | ||
| 66 | #if LCDWIDTH == 64 | 71 | #if LCDWIDTH == 64 |
| 67 | #if LCDWIDTH == 48 | 72 | # if LCDWIDTH == 48 |
| 68 | static uint8_t micro_oled_screen_buffer[] = { | 73 | static uint8_t micro_oled_screen_buffer[] = { |
| 69 | // QMK Logo - generated at http://www.majer.ch/lcd/adf_bitmap.php | 74 | // QMK Logo - generated at http://www.majer.ch/lcd/adf_bitmap.php |
| 70 | //64x48 image | 75 | // 64x48 image |
| 71 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 76 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x60, 0x60, 0xF8, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0x1F, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x1F, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xF8, 0x60, 0x60, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 72 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 77 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8C, 0x8C, 0x8C, 0x8C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x8C, 0x8C, 0x8C, 0x8C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0x31, 0x31, 0x31, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF8, 0xF1, 0xE3, 0xE7, 0xCF, 0xCF, 0xCF, 0xCF, 0x00, 0x00, 0xCF, 0xCF, 0xCF, 0xC7, 0xE7, 0xE3, 0xF1, 0xF8, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x31, 0x31, 0x31, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 73 | 0x00, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x00, 0x00, | 78 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x1F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x1F, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 74 | 0x00, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x00, 0x00, | 79 | # endif |
| 75 | 0x00, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 76 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 77 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 78 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x60, 0x60, | ||
| 79 | 0xF8, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0x1F, 0x1F, 0xFF, 0xFF, | ||
| 80 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x1F, 0xFF, 0xFF, 0xFF, | ||
| 81 | 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x1F, 0xFF, 0xFF, 0xFF, 0xFE, | ||
| 82 | 0xFE, 0xF8, 0x60, 0x60, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, | ||
| 83 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 84 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 85 | 0x8C, 0x8C, 0x8C, 0x8C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | ||
| 86 | 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, | ||
| 87 | 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, | ||
| 88 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x8C, 0x8C, 0x8C, 0x8C, | ||
| 89 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 90 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 91 | 0x00, 0x00, 0x00, 0x00, 0x31, 0x31, 0x31, 0x31, 0xFF, 0xFF, | ||
| 92 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF8, 0xF1, 0xE3, 0xE7, 0xCF, | ||
| 93 | 0xCF, 0xCF, 0xCF, 0x00, 0x00, 0xCF, 0xCF, 0xCF, 0xC7, 0xE7, | ||
| 94 | 0xE3, 0xF1, 0xF8, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | ||
| 95 | 0x31, 0x31, 0x31, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 96 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 97 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, | ||
| 98 | 0x06, 0x06, 0x1F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | ||
| 99 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0xF8, 0xFF, | ||
| 100 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | ||
| 101 | 0xFF, 0x7F, 0x7F, 0x1F, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, | ||
| 102 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 103 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 104 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 105 | 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, | ||
| 106 | 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, | ||
| 107 | 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 108 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 109 | 0x00, 0x00, 0x00, 0x00 | ||
| 110 | }; | ||
| 111 | #endif | ||
| 112 | #elif LCDWIDTH == 128 | 80 | #elif LCDWIDTH == 128 |
| 113 | #if LCDHEIGHT == 32 | 81 | # if LCDHEIGHT == 32 |
| 114 | static uint8_t micro_oled_screen_buffer[LCDWIDTH*LCDWIDTH/8] = { | 82 | static uint8_t micro_oled_screen_buffer[LCDWIDTH * LCDWIDTH / 8] = { |
| 115 | //128x32 qmk image | 83 | // 128x32 qmk image |
| 116 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 84 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xE0, 0xFC, 0xFC, 0xE0, 0xFC, 0xFC, 0xE0, 0xF0, 0xFC, 0xE0, 0xE0, 0xFC, 0xE0, 0xE0, 0xFC, 0xFC, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x10, 0x10, 0x30, 0xE0, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 117 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 85 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0xB2, 0xB2, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x03, 0xFF, 0xFF, 0xFF, 0x03, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xB7, 0xB2, 0xB2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x02, 0x02, 0x03, 0x01, 0x00, 0x06, 0x1F, 0x10, 0x10, 0x10, 0x1F, 0x06, 0x00, 0x03, 0x1E, 0x18, 0x0F, 0x01, 0x0F, 0x18, 0x1E, 0x01, 0x00, 0x0F, 0x1F, 0x12, 0x02, 0x12, 0x13, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x0E, 0x1F, 0x12, 0x02, 0x12, 0x13, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 118 | 0x00, 0x80, 0xC0, 0xE0, 0xE0, 0xFC, 0xFC, 0xE0, 0xFC, 0xFC, | 86 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x4D, 0x4D, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xF9, 0xF3, 0xF3, 0xC0, 0x80, 0xF3, 0xF3, 0xF3, 0xF9, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xED, 0x4D, 0x4D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x20, 0x10, 0x10, 0xE0, 0xC0, 0x00, 0x70, 0xC0, 0x00, 0x80, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x0C, 0x04, 0x04, 0x04, 0x04, 0x1C, 0xF0, 0x00, 0x00, 0xFC, 0x0C, 0x38, 0xE0, 0x00, 0x00, 0xC0, 0x38, 0x0C, 0xFC, 0x00, 0x00, 0xFC, 0xFC, 0x60, 0x90, 0x0C, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 119 | 0xE0, 0xF0, 0xFC, 0xE0, 0xE0, 0xFC, 0xE0, 0xE0, 0xFC, 0xFC, | 87 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x07, 0x3F, 0x3F, 0x07, 0x3F, 0x3F, 0x07, 0x0F, 0x3F, 0x07, 0x07, 0x3F, 0x07, 0x07, 0x3F, 0x3F, 0x07, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x06, 0x04, 0x04, 0x07, 0x01, 0x00, 0x00, 0x13, 0x1E, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x04, 0x04, 0x04, 0x04, 0x07, 0x0D, 0x08, 0x00, 0x07, 0x00, 0x00, 0x01, 0x07, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x07, 0x07, 0x00, 0x01, 0x03, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 120 | 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 88 | # elif LCDHEIGHT == 64 |
| 121 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 89 | static uint8_t micro_oled_screen_buffer[LCDWIDTH * LCDWIDTH / 8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 122 | 0x00, 0x00, 0x00, 0xF0, 0x10, 0x10, 0x30, 0xE0, 0x00, 0x00, | 90 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xF8, 0xFC, 0xFC, 0xFE, 0xFE, 0xFF, 0x7F, 0x7E, 0xFE, 0xFF, 0xFF, 0xFE, 0xFE, 0x7F, 0x7F, 0xFE, 0xFE, 0xFF, 0xFF, 0xFE, 0x7E, 0x7F, 0xFF, 0xFE, 0xFE, 0xFC, 0xFC, 0xF8, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 123 | 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x00, 0x00, | 91 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0x88, 0xDD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDD, 0x88, 0x88, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 124 | 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, 0x80, | 92 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99, 0x99, 0x99, 0x99, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xF0, 0xF3, 0xF3, 0xE7, 0xE7, 0x00, 0x00, 0xE7, 0xE7, 0xF3, 0xF3, 0xF0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x99, 0x99, 0x99, 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 125 | 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, | 93 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x0F, 0x1F, 0x3F, 0x3F, 0x3F, 0xFF, 0xFF, 0x3F, 0x3F, 0xFF, 0xFF, 0x3F, 0x3F, 0xFF, 0xFF, 0x3F, 0x3F, 0xFF, 0xFF, 0x3F, 0x3F, 0xFF, 0xFF, 0x3F, 0x3F, 0x3F, 0x1F, 0x0F, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 126 | 0x80, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, | 94 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x00, 0x00, 0x03, 0x01, 0x00, 0x80, 0x03, 0x03, 0x00, 0x00, 0x01, 0x03, 0x00, 0x80, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 127 | 0x80, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 95 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x11, 0x11, 0x11, 0x0E, 0x00, 0x70, 0x88, 0x04, 0x04, 0x04, 0xF8, 0x00, 0x00, 0x3C, 0xE0, 0xC0, 0x38, 0x1C, 0xE0, 0x80, 0x70, 0x0C, 0x00, 0xF8, 0xAC, 0x24, 0x24, 0x3C, 0x30, 0x00, 0x00, 0xFC, 0x0C, 0x04, 0x00, 0xF8, 0xAC, 0x24, 0x24, 0x2C, 0x30, 0x00, 0x70, 0xDC, 0x04, 0x04, 0x88, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x8C, 0x04, 0x04, 0xF8, 0x00, 0x04, 0x3C, 0xE0, 0x80, 0xF0, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x83, 0x01, 0x01, 0x01, 0x81, 0xFE, 0x3C, 0x00, 0x00, 0xFF, 0x03, 0x0E, 0x70, 0xC0, 0xE0, 0x38, 0x06, 0x03, 0xFF, 0x00, 0x00, 0xFF, 0x18, 0x38, 0x66, 0xC3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 128 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 96 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 129 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 97 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 130 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0xB2, 0xB2, 0xFF, | 98 | // TODO: generate bitmap of QMK logo here |
| 131 | 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x03, 0xFF, 0xFF, 0xFF, 0x03, | 99 | # endif |
| 132 | 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x03, 0xFF, 0xFF, 0xFF, | ||
| 133 | 0xFF, 0xB7, 0xB2, 0xB2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 134 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 135 | 0x00, 0x1F, 0x02, 0x02, 0x03, 0x01, 0x00, 0x06, 0x1F, 0x10, | ||
| 136 | 0x10, 0x10, 0x1F, 0x06, 0x00, 0x03, 0x1E, 0x18, 0x0F, 0x01, | ||
| 137 | 0x0F, 0x18, 0x1E, 0x01, 0x00, 0x0F, 0x1F, 0x12, 0x02, 0x12, | ||
| 138 | 0x13, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x0E, 0x1F, 0x12, | ||
| 139 | 0x02, 0x12, 0x13, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x1F, | ||
| 140 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 141 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 142 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 143 | 0x00, 0x00, 0x00, 0x00, 0x48, 0x4D, 0x4D, 0xFF, 0xFF, 0xFF, | ||
| 144 | 0xFF, 0xFF, 0xFE, 0xF8, 0xF9, 0xF3, 0xF3, 0xC0, 0x80, 0xF3, | ||
| 145 | 0xF3, 0xF3, 0xF9, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xED, | ||
| 146 | 0x4D, 0x4D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 147 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 148 | 0x00, 0xFE, 0x20, 0x10, 0x10, 0xE0, 0xC0, 0x00, 0x70, 0xC0, | ||
| 149 | 0x00, 0x80, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x0C, | ||
| 150 | 0x04, 0x04, 0x04, 0x04, 0x1C, 0xF0, 0x00, 0x00, 0xFC, 0x0C, | ||
| 151 | 0x38, 0xE0, 0x00, 0x00, 0xC0, 0x38, 0x0C, 0xFC, 0x00, 0x00, | ||
| 152 | 0xFC, 0xFC, 0x60, 0x90, 0x0C, 0x04, 0x00, 0x00, 0x00, 0x00, | ||
| 153 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 154 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 155 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 156 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x07, 0x3F, | ||
| 157 | 0x3F, 0x07, 0x3F, 0x3F, 0x07, 0x0F, 0x3F, 0x07, 0x07, 0x3F, | ||
| 158 | 0x07, 0x07, 0x3F, 0x3F, 0x07, 0x07, 0x03, 0x00, 0x00, 0x00, | ||
| 159 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 160 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, | ||
| 161 | 0x06, 0x04, 0x04, 0x07, 0x01, 0x00, 0x00, 0x13, 0x1E, 0x03, | ||
| 162 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x04, 0x04, | ||
| 163 | 0x04, 0x04, 0x07, 0x0D, 0x08, 0x00, 0x07, 0x00, 0x00, 0x01, | ||
| 164 | 0x07, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x07, 0x07, | ||
| 165 | 0x00, 0x01, 0x03, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 166 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 167 | 0x00, 0x00 | ||
| 168 | }; | ||
| 169 | #elif LCDHEIGHT == 64 | ||
| 170 | static uint8_t micro_oled_screen_buffer[LCDWIDTH*LCDWIDTH/8] = { | ||
| 171 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 172 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 173 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 174 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 175 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 176 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 177 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 178 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, | ||
| 179 | 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, | ||
| 180 | 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, | ||
| 181 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 182 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 183 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 184 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 185 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 186 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 187 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 188 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 189 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 190 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 191 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 192 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 193 | 0xC0, 0xC0, 0xC0, 0xC0, 0xF8, 0xFC, 0xFC, 0xFE, 0xFE, 0xFF, | ||
| 194 | 0x7F, 0x7E, 0xFE, 0xFF, 0xFF, 0xFE, 0xFE, 0x7F, 0x7F, 0xFE, | ||
| 195 | 0xFE, 0xFF, 0xFF, 0xFE, 0x7E, 0x7F, 0xFF, 0xFE, 0xFE, 0xFC, | ||
| 196 | 0xFC, 0xF8, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, | ||
| 197 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 198 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 199 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 200 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 201 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 202 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 203 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 204 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 205 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 206 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 207 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 208 | 0x00, 0x88, 0x88, 0x88, 0xDD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | ||
| 209 | 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, | ||
| 210 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, | ||
| 211 | 0xFF, 0xFF, 0xFF, 0xDD, 0x88, 0x88, 0x88, 0x00, 0x00, 0x00, | ||
| 212 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 213 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 214 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 215 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 216 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 217 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 218 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 219 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 220 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 221 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 222 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 223 | 0x00, 0x00, 0x99, 0x99, 0x99, 0x99, 0xFF, 0xFF, 0xFF, 0xFF, | ||
| 224 | 0xFF, 0xFF, 0xFE, 0xF8, 0xF0, 0xF3, 0xF3, 0xE7, 0xE7, 0x00, | ||
| 225 | 0x00, 0xE7, 0xE7, 0xF3, 0xF3, 0xF0, 0xF8, 0xFE, 0xFF, 0xFF, | ||
| 226 | 0xFF, 0xFF, 0xFF, 0xFF, 0x99, 0x99, 0x99, 0x99, 0x00, 0x00, | ||
| 227 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 228 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 229 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 230 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 231 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 232 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 233 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 234 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 235 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 236 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 237 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 238 | 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x0F, 0x1F, 0x3F, | ||
| 239 | 0x3F, 0x3F, 0xFF, 0xFF, 0x3F, 0x3F, 0xFF, 0xFF, 0x3F, 0x3F, | ||
| 240 | 0xFF, 0xFF, 0x3F, 0x3F, 0xFF, 0xFF, 0x3F, 0x3F, 0xFF, 0xFF, | ||
| 241 | 0x3F, 0x3F, 0x3F, 0x1F, 0x0F, 0x01, 0x01, 0x01, 0x01, 0x00, | ||
| 242 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 243 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 244 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 245 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 246 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 247 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 248 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 249 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 250 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 251 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 252 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 253 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 254 | 0x00, 0x00, 0x00, 0x03, 0x01, 0x00, 0x00, 0x03, 0x01, 0x00, | ||
| 255 | 0x80, 0x03, 0x03, 0x00, 0x00, 0x01, 0x03, 0x00, 0x80, 0x01, | ||
| 256 | 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 257 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 258 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 259 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 260 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 261 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 262 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 263 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 264 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 265 | 0x00, 0x00, 0x00, 0xFF, 0x11, 0x11, 0x11, 0x0E, 0x00, 0x70, | ||
| 266 | 0x88, 0x04, 0x04, 0x04, 0xF8, 0x00, 0x00, 0x3C, 0xE0, 0xC0, | ||
| 267 | 0x38, 0x1C, 0xE0, 0x80, 0x70, 0x0C, 0x00, 0xF8, 0xAC, 0x24, | ||
| 268 | 0x24, 0x3C, 0x30, 0x00, 0x00, 0xFC, 0x0C, 0x04, 0x00, 0xF8, | ||
| 269 | 0xAC, 0x24, 0x24, 0x2C, 0x30, 0x00, 0x70, 0xDC, 0x04, 0x04, | ||
| 270 | 0x88, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, | ||
| 271 | 0x8C, 0x04, 0x04, 0xF8, 0x00, 0x04, 0x3C, 0xE0, 0x80, 0xF0, | ||
| 272 | 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x83, 0x01, 0x01, | ||
| 273 | 0x01, 0x81, 0xFE, 0x3C, 0x00, 0x00, 0xFF, 0x03, 0x0E, 0x70, | ||
| 274 | 0xC0, 0xE0, 0x38, 0x06, 0x03, 0xFF, 0x00, 0x00, 0xFF, 0x18, | ||
| 275 | 0x38, 0x66, 0xC3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 276 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 277 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 278 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 279 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 280 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 281 | 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, | ||
| 282 | 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, | ||
| 283 | 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | ||
| 284 | 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, | ||
| 285 | 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 286 | 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0x03, | ||
| 287 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, | ||
| 288 | 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, 0x00, 0x01, 0x00, 0x00, | ||
| 289 | 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, | ||
| 290 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 291 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 292 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 293 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 294 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 295 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 296 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 297 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 298 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 299 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 300 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 301 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 302 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 303 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 304 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 305 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 306 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | ||
| 307 | }; | ||
| 308 | //TODO: generate bitmap of QMK logo here | ||
| 309 | #endif | ||
| 310 | #else | 100 | #else |
| 311 | //catchall for custom screen szies | 101 | // catchall for custom screen szies |
| 312 | static uint8_t micro_oled_screen_buffer[LCDWIDTH*LCDWIDTH/8] = {0}; | 102 | static uint8_t micro_oled_screen_buffer[LCDWIDTH * LCDWIDTH / 8] = {0}; |
| 313 | #endif | 103 | #endif |
| 314 | 104 | ||
| 315 | |||
| 316 | |||
| 317 | void micro_oled_init(void) { | 105 | void micro_oled_init(void) { |
| 318 | i2c_init(); | 106 | i2c_init(); |
| 319 | i2c_start(I2C_ADDRESS_SA0_1); | 107 | i2c_start(I2C_ADDRESS_SA0_1); |
| 320 | 108 | ||
| 321 | // Display Init sequence for 64x48 OLED module | 109 | // Display Init sequence for 64x48 OLED module |
| 322 | send_command(DISPLAYOFF); // 0xAE | 110 | send_command(DISPLAYOFF); // 0xAE |
| 323 | 111 | ||
| 324 | send_command(SETDISPLAYCLOCKDIV); // 0xD5 | 112 | send_command(SETDISPLAYCLOCKDIV); // 0xD5 |
| 325 | send_command(0x80); // the suggested ratio 0x80 | 113 | send_command(0x80); // the suggested ratio 0x80 |
| 326 | 114 | ||
| 327 | send_command(SETMULTIPLEX); // 0xA8 | 115 | send_command(SETMULTIPLEX); // 0xA8 |
| 328 | send_command(LCDHEIGHT - 1); | 116 | send_command(LCDHEIGHT - 1); |
| 329 | 117 | ||
| 330 | send_command(SETDISPLAYOFFSET); // 0xD3 | 118 | send_command(SETDISPLAYOFFSET); // 0xD3 |
| 331 | send_command(0x00); // no offset | 119 | send_command(0x00); // no offset |
| 332 | 120 | ||
| 333 | send_command(SETSTARTLINE | 0x00); // line #0 | 121 | send_command(SETSTARTLINE | 0x00); // line #0 |
| 334 | 122 | ||
| 335 | send_command(CHARGEPUMP); // enable charge pump | 123 | send_command(CHARGEPUMP); // enable charge pump |
| 336 | send_command(0x14); | 124 | send_command(0x14); |
| 337 | 125 | ||
| 338 | send_command(NORMALDISPLAY); // 0xA6 | 126 | send_command(NORMALDISPLAY); // 0xA6 |
| 339 | send_command(DISPLAYALLONRESUME); // 0xA4 | 127 | send_command(DISPLAYALLONRESUME); // 0xA4 |
| 340 | 128 | ||
| 341 | //display at regular orientation | 129 | // display at regular orientation |
| 342 | send_command(SEGREMAP | 0x1); | 130 | send_command(SEGREMAP | 0x1); |
| 343 | send_command(COMSCANDEC); | 131 | send_command(COMSCANDEC); |
| 344 | 132 | ||
| 345 | //rotate display 180 | 133 | // rotate display 180 |
| 346 | #ifdef micro_oled_rotate_180 | 134 | #ifdef micro_oled_rotate_180 |
| 347 | send_command(SEGREMAP); | 135 | send_command(SEGREMAP); |
| 348 | send_command(COMSCANINC); | 136 | send_command(COMSCANINC); |
| 349 | #endif | 137 | #endif |
| 350 | 138 | ||
| 351 | send_command(MEMORYMODE); | 139 | send_command(MEMORYMODE); |
| 352 | send_command(0x10); | 140 | send_command(0x10); |
| 353 | 141 | ||
| 354 | send_command(SETCOMPINS); // 0xDA | 142 | send_command(SETCOMPINS); // 0xDA |
| 355 | if (LCDHEIGHT > 32) { | 143 | if (LCDHEIGHT > 32) { |
| 356 | send_command(0x12); | 144 | send_command(0x12); |
| 357 | } else { | 145 | } else { |
| 358 | send_command(0x02); | 146 | send_command(0x02); |
| 359 | } | 147 | } |
| 360 | send_command(SETCONTRAST); // 0x81 | 148 | send_command(SETCONTRAST); // 0x81 |
| 361 | send_command(0x8F); | 149 | send_command(0x8F); |
| 362 | 150 | ||
| 363 | send_command(SETPRECHARGE); // 0xd9 | 151 | send_command(SETPRECHARGE); // 0xd9 |
| 364 | send_command(0xF1); | 152 | send_command(0xF1); |
| 365 | 153 | ||
| 366 | send_command(SETVCOMDESELECT); // 0xDB | 154 | send_command(SETVCOMDESELECT); // 0xDB |
| 367 | send_command(0x40); | 155 | send_command(0x40); |
| 368 | 156 | ||
| 369 | send_command(DISPLAYON); //--turn on oled panel | 157 | send_command(DISPLAYON); //--turn on oled panel |
| 370 | clear_screen(); // Erase hardware memory inside the OLED controller to avoid random data in memory. | 158 | clear_screen(); // Erase hardware memory inside the OLED controller to avoid random data in memory. |
| 371 | send_buffer(); | 159 | send_buffer(); |
| 372 | } | 160 | } |
| 373 | 161 | ||
| 374 | void send_command(uint8_t command) { | 162 | void send_command(uint8_t command) { |
| 375 | micro_oled_transfer_buffer[0] = I2C_COMMAND; | 163 | micro_oled_transfer_buffer[0] = I2C_COMMAND; |
| 376 | micro_oled_transfer_buffer[1] = command; | 164 | micro_oled_transfer_buffer[1] = command; |
| 377 | i2c_transmit(I2C_ADDRESS_SA0_1 << 1, micro_oled_transfer_buffer, 2, 100); | 165 | i2c_transmit(I2C_ADDRESS_SA0_1 << 1, micro_oled_transfer_buffer, 2, 100); |
| 378 | } | 166 | } |
| 379 | 167 | ||
| 380 | void send_data(uint8_t data) { | 168 | void send_data(uint8_t data) { |
| 381 | micro_oled_transfer_buffer[0] = I2C_DATA; | 169 | micro_oled_transfer_buffer[0] = I2C_DATA; |
| 382 | micro_oled_transfer_buffer[1] = data; | 170 | micro_oled_transfer_buffer[1] = data; |
| 383 | i2c_transmit(I2C_ADDRESS_SA0_1 << 1, micro_oled_transfer_buffer, 2, 100); | 171 | i2c_transmit(I2C_ADDRESS_SA0_1 << 1, micro_oled_transfer_buffer, 2, 100); |
| 384 | } | 172 | } |
| 385 | 173 | ||
| 386 | /** \brief Set SSD1306 page address. | 174 | /** \brief Set SSD1306 page address. |
| 387 | Send page address command and address to the SSD1306 OLED controller. | 175 | Send page address command and address to the SSD1306 OLED controller. |
| 388 | */ | 176 | */ |
| 389 | void set_page_address(uint8_t address) { | 177 | void set_page_address(uint8_t address) { |
| 390 | address = (0xB0 | address); | 178 | address = (0xB0 | address); |
| 391 | send_command(address); | 179 | send_command(address); |
| 392 | } | 180 | } |
| 393 | 181 | ||
| 394 | /** \brief Set SSD1306 column address. | 182 | /** \brief Set SSD1306 column address. |
| 395 | Send column address command and address to the SSD1306 OLED controller. | 183 | Send column address command and address to the SSD1306 OLED controller. |
| 396 | */ | 184 | */ |
| 397 | void set_column_address(uint8_t address) { | 185 | void set_column_address(uint8_t address) { |
| 398 | send_command( ( 0x10 | (address >> 4) ) + ((128 - LCDWIDTH) >> 8) ); | 186 | send_command((0x10 | (address >> 4)) + ((128 - LCDWIDTH) >> 8)); |
| 399 | send_command( 0x0F & address ); | 187 | send_command(0x0F & address); |
| 400 | } | 188 | } |
| 401 | 189 | ||
| 402 | /** \brief Clear SSD1306's memory. | 190 | /** \brief Clear SSD1306's memory. |
| 403 | To clear GDRAM inside the LCD controller. | 191 | To clear GDRAM inside the LCD controller. |
| 404 | */ | 192 | */ |
| 405 | void clear_screen(void) { | 193 | void clear_screen(void) { |
| 406 | for (int i=0;i<8; i++) { | 194 | for (int i = 0; i < 8; i++) { |
| 407 | set_page_address(i); | 195 | set_page_address(i); |
| 408 | set_column_address(0); | 196 | set_column_address(0); |
| 409 | for (int j=0; j<0x80; j++) { | 197 | for (int j = 0; j < 0x80; j++) { |
| 410 | send_data(0); | 198 | send_data(0); |
| 199 | } | ||
| 411 | } | 200 | } |
| 412 | } | ||
| 413 | } | 201 | } |
| 414 | 202 | ||
| 415 | /** \brief Clear SSD1306's memory. | 203 | /** \brief Clear SSD1306's memory. |
| 416 | To clear GDRAM inside the LCD controller. | 204 | To clear GDRAM inside the LCD controller. |
| 417 | */ | 205 | */ |
| 418 | void clear_buffer(void) { | 206 | void clear_buffer(void) { |
| 419 | //384 | 207 | // 384 |
| 420 | memset(micro_oled_screen_buffer, 0, LCDWIDTH*LCDWIDTH/8); | 208 | memset(micro_oled_screen_buffer, 0, LCDWIDTH * LCDWIDTH / 8); |
| 421 | } | 209 | } |
| 422 | 210 | ||
| 423 | /** \brief Invert display. | 211 | /** \brief Invert display. |
| 424 | The PIXEL_ON color of the display will turn to PIXEL_OFF and the PIXEL_OFF will turn to PIXEL_ON. | 212 | The PIXEL_ON color of the display will turn to PIXEL_OFF and the PIXEL_OFF will turn to PIXEL_ON. |
| 425 | */ | 213 | */ |
| 426 | void invert_screen(bool invert) { | 214 | void invert_screen(bool invert) { |
| 427 | if (invert) { | 215 | if (invert) { |
| 428 | send_command(INVERTDISPLAY); | 216 | send_command(INVERTDISPLAY); |
| 429 | } else { | 217 | } else { |
| 430 | send_command(NORMALDISPLAY); | 218 | send_command(NORMALDISPLAY); |
| 431 | } | 219 | } |
| 432 | } | 220 | } |
| 433 | 221 | ||
| 434 | /** \brief Set contrast. | 222 | /** \brief Set contrast. |
| 435 | OLED contract value from 0 to 255. Note: Contrast level is not very obvious. | 223 | OLED contract value from 0 to 255. Note: Contrast level is not very obvious. |
| 436 | */ | 224 | */ |
| 437 | void set_contrast(uint8_t contrast) { | 225 | void set_contrast(uint8_t contrast) { |
| 438 | send_command(SETCONTRAST); // 0x81 | 226 | send_command(SETCONTRAST); // 0x81 |
| 439 | send_command(contrast); | 227 | send_command(contrast); |
| 440 | } | 228 | } |
| 441 | 229 | ||
| 442 | /** \brief Transfer display buffer. | 230 | /** \brief Transfer display buffer. |
| 443 | Sends the updated buffer to the controller - the current status is checked before to save i2c exectution time | 231 | Sends the updated buffer to the controller - the current status is checked before to save i2c exectution time |
| 444 | */ | 232 | */ |
| 445 | void send_buffer(void) { | 233 | void send_buffer(void) { |
| 446 | uint8_t i, j; | 234 | uint8_t i, j; |
| 447 | 235 | ||
| 448 | uint8_t page_addr = 0xFF; | 236 | uint8_t page_addr = 0xFF; |
| 449 | for (i = 0; i < LCDHEIGHT/8; i++) { | 237 | for (i = 0; i < LCDHEIGHT / 8; i++) { |
| 450 | uint8_t col_addr = 0xFF; | 238 | uint8_t col_addr = 0xFF; |
| 451 | for (j = 0; j < LCDWIDTH; j++) { | 239 | for (j = 0; j < LCDWIDTH; j++) { |
| 452 | if (micro_oled_screen_buffer[i*LCDWIDTH+j] != micro_oled_screen_current[i*LCDWIDTH+j]) { | 240 | if (micro_oled_screen_buffer[i * LCDWIDTH + j] != micro_oled_screen_current[i * LCDWIDTH + j]) { |
| 453 | if (page_addr != i) { | 241 | if (page_addr != i) { |
| 454 | set_page_address(i); | 242 | set_page_address(i); |
| 243 | } | ||
| 244 | if (col_addr != j) { | ||
| 245 | set_column_address(j); | ||
| 246 | } | ||
| 247 | send_data(micro_oled_screen_buffer[i * LCDWIDTH + j]); | ||
| 248 | micro_oled_screen_current[i * LCDWIDTH + j] = micro_oled_screen_buffer[i * LCDWIDTH + j]; | ||
| 249 | col_addr = j + 1; | ||
| 250 | } | ||
| 455 | } | 251 | } |
| 456 | if (col_addr != j) { | ||
| 457 | set_column_address(j); | ||
| 458 | } | ||
| 459 | send_data(micro_oled_screen_buffer[i*LCDWIDTH+j]); | ||
| 460 | micro_oled_screen_current[i*LCDWIDTH+j] = micro_oled_screen_buffer[i*LCDWIDTH+j]; | ||
| 461 | col_addr = j + 1; | ||
| 462 | } | ||
| 463 | } | 252 | } |
| 464 | } | ||
| 465 | } | 253 | } |
| 466 | 254 | ||
| 467 | /** \brief Draw pixel with color and mode. | 255 | /** \brief Draw pixel with color and mode. |
| 468 | Draw color pixel in the screen buffer's x,y position with NORM or XOR draw mode. | 256 | Draw color pixel in the screen buffer's x,y position with NORM or XOR draw mode. |
| 469 | */ | 257 | */ |
| 470 | void draw_pixel(uint8_t x, uint8_t y, uint8_t color, uint8_t mode) { | 258 | void draw_pixel(uint8_t x, uint8_t y, uint8_t color, uint8_t mode) { |
| 471 | if ((x<0) || (x>=LCDWIDTH) || (y<0) || (y>=LCDHEIGHT)) | 259 | if ((x < 0) || (x >= LCDWIDTH) || (y < 0) || (y >= LCDHEIGHT)) return; |
| 472 | return; | 260 | |
| 473 | 261 | if (mode == XOR) { | |
| 474 | if (mode == XOR) { | 262 | if (color == PIXEL_ON) micro_oled_screen_buffer[x + (y / 8) * LCDWIDTH] ^= _BV((y % 8)); |
| 475 | if (color == PIXEL_ON) | 263 | } else { |
| 476 | micro_oled_screen_buffer[x + (y/8)*LCDWIDTH] ^= _BV((y%8)); | 264 | if (color == PIXEL_ON) |
| 477 | } else { | 265 | micro_oled_screen_buffer[x + (y / 8) * LCDWIDTH] |= _BV((y % 8)); |
| 478 | if (color == PIXEL_ON) | 266 | else |
| 479 | micro_oled_screen_buffer[x + (y/8)*LCDWIDTH] |= _BV((y%8)); | 267 | micro_oled_screen_buffer[x + (y / 8) * LCDWIDTH] &= ~_BV((y % 8)); |
| 480 | else | 268 | } |
| 481 | micro_oled_screen_buffer[x + (y/8)*LCDWIDTH] &= ~_BV((y%8)); | ||
| 482 | } | ||
| 483 | } | 269 | } |
| 484 | 270 | ||
| 485 | /** \brief Draw line with color and mode. | 271 | /** \brief Draw line with color and mode. |
| 486 | Draw line using color and mode from x0,y0 to x1,y1 of the screen buffer. | 272 | Draw line using color and mode from x0,y0 to x1,y1 of the screen buffer. |
| 487 | */ | 273 | */ |
| 488 | void draw_line(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t color, uint8_t mode) { | 274 | void draw_line(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t color, uint8_t mode) { |
| 489 | uint8_t steep = abs(y1 - y0) > abs(x1 - x0); | 275 | uint8_t steep = abs(y1 - y0) > abs(x1 - x0); |
| 490 | if (steep) { | ||
| 491 | swap(x0, y0); | ||
| 492 | swap(x1, y1); | ||
| 493 | } | ||
| 494 | |||
| 495 | if (x0 > x1) { | ||
| 496 | swap(x0, x1); | ||
| 497 | swap(y0, y1); | ||
| 498 | } | ||
| 499 | |||
| 500 | uint8_t dx, dy; | ||
| 501 | dx = x1 - x0; | ||
| 502 | dy = abs(y1 - y0); | ||
| 503 | |||
| 504 | int8_t err = dx / 2; | ||
| 505 | int8_t ystep; | ||
| 506 | |||
| 507 | if (y0 < y1) { | ||
| 508 | ystep = 1; | ||
| 509 | } else { | ||
| 510 | ystep = -1;} | ||
| 511 | |||
| 512 | for (; x0<x1; x0++) { | ||
| 513 | if (steep) { | 276 | if (steep) { |
| 514 | draw_pixel(y0, x0, color, mode); | 277 | swap(x0, y0); |
| 278 | swap(x1, y1); | ||
| 279 | } | ||
| 280 | |||
| 281 | if (x0 > x1) { | ||
| 282 | swap(x0, x1); | ||
| 283 | swap(y0, y1); | ||
| 284 | } | ||
| 285 | |||
| 286 | uint8_t dx, dy; | ||
| 287 | dx = x1 - x0; | ||
| 288 | dy = abs(y1 - y0); | ||
| 289 | |||
| 290 | int8_t err = dx / 2; | ||
| 291 | int8_t ystep; | ||
| 292 | |||
| 293 | if (y0 < y1) { | ||
| 294 | ystep = 1; | ||
| 515 | } else { | 295 | } else { |
| 516 | draw_pixel(x0, y0, color, mode); | 296 | ystep = -1; |
| 517 | } | 297 | } |
| 518 | err -= dy; | 298 | |
| 519 | if (err < 0) { | 299 | for (; x0 < x1; x0++) { |
| 520 | y0 += ystep; | 300 | if (steep) { |
| 521 | err += dx; | 301 | draw_pixel(y0, x0, color, mode); |
| 302 | } else { | ||
| 303 | draw_pixel(x0, y0, color, mode); | ||
| 304 | } | ||
| 305 | err -= dy; | ||
| 306 | if (err < 0) { | ||
| 307 | y0 += ystep; | ||
| 308 | err += dx; | ||
| 309 | } | ||
| 522 | } | 310 | } |
| 523 | } | ||
| 524 | } | 311 | } |
| 525 | 312 | ||
| 526 | /** \brief Draw horizontal line with color and mode. | 313 | /** \brief Draw horizontal line with color and mode. |
| 527 | Draw horizontal line using color and mode from x,y to x+width,y of the screen buffer. | 314 | Draw horizontal line using color and mode from x,y to x+width,y of the screen buffer. |
| 528 | */ | 315 | */ |
| 529 | void draw_line_hori(uint8_t x, uint8_t y, uint8_t width, uint8_t color, uint8_t mode) { | 316 | void draw_line_hori(uint8_t x, uint8_t y, uint8_t width, uint8_t color, uint8_t mode) { draw_line(x, y, x + width, y, color, mode); } |
| 530 | draw_line(x,y,x+width,y,color,mode); | ||
| 531 | } | ||
| 532 | 317 | ||
| 533 | /** \brief Draw vertical line. | 318 | /** \brief Draw vertical line. |
| 534 | Draw vertical line using current fore color and current draw mode from x,y to x,y+height of the screen buffer. | 319 | Draw vertical line using current fore color and current draw mode from x,y to x,y+height of the screen buffer. |
| 535 | */ | 320 | */ |
| 536 | void draw_line_vert(uint8_t x, uint8_t y, uint8_t height, bool color, uint8_t mode) { | 321 | void draw_line_vert(uint8_t x, uint8_t y, uint8_t height, bool color, uint8_t mode) { draw_line(x, y, x, y + height, color, mode); } |
| 537 | draw_line(x,y,x,y+height,color,mode); | ||
| 538 | } | ||
| 539 | 322 | ||
| 540 | /** \brief Draw rectangle with color and mode. | 323 | /** \brief Draw rectangle with color and mode. |
| 541 | Draw rectangle using color and mode from x,y to x+width,y+height of the screen buffer. | 324 | Draw rectangle using color and mode from x,y to x+width,y+height of the screen buffer. |
| 542 | */ | 325 | */ |
| 543 | void draw_rect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode) { | 326 | void draw_rect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode) { |
| 544 | uint8_t tempHeight; | 327 | uint8_t tempHeight; |
| 545 | 328 | ||
| 546 | draw_line_hori(x,y, width, color, mode); | 329 | draw_line_hori(x, y, width, color, mode); |
| 547 | draw_line_hori(x,y+height-1, width, color, mode); | 330 | draw_line_hori(x, y + height - 1, width, color, mode); |
| 548 | 331 | ||
| 549 | tempHeight=height-2; | 332 | tempHeight = height - 2; |
| 550 | 333 | ||
| 551 | // skip drawing vertical lines to avoid overlapping of pixel that will | 334 | // skip drawing vertical lines to avoid overlapping of pixel that will |
| 552 | // affect XOR plot if no pixel in between horizontal lines | 335 | // affect XOR plot if no pixel in between horizontal lines |
| 553 | if (tempHeight<1) return; | 336 | if (tempHeight < 1) return; |
| 554 | 337 | ||
| 555 | draw_line_vert(x,y+1, tempHeight, color, mode); | 338 | draw_line_vert(x, y + 1, tempHeight, color, mode); |
| 556 | draw_line_vert(x+width-1, y+1, tempHeight, color, mode); | 339 | draw_line_vert(x + width - 1, y + 1, tempHeight, color, mode); |
| 557 | } | 340 | } |
| 558 | 341 | ||
| 559 | /** \brief Draw rectangle with color and mode. | 342 | /** \brief Draw rectangle with color and mode. |
| 560 | Draw rectangle using color and mode from x,y to x+width,y+height of the screen buffer. | 343 | Draw rectangle using color and mode from x,y to x+width,y+height of the screen buffer. |
| 561 | */ | 344 | */ |
| 562 | void draw_rect_soft(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode) { | 345 | void draw_rect_soft(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode) { |
| 563 | uint8_t tempHeight; | 346 | uint8_t tempHeight; |
| 564 | 347 | ||
| 565 | draw_line_hori(x+1,y, width-2, color, mode); | 348 | draw_line_hori(x + 1, y, width - 2, color, mode); |
| 566 | draw_line_hori(x+1,y+height-1, width-2, color, mode); | 349 | draw_line_hori(x + 1, y + height - 1, width - 2, color, mode); |
| 567 | 350 | ||
| 568 | tempHeight=height-2; | 351 | tempHeight = height - 2; |
| 569 | 352 | ||
| 570 | // skip drawing vertical lines to avoid overlapping of pixel that will | 353 | // skip drawing vertical lines to avoid overlapping of pixel that will |
| 571 | // affect XOR plot if no pixel in between horizontal lines | 354 | // affect XOR plot if no pixel in between horizontal lines |
| 572 | if (tempHeight<1) return; | 355 | if (tempHeight < 1) return; |
| 573 | 356 | ||
| 574 | draw_line_vert(x,y+1, tempHeight, color, mode); | 357 | draw_line_vert(x, y + 1, tempHeight, color, mode); |
| 575 | draw_line_vert(x+width-1, y+1, tempHeight, color, mode); | 358 | draw_line_vert(x + width - 1, y + 1, tempHeight, color, mode); |
| 576 | } | 359 | } |
| 577 | 360 | ||
| 578 | /** \brief Draw filled rectangle with color and mode. | 361 | /** \brief Draw filled rectangle with color and mode. |
| 579 | Draw filled rectangle using color and mode from x,y to x+width,y+height of the screen buffer. | 362 | Draw filled rectangle using color and mode from x,y to x+width,y+height of the screen buffer. |
| 580 | */ | 363 | */ |
| 581 | void draw_rect_filled(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode) { | 364 | void draw_rect_filled(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode) { |
| 582 | // TODO - need to optimise the memory map draw so that this function will not call pixel one by one | 365 | // TODO - need to optimise the memory map draw so that this function will not call pixel one by one |
| 583 | for (int i=x; i<x+width;i++) { | 366 | for (int i = x; i < x + width; i++) { |
| 584 | draw_line_vert(i,y, height, color, mode); | 367 | draw_line_vert(i, y, height, color, mode); |
| 585 | } | 368 | } |
| 586 | } | 369 | } |
| 587 | 370 | ||
| 588 | /** \brief Draw filled rectangle with color and mode. | 371 | /** \brief Draw filled rectangle with color and mode. |
| 589 | Draw filled rectangle using color and mode from x,y to x+width,y+height of the screen buffer. | 372 | Draw filled rectangle using color and mode from x,y to x+width,y+height of the screen buffer. |
| 590 | */ | 373 | */ |
| 591 | void draw_rect_filled_soft(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode) { | 374 | void draw_rect_filled_soft(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode) { |
| 592 | // TODO - need to optimise the memory map draw so that this function will not call pixel one by one | 375 | // TODO - need to optimise the memory map draw so that this function will not call pixel one by one |
| 593 | for (int i=x; i<x+width;i++) { | 376 | for (int i = x; i < x + width; i++) { |
| 594 | if (i == x || i == (x + width - 1)) | 377 | if (i == x || i == (x + width - 1)) |
| 595 | draw_line_vert(i, y+1, height-2, color, mode); | 378 | draw_line_vert(i, y + 1, height - 2, color, mode); |
| 596 | else | 379 | else |
| 597 | draw_line_vert(i, y, height, color, mode); | 380 | draw_line_vert(i, y, height, color, mode); |
| 598 | } | 381 | } |
| 599 | } | 382 | } |
| 600 | 383 | ||
| 601 | /** \brief Draw character with color and mode. | 384 | /** \brief Draw character with color and mode. |
| 602 | Draw character c using color and draw mode at x,y. | 385 | Draw character c using color and draw mode at x,y. |
| 603 | */ | 386 | */ |
| 604 | void draw_char(uint8_t x, uint8_t y, uint8_t c, uint8_t color, uint8_t mode, uint8_t font) { | 387 | void draw_char(uint8_t x, uint8_t y, uint8_t c, uint8_t color, uint8_t mode, uint8_t font) { |
| 605 | // TODO - New routine to take font of any height, at the moment limited to font height in multiple of 8 pixels | 388 | // TODO - New routine to take font of any height, at the moment limited to font height in multiple of 8 pixels |
| 606 | 389 | ||
| 607 | uint8_t rowsToDraw,row, tempC; | 390 | uint8_t rowsToDraw, row, tempC; |
| 608 | uint8_t i,j,temp; | 391 | uint8_t i, j, temp; |
| 609 | uint16_t charPerBitmapRow,charColPositionOnBitmap,charRowPositionOnBitmap,charBitmapStartPosition; | 392 | uint16_t charPerBitmapRow, charColPositionOnBitmap, charRowPositionOnBitmap, charBitmapStartPosition; |
| 610 | 393 | ||
| 611 | if ((font>=TOTALFONTS) || (font<0)) | 394 | if ((font >= TOTALFONTS) || (font < 0)) return; |
| 612 | return; | 395 | |
| 613 | 396 | uint8_t fontType = font; | |
| 614 | uint8_t fontType = font; | 397 | uint8_t fontWidth = pgm_read_byte(fonts_pointer[fontType] + 0); |
| 615 | uint8_t fontWidth = pgm_read_byte(fonts_pointer[fontType]+0); | 398 | uint8_t fontHeight = pgm_read_byte(fonts_pointer[fontType] + 1); |
| 616 | uint8_t fontHeight = pgm_read_byte(fonts_pointer[fontType]+1); | 399 | uint8_t fontStartChar = pgm_read_byte(fonts_pointer[fontType] + 2); |
| 617 | uint8_t fontStartChar = pgm_read_byte(fonts_pointer[fontType]+2); | 400 | uint8_t fontTotalChar = pgm_read_byte(fonts_pointer[fontType] + 3); |
| 618 | uint8_t fontTotalChar = pgm_read_byte(fonts_pointer[fontType]+3); | 401 | uint16_t fontMapWidth = (pgm_read_byte(fonts_pointer[fontType] + 4) * 100) + pgm_read_byte(fonts_pointer[fontType] + 5); // two bytes values into integer 16 |
| 619 | uint16_t fontMapWidth = (pgm_read_byte(fonts_pointer[fontType]+4)*100)+pgm_read_byte(fonts_pointer[fontType]+5); // two bytes values into integer 16 | 402 | |
| 620 | 403 | if ((c < fontStartChar) || (c > (fontStartChar + fontTotalChar - 1))) // no bitmap for the required c | |
| 621 | if ((c<fontStartChar) || (c>(fontStartChar+fontTotalChar-1))) // no bitmap for the required c | 404 | return; |
| 622 | return; | 405 | |
| 623 | 406 | tempC = c - fontStartChar; | |
| 624 | tempC=c-fontStartChar; | 407 | |
| 625 | 408 | // each row (in datasheet is call page) is 8 bits high, 16 bit high character will have 2 rows to be drawn | |
| 626 | // each row (in datasheet is call page) is 8 bits high, 16 bit high character will have 2 rows to be drawn | 409 | rowsToDraw = fontHeight / 8; // 8 is LCD's page size, see SSD1306 datasheet |
| 627 | rowsToDraw=fontHeight/8; // 8 is LCD's page size, see SSD1306 datasheet | 410 | if (rowsToDraw <= 1) rowsToDraw = 1; |
| 628 | if (rowsToDraw<=1) rowsToDraw=1; | 411 | |
| 629 | 412 | // the following draw function can draw anywhere on the screen, but SLOW pixel by pixel draw | |
| 630 | // the following draw function can draw anywhere on the screen, but SLOW pixel by pixel draw | 413 | if (rowsToDraw == 1) { |
| 631 | if (rowsToDraw==1) { | 414 | for (i = 0; i < fontWidth + 1; i++) { |
| 632 | for (i=0;i<fontWidth+1;i++) { | 415 | if (i == fontWidth) // this is done in a weird way because for 5x7 font, there is no margin, this code add a margin after col 5 |
| 633 | if (i==fontWidth) // this is done in a weird way because for 5x7 font, there is no margin, this code add a margin after col 5 | 416 | temp = 0; |
| 634 | temp=0; | 417 | else |
| 635 | else | 418 | temp = pgm_read_byte(fonts_pointer[fontType] + FONTHEADERSIZE + (tempC * fontWidth) + i); |
| 636 | temp=pgm_read_byte(fonts_pointer[fontType]+FONTHEADERSIZE+(tempC*fontWidth)+i); | 419 | |
| 637 | 420 | for (j = 0; j < 8; j++) { // 8 is the LCD's page height (see datasheet for explanation) | |
| 638 | for (j=0;j<8;j++) { // 8 is the LCD's page height (see datasheet for explanation) | 421 | if (temp & 0x1) { |
| 639 | if (temp & 0x1) { | 422 | draw_pixel(x + i, y + j, color, mode); |
| 640 | draw_pixel(x+i, y+j, color,mode); | 423 | } else { |
| 424 | draw_pixel(x + i, y + j, !color, mode); | ||
| 425 | } | ||
| 426 | |||
| 427 | temp >>= 1; | ||
| 428 | } | ||
| 641 | } | 429 | } |
| 642 | else { | 430 | return; |
| 643 | draw_pixel(x+i, y+j, !color,mode); | ||
| 644 | } | ||
| 645 | |||
| 646 | temp >>=1; | ||
| 647 | } | ||
| 648 | } | 431 | } |
| 649 | return; | 432 | |
| 650 | } | 433 | // font height over 8 bit |
| 651 | 434 | // take character "0" ASCII 48 as example | |
| 652 | // font height over 8 bit | 435 | charPerBitmapRow = fontMapWidth / fontWidth; // 256/8 =32 char per row |
| 653 | // take character "0" ASCII 48 as example | 436 | charColPositionOnBitmap = tempC % charPerBitmapRow; // =16 |
| 654 | charPerBitmapRow = fontMapWidth/fontWidth; // 256/8 =32 char per row | 437 | charRowPositionOnBitmap = (int)(tempC / charPerBitmapRow); // =1 |
| 655 | charColPositionOnBitmap = tempC % charPerBitmapRow; // =16 | 438 | charBitmapStartPosition = (charRowPositionOnBitmap * fontMapWidth * (fontHeight / 8)) + (charColPositionOnBitmap * fontWidth); |
| 656 | charRowPositionOnBitmap = (int)(tempC/charPerBitmapRow); // =1 | 439 | |
| 657 | charBitmapStartPosition = (charRowPositionOnBitmap * fontMapWidth * (fontHeight/8)) + (charColPositionOnBitmap * fontWidth) ; | 440 | // each row on LCD is 8 bit height (see datasheet for explanation) |
| 658 | 441 | for (row = 0; row < rowsToDraw; row++) { | |
| 659 | // each row on LCD is 8 bit height (see datasheet for explanation) | 442 | for (i = 0; i < fontWidth; i++) { |
| 660 | for(row=0;row<rowsToDraw;row++) { | 443 | temp = pgm_read_byte(fonts_pointer[fontType] + FONTHEADERSIZE + (charBitmapStartPosition + i + (row * fontMapWidth))); |
| 661 | for (i=0; i<fontWidth;i++) { | 444 | for (j = 0; j < 8; j++) { // 8 is the LCD's page height (see datasheet for explanation) |
| 662 | temp=pgm_read_byte(fonts_pointer[fontType]+FONTHEADERSIZE+(charBitmapStartPosition+i+(row*fontMapWidth))); | 445 | if (temp & 0x1) { |
| 663 | for (j=0;j<8;j++) { // 8 is the LCD's page height (see datasheet for explanation) | 446 | draw_pixel(x + i, y + j + (row * 8), color, mode); |
| 664 | if (temp & 0x1) { | 447 | } else { |
| 665 | draw_pixel(x+i,y+j+(row*8), color, mode); | 448 | draw_pixel(x + i, y + j + (row * 8), !color, mode); |
| 666 | } | 449 | } |
| 667 | else { | 450 | temp >>= 1; |
| 668 | draw_pixel(x+i,y+j+(row*8), !color, mode); | 451 | } |
| 669 | } | 452 | } |
| 670 | temp >>=1; | ||
| 671 | } | ||
| 672 | } | 453 | } |
| 673 | } | ||
| 674 | |||
| 675 | } | 454 | } |
| 676 | 455 | ||
| 677 | void draw_string(uint8_t x, uint8_t y, char * string, uint8_t color, uint8_t mode, uint8_t font) { | 456 | void draw_string(uint8_t x, uint8_t y, char* string, uint8_t color, uint8_t mode, uint8_t font) { |
| 678 | 457 | if ((font >= TOTALFONTS) || (font < 0)) return; | |
| 679 | if ((font>=TOTALFONTS) || (font<0)) | ||
| 680 | return; | ||
| 681 | 458 | ||
| 682 | uint8_t fontType = font; | 459 | uint8_t fontType = font; |
| 683 | uint8_t fontWidth = pgm_read_byte(fonts_pointer[fontType]+0); | 460 | uint8_t fontWidth = pgm_read_byte(fonts_pointer[fontType] + 0); |
| 684 | |||
| 685 | uint8_t cur_x = x; | ||
| 686 | for (int i = 0; i < strlen(string); i++) { | ||
| 687 | draw_char(cur_x, y, string[i], color, mode, font); | ||
| 688 | cur_x += fontWidth + 1; | ||
| 689 | } | ||
| 690 | 461 | ||
| 462 | uint8_t cur_x = x; | ||
| 463 | for (int i = 0; i < strlen(string); i++) { | ||
| 464 | draw_char(cur_x, y, string[i], color, mode, font); | ||
| 465 | cur_x += fontWidth + 1; | ||
| 466 | } | ||
| 691 | } | 467 | } |
diff --git a/drivers/qwiic/micro_oled.h b/drivers/qwiic/micro_oled.h index 5d6a1029e..814143df1 100644 --- a/drivers/qwiic/micro_oled.h +++ b/drivers/qwiic/micro_oled.h | |||
| @@ -49,86 +49,86 @@ void draw_rect_soft(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t | |||
| 49 | void draw_rect_filled(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode); | 49 | void draw_rect_filled(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode); |
| 50 | void draw_rect_filled_soft(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode); | 50 | void draw_rect_filled_soft(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode); |
| 51 | void draw_char(uint8_t x, uint8_t y, uint8_t c, uint8_t color, uint8_t mode, uint8_t font); | 51 | void draw_char(uint8_t x, uint8_t y, uint8_t c, uint8_t color, uint8_t mode, uint8_t font); |
| 52 | void draw_string(uint8_t x, uint8_t y, char * string, uint8_t color, uint8_t mode, uint8_t font); | 52 | void draw_string(uint8_t x, uint8_t y, char* string, uint8_t color, uint8_t mode, uint8_t font); |
| 53 | 53 | ||
| 54 | #define I2C_ADDRESS_SA0_0 0b0111100 | 54 | #define I2C_ADDRESS_SA0_0 0b0111100 |
| 55 | #ifndef I2C_ADDRESS_SA0_1 | 55 | #ifndef I2C_ADDRESS_SA0_1 |
| 56 | #define I2C_ADDRESS_SA0_1 0b0111101 | 56 | # define I2C_ADDRESS_SA0_1 0b0111101 |
| 57 | #endif | 57 | #endif |
| 58 | #define I2C_COMMAND 0x00 | 58 | #define I2C_COMMAND 0x00 |
| 59 | #define I2C_DATA 0x40 | 59 | #define I2C_DATA 0x40 |
| 60 | #define PIXEL_OFF 0 | 60 | #define PIXEL_OFF 0 |
| 61 | #define PIXEL_ON 1 | 61 | #define PIXEL_ON 1 |
| 62 | 62 | ||
| 63 | #ifndef LCDWIDTH | 63 | #ifndef LCDWIDTH |
| 64 | #define LCDWIDTH 64 | 64 | # define LCDWIDTH 64 |
| 65 | #endif | 65 | #endif |
| 66 | #ifndef LCDWIDTH | 66 | #ifndef LCDWIDTH |
| 67 | #define LCDHEIGHT 48 | 67 | # define LCDHEIGHT 48 |
| 68 | #endif | 68 | #endif |
| 69 | #define FONTHEADERSIZE 6 | 69 | #define FONTHEADERSIZE 6 |
| 70 | 70 | ||
| 71 | #define NORM 0 | 71 | #define NORM 0 |
| 72 | #define XOR 1 | 72 | #define XOR 1 |
| 73 | 73 | ||
| 74 | #define PAGE 0 | 74 | #define PAGE 0 |
| 75 | #define ALL 1 | 75 | #define ALL 1 |
| 76 | 76 | ||
| 77 | #define WIDGETSTYLE0 0 | 77 | #define WIDGETSTYLE0 0 |
| 78 | #define WIDGETSTYLE1 1 | 78 | #define WIDGETSTYLE1 1 |
| 79 | #define WIDGETSTYLE2 2 | 79 | #define WIDGETSTYLE2 2 |
| 80 | 80 | ||
| 81 | #define SETCONTRAST 0x81 | 81 | #define SETCONTRAST 0x81 |
| 82 | #define DISPLAYALLONRESUME 0xA4 | 82 | #define DISPLAYALLONRESUME 0xA4 |
| 83 | #define DISPLAYALLON 0xA5 | 83 | #define DISPLAYALLON 0xA5 |
| 84 | #define NORMALDISPLAY 0xA6 | 84 | #define NORMALDISPLAY 0xA6 |
| 85 | #define INVERTDISPLAY 0xA7 | 85 | #define INVERTDISPLAY 0xA7 |
| 86 | #define DISPLAYOFF 0xAE | 86 | #define DISPLAYOFF 0xAE |
| 87 | #define DISPLAYON 0xAF | 87 | #define DISPLAYON 0xAF |
| 88 | #define SETDISPLAYOFFSET 0xD3 | 88 | #define SETDISPLAYOFFSET 0xD3 |
| 89 | #define SETCOMPINS 0xDA | 89 | #define SETCOMPINS 0xDA |
| 90 | #define SETVCOMDESELECT 0xDB | 90 | #define SETVCOMDESELECT 0xDB |
| 91 | #define SETDISPLAYCLOCKDIV 0xD5 | 91 | #define SETDISPLAYCLOCKDIV 0xD5 |
| 92 | #define SETPRECHARGE 0xD9 | 92 | #define SETPRECHARGE 0xD9 |
| 93 | #define SETMULTIPLEX 0xA8 | 93 | #define SETMULTIPLEX 0xA8 |
| 94 | #define SETLOWCOLUMN 0x00 | 94 | #define SETLOWCOLUMN 0x00 |
| 95 | #define SETHIGHCOLUMN 0x10 | 95 | #define SETHIGHCOLUMN 0x10 |
| 96 | #define SETSTARTLINE 0x40 | 96 | #define SETSTARTLINE 0x40 |
| 97 | #define MEMORYMODE 0x20 | 97 | #define MEMORYMODE 0x20 |
| 98 | #define COMSCANINC 0xC0 | 98 | #define COMSCANINC 0xC0 |
| 99 | #define COMSCANDEC 0xC8 | 99 | #define COMSCANDEC 0xC8 |
| 100 | #define SEGREMAP 0xA0 | 100 | #define SEGREMAP 0xA0 |
| 101 | #define CHARGEPUMP 0x8D | 101 | #define CHARGEPUMP 0x8D |
| 102 | #define EXTERNALVCC 0x01 | 102 | #define EXTERNALVCC 0x01 |
| 103 | #define SWITCHCAPVCC 0x02 | 103 | #define SWITCHCAPVCC 0x02 |
| 104 | 104 | ||
| 105 | // Scroll | 105 | // Scroll |
| 106 | #define ACTIVATESCROLL 0x2F | 106 | #define ACTIVATESCROLL 0x2F |
| 107 | #define DEACTIVATESCROLL 0x2E | 107 | #define DEACTIVATESCROLL 0x2E |
| 108 | #define SETVERTICALSCROLLAREA 0xA3 | 108 | #define SETVERTICALSCROLLAREA 0xA3 |
| 109 | #define RIGHTHORIZONTALSCROLL 0x26 | 109 | #define RIGHTHORIZONTALSCROLL 0x26 |
| 110 | #define LEFT_HORIZONTALSCROLL 0x27 | 110 | #define LEFT_HORIZONTALSCROLL 0x27 |
| 111 | #define VERTICALRIGHTHORIZONTALSCROLL 0x29 | 111 | #define VERTICALRIGHTHORIZONTALSCROLL 0x29 |
| 112 | #define VERTICALLEFTHORIZONTALSCROLL 0x2A | 112 | #define VERTICALLEFTHORIZONTALSCROLL 0x2A |
| 113 | 113 | ||
| 114 | typedef enum CMD { | 114 | typedef enum CMD { |
| 115 | CMD_CLEAR, //0 | 115 | CMD_CLEAR, // 0 |
| 116 | CMD_INVERT, //1 | 116 | CMD_INVERT, // 1 |
| 117 | CMD_CONTRAST, //2 | 117 | CMD_CONTRAST, // 2 |
| 118 | CMD_DISPLAY, //3 | 118 | CMD_DISPLAY, // 3 |
| 119 | CMD_SETCURSOR, //4 | 119 | CMD_SETCURSOR, // 4 |
| 120 | CMD_PIXEL, //5 | 120 | CMD_PIXEL, // 5 |
| 121 | CMD_LINE, //6 | 121 | CMD_LINE, // 6 |
| 122 | CMD_LINEH, //7 | 122 | CMD_LINEH, // 7 |
| 123 | CMD_LINEV, //8 | 123 | CMD_LINEV, // 8 |
| 124 | CMD_RECT, //9 | 124 | CMD_RECT, // 9 |
| 125 | CMD_RECTFILL, //10 | 125 | CMD_RECTFILL, // 10 |
| 126 | CMD_CIRCLE, //11 | 126 | CMD_CIRCLE, // 11 |
| 127 | CMD_CIRCLEFILL, //12 | 127 | CMD_CIRCLEFILL, // 12 |
| 128 | CMD_DRAWCHAR, //13 | 128 | CMD_DRAWCHAR, // 13 |
| 129 | CMD_DRAWBITMAP, //14 | 129 | CMD_DRAWBITMAP, // 14 |
| 130 | CMD_GETLCDWIDTH, //15 | 130 | CMD_GETLCDWIDTH, // 15 |
| 131 | CMD_GETLCDHEIGHT, //16 | 131 | CMD_GETLCDHEIGHT, // 16 |
| 132 | CMD_SETCOLOR, //17 | 132 | CMD_SETCOLOR, // 17 |
| 133 | CMD_SETDRAWMODE //18 | 133 | CMD_SETDRAWMODE // 18 |
| 134 | } commCommand_t; \ No newline at end of file | 134 | } commCommand_t; \ No newline at end of file |
diff --git a/drivers/qwiic/qwiic.c b/drivers/qwiic/qwiic.c index 904791992..316d6539c 100644 --- a/drivers/qwiic/qwiic.c +++ b/drivers/qwiic/qwiic.c | |||
| @@ -16,16 +16,16 @@ | |||
| 16 | #include "qwiic.h" | 16 | #include "qwiic.h" |
| 17 | 17 | ||
| 18 | void qwiic_init(void) { | 18 | void qwiic_init(void) { |
| 19 | #ifdef QWIIC_JOYSTIIC_ENABLE | 19 | #ifdef QWIIC_JOYSTIIC_ENABLE |
| 20 | joystiic_init(); | 20 | joystiic_init(); |
| 21 | #endif | 21 | #endif |
| 22 | #ifdef QWIIC_MICRO_OLED_ENABLE | 22 | #ifdef QWIIC_MICRO_OLED_ENABLE |
| 23 | micro_oled_init(); | 23 | micro_oled_init(); |
| 24 | #endif | 24 | #endif |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | void qwiic_task(void) { | 27 | void qwiic_task(void) { |
| 28 | #ifdef QWIIC_JOYSTIIC_ENABLE | 28 | #ifdef QWIIC_JOYSTIIC_ENABLE |
| 29 | joystiic_task(); | 29 | joystiic_task(); |
| 30 | #endif | 30 | #endif |
| 31 | } | 31 | } |
diff --git a/drivers/qwiic/qwiic.h b/drivers/qwiic/qwiic.h index 160fb28df..8c3d1c8d6 100644 --- a/drivers/qwiic/qwiic.h +++ b/drivers/qwiic/qwiic.h | |||
| @@ -18,10 +18,10 @@ | |||
| 18 | #include "i2c_master.h" | 18 | #include "i2c_master.h" |
| 19 | 19 | ||
| 20 | #ifdef QWIIC_JOYSTIIC_ENABLE | 20 | #ifdef QWIIC_JOYSTIIC_ENABLE |
| 21 | #include "joystiic.h" | 21 | # include "joystiic.h" |
| 22 | #endif | 22 | #endif |
| 23 | #ifdef QWIIC_MICRO_OLED_ENABLE | 23 | #ifdef QWIIC_MICRO_OLED_ENABLE |
| 24 | #include "micro_oled.h" | 24 | # include "micro_oled.h" |
| 25 | #endif | 25 | #endif |
| 26 | 26 | ||
| 27 | void qwiic_init(void); | 27 | void qwiic_init(void); |
diff --git a/drivers/qwiic/util/font5x7.h b/drivers/qwiic/util/font5x7.h index 0bad206b7..a641945aa 100644 --- a/drivers/qwiic/util/font5x7.h +++ b/drivers/qwiic/util/font5x7.h | |||
| @@ -29,260 +29,11 @@ https://github.com/emil01/SparkFun_Micro_OLED_Arduino_Library/ | |||
| 29 | // Standard ASCII 5x7 font | 29 | // Standard ASCII 5x7 font |
| 30 | static const unsigned char font5x7[] PROGMEM = { | 30 | static const unsigned char font5x7[] PROGMEM = { |
| 31 | // first row defines - FONTWIDTH, FONTHEIGHT, ASCII START CHAR, TOTAL CHARACTERS, FONT MAP WIDTH HIGH, FONT MAP WIDTH LOW (2,56 meaning 256) | 31 | // first row defines - FONTWIDTH, FONTHEIGHT, ASCII START CHAR, TOTAL CHARACTERS, FONT MAP WIDTH HIGH, FONT MAP WIDTH LOW (2,56 meaning 256) |
| 32 | 5,8,0,255,12,75, | 32 | 5, 8, 0, 255, 12, 75, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00, 0x18, 0x3C, 0x18, 0x00, 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, 0x18, 0x24, 0x18, 0x00, 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x26, 0x29, 0x79, 0x29, 0x26, 0x40, 0x7F, 0x05, 0x05, 0x07, 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x14, 0x22, 0x7F, 0x22, 0x14, 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, 0x66, 0x89, 0x95, 0x6A, 0x60, 0x60, 0x60, 0x60, 0x60, 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x08, 0x04, 0x7E, 0x04, 0x08, 0x10, 0x20, 0x7E, 0x20, 0x10, 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x1E, 0x10, 0x10, 0x10, 0x10, 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x30, 0x38, 0x3E, 0x38, 0x30, |
| 33 | 0x00, 0x00, 0x00, 0x00, 0x00, | 33 | 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x23, 0x13, 0x08, 0x64, 0x62, 0x36, 0x49, 0x56, 0x20, 0x50, 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, 0x41, 0x22, 0x1C, 0x00, 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, 0x80, 0x70, 0x30, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x60, 0x60, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x72, 0x49, 0x49, 0x49, 0x46, 0x21, 0x41, 0x49, 0x4D, 0x33, 0x18, 0x14, 0x12, 0x7F, 0x10, 0x27, 0x45, 0x45, 0x45, 0x39, 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x41, 0x21, 0x11, 0x09, 0x07, 0x36, 0x49, 0x49, 0x49, 0x36, 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x40, 0x34, 0x00, 0x00, 0x00, 0x08, 0x14, 0x22, 0x41, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, 0x41, 0x22, 0x14, 0x08, 0x02, |
| 34 | 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, | 34 | 0x01, 0x59, 0x09, 0x06, 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x7F, 0x49, 0x49, 0x49, 0x36, 0x3E, 0x41, 0x41, 0x41, 0x22, 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x7F, 0x49, 0x49, 0x49, 0x41, 0x7F, 0x09, 0x09, 0x09, 0x01, 0x3E, 0x41, 0x41, 0x51, 0x73, 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, 0x41, 0x7F, 0x41, 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, 0x7F, 0x08, 0x14, 0x22, 0x41, 0x7F, 0x40, 0x40, 0x40, 0x40, 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x7F, 0x09, 0x09, 0x09, 0x06, 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x7F, 0x09, 0x19, 0x29, 0x46, 0x26, 0x49, 0x49, 0x49, 0x32, 0x03, 0x01, 0x7F, 0x01, 0x03, 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x63, 0x14, 0x08, 0x14, 0x63, 0x03, 0x04, 0x78, 0x04, 0x03, 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, 0x41, 0x41, 0x41, 0x7F, 0x04, 0x02, 0x01, 0x02, 0x04, 0x40, 0x40, |
| 35 | 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, | 35 | 0x40, 0x40, 0x40, 0x00, 0x03, 0x07, 0x08, 0x00, 0x20, 0x54, 0x54, 0x78, 0x40, 0x7F, 0x28, 0x44, 0x44, 0x38, 0x38, 0x44, 0x44, 0x44, 0x28, 0x38, 0x44, 0x44, 0x28, 0x7F, 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, 0x08, 0x7E, 0x09, 0x02, 0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, 0x44, 0x7D, 0x40, 0x00, 0x20, 0x40, 0x40, 0x3D, 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00, 0x7C, 0x04, 0x78, 0x04, 0x78, 0x7C, 0x08, 0x04, 0x04, 0x78, 0x38, 0x44, 0x44, 0x44, 0x38, 0xFC, 0x18, 0x24, 0x24, 0x18, 0x18, 0x24, 0x24, 0x18, 0xFC, 0x7C, 0x08, 0x04, 0x04, 0x08, 0x48, 0x54, 0x54, 0x54, 0x24, 0x04, 0x04, 0x3F, 0x44, 0x24, 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x44, 0x28, 0x10, 0x28, 0x44, 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x41, 0x36, 0x08, 0x00, 0x02, 0x01, 0x02, 0x04, 0x02, 0x3C, 0x26, 0x23, |
| 36 | 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, | 36 | 0x26, 0x3C, 0x1E, 0xA1, 0xA1, 0x61, 0x12, 0x3A, 0x40, 0x40, 0x20, 0x7A, 0x38, 0x54, 0x54, 0x55, 0x59, 0x21, 0x55, 0x55, 0x79, 0x41, 0x21, 0x54, 0x54, 0x78, 0x41, 0x21, 0x55, 0x54, 0x78, 0x40, 0x20, 0x54, 0x55, 0x79, 0x40, 0x0C, 0x1E, 0x52, 0x72, 0x12, 0x39, 0x55, 0x55, 0x55, 0x59, 0x39, 0x54, 0x54, 0x54, 0x59, 0x39, 0x55, 0x54, 0x54, 0x58, 0x00, 0x00, 0x45, 0x7C, 0x41, 0x00, 0x02, 0x45, 0x7D, 0x42, 0x00, 0x01, 0x45, 0x7C, 0x40, 0xF0, 0x29, 0x24, 0x29, 0xF0, 0xF0, 0x28, 0x25, 0x28, 0xF0, 0x7C, 0x54, 0x55, 0x45, 0x00, 0x20, 0x54, 0x54, 0x7C, 0x54, 0x7C, 0x0A, 0x09, 0x7F, 0x49, 0x32, 0x49, 0x49, 0x49, 0x32, 0x32, 0x48, 0x48, 0x48, 0x32, 0x32, 0x4A, 0x48, 0x48, 0x30, 0x3A, 0x41, 0x41, 0x21, 0x7A, 0x3A, 0x42, 0x40, 0x20, 0x78, 0x00, 0x9D, 0xA0, 0xA0, 0x7D, 0x39, 0x44, 0x44, 0x44, 0x39, 0x3D, 0x40, 0x40, 0x40, 0x3D, 0x3C, 0x24, 0xFF, 0x24, 0x24, 0x48, 0x7E, 0x49, 0x43, 0x66, 0x2B, 0x2F, 0xFC, 0x2F, 0x2B, 0xFF, 0x09, 0x29, 0xF6, 0x20, 0xC0, 0x88, 0x7E, 0x09, |
| 37 | 0x18, 0x3C, 0x7E, 0x3C, 0x18, | 37 | 0x03, 0x20, 0x54, 0x54, 0x79, 0x41, 0x00, 0x00, 0x44, 0x7D, 0x41, 0x30, 0x48, 0x48, 0x4A, 0x32, 0x38, 0x40, 0x40, 0x22, 0x7A, 0x00, 0x7A, 0x0A, 0x0A, 0x72, 0x7D, 0x0D, 0x19, 0x31, 0x7D, 0x26, 0x29, 0x29, 0x2F, 0x28, 0x26, 0x29, 0x29, 0x29, 0x26, 0x30, 0x48, 0x4D, 0x40, 0x20, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x2F, 0x10, 0xC8, 0xAC, 0xBA, 0x2F, 0x10, 0x28, 0x34, 0xFA, 0x00, 0x00, 0x7B, 0x00, 0x00, 0x08, 0x14, 0x2A, 0x14, 0x22, 0x22, 0x14, 0x2A, 0x14, 0x08, 0xAA, 0x00, 0x55, 0x00, 0xAA, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x10, 0x10, 0x10, 0xFF, 0x00, 0x14, 0x14, 0x14, 0xFF, 0x00, 0x10, 0x10, 0xFF, 0x00, 0xFF, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x14, 0x14, 0x14, 0xFC, 0x00, 0x14, 0x14, 0xF7, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x14, 0x14, 0xF4, 0x04, 0xFC, 0x14, 0x14, 0x17, 0x10, 0x1F, 0x10, 0x10, 0x1F, 0x10, 0x1F, 0x14, 0x14, 0x14, 0x1F, 0x00, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, |
| 38 | 0x1C, 0x57, 0x7D, 0x57, 0x1C, | 38 | 0x10, 0x10, 0x10, 0x1F, 0x10, 0x10, 0x10, 0x10, 0xF0, 0x10, 0x00, 0x00, 0x00, 0xFF, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xFF, 0x10, 0x00, 0x00, 0x00, 0xFF, 0x14, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x1F, 0x10, 0x17, 0x00, 0x00, 0xFC, 0x04, 0xF4, 0x14, 0x14, 0x17, 0x10, 0x17, 0x14, 0x14, 0xF4, 0x04, 0xF4, 0x00, 0x00, 0xFF, 0x00, 0xF7, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0xF7, 0x00, 0xF7, 0x14, 0x14, 0x14, 0x17, 0x14, 0x10, 0x10, 0x1F, 0x10, 0x1F, 0x14, 0x14, 0x14, 0xF4, 0x14, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x00, 0x00, 0x1F, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x1F, 0x14, 0x00, 0x00, 0x00, 0xFC, 0x14, 0x00, 0x00, 0xF0, 0x10, 0xF0, 0x10, 0x10, 0xFF, 0x10, 0xFF, 0x14, 0x14, 0x14, 0xFF, 0x14, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x38, 0x44, 0x44, 0x38, 0x44, 0x7C, |
| 39 | 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, | 39 | 0x2A, 0x2A, 0x3E, 0x14, 0x7E, 0x02, 0x02, 0x06, 0x06, 0x02, 0x7E, 0x02, 0x7E, 0x02, 0x63, 0x55, 0x49, 0x41, 0x63, 0x38, 0x44, 0x44, 0x3C, 0x04, 0x40, 0x7E, 0x20, 0x1E, 0x20, 0x06, 0x02, 0x7E, 0x02, 0x02, 0x99, 0xA5, 0xE7, 0xA5, 0x99, 0x1C, 0x2A, 0x49, 0x2A, 0x1C, 0x4C, 0x72, 0x01, 0x72, 0x4C, 0x30, 0x4A, 0x4D, 0x4D, 0x30, 0x30, 0x48, 0x78, 0x48, 0x30, 0xBC, 0x62, 0x5A, 0x46, 0x3D, 0x3E, 0x49, 0x49, 0x49, 0x00, 0x7E, 0x01, 0x01, 0x01, 0x7E, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x44, 0x44, 0x5F, 0x44, 0x44, 0x40, 0x51, 0x4A, 0x44, 0x40, 0x40, 0x44, 0x4A, 0x51, 0x40, 0x00, 0x00, 0xFF, 0x01, 0x03, 0xE0, 0x80, 0xFF, 0x00, 0x00, 0x08, 0x08, 0x6B, 0x6B, 0x08, 0x36, 0x12, 0x36, 0x24, 0x36, 0x06, 0x0F, 0x09, 0x0F, 0x06, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x30, 0x40, 0xFF, 0x01, 0x01, 0x00, 0x1F, 0x01, 0x01, 0x1E, 0x00, 0x19, 0x1D, 0x17, 0x12, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 40 | 0x00, 0x18, 0x3C, 0x18, 0x00, | ||
| 41 | 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, | ||
| 42 | 0x00, 0x18, 0x24, 0x18, 0x00, | ||
| 43 | 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, | ||
| 44 | 0x30, 0x48, 0x3A, 0x06, 0x0E, | ||
| 45 | 0x26, 0x29, 0x79, 0x29, 0x26, | ||
| 46 | 0x40, 0x7F, 0x05, 0x05, 0x07, | ||
| 47 | 0x40, 0x7F, 0x05, 0x25, 0x3F, | ||
| 48 | 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, | ||
| 49 | 0x7F, 0x3E, 0x1C, 0x1C, 0x08, | ||
| 50 | 0x08, 0x1C, 0x1C, 0x3E, 0x7F, | ||
| 51 | 0x14, 0x22, 0x7F, 0x22, 0x14, | ||
| 52 | 0x5F, 0x5F, 0x00, 0x5F, 0x5F, | ||
| 53 | 0x06, 0x09, 0x7F, 0x01, 0x7F, | ||
| 54 | 0x00, 0x66, 0x89, 0x95, 0x6A, | ||
| 55 | 0x60, 0x60, 0x60, 0x60, 0x60, | ||
| 56 | 0x94, 0xA2, 0xFF, 0xA2, 0x94, | ||
| 57 | 0x08, 0x04, 0x7E, 0x04, 0x08, | ||
| 58 | 0x10, 0x20, 0x7E, 0x20, 0x10, | ||
| 59 | 0x08, 0x08, 0x2A, 0x1C, 0x08, | ||
| 60 | 0x08, 0x1C, 0x2A, 0x08, 0x08, | ||
| 61 | 0x1E, 0x10, 0x10, 0x10, 0x10, | ||
| 62 | 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, | ||
| 63 | 0x30, 0x38, 0x3E, 0x38, 0x30, | ||
| 64 | 0x06, 0x0E, 0x3E, 0x0E, 0x06, | ||
| 65 | 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 66 | 0x00, 0x00, 0x5F, 0x00, 0x00, | ||
| 67 | 0x00, 0x07, 0x00, 0x07, 0x00, | ||
| 68 | 0x14, 0x7F, 0x14, 0x7F, 0x14, | ||
| 69 | 0x24, 0x2A, 0x7F, 0x2A, 0x12, | ||
| 70 | 0x23, 0x13, 0x08, 0x64, 0x62, | ||
| 71 | 0x36, 0x49, 0x56, 0x20, 0x50, | ||
| 72 | 0x00, 0x08, 0x07, 0x03, 0x00, | ||
| 73 | 0x00, 0x1C, 0x22, 0x41, 0x00, | ||
| 74 | 0x00, 0x41, 0x22, 0x1C, 0x00, | ||
| 75 | 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, | ||
| 76 | 0x08, 0x08, 0x3E, 0x08, 0x08, | ||
| 77 | 0x00, 0x80, 0x70, 0x30, 0x00, | ||
| 78 | 0x08, 0x08, 0x08, 0x08, 0x08, | ||
| 79 | 0x00, 0x00, 0x60, 0x60, 0x00, | ||
| 80 | 0x20, 0x10, 0x08, 0x04, 0x02, | ||
| 81 | 0x3E, 0x51, 0x49, 0x45, 0x3E, | ||
| 82 | 0x00, 0x42, 0x7F, 0x40, 0x00, | ||
| 83 | 0x72, 0x49, 0x49, 0x49, 0x46, | ||
| 84 | 0x21, 0x41, 0x49, 0x4D, 0x33, | ||
| 85 | 0x18, 0x14, 0x12, 0x7F, 0x10, | ||
| 86 | 0x27, 0x45, 0x45, 0x45, 0x39, | ||
| 87 | 0x3C, 0x4A, 0x49, 0x49, 0x31, | ||
| 88 | 0x41, 0x21, 0x11, 0x09, 0x07, | ||
| 89 | 0x36, 0x49, 0x49, 0x49, 0x36, | ||
| 90 | 0x46, 0x49, 0x49, 0x29, 0x1E, | ||
| 91 | 0x00, 0x00, 0x14, 0x00, 0x00, | ||
| 92 | 0x00, 0x40, 0x34, 0x00, 0x00, | ||
| 93 | 0x00, 0x08, 0x14, 0x22, 0x41, | ||
| 94 | 0x14, 0x14, 0x14, 0x14, 0x14, | ||
| 95 | 0x00, 0x41, 0x22, 0x14, 0x08, | ||
| 96 | 0x02, 0x01, 0x59, 0x09, 0x06, | ||
| 97 | 0x3E, 0x41, 0x5D, 0x59, 0x4E, | ||
| 98 | 0x7C, 0x12, 0x11, 0x12, 0x7C, | ||
| 99 | 0x7F, 0x49, 0x49, 0x49, 0x36, | ||
| 100 | 0x3E, 0x41, 0x41, 0x41, 0x22, | ||
| 101 | 0x7F, 0x41, 0x41, 0x41, 0x3E, | ||
| 102 | 0x7F, 0x49, 0x49, 0x49, 0x41, | ||
| 103 | 0x7F, 0x09, 0x09, 0x09, 0x01, | ||
| 104 | 0x3E, 0x41, 0x41, 0x51, 0x73, | ||
| 105 | 0x7F, 0x08, 0x08, 0x08, 0x7F, | ||
| 106 | 0x00, 0x41, 0x7F, 0x41, 0x00, | ||
| 107 | 0x20, 0x40, 0x41, 0x3F, 0x01, | ||
| 108 | 0x7F, 0x08, 0x14, 0x22, 0x41, | ||
| 109 | 0x7F, 0x40, 0x40, 0x40, 0x40, | ||
| 110 | 0x7F, 0x02, 0x1C, 0x02, 0x7F, | ||
| 111 | 0x7F, 0x04, 0x08, 0x10, 0x7F, | ||
| 112 | 0x3E, 0x41, 0x41, 0x41, 0x3E, | ||
| 113 | 0x7F, 0x09, 0x09, 0x09, 0x06, | ||
| 114 | 0x3E, 0x41, 0x51, 0x21, 0x5E, | ||
| 115 | 0x7F, 0x09, 0x19, 0x29, 0x46, | ||
| 116 | 0x26, 0x49, 0x49, 0x49, 0x32, | ||
| 117 | 0x03, 0x01, 0x7F, 0x01, 0x03, | ||
| 118 | 0x3F, 0x40, 0x40, 0x40, 0x3F, | ||
| 119 | 0x1F, 0x20, 0x40, 0x20, 0x1F, | ||
| 120 | 0x3F, 0x40, 0x38, 0x40, 0x3F, | ||
| 121 | 0x63, 0x14, 0x08, 0x14, 0x63, | ||
| 122 | 0x03, 0x04, 0x78, 0x04, 0x03, | ||
| 123 | 0x61, 0x59, 0x49, 0x4D, 0x43, | ||
| 124 | 0x00, 0x7F, 0x41, 0x41, 0x41, | ||
| 125 | 0x02, 0x04, 0x08, 0x10, 0x20, | ||
| 126 | 0x00, 0x41, 0x41, 0x41, 0x7F, | ||
| 127 | 0x04, 0x02, 0x01, 0x02, 0x04, | ||
| 128 | 0x40, 0x40, 0x40, 0x40, 0x40, | ||
| 129 | 0x00, 0x03, 0x07, 0x08, 0x00, | ||
| 130 | 0x20, 0x54, 0x54, 0x78, 0x40, | ||
| 131 | 0x7F, 0x28, 0x44, 0x44, 0x38, | ||
| 132 | 0x38, 0x44, 0x44, 0x44, 0x28, | ||
| 133 | 0x38, 0x44, 0x44, 0x28, 0x7F, | ||
| 134 | 0x38, 0x54, 0x54, 0x54, 0x18, | ||
| 135 | 0x00, 0x08, 0x7E, 0x09, 0x02, | ||
| 136 | 0x18, 0xA4, 0xA4, 0x9C, 0x78, | ||
| 137 | 0x7F, 0x08, 0x04, 0x04, 0x78, | ||
| 138 | 0x00, 0x44, 0x7D, 0x40, 0x00, | ||
| 139 | 0x20, 0x40, 0x40, 0x3D, 0x00, | ||
| 140 | 0x7F, 0x10, 0x28, 0x44, 0x00, | ||
| 141 | 0x00, 0x41, 0x7F, 0x40, 0x00, | ||
| 142 | 0x7C, 0x04, 0x78, 0x04, 0x78, | ||
| 143 | 0x7C, 0x08, 0x04, 0x04, 0x78, | ||
| 144 | 0x38, 0x44, 0x44, 0x44, 0x38, | ||
| 145 | 0xFC, 0x18, 0x24, 0x24, 0x18, | ||
| 146 | 0x18, 0x24, 0x24, 0x18, 0xFC, | ||
| 147 | 0x7C, 0x08, 0x04, 0x04, 0x08, | ||
| 148 | 0x48, 0x54, 0x54, 0x54, 0x24, | ||
| 149 | 0x04, 0x04, 0x3F, 0x44, 0x24, | ||
| 150 | 0x3C, 0x40, 0x40, 0x20, 0x7C, | ||
| 151 | 0x1C, 0x20, 0x40, 0x20, 0x1C, | ||
| 152 | 0x3C, 0x40, 0x30, 0x40, 0x3C, | ||
| 153 | 0x44, 0x28, 0x10, 0x28, 0x44, | ||
| 154 | 0x4C, 0x90, 0x90, 0x90, 0x7C, | ||
| 155 | 0x44, 0x64, 0x54, 0x4C, 0x44, | ||
| 156 | 0x00, 0x08, 0x36, 0x41, 0x00, | ||
| 157 | 0x00, 0x00, 0x77, 0x00, 0x00, | ||
| 158 | 0x00, 0x41, 0x36, 0x08, 0x00, | ||
| 159 | 0x02, 0x01, 0x02, 0x04, 0x02, | ||
| 160 | 0x3C, 0x26, 0x23, 0x26, 0x3C, | ||
| 161 | 0x1E, 0xA1, 0xA1, 0x61, 0x12, | ||
| 162 | 0x3A, 0x40, 0x40, 0x20, 0x7A, | ||
| 163 | 0x38, 0x54, 0x54, 0x55, 0x59, | ||
| 164 | 0x21, 0x55, 0x55, 0x79, 0x41, | ||
| 165 | 0x21, 0x54, 0x54, 0x78, 0x41, | ||
| 166 | 0x21, 0x55, 0x54, 0x78, 0x40, | ||
| 167 | 0x20, 0x54, 0x55, 0x79, 0x40, | ||
| 168 | 0x0C, 0x1E, 0x52, 0x72, 0x12, | ||
| 169 | 0x39, 0x55, 0x55, 0x55, 0x59, | ||
| 170 | 0x39, 0x54, 0x54, 0x54, 0x59, | ||
| 171 | 0x39, 0x55, 0x54, 0x54, 0x58, | ||
| 172 | 0x00, 0x00, 0x45, 0x7C, 0x41, | ||
| 173 | 0x00, 0x02, 0x45, 0x7D, 0x42, | ||
| 174 | 0x00, 0x01, 0x45, 0x7C, 0x40, | ||
| 175 | 0xF0, 0x29, 0x24, 0x29, 0xF0, | ||
| 176 | 0xF0, 0x28, 0x25, 0x28, 0xF0, | ||
| 177 | 0x7C, 0x54, 0x55, 0x45, 0x00, | ||
| 178 | 0x20, 0x54, 0x54, 0x7C, 0x54, | ||
| 179 | 0x7C, 0x0A, 0x09, 0x7F, 0x49, | ||
| 180 | 0x32, 0x49, 0x49, 0x49, 0x32, | ||
| 181 | 0x32, 0x48, 0x48, 0x48, 0x32, | ||
| 182 | 0x32, 0x4A, 0x48, 0x48, 0x30, | ||
| 183 | 0x3A, 0x41, 0x41, 0x21, 0x7A, | ||
| 184 | 0x3A, 0x42, 0x40, 0x20, 0x78, | ||
| 185 | 0x00, 0x9D, 0xA0, 0xA0, 0x7D, | ||
| 186 | 0x39, 0x44, 0x44, 0x44, 0x39, | ||
| 187 | 0x3D, 0x40, 0x40, 0x40, 0x3D, | ||
| 188 | 0x3C, 0x24, 0xFF, 0x24, 0x24, | ||
| 189 | 0x48, 0x7E, 0x49, 0x43, 0x66, | ||
| 190 | 0x2B, 0x2F, 0xFC, 0x2F, 0x2B, | ||
| 191 | 0xFF, 0x09, 0x29, 0xF6, 0x20, | ||
| 192 | 0xC0, 0x88, 0x7E, 0x09, 0x03, | ||
| 193 | 0x20, 0x54, 0x54, 0x79, 0x41, | ||
| 194 | 0x00, 0x00, 0x44, 0x7D, 0x41, | ||
| 195 | 0x30, 0x48, 0x48, 0x4A, 0x32, | ||
| 196 | 0x38, 0x40, 0x40, 0x22, 0x7A, | ||
| 197 | 0x00, 0x7A, 0x0A, 0x0A, 0x72, | ||
| 198 | 0x7D, 0x0D, 0x19, 0x31, 0x7D, | ||
| 199 | 0x26, 0x29, 0x29, 0x2F, 0x28, | ||
| 200 | 0x26, 0x29, 0x29, 0x29, 0x26, | ||
| 201 | 0x30, 0x48, 0x4D, 0x40, 0x20, | ||
| 202 | 0x38, 0x08, 0x08, 0x08, 0x08, | ||
| 203 | 0x08, 0x08, 0x08, 0x08, 0x38, | ||
| 204 | 0x2F, 0x10, 0xC8, 0xAC, 0xBA, | ||
| 205 | 0x2F, 0x10, 0x28, 0x34, 0xFA, | ||
| 206 | 0x00, 0x00, 0x7B, 0x00, 0x00, | ||
| 207 | 0x08, 0x14, 0x2A, 0x14, 0x22, | ||
| 208 | 0x22, 0x14, 0x2A, 0x14, 0x08, | ||
| 209 | 0xAA, 0x00, 0x55, 0x00, 0xAA, | ||
| 210 | 0xAA, 0x55, 0xAA, 0x55, 0xAA, | ||
| 211 | 0x00, 0x00, 0x00, 0xFF, 0x00, | ||
| 212 | 0x10, 0x10, 0x10, 0xFF, 0x00, | ||
| 213 | 0x14, 0x14, 0x14, 0xFF, 0x00, | ||
| 214 | 0x10, 0x10, 0xFF, 0x00, 0xFF, | ||
| 215 | 0x10, 0x10, 0xF0, 0x10, 0xF0, | ||
| 216 | 0x14, 0x14, 0x14, 0xFC, 0x00, | ||
| 217 | 0x14, 0x14, 0xF7, 0x00, 0xFF, | ||
| 218 | 0x00, 0x00, 0xFF, 0x00, 0xFF, | ||
| 219 | 0x14, 0x14, 0xF4, 0x04, 0xFC, | ||
| 220 | 0x14, 0x14, 0x17, 0x10, 0x1F, | ||
| 221 | 0x10, 0x10, 0x1F, 0x10, 0x1F, | ||
| 222 | 0x14, 0x14, 0x14, 0x1F, 0x00, | ||
| 223 | 0x10, 0x10, 0x10, 0xF0, 0x00, | ||
| 224 | 0x00, 0x00, 0x00, 0x1F, 0x10, | ||
| 225 | 0x10, 0x10, 0x10, 0x1F, 0x10, | ||
| 226 | 0x10, 0x10, 0x10, 0xF0, 0x10, | ||
| 227 | 0x00, 0x00, 0x00, 0xFF, 0x10, | ||
| 228 | 0x10, 0x10, 0x10, 0x10, 0x10, | ||
| 229 | 0x10, 0x10, 0x10, 0xFF, 0x10, | ||
| 230 | 0x00, 0x00, 0x00, 0xFF, 0x14, | ||
| 231 | 0x00, 0x00, 0xFF, 0x00, 0xFF, | ||
| 232 | 0x00, 0x00, 0x1F, 0x10, 0x17, | ||
| 233 | 0x00, 0x00, 0xFC, 0x04, 0xF4, | ||
| 234 | 0x14, 0x14, 0x17, 0x10, 0x17, | ||
| 235 | 0x14, 0x14, 0xF4, 0x04, 0xF4, | ||
| 236 | 0x00, 0x00, 0xFF, 0x00, 0xF7, | ||
| 237 | 0x14, 0x14, 0x14, 0x14, 0x14, | ||
| 238 | 0x14, 0x14, 0xF7, 0x00, 0xF7, | ||
| 239 | 0x14, 0x14, 0x14, 0x17, 0x14, | ||
| 240 | 0x10, 0x10, 0x1F, 0x10, 0x1F, | ||
| 241 | 0x14, 0x14, 0x14, 0xF4, 0x14, | ||
| 242 | 0x10, 0x10, 0xF0, 0x10, 0xF0, | ||
| 243 | 0x00, 0x00, 0x1F, 0x10, 0x1F, | ||
| 244 | 0x00, 0x00, 0x00, 0x1F, 0x14, | ||
| 245 | 0x00, 0x00, 0x00, 0xFC, 0x14, | ||
| 246 | 0x00, 0x00, 0xF0, 0x10, 0xF0, | ||
| 247 | 0x10, 0x10, 0xFF, 0x10, 0xFF, | ||
| 248 | 0x14, 0x14, 0x14, 0xFF, 0x14, | ||
| 249 | 0x10, 0x10, 0x10, 0x1F, 0x00, | ||
| 250 | 0x00, 0x00, 0x00, 0xF0, 0x10, | ||
| 251 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | ||
| 252 | 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, | ||
| 253 | 0xFF, 0xFF, 0xFF, 0x00, 0x00, | ||
| 254 | 0x00, 0x00, 0x00, 0xFF, 0xFF, | ||
| 255 | 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, | ||
| 256 | 0x38, 0x44, 0x44, 0x38, 0x44, | ||
| 257 | 0x7C, 0x2A, 0x2A, 0x3E, 0x14, | ||
| 258 | 0x7E, 0x02, 0x02, 0x06, 0x06, | ||
| 259 | 0x02, 0x7E, 0x02, 0x7E, 0x02, | ||
| 260 | 0x63, 0x55, 0x49, 0x41, 0x63, | ||
| 261 | 0x38, 0x44, 0x44, 0x3C, 0x04, | ||
| 262 | 0x40, 0x7E, 0x20, 0x1E, 0x20, | ||
| 263 | 0x06, 0x02, 0x7E, 0x02, 0x02, | ||
| 264 | 0x99, 0xA5, 0xE7, 0xA5, 0x99, | ||
| 265 | 0x1C, 0x2A, 0x49, 0x2A, 0x1C, | ||
| 266 | 0x4C, 0x72, 0x01, 0x72, 0x4C, | ||
| 267 | 0x30, 0x4A, 0x4D, 0x4D, 0x30, | ||
| 268 | 0x30, 0x48, 0x78, 0x48, 0x30, | ||
| 269 | 0xBC, 0x62, 0x5A, 0x46, 0x3D, | ||
| 270 | 0x3E, 0x49, 0x49, 0x49, 0x00, | ||
| 271 | 0x7E, 0x01, 0x01, 0x01, 0x7E, | ||
| 272 | 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, | ||
| 273 | 0x44, 0x44, 0x5F, 0x44, 0x44, | ||
| 274 | 0x40, 0x51, 0x4A, 0x44, 0x40, | ||
| 275 | 0x40, 0x44, 0x4A, 0x51, 0x40, | ||
| 276 | 0x00, 0x00, 0xFF, 0x01, 0x03, | ||
| 277 | 0xE0, 0x80, 0xFF, 0x00, 0x00, | ||
| 278 | 0x08, 0x08, 0x6B, 0x6B, 0x08, | ||
| 279 | 0x36, 0x12, 0x36, 0x24, 0x36, | ||
| 280 | 0x06, 0x0F, 0x09, 0x0F, 0x06, | ||
| 281 | 0x00, 0x00, 0x18, 0x18, 0x00, | ||
| 282 | 0x00, 0x00, 0x10, 0x10, 0x00, | ||
| 283 | 0x30, 0x40, 0xFF, 0x01, 0x01, | ||
| 284 | 0x00, 0x1F, 0x01, 0x01, 0x1E, | ||
| 285 | 0x00, 0x19, 0x1D, 0x17, 0x12, | ||
| 286 | 0x00, 0x3C, 0x3C, 0x3C, 0x3C, | ||
| 287 | 0x00, 0x00, 0x00, 0x00, 0x00 | ||
| 288 | }; | ||
diff --git a/drivers/qwiic/util/font8x16.h b/drivers/qwiic/util/font8x16.h index c070e4ec8..4d3c23786 100644 --- a/drivers/qwiic/util/font8x16.h +++ b/drivers/qwiic/util/font8x16.h | |||
| @@ -27,101 +27,13 @@ https://github.com/emil01/SparkFun_Micro_OLED_Arduino_Library/ | |||
| 27 | 27 | ||
| 28 | static const unsigned char font8x16[] PROGMEM = { | 28 | static const unsigned char font8x16[] PROGMEM = { |
| 29 | // first row defines - FONTWIDTH, FONTHEIGHT, ASCII START CHAR, TOTAL CHARACTERS, FONT MAP WIDTH HIGH, FONT MAP WIDTH LOW (2,56 meaning 256) | 29 | // first row defines - FONTWIDTH, FONTHEIGHT, ASCII START CHAR, TOTAL CHARACTERS, FONT MAP WIDTH HIGH, FONT MAP WIDTH LOW (2,56 meaning 256) |
| 30 | 8,16,32,96,2,56, | 30 | 8, 16, 32, 96, 2, 56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0xD0, 0xBE, 0x90, 0xD0, 0xBE, 0x90, 0x00, 0x00, 0x1C, 0x62, 0xFF, 0xC2, 0x80, 0x00, 0x00, 0x0C, 0x12, 0x92, 0x4C, 0xB0, 0x88, 0x06, 0x00, 0x80, 0x7C, 0x62, 0xB2, 0x1C, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x18, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x02, 0x02, 0x04, 0x18, 0xE0, 0x00, 0x00, 0x00, 0x24, 0x18, 0x7E, 0x18, 0x24, 0x00, 0x00, 0x80, 0x80, 0x80, 0xF0, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x60, 0x18, 0x06, 0x00, 0x00, 0xF8, 0x04, 0xC2, 0x32, 0x0C, 0xF8, 0x00, 0x00, 0x00, 0x04, 0x04, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x82, 0x42, 0x22, |
| 31 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, | 31 | 0x1C, 0x00, 0x00, 0x00, 0x02, 0x22, 0x22, 0x22, 0xDC, 0x00, 0x00, 0xC0, 0xA0, 0x98, 0x84, 0xFE, 0x80, 0x80, 0x00, 0x00, 0x1E, 0x12, 0x12, 0x22, 0xC2, 0x00, 0x00, 0xF8, 0x44, 0x22, 0x22, 0x22, 0xC0, 0x00, 0x00, 0x00, 0x02, 0x02, 0xC2, 0x32, 0x0A, 0x06, 0x00, 0x00, 0x8C, 0x52, 0x22, 0x52, 0x8C, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x26, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, 0x10, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80, 0x00, 0x00, 0x02, 0x82, 0x42, 0x22, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x0F, 0x04, 0x03, 0x00, 0x00, 0x04, 0x02, 0x01, 0x03, 0x04, 0x04, 0x03, 0x00, |
| 32 | 0x00, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0xD0, 0xBE, 0x90, 0xD0, 0xBE, 0x90, 0x00, | 32 | 0x03, 0x04, 0x04, 0x04, 0x05, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x06, 0x08, 0x10, 0x10, 0x00, 0x00, 0x00, 0x10, 0x10, 0x08, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x04, 0x04, 0x07, 0x04, 0x04, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x01, 0x02, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x04, 0x04, |
| 33 | 0x00, 0x1C, 0x62, 0xFF, 0xC2, 0x80, 0x00, 0x00, 0x0C, 0x12, 0x92, 0x4C, 0xB0, 0x88, 0x06, 0x00, | 33 | 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x04, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x04, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x04, 0x72, 0x8A, 0xFA, 0x84, 0x78, 0x00, 0x00, 0xC0, 0x38, 0x06, 0x38, 0xC0, 0x00, 0x00, 0x00, 0xFE, 0x22, 0x22, 0x22, 0xDC, 0x00, 0x00, 0xF8, 0x04, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0xFE, 0x02, 0x02, 0x02, 0x04, 0xF8, 0x00, 0x00, 0x00, 0xFE, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 0xFE, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0xF8, 0x04, 0x02, 0x02, 0x22, 0xE2, 0x00, 0x00, 0xFE, 0x20, 0x20, 0x20, 0x20, 0xFE, 0x00, 0x00, 0x00, 0x02, 0x02, 0xFE, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0xFE, 0x00, 0x00, 0xFE, 0x40, 0xB0, 0x08, 0x04, 0x02, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, |
| 34 | 0x80, 0x7C, 0x62, 0xB2, 0x1C, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x0E, 0x00, 0x00, 0x00, 0x00, | 34 | 0x00, 0x00, 0xFE, 0x0C, 0x70, 0x80, 0x70, 0x0C, 0xFE, 0x00, 0xFE, 0x0C, 0x30, 0xC0, 0x00, 0xFE, 0x00, 0x00, 0xF8, 0x04, 0x02, 0x02, 0x04, 0xF8, 0x00, 0x00, 0xFE, 0x42, 0x42, 0x42, 0x22, 0x1C, 0x00, 0x00, 0xF8, 0x04, 0x02, 0x02, 0x04, 0xF8, 0x00, 0x00, 0x00, 0xFE, 0x42, 0x42, 0xA2, 0x1C, 0x00, 0x00, 0x00, 0x1C, 0x22, 0x42, 0x42, 0x80, 0x00, 0x00, 0x02, 0x02, 0x02, 0xFE, 0x02, 0x02, 0x02, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x06, 0x38, 0xC0, 0x00, 0xC0, 0x38, 0x06, 0x00, 0x3E, 0xC0, 0xF0, 0x0E, 0xF0, 0xC0, 0x3E, 0x00, 0x00, 0x06, 0x98, 0x60, 0x98, 0x06, 0x00, 0x00, 0x00, 0x06, 0x18, 0xE0, 0x18, 0x06, 0x00, 0x00, 0x02, 0x02, 0xC2, 0x32, 0x0A, 0x06, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x06, 0x18, 0x60, 0x80, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0xFE, 0x00, 0x00, 0x00, 0x40, 0x30, 0x0C, 0x0C, 0x30, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, |
| 35 | 0x00, 0xE0, 0x18, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x02, 0x02, 0x04, 0x18, 0xE0, 0x00, 0x00, | 35 | 0x02, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x06, 0x00, 0x00, 0x07, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x01, 0x02, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x07, 0x04, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x04, 0x04, 0x07, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x04, 0x07, 0x04, 0x04, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x07, 0x00, 0x00, 0x01, 0x02, 0x04, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x07, 0x00, 0x00, 0x01, 0x02, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x0C, 0x12, 0x11, 0x10, 0x00, 0x00, 0x07, 0x00, 0x00, 0x01, 0x06, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, |
| 36 | 0x00, 0x24, 0x18, 0x7E, 0x18, 0x24, 0x00, 0x00, 0x80, 0x80, 0x80, 0xF0, 0x80, 0x80, 0x80, 0x00, | 36 | 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x01, 0x00, 0x01, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x06, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x00, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, 0x00, 0xFE, 0x20, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xFE, 0x00, 0x00, 0x00, 0xE0, 0x90, 0x90, 0x90, 0xE0, 0x00, 0x00, 0x00, 0x20, 0xFC, 0x22, 0x22, 0x22, 0x02, |
| 37 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, | 37 | 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, 0x00, 0xFE, 0x20, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x10, 0x10, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0xF2, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x80, 0x40, 0x20, 0x10, 0x00, 0x00, 0x00, 0x02, 0x02, 0xFE, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x20, 0x10, 0xF0, 0x20, 0x10, 0xF0, 0x00, 0x00, 0xF0, 0x20, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x00, 0xF0, 0x20, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0x20, 0x10, 0x10, 0x70, 0x00, 0x00, 0x00, 0x60, 0x90, 0x90, 0x90, 0x20, 0x00, 0x00, 0x00, 0x20, 0x20, 0xFC, 0x20, 0x20, 0x20, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x70, 0x80, 0x00, 0x80, 0x70, 0x00, 0x00, 0xF0, 0x00, 0xC0, 0x30, 0xC0, 0x00, 0xF0, 0x00, 0x00, 0x30, 0xC0, 0xC0, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0xC0, 0x00, 0x80, 0x70, 0x00, 0x00, 0x00, 0x10, |
| 38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x60, 0x18, 0x06, 0x00, 0x00, | 38 | 0x10, 0x90, 0x50, 0x30, 0x00, 0x00, 0x00, 0x80, 0x80, 0x7E, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x7E, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x02, 0x07, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x02, 0x07, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x24, 0x24, 0x22, 0x1F, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x01, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x00, 0x00, 0x07, 0x00, 0x00, 0x07, 0x00, |
| 39 | 0xF8, 0x04, 0xC2, 0x32, 0x0C, 0xF8, 0x00, 0x00, 0x00, 0x04, 0x04, 0xFE, 0x00, 0x00, 0x00, 0x00, | 39 | 0x00, 0x07, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x3F, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x02, 0x3F, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x00, 0x00, 0x03, 0x04, 0x04, 0x02, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x03, 0x00, 0x00, 0x00, 0x01, 0x06, 0x01, 0x00, 0x01, 0x06, 0x01, 0x00, 0x00, 0x06, 0x01, 0x01, 0x06, 0x00, 0x00, 0x00, 0x20, 0x20, 0x31, 0x0E, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0x05, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 40 | 0x00, 0x02, 0x82, 0x42, 0x22, 0x1C, 0x00, 0x00, 0x00, 0x02, 0x22, 0x22, 0x22, 0xDC, 0x00, 0x00, | ||
| 41 | 0xC0, 0xA0, 0x98, 0x84, 0xFE, 0x80, 0x80, 0x00, 0x00, 0x1E, 0x12, 0x12, 0x22, 0xC2, 0x00, 0x00, | ||
| 42 | 0xF8, 0x44, 0x22, 0x22, 0x22, 0xC0, 0x00, 0x00, 0x00, 0x02, 0x02, 0xC2, 0x32, 0x0A, 0x06, 0x00, | ||
| 43 | 0x00, 0x8C, 0x52, 0x22, 0x52, 0x8C, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x26, 0xF8, 0x00, 0x00, | ||
| 44 | 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, | ||
| 45 | 0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, | ||
| 46 | 0x10, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80, 0x00, 0x00, 0x02, 0x82, 0x42, 0x22, 0x1C, 0x00, 0x00, | ||
| 47 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, | ||
| 48 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, | ||
| 49 | 0x00, 0x04, 0x04, 0x0F, 0x04, 0x03, 0x00, 0x00, 0x04, 0x02, 0x01, 0x03, 0x04, 0x04, 0x03, 0x00, | ||
| 50 | 0x03, 0x04, 0x04, 0x04, 0x05, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 51 | 0x00, 0x03, 0x06, 0x08, 0x10, 0x10, 0x00, 0x00, 0x00, 0x10, 0x10, 0x08, 0x06, 0x03, 0x00, 0x00, | ||
| 52 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, | ||
| 53 | 0x00, 0x00, 0x16, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 54 | 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 55 | 0x01, 0x03, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x04, 0x04, 0x07, 0x04, 0x04, 0x00, 0x00, | ||
| 56 | 0x00, 0x07, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, | ||
| 57 | 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, | ||
| 58 | 0x01, 0x02, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 59 | 0x00, 0x03, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00, | ||
| 60 | 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x0E, 0x00, 0x00, 0x00, 0x00, | ||
| 61 | 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x04, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, | ||
| 62 | 0x04, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 63 | 0xF8, 0x04, 0x72, 0x8A, 0xFA, 0x84, 0x78, 0x00, 0x00, 0xC0, 0x38, 0x06, 0x38, 0xC0, 0x00, 0x00, | ||
| 64 | 0x00, 0xFE, 0x22, 0x22, 0x22, 0xDC, 0x00, 0x00, 0xF8, 0x04, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, | ||
| 65 | 0xFE, 0x02, 0x02, 0x02, 0x04, 0xF8, 0x00, 0x00, 0x00, 0xFE, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, | ||
| 66 | 0x00, 0xFE, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0xF8, 0x04, 0x02, 0x02, 0x22, 0xE2, 0x00, 0x00, | ||
| 67 | 0xFE, 0x20, 0x20, 0x20, 0x20, 0xFE, 0x00, 0x00, 0x00, 0x02, 0x02, 0xFE, 0x02, 0x02, 0x00, 0x00, | ||
| 68 | 0x00, 0x00, 0x00, 0x02, 0x02, 0xFE, 0x00, 0x00, 0xFE, 0x40, 0xB0, 0x08, 0x04, 0x02, 0x00, 0x00, | ||
| 69 | 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x0C, 0x70, 0x80, 0x70, 0x0C, 0xFE, 0x00, | ||
| 70 | 0xFE, 0x0C, 0x30, 0xC0, 0x00, 0xFE, 0x00, 0x00, 0xF8, 0x04, 0x02, 0x02, 0x04, 0xF8, 0x00, 0x00, | ||
| 71 | 0xFE, 0x42, 0x42, 0x42, 0x22, 0x1C, 0x00, 0x00, 0xF8, 0x04, 0x02, 0x02, 0x04, 0xF8, 0x00, 0x00, | ||
| 72 | 0x00, 0xFE, 0x42, 0x42, 0xA2, 0x1C, 0x00, 0x00, 0x00, 0x1C, 0x22, 0x42, 0x42, 0x80, 0x00, 0x00, | ||
| 73 | 0x02, 0x02, 0x02, 0xFE, 0x02, 0x02, 0x02, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, | ||
| 74 | 0x06, 0x38, 0xC0, 0x00, 0xC0, 0x38, 0x06, 0x00, 0x3E, 0xC0, 0xF0, 0x0E, 0xF0, 0xC0, 0x3E, 0x00, | ||
| 75 | 0x00, 0x06, 0x98, 0x60, 0x98, 0x06, 0x00, 0x00, 0x00, 0x06, 0x18, 0xE0, 0x18, 0x06, 0x00, 0x00, | ||
| 76 | 0x02, 0x02, 0xC2, 0x32, 0x0A, 0x06, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x02, 0x02, 0x02, 0x02, 0x00, | ||
| 77 | 0x00, 0x06, 0x18, 0x60, 0x80, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0xFE, 0x00, 0x00, 0x00, | ||
| 78 | 0x40, 0x30, 0x0C, 0x0C, 0x30, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 79 | 0x01, 0x02, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x06, 0x00, | ||
| 80 | 0x00, 0x07, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x01, 0x02, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, | ||
| 81 | 0x07, 0x04, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, | ||
| 82 | 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x04, 0x04, 0x07, 0x00, 0x00, | ||
| 83 | 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x04, 0x07, 0x04, 0x04, 0x00, 0x00, | ||
| 84 | 0x00, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x07, 0x00, 0x00, 0x01, 0x02, 0x04, 0x00, 0x00, | ||
| 85 | 0x00, 0x07, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x07, 0x00, | ||
| 86 | 0x07, 0x00, 0x00, 0x00, 0x03, 0x07, 0x00, 0x00, 0x01, 0x02, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00, | ||
| 87 | 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x0C, 0x12, 0x11, 0x10, 0x00, | ||
| 88 | 0x00, 0x07, 0x00, 0x00, 0x01, 0x06, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, | ||
| 89 | 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, | ||
| 90 | 0x00, 0x00, 0x01, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, | ||
| 91 | 0x00, 0x06, 0x01, 0x00, 0x01, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, | ||
| 92 | 0x06, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, 0x00, | ||
| 93 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x00, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, | ||
| 94 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, | ||
| 95 | 0x00, 0x00, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, | ||
| 96 | 0x00, 0xFE, 0x20, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, | ||
| 97 | 0x00, 0xE0, 0x10, 0x10, 0x10, 0xFE, 0x00, 0x00, 0x00, 0xE0, 0x90, 0x90, 0x90, 0xE0, 0x00, 0x00, | ||
| 98 | 0x00, 0x20, 0xFC, 0x22, 0x22, 0x22, 0x02, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, | ||
| 99 | 0x00, 0xFE, 0x20, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x10, 0x10, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 100 | 0x00, 0x10, 0x10, 0x10, 0xF2, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x80, 0x40, 0x20, 0x10, 0x00, 0x00, | ||
| 101 | 0x00, 0x02, 0x02, 0xFE, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x20, 0x10, 0xF0, 0x20, 0x10, 0xF0, 0x00, | ||
| 102 | 0x00, 0xF0, 0x20, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xE0, 0x00, 0x00, | ||
| 103 | 0x00, 0xF0, 0x20, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, | ||
| 104 | 0x00, 0xF0, 0x20, 0x10, 0x10, 0x70, 0x00, 0x00, 0x00, 0x60, 0x90, 0x90, 0x90, 0x20, 0x00, 0x00, | ||
| 105 | 0x00, 0x20, 0x20, 0xFC, 0x20, 0x20, 0x20, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, | ||
| 106 | 0x00, 0x70, 0x80, 0x00, 0x80, 0x70, 0x00, 0x00, 0xF0, 0x00, 0xC0, 0x30, 0xC0, 0x00, 0xF0, 0x00, | ||
| 107 | 0x00, 0x30, 0xC0, 0xC0, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0xC0, 0x00, 0x80, 0x70, 0x00, 0x00, | ||
| 108 | 0x00, 0x10, 0x10, 0x90, 0x50, 0x30, 0x00, 0x00, 0x00, 0x80, 0x80, 0x7E, 0x02, 0x02, 0x00, 0x00, | ||
| 109 | 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x7E, 0x80, 0x80, 0x00, 0x00, | ||
| 110 | 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 111 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x02, 0x07, 0x00, 0x00, | ||
| 112 | 0x00, 0x07, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, | ||
| 113 | 0x00, 0x03, 0x04, 0x04, 0x02, 0x07, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, | ||
| 114 | 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x24, 0x24, 0x22, 0x1F, 0x00, 0x00, | ||
| 115 | 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x00, 0x00, 0x00, | ||
| 116 | 0x20, 0x20, 0x20, 0x20, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x01, 0x02, 0x04, 0x00, 0x00, | ||
| 117 | 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x00, 0x00, 0x07, 0x00, 0x00, 0x07, 0x00, 0x00, 0x07, 0x00, | ||
| 118 | 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, | ||
| 119 | 0x00, 0x3F, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x02, 0x3F, 0x00, 0x00, | ||
| 120 | 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, | ||
| 121 | 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x00, 0x00, 0x03, 0x04, 0x04, 0x02, 0x07, 0x00, 0x00, | ||
| 122 | 0x00, 0x00, 0x03, 0x04, 0x03, 0x00, 0x00, 0x00, 0x01, 0x06, 0x01, 0x00, 0x01, 0x06, 0x01, 0x00, | ||
| 123 | 0x00, 0x06, 0x01, 0x01, 0x06, 0x00, 0x00, 0x00, 0x20, 0x20, 0x31, 0x0E, 0x03, 0x00, 0x00, 0x00, | ||
| 124 | 0x00, 0x06, 0x05, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x00, 0x00, | ||
| 125 | 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, | ||
| 126 | 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | ||
| 127 | }; | ||
diff --git a/drivers/ugfx/gdisp/is31fl3731c/board_is31fl3731c_template.h b/drivers/ugfx/gdisp/is31fl3731c/board_is31fl3731c_template.h index f248cc25b..0755ddf6c 100644 --- a/drivers/ugfx/gdisp/is31fl3731c/board_is31fl3731c_template.h +++ b/drivers/ugfx/gdisp/is31fl3731c/board_is31fl3731c_template.h | |||
| @@ -19,54 +19,53 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 19 | #define _GDISP_LLD_BOARD_H | 19 | #define _GDISP_LLD_BOARD_H |
| 20 | 20 | ||
| 21 | static const I2CConfig i2ccfg = { | 21 | static const I2CConfig i2ccfg = { |
| 22 | 400000 // clock speed (Hz); 400kHz max for IS31 | 22 | 400000 // clock speed (Hz); 400kHz max for IS31 |
| 23 | }; | 23 | }; |
| 24 | 24 | ||
| 25 | static const uint8_t led_mask[] = { | 25 | static const uint8_t led_mask[] = { |
| 26 | 0xFF, 0x00, /* C1-1 -> C1-16 */ | 26 | 0xFF, 0x00, /* C1-1 -> C1-16 */ |
| 27 | 0xFF, 0x00, /* C2-1 -> C2-16 */ | 27 | 0xFF, 0x00, /* C2-1 -> C2-16 */ |
| 28 | 0xFF, 0x00, /* C3-1 -> C3-16 */ | 28 | 0xFF, 0x00, /* C3-1 -> C3-16 */ |
| 29 | 0xFF, 0x00, /* C4-1 -> C4-16 */ | 29 | 0xFF, 0x00, /* C4-1 -> C4-16 */ |
| 30 | 0x3F, 0x00, /* C5-1 -> C5-16 */ | 30 | 0x3F, 0x00, /* C5-1 -> C5-16 */ |
| 31 | 0x00, 0x00, /* C6-1 -> C6-16 */ | 31 | 0x00, 0x00, /* C6-1 -> C6-16 */ |
| 32 | 0x00, 0x00, /* C7-1 -> C7-16 */ | 32 | 0x00, 0x00, /* C7-1 -> C7-16 */ |
| 33 | 0x00, 0x00, /* C8-1 -> C8-16 */ | 33 | 0x00, 0x00, /* C8-1 -> C8-16 */ |
| 34 | 0x00, 0x00, /* C9-1 -> C9-16 */ | 34 | 0x00, 0x00, /* C9-1 -> C9-16 */ |
| 35 | }; | 35 | }; |
| 36 | 36 | ||
| 37 | // The address of the LED | 37 | // The address of the LED |
| 38 | #define LA(c, r) (c + r * 16 ) | 38 | #define LA(c, r) (c + r * 16) |
| 39 | // Need to be an address that is not mapped, but inside the range of the controller matrix | 39 | // Need to be an address that is not mapped, but inside the range of the controller matrix |
| 40 | #define NA LA(8, 8) | 40 | #define NA LA(8, 8) |
| 41 | 41 | ||
| 42 | // The numbers in the comments are the led numbers DXX on the PCB | 42 | // The numbers in the comments are the led numbers DXX on the PCB |
| 43 | // The mapping is taken from the schematic of left hand side | 43 | // The mapping is taken from the schematic of left hand side |
| 44 | static const uint8_t led_mapping[GDISP_SCREEN_HEIGHT][GDISP_SCREEN_WIDTH] = { | 44 | static const uint8_t led_mapping[GDISP_SCREEN_HEIGHT][GDISP_SCREEN_WIDTH] = { |
| 45 | // 45 44 43 42 41 40 39 | 45 | // 45 44 43 42 41 40 39 |
| 46 | { LA(1, 1), LA(1, 0), LA(0, 4), LA(0, 3), LA(0, 2), LA(0, 1), LA(0, 0)}, | 46 | {LA(1, 1), LA(1, 0), LA(0, 4), LA(0, 3), LA(0, 2), LA(0, 1), LA(0, 0)}, |
| 47 | // 52 51 50 49 48 47 46 | 47 | // 52 51 50 49 48 47 46 |
| 48 | { LA(2, 3), LA(2, 2), LA(2, 1), LA(2, 0), LA(1, 4), LA(1, 3), LA(1, 2) }, | 48 | {LA(2, 3), LA(2, 2), LA(2, 1), LA(2, 0), LA(1, 4), LA(1, 3), LA(1, 2)}, |
| 49 | // 58 57 56 55 54 53 N/A | 49 | // 58 57 56 55 54 53 N/A |
| 50 | { LA(3, 4), LA(3, 3), LA(3, 2), LA(3, 1), LA(3, 0), LA(2, 4), NA }, | 50 | {LA(3, 4), LA(3, 3), LA(3, 2), LA(3, 1), LA(3, 0), LA(2, 4), NA}, |
| 51 | // 67 66 65 64 63 62 61 | 51 | // 67 66 65 64 63 62 61 |
| 52 | { LA(5, 3), LA(5, 2), LA(5, 1), LA(5, 0), LA(4, 4), LA(4, 3), LA(4, 2) }, | 52 | {LA(5, 3), LA(5, 2), LA(5, 1), LA(5, 0), LA(4, 4), LA(4, 3), LA(4, 2)}, |
| 53 | // 76 75 74 73 72 60 59 | 53 | // 76 75 74 73 72 60 59 |
| 54 | { LA(7, 3), LA(7, 2), LA(7, 1), LA(7, 0), LA(6, 3), LA(4, 1), LA(4, 0) }, | 54 | {LA(7, 3), LA(7, 2), LA(7, 1), LA(7, 0), LA(6, 3), LA(4, 1), LA(4, 0)}, |
| 55 | // N/A N/A N/A N/A N/A N/A 68 | 55 | // N/A N/A N/A N/A N/A N/A 68 |
| 56 | { NA, NA, NA, NA, NA, NA, LA(5, 4) }, | 56 | {NA, NA, NA, NA, NA, NA, LA(5, 4)}, |
| 57 | // N/A N/A N/A N/A 71 70 69 | 57 | // N/A N/A N/A N/A 71 70 69 |
| 58 | { NA, NA, NA, NA, LA(6, 2), LA(6, 1), LA(6, 0) }, | 58 | {NA, NA, NA, NA, LA(6, 2), LA(6, 1), LA(6, 0)}, |
| 59 | }; | 59 | }; |
| 60 | 60 | ||
| 61 | 61 | #define IS31_ADDR_DEFAULT 0x74 // AD connected to GND | |
| 62 | #define IS31_ADDR_DEFAULT 0x74 // AD connected to GND | ||
| 63 | #define IS31_TIMEOUT 5000 | 62 | #define IS31_TIMEOUT 5000 |
| 64 | 63 | ||
| 65 | static GFXINLINE void init_board(GDisplay *g) { | 64 | static GFXINLINE void init_board(GDisplay* g) { |
| 66 | (void) g; | 65 | (void)g; |
| 67 | /* I2C pins */ | 66 | /* I2C pins */ |
| 68 | palSetPadMode(GPIOB, 0, PAL_MODE_ALTERNATIVE_2); // PTB0/I2C0/SCL | 67 | palSetPadMode(GPIOB, 0, PAL_MODE_ALTERNATIVE_2); // PTB0/I2C0/SCL |
| 69 | palSetPadMode(GPIOB, 1, PAL_MODE_ALTERNATIVE_2); // PTB1/I2C0/SDA | 68 | palSetPadMode(GPIOB, 1, PAL_MODE_ALTERNATIVE_2); // PTB1/I2C0/SDA |
| 70 | palSetPadMode(GPIOB, 16, PAL_MODE_OUTPUT_PUSHPULL); | 69 | palSetPadMode(GPIOB, 16, PAL_MODE_OUTPUT_PUSHPULL); |
| 71 | palClearPad(GPIOB, 16); | 70 | palClearPad(GPIOB, 16); |
| 72 | /* start I2C */ | 71 | /* start I2C */ |
| @@ -77,34 +76,30 @@ static GFXINLINE void init_board(GDisplay *g) { | |||
| 77 | I2CD1.i2c->FLT = 4; | 76 | I2CD1.i2c->FLT = 4; |
| 78 | } | 77 | } |
| 79 | 78 | ||
| 80 | static GFXINLINE void post_init_board(GDisplay *g) { | 79 | static GFXINLINE void post_init_board(GDisplay* g) { (void)g; } |
| 81 | (void) g; | ||
| 82 | } | ||
| 83 | 80 | ||
| 84 | static GFXINLINE const uint8_t* get_led_mask(GDisplay* g) { | 81 | static GFXINLINE const uint8_t* get_led_mask(GDisplay* g) { |
| 85 | (void) g; | 82 | (void)g; |
| 86 | return led_mask; | 83 | return led_mask; |
| 87 | } | 84 | } |
| 88 | 85 | ||
| 89 | static GFXINLINE uint8_t get_led_address(GDisplay* g, uint16_t x, uint16_t y) | 86 | static GFXINLINE uint8_t get_led_address(GDisplay* g, uint16_t x, uint16_t y) { |
| 90 | { | 87 | (void)g; |
| 91 | (void) g; | ||
| 92 | return led_mapping[y][x]; | 88 | return led_mapping[y][x]; |
| 93 | } | 89 | } |
| 94 | 90 | ||
| 95 | static GFXINLINE void set_hardware_shutdown(GDisplay* g, bool shutdown) { | 91 | static GFXINLINE void set_hardware_shutdown(GDisplay* g, bool shutdown) { |
| 96 | (void) g; | 92 | (void)g; |
| 97 | if(!shutdown) { | 93 | if (!shutdown) { |
| 98 | palSetPad(GPIOB, 16); | 94 | palSetPad(GPIOB, 16); |
| 99 | } | 95 | } else { |
| 100 | else { | ||
| 101 | palClearPad(GPIOB, 16); | 96 | palClearPad(GPIOB, 16); |
| 102 | } | 97 | } |
| 103 | } | 98 | } |
| 104 | 99 | ||
| 105 | static GFXINLINE void write_data(GDisplay *g, uint8_t* data, uint16_t length) { | 100 | static GFXINLINE void write_data(GDisplay* g, uint8_t* data, uint16_t length) { |
| 106 | (void) g; | 101 | (void)g; |
| 107 | i2cMasterTransmitTimeout(&I2CD1, IS31_ADDR_DEFAULT, data, length, 0, 0, US2ST(IS31_TIMEOUT)); | 102 | i2cMasterTransmitTimeout(&I2CD1, IS31_ADDR_DEFAULT, data, length, 0, 0, US2ST(IS31_TIMEOUT)); |
| 108 | } | 103 | } |
| 109 | 104 | ||
| 110 | #endif /* _GDISP_LLD_BOARD_H */ | 105 | #endif /* _GDISP_LLD_BOARD_H */ |
diff --git a/drivers/ugfx/gdisp/is31fl3731c/gdisp_is31fl3731c.c b/drivers/ugfx/gdisp/is31fl3731c/gdisp_is31fl3731c.c index 917adadb8..718824402 100644 --- a/drivers/ugfx/gdisp/is31fl3731c/gdisp_is31fl3731c.c +++ b/drivers/ugfx/gdisp/is31fl3731c/gdisp_is31fl3731c.c | |||
| @@ -19,15 +19,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 19 | 19 | ||
| 20 | #if GFX_USE_GDISP | 20 | #if GFX_USE_GDISP |
| 21 | 21 | ||
| 22 | #define GDISP_DRIVER_VMT GDISPVMT_IS31FL3731C_QMK | 22 | # define GDISP_DRIVER_VMT GDISPVMT_IS31FL3731C_QMK |
| 23 | #define GDISP_SCREEN_HEIGHT LED_HEIGHT | 23 | # define GDISP_SCREEN_HEIGHT LED_HEIGHT |
| 24 | #define GDISP_SCREEN_WIDTH LED_WIDTH | 24 | # define GDISP_SCREEN_WIDTH LED_WIDTH |
| 25 | 25 | ||
| 26 | #include "gdisp_lld_config.h" | 26 | # include "gdisp_lld_config.h" |
| 27 | #include "src/gdisp/gdisp_driver.h" | 27 | # include "src/gdisp/gdisp_driver.h" |
| 28 | |||
| 29 | #include "board_is31fl3731c.h" | ||
| 30 | 28 | ||
| 29 | # include "board_is31fl3731c.h" | ||
| 31 | 30 | ||
| 32 | // Can't include led_tables from here | 31 | // Can't include led_tables from here |
| 33 | extern const uint8_t CIE1931_CURVE[]; | 32 | extern const uint8_t CIE1931_CURVE[]; |
| @@ -36,96 +35,96 @@ extern const uint8_t CIE1931_CURVE[]; | |||
| 36 | /* Driver local definitions. */ | 35 | /* Driver local definitions. */ |
| 37 | /*===========================================================================*/ | 36 | /*===========================================================================*/ |
| 38 | 37 | ||
| 39 | #ifndef GDISP_INITIAL_CONTRAST | 38 | # ifndef GDISP_INITIAL_CONTRAST |
| 40 | #define GDISP_INITIAL_CONTRAST 0 | 39 | # define GDISP_INITIAL_CONTRAST 0 |
| 41 | #endif | 40 | # endif |
| 42 | #ifndef GDISP_INITIAL_BACKLIGHT | 41 | # ifndef GDISP_INITIAL_BACKLIGHT |
| 43 | #define GDISP_INITIAL_BACKLIGHT 0 | 42 | # define GDISP_INITIAL_BACKLIGHT 0 |
| 44 | #endif | 43 | # endif |
| 45 | 44 | ||
| 46 | #define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER<<0) | 45 | # define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER << 0) |
| 47 | 46 | ||
| 48 | #define IS31_ADDR_DEFAULT 0x74 | 47 | # define IS31_ADDR_DEFAULT 0x74 |
| 49 | 48 | ||
| 50 | #define IS31_REG_CONFIG 0x00 | 49 | # define IS31_REG_CONFIG 0x00 |
| 51 | // bits in reg | 50 | // bits in reg |
| 52 | #define IS31_REG_CONFIG_PICTUREMODE 0x00 | 51 | # define IS31_REG_CONFIG_PICTUREMODE 0x00 |
| 53 | #define IS31_REG_CONFIG_AUTOPLAYMODE 0x08 | 52 | # define IS31_REG_CONFIG_AUTOPLAYMODE 0x08 |
| 54 | #define IS31_REG_CONFIG_AUDIOPLAYMODE 0x18 | 53 | # define IS31_REG_CONFIG_AUDIOPLAYMODE 0x18 |
| 55 | // D2:D0 bits are starting frame for autoplay mode | 54 | // D2:D0 bits are starting frame for autoplay mode |
| 56 | 55 | ||
| 57 | #define IS31_REG_PICTDISP 0x01 // D2:D0 frame select for picture mode | 56 | # define IS31_REG_PICTDISP 0x01 // D2:D0 frame select for picture mode |
| 58 | 57 | ||
| 59 | #define IS31_REG_AUTOPLAYCTRL1 0x02 | 58 | # define IS31_REG_AUTOPLAYCTRL1 0x02 |
| 60 | // D6:D4 number of loops (000=infty) | 59 | // D6:D4 number of loops (000=infty) |
| 61 | // D2:D0 number of frames to be used | 60 | // D2:D0 number of frames to be used |
| 62 | 61 | ||
| 63 | #define IS31_REG_AUTOPLAYCTRL2 0x03 // D5:D0 delay time (*11ms) | 62 | # define IS31_REG_AUTOPLAYCTRL2 0x03 // D5:D0 delay time (*11ms) |
| 64 | 63 | ||
| 65 | #define IS31_REG_DISPLAYOPT 0x05 | 64 | # define IS31_REG_DISPLAYOPT 0x05 |
| 66 | #define IS31_REG_DISPLAYOPT_INTENSITY_SAME 0x20 // same intensity for all frames | 65 | # define IS31_REG_DISPLAYOPT_INTENSITY_SAME 0x20 // same intensity for all frames |
| 67 | #define IS31_REG_DISPLAYOPT_BLINK_ENABLE 0x8 | 66 | # define IS31_REG_DISPLAYOPT_BLINK_ENABLE 0x8 |
| 68 | // D2:D0 bits blink period time (*0.27s) | 67 | // D2:D0 bits blink period time (*0.27s) |
| 69 | 68 | ||
| 70 | #define IS31_REG_AUDIOSYNC 0x06 | 69 | # define IS31_REG_AUDIOSYNC 0x06 |
| 71 | #define IS31_REG_AUDIOSYNC_ENABLE 0x1 | 70 | # define IS31_REG_AUDIOSYNC_ENABLE 0x1 |
| 72 | 71 | ||
| 73 | #define IS31_REG_FRAMESTATE 0x07 | 72 | # define IS31_REG_FRAMESTATE 0x07 |
| 74 | 73 | ||
| 75 | #define IS31_REG_BREATHCTRL1 0x08 | 74 | # define IS31_REG_BREATHCTRL1 0x08 |
| 76 | // D6:D4 fade out time (26ms*2^i) | 75 | // D6:D4 fade out time (26ms*2^i) |
| 77 | // D2:D0 fade in time (26ms*2^i) | 76 | // D2:D0 fade in time (26ms*2^i) |
| 78 | 77 | ||
| 79 | #define IS31_REG_BREATHCTRL2 0x09 | 78 | # define IS31_REG_BREATHCTRL2 0x09 |
| 80 | #define IS31_REG_BREATHCTRL2_ENABLE 0x10 | 79 | # define IS31_REG_BREATHCTRL2_ENABLE 0x10 |
| 81 | // D2:D0 extinguish time (3.5ms*2^i) | 80 | // D2:D0 extinguish time (3.5ms*2^i) |
| 82 | 81 | ||
| 83 | #define IS31_REG_SHUTDOWN 0x0A | 82 | # define IS31_REG_SHUTDOWN 0x0A |
| 84 | #define IS31_REG_SHUTDOWN_OFF 0x0 | 83 | # define IS31_REG_SHUTDOWN_OFF 0x0 |
| 85 | #define IS31_REG_SHUTDOWN_ON 0x1 | 84 | # define IS31_REG_SHUTDOWN_ON 0x1 |
| 86 | 85 | ||
| 87 | #define IS31_REG_AGCCTRL 0x0B | 86 | # define IS31_REG_AGCCTRL 0x0B |
| 88 | #define IS31_REG_ADCRATE 0x0C | 87 | # define IS31_REG_ADCRATE 0x0C |
| 89 | 88 | ||
| 90 | #define IS31_COMMANDREGISTER 0xFD | 89 | # define IS31_COMMANDREGISTER 0xFD |
| 91 | #define IS31_FUNCTIONREG 0x0B // helpfully called 'page nine' | 90 | # define IS31_FUNCTIONREG 0x0B // helpfully called 'page nine' |
| 92 | #define IS31_FUNCTIONREG_SIZE 0xD | 91 | # define IS31_FUNCTIONREG_SIZE 0xD |
| 93 | 92 | ||
| 94 | #define IS31_FRAME_SIZE 0xB4 | 93 | # define IS31_FRAME_SIZE 0xB4 |
| 95 | 94 | ||
| 96 | #define IS31_PWM_REG 0x24 | 95 | # define IS31_PWM_REG 0x24 |
| 97 | #define IS31_PWM_SIZE 0x90 | 96 | # define IS31_PWM_SIZE 0x90 |
| 98 | 97 | ||
| 99 | #define IS31_LED_MASK_SIZE 0x12 | 98 | # define IS31_LED_MASK_SIZE 0x12 |
| 100 | 99 | ||
| 101 | #define IS31 | 100 | # define IS31 |
| 102 | 101 | ||
| 103 | /*===========================================================================*/ | 102 | /*===========================================================================*/ |
| 104 | /* Driver local functions. */ | 103 | /* Driver local functions. */ |
| 105 | /*===========================================================================*/ | 104 | /*===========================================================================*/ |
| 106 | 105 | ||
| 107 | typedef struct{ | 106 | typedef struct { |
| 108 | uint8_t write_buffer_offset; | 107 | uint8_t write_buffer_offset; |
| 109 | uint8_t write_buffer[IS31_FRAME_SIZE]; | 108 | uint8_t write_buffer[IS31_FRAME_SIZE]; |
| 110 | uint8_t frame_buffer[GDISP_SCREEN_HEIGHT * GDISP_SCREEN_WIDTH]; | 109 | uint8_t frame_buffer[GDISP_SCREEN_HEIGHT * GDISP_SCREEN_WIDTH]; |
| 111 | uint8_t page; | 110 | uint8_t page; |
| 112 | }__attribute__((__packed__)) PrivData; | 111 | } __attribute__((__packed__)) PrivData; |
| 113 | 112 | ||
| 114 | // Some common routines and macros | 113 | // Some common routines and macros |
| 115 | #define PRIV(g) ((PrivData*)g->priv) | 114 | # define PRIV(g) ((PrivData *)g->priv) |
| 116 | 115 | ||
| 117 | /*===========================================================================*/ | 116 | /*===========================================================================*/ |
| 118 | /* Driver exported functions. */ | 117 | /* Driver exported functions. */ |
| 119 | /*===========================================================================*/ | 118 | /*===========================================================================*/ |
| 120 | 119 | ||
| 121 | static GFXINLINE void write_page(GDisplay* g, uint8_t page) { | 120 | static GFXINLINE void write_page(GDisplay *g, uint8_t page) { |
| 122 | uint8_t tx[2] __attribute__((aligned(2))); | 121 | uint8_t tx[2] __attribute__((aligned(2))); |
| 123 | tx[0] = IS31_COMMANDREGISTER; | 122 | tx[0] = IS31_COMMANDREGISTER; |
| 124 | tx[1] = page; | 123 | tx[1] = page; |
| 125 | write_data(g, tx, 2); | 124 | write_data(g, tx, 2); |
| 126 | } | 125 | } |
| 127 | 126 | ||
| 128 | static GFXINLINE void write_register(GDisplay* g, uint8_t page, uint8_t reg, uint8_t data) { | 127 | static GFXINLINE void write_register(GDisplay *g, uint8_t page, uint8_t reg, uint8_t data) { |
| 129 | uint8_t tx[2] __attribute__((aligned(2))); | 128 | uint8_t tx[2] __attribute__((aligned(2))); |
| 130 | tx[0] = reg; | 129 | tx[0] = reg; |
| 131 | tx[1] = data; | 130 | tx[1] = data; |
| @@ -136,7 +135,7 @@ static GFXINLINE void write_register(GDisplay* g, uint8_t page, uint8_t reg, uin | |||
| 136 | static GFXINLINE void write_ram(GDisplay *g, uint8_t page, uint16_t offset, uint16_t length) { | 135 | static GFXINLINE void write_ram(GDisplay *g, uint8_t page, uint16_t offset, uint16_t length) { |
| 137 | PRIV(g)->write_buffer_offset = offset; | 136 | PRIV(g)->write_buffer_offset = offset; |
| 138 | write_page(g, page); | 137 | write_page(g, page); |
| 139 | write_data(g, (uint8_t*)PRIV(g), length + 1); | 138 | write_data(g, (uint8_t *)PRIV(g), length + 1); |
| 140 | } | 139 | } |
| 141 | 140 | ||
| 142 | LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { | 141 | LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { |
| @@ -160,10 +159,9 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { | |||
| 160 | write_ram(g, IS31_FUNCTIONREG, 0, IS31_FUNCTIONREG_SIZE); | 159 | write_ram(g, IS31_FUNCTIONREG, 0, IS31_FUNCTIONREG_SIZE); |
| 161 | gfxSleepMilliseconds(10); | 160 | gfxSleepMilliseconds(10); |
| 162 | 161 | ||
| 163 | |||
| 164 | // zero all LED registers on all 8 pages, and enable the mask | 162 | // zero all LED registers on all 8 pages, and enable the mask |
| 165 | __builtin_memcpy(PRIV(g)->write_buffer, get_led_mask(g), IS31_LED_MASK_SIZE); | 163 | __builtin_memcpy(PRIV(g)->write_buffer, get_led_mask(g), IS31_LED_MASK_SIZE); |
| 166 | for(uint8_t i=0; i<8; i++) { | 164 | for (uint8_t i = 0; i < 8; i++) { |
| 167 | write_ram(g, i, 0, IS31_FRAME_SIZE); | 165 | write_ram(g, i, 0, IS31_FRAME_SIZE); |
| 168 | gfxSleepMilliseconds(1); | 166 | gfxSleepMilliseconds(1); |
| 169 | } | 167 | } |
| @@ -176,133 +174,129 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { | |||
| 176 | post_init_board(g); | 174 | post_init_board(g); |
| 177 | 175 | ||
| 178 | /* Initialise the GDISP structure */ | 176 | /* Initialise the GDISP structure */ |
| 179 | g->g.Width = GDISP_SCREEN_WIDTH; | 177 | g->g.Width = GDISP_SCREEN_WIDTH; |
| 180 | g->g.Height = GDISP_SCREEN_HEIGHT; | 178 | g->g.Height = GDISP_SCREEN_HEIGHT; |
| 181 | g->g.Orientation = GDISP_ROTATE_0; | 179 | g->g.Orientation = GDISP_ROTATE_0; |
| 182 | g->g.Powermode = powerOff; | 180 | g->g.Powermode = powerOff; |
| 183 | g->g.Backlight = GDISP_INITIAL_BACKLIGHT; | 181 | g->g.Backlight = GDISP_INITIAL_BACKLIGHT; |
| 184 | g->g.Contrast = GDISP_INITIAL_CONTRAST; | 182 | g->g.Contrast = GDISP_INITIAL_CONTRAST; |
| 185 | return TRUE; | 183 | return TRUE; |
| 186 | } | 184 | } |
| 187 | 185 | ||
| 188 | #if GDISP_HARDWARE_FLUSH | 186 | # if GDISP_HARDWARE_FLUSH |
| 189 | LLDSPEC void gdisp_lld_flush(GDisplay *g) { | 187 | LLDSPEC void gdisp_lld_flush(GDisplay *g) { |
| 190 | // Don't flush if we don't need it. | 188 | // Don't flush if we don't need it. |
| 191 | if (!(g->flags & GDISP_FLG_NEEDFLUSH)) | 189 | if (!(g->flags & GDISP_FLG_NEEDFLUSH)) return; |
| 192 | return; | 190 | |
| 193 | 191 | PRIV(g)->page++; | |
| 194 | PRIV(g)->page++; | 192 | PRIV(g)->page %= 2; |
| 195 | PRIV(g)->page %= 2; | 193 | // TODO: some smarter algorithm for this |
| 196 | // TODO: some smarter algorithm for this | 194 | // We should run only one physical page at a time |
| 197 | // We should run only one physical page at a time | 195 | // This way we don't need to send so much data, and |
| 198 | // This way we don't need to send so much data, and | 196 | // we could use slightly less memory |
| 199 | // we could use slightly less memory | 197 | uint8_t *src = PRIV(g)->frame_buffer; |
| 200 | uint8_t* src = PRIV(g)->frame_buffer; | 198 | for (int y = 0; y < GDISP_SCREEN_HEIGHT; y++) { |
| 201 | for (int y=0;y<GDISP_SCREEN_HEIGHT;y++) { | 199 | for (int x = 0; x < GDISP_SCREEN_WIDTH; x++) { |
| 202 | for (int x=0;x<GDISP_SCREEN_WIDTH;x++) { | 200 | uint8_t val = (uint16_t)*src * g->g.Backlight / 100; |
| 203 | uint8_t val = (uint16_t)*src * g->g.Backlight / 100; | 201 | PRIV(g)->write_buffer[get_led_address(g, x, y)] = CIE1931_CURVE[val]; |
| 204 | PRIV(g)->write_buffer[get_led_address(g, x, y)]=CIE1931_CURVE[val]; | 202 | ++src; |
| 205 | ++src; | ||
| 206 | } | ||
| 207 | } | 203 | } |
| 208 | write_ram(g, PRIV(g)->page, IS31_PWM_REG, IS31_PWM_SIZE); | ||
| 209 | gfxSleepMilliseconds(1); | ||
| 210 | write_register(g, IS31_FUNCTIONREG, IS31_REG_PICTDISP, PRIV(g)->page); | ||
| 211 | |||
| 212 | g->flags &= ~GDISP_FLG_NEEDFLUSH; | ||
| 213 | } | 204 | } |
| 214 | #endif | 205 | write_ram(g, PRIV(g)->page, IS31_PWM_REG, IS31_PWM_SIZE); |
| 206 | gfxSleepMilliseconds(1); | ||
| 207 | write_register(g, IS31_FUNCTIONREG, IS31_REG_PICTDISP, PRIV(g)->page); | ||
| 215 | 208 | ||
| 216 | #if GDISP_HARDWARE_DRAWPIXEL | 209 | g->flags &= ~GDISP_FLG_NEEDFLUSH; |
| 217 | LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) { | 210 | } |
| 218 | coord_t x, y; | 211 | # endif |
| 219 | 212 | ||
| 220 | switch(g->g.Orientation) { | 213 | # if GDISP_HARDWARE_DRAWPIXEL |
| 214 | LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) { | ||
| 215 | coord_t x, y; | ||
| 216 | |||
| 217 | switch (g->g.Orientation) { | ||
| 221 | default: | 218 | default: |
| 222 | case GDISP_ROTATE_0: | 219 | case GDISP_ROTATE_0: |
| 223 | x = g->p.x; | 220 | x = g->p.x; |
| 224 | y = g->p.y; | 221 | y = g->p.y; |
| 225 | break; | 222 | break; |
| 226 | case GDISP_ROTATE_180: | 223 | case GDISP_ROTATE_180: |
| 227 | x = GDISP_SCREEN_WIDTH-1 - g->p.x; | 224 | x = GDISP_SCREEN_WIDTH - 1 - g->p.x; |
| 228 | y = g->p.y; | 225 | y = g->p.y; |
| 229 | break; | 226 | break; |
| 230 | } | ||
| 231 | PRIV(g)->frame_buffer[y * GDISP_SCREEN_WIDTH + x] = gdispColor2Native(g->p.color); | ||
| 232 | g->flags |= GDISP_FLG_NEEDFLUSH; | ||
| 233 | } | 227 | } |
| 234 | #endif | 228 | PRIV(g)->frame_buffer[y * GDISP_SCREEN_WIDTH + x] = gdispColor2Native(g->p.color); |
| 229 | g->flags |= GDISP_FLG_NEEDFLUSH; | ||
| 230 | } | ||
| 231 | # endif | ||
| 235 | 232 | ||
| 236 | #if GDISP_HARDWARE_PIXELREAD | 233 | # if GDISP_HARDWARE_PIXELREAD |
| 237 | LLDSPEC color_t gdisp_lld_get_pixel_color(GDisplay *g) { | 234 | LLDSPEC color_t gdisp_lld_get_pixel_color(GDisplay *g) { |
| 238 | coord_t x, y; | 235 | coord_t x, y; |
| 239 | 236 | ||
| 240 | switch(g->g.Orientation) { | 237 | switch (g->g.Orientation) { |
| 241 | default: | 238 | default: |
| 242 | case GDISP_ROTATE_0: | 239 | case GDISP_ROTATE_0: |
| 243 | x = g->p.x; | 240 | x = g->p.x; |
| 244 | y = g->p.y; | 241 | y = g->p.y; |
| 245 | break; | 242 | break; |
| 246 | case GDISP_ROTATE_180: | 243 | case GDISP_ROTATE_180: |
| 247 | x = GDISP_SCREEN_WIDTH-1 - g->p.x; | 244 | x = GDISP_SCREEN_WIDTH - 1 - g->p.x; |
| 248 | y = g->p.y; | 245 | y = g->p.y; |
| 249 | break; | 246 | break; |
| 250 | } | ||
| 251 | return gdispNative2Color(PRIV(g)->frame_buffer[y * GDISP_SCREEN_WIDTH + x]); | ||
| 252 | } | 247 | } |
| 253 | #endif | 248 | return gdispNative2Color(PRIV(g)->frame_buffer[y * GDISP_SCREEN_WIDTH + x]); |
| 249 | } | ||
| 250 | # endif | ||
| 254 | 251 | ||
| 255 | #if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL | 252 | # if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL |
| 256 | LLDSPEC void gdisp_lld_control(GDisplay *g) { | 253 | LLDSPEC void gdisp_lld_control(GDisplay *g) { |
| 257 | switch(g->p.x) { | 254 | switch (g->p.x) { |
| 258 | case GDISP_CONTROL_POWER: | 255 | case GDISP_CONTROL_POWER: |
| 259 | if (g->g.Powermode == (powermode_t)g->p.ptr) | 256 | if (g->g.Powermode == (powermode_t)g->p.ptr) return; |
| 260 | return; | 257 | switch ((powermode_t)g->p.ptr) { |
| 261 | switch((powermode_t)g->p.ptr) { | 258 | case powerOff: |
| 262 | case powerOff: | 259 | case powerSleep: |
| 263 | case powerSleep: | 260 | case powerDeepSleep: |
| 264 | case powerDeepSleep: | 261 | write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_OFF); |
| 265 | write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_OFF); | 262 | break; |
| 266 | break; | 263 | case powerOn: |
| 267 | case powerOn: | 264 | write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_ON); |
| 268 | write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_ON); | 265 | break; |
| 269 | break; | 266 | default: |
| 270 | default: | 267 | return; |
| 271 | return; | ||
| 272 | } | 268 | } |
| 273 | g->g.Powermode = (powermode_t)g->p.ptr; | 269 | g->g.Powermode = (powermode_t)g->p.ptr; |
| 274 | return; | 270 | return; |
| 275 | 271 | ||
| 276 | case GDISP_CONTROL_ORIENTATION: | 272 | case GDISP_CONTROL_ORIENTATION: |
| 277 | if (g->g.Orientation == (orientation_t)g->p.ptr) | 273 | if (g->g.Orientation == (orientation_t)g->p.ptr) return; |
| 278 | return; | 274 | switch ((orientation_t)g->p.ptr) { |
| 279 | switch((orientation_t)g->p.ptr) { | 275 | /* Rotation is handled by the drawing routines */ |
| 280 | /* Rotation is handled by the drawing routines */ | 276 | case GDISP_ROTATE_0: |
| 281 | case GDISP_ROTATE_0: | 277 | case GDISP_ROTATE_180: |
| 282 | case GDISP_ROTATE_180: | 278 | g->g.Height = GDISP_SCREEN_HEIGHT; |
| 283 | g->g.Height = GDISP_SCREEN_HEIGHT; | 279 | g->g.Width = GDISP_SCREEN_WIDTH; |
| 284 | g->g.Width = GDISP_SCREEN_WIDTH; | 280 | break; |
| 285 | break; | 281 | case GDISP_ROTATE_90: |
| 286 | case GDISP_ROTATE_90: | 282 | case GDISP_ROTATE_270: |
| 287 | case GDISP_ROTATE_270: | 283 | g->g.Height = GDISP_SCREEN_WIDTH; |
| 288 | g->g.Height = GDISP_SCREEN_WIDTH; | 284 | g->g.Width = GDISP_SCREEN_HEIGHT; |
| 289 | g->g.Width = GDISP_SCREEN_HEIGHT; | 285 | break; |
| 290 | break; | 286 | default: |
| 291 | default: | 287 | return; |
| 292 | return; | ||
| 293 | } | 288 | } |
| 294 | g->g.Orientation = (orientation_t)g->p.ptr; | 289 | g->g.Orientation = (orientation_t)g->p.ptr; |
| 295 | return; | 290 | return; |
| 296 | 291 | ||
| 297 | case GDISP_CONTROL_BACKLIGHT: | 292 | case GDISP_CONTROL_BACKLIGHT: |
| 298 | if (g->g.Backlight == (unsigned)g->p.ptr) | 293 | if (g->g.Backlight == (unsigned)g->p.ptr) return; |
| 299 | return; | 294 | unsigned val = (unsigned)g->p.ptr; |
| 300 | unsigned val = (unsigned)g->p.ptr; | ||
| 301 | g->g.Backlight = val > 100 ? 100 : val; | 295 | g->g.Backlight = val > 100 ? 100 : val; |
| 302 | g->flags |= GDISP_FLG_NEEDFLUSH; | 296 | g->flags |= GDISP_FLG_NEEDFLUSH; |
| 303 | return; | 297 | return; |
| 304 | } | ||
| 305 | } | 298 | } |
| 306 | #endif // GDISP_NEED_CONTROL | 299 | } |
| 300 | # endif // GDISP_NEED_CONTROL | ||
| 307 | 301 | ||
| 308 | #endif // GFX_USE_GDISP | 302 | #endif // GFX_USE_GDISP |
diff --git a/drivers/ugfx/gdisp/is31fl3731c/gdisp_lld_config.h b/drivers/ugfx/gdisp/is31fl3731c/gdisp_lld_config.h index 588d688cf..1b9fadba1 100644 --- a/drivers/ugfx/gdisp/is31fl3731c/gdisp_lld_config.h +++ b/drivers/ugfx/gdisp/is31fl3731c/gdisp_lld_config.h | |||
| @@ -24,13 +24,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 24 | /* Driver hardware support. */ | 24 | /* Driver hardware support. */ |
| 25 | /*===========================================================================*/ | 25 | /*===========================================================================*/ |
| 26 | 26 | ||
| 27 | #define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing | 27 | # define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing |
| 28 | #define GDISP_HARDWARE_DRAWPIXEL TRUE | 28 | # define GDISP_HARDWARE_DRAWPIXEL TRUE |
| 29 | #define GDISP_HARDWARE_PIXELREAD TRUE | 29 | # define GDISP_HARDWARE_PIXELREAD TRUE |
| 30 | #define GDISP_HARDWARE_CONTROL TRUE | 30 | # define GDISP_HARDWARE_CONTROL TRUE |
| 31 | 31 | ||
| 32 | #define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_GRAY256 | 32 | # define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_GRAY256 |
| 33 | 33 | ||
| 34 | #endif /* GFX_USE_GDISP */ | 34 | #endif /* GFX_USE_GDISP */ |
| 35 | 35 | ||
| 36 | #endif /* _GDISP_LLD_CONFIG_H */ | 36 | #endif /* _GDISP_LLD_CONFIG_H */ |
diff --git a/drivers/ugfx/gdisp/st7565/board_st7565_template.h b/drivers/ugfx/gdisp/st7565/board_st7565_template.h index 9ab636c95..194f8ea24 100644 --- a/drivers/ugfx/gdisp/st7565/board_st7565_template.h +++ b/drivers/ugfx/gdisp/st7565/board_st7565_template.h | |||
| @@ -8,10 +8,10 @@ | |||
| 8 | #ifndef _GDISP_LLD_BOARD_H | 8 | #ifndef _GDISP_LLD_BOARD_H |
| 9 | #define _GDISP_LLD_BOARD_H | 9 | #define _GDISP_LLD_BOARD_H |
| 10 | 10 | ||
| 11 | #define ST7565_LCD_BIAS ST7565_LCD_BIAS_9 // actually 6 | 11 | #define ST7565_LCD_BIAS ST7565_LCD_BIAS_9 // actually 6 |
| 12 | #define ST7565_ADC ST7565_ADC_NORMAL | 12 | #define ST7565_ADC ST7565_ADC_NORMAL |
| 13 | #define ST7565_COM_SCAN ST7565_COM_SCAN_DEC | 13 | #define ST7565_COM_SCAN ST7565_COM_SCAN_DEC |
| 14 | #define ST7565_PAGE_ORDER 0,1,2,3 | 14 | #define ST7565_PAGE_ORDER 0, 1, 2, 3 |
| 15 | /* | 15 | /* |
| 16 | * Custom page order for several LCD boards, e.g. HEM12864-99 | 16 | * Custom page order for several LCD boards, e.g. HEM12864-99 |
| 17 | * #define ST7565_PAGE_ORDER 4,5,6,7,0,1,2,3 | 17 | * #define ST7565_PAGE_ORDER 4,5,6,7,0,1,2,3 |
| @@ -25,11 +25,9 @@ | |||
| 25 | #define ST7565_SLCK_PIN 5 | 25 | #define ST7565_SLCK_PIN 5 |
| 26 | #define ST7565_SS_PIN 4 | 26 | #define ST7565_SS_PIN 4 |
| 27 | 27 | ||
| 28 | #define palSetPadModeRaw(portname, bits) \ | 28 | #define palSetPadModeRaw(portname, bits) ST7565_PORT->PCR[ST7565_##portname##_PIN] = bits |
| 29 | ST7565_PORT->PCR[ST7565_##portname##_PIN] = bits | ||
| 30 | 29 | ||
| 31 | #define palSetPadModeNamed(portname, portmode) \ | 30 | #define palSetPadModeNamed(portname, portmode) palSetPadMode(ST7565_GPIOPORT, ST7565_##portname##_PIN, portmode) |
| 32 | palSetPadMode(ST7565_GPIOPORT, ST7565_##portname##_PIN, portmode) | ||
| 33 | 31 | ||
| 34 | #define ST7565_SPI_MODE PORTx_PCRn_DSE | PORTx_PCRn_MUX(2) | 32 | #define ST7565_SPI_MODE PORTx_PCRn_DSE | PORTx_PCRn_MUX(2) |
| 35 | // DSPI Clock and Transfer Attributes | 33 | // DSPI Clock and Transfer Attributes |
| @@ -37,38 +35,37 @@ | |||
| 37 | // MSB First | 35 | // MSB First |
| 38 | // CLK Low by default | 36 | // CLK Low by default |
| 39 | static const SPIConfig spi1config = { | 37 | static const SPIConfig spi1config = { |
| 40 | // Operation complete callback or @p NULL. | 38 | // Operation complete callback or @p NULL. |
| 41 | .end_cb = NULL, | 39 | .end_cb = NULL, |
| 42 | //The chip select line port - when not using pcs. | 40 | // The chip select line port - when not using pcs. |
| 43 | .ssport = ST7565_GPIOPORT, | 41 | .ssport = ST7565_GPIOPORT, |
| 44 | // brief The chip select line pad number - when not using pcs. | 42 | // brief The chip select line pad number - when not using pcs. |
| 45 | .sspad=ST7565_SS_PIN, | 43 | .sspad = ST7565_SS_PIN, |
| 46 | // SPI initialization data. | 44 | // SPI initialization data. |
| 47 | .tar0 = | 45 | .tar0 = SPIx_CTARn_FMSZ(7) // Frame size = 8 bytes |
| 48 | SPIx_CTARn_FMSZ(7) // Frame size = 8 bytes | 46 | | SPIx_CTARn_ASC(1) // After SCK Delay Scaler (min 50 ns) = 55.56ns |
| 49 | | SPIx_CTARn_ASC(1) // After SCK Delay Scaler (min 50 ns) = 55.56ns | 47 | | SPIx_CTARn_DT(0) // Delay After Transfer Scaler (no minimum)= 27.78ns |
| 50 | | SPIx_CTARn_DT(0) // Delay After Transfer Scaler (no minimum)= 27.78ns | 48 | | SPIx_CTARn_CSSCK(0) // PCS to SCK Delay Scaler (min 20 ns) = 27.78ns |
| 51 | | SPIx_CTARn_CSSCK(0) // PCS to SCK Delay Scaler (min 20 ns) = 27.78ns | 49 | | SPIx_CTARn_PBR(0) // Baud Rate Prescaler = 2 |
| 52 | | SPIx_CTARn_PBR(0) // Baud Rate Prescaler = 2 | 50 | | SPIx_CTARn_BR(0) // Baud rate (min 50ns) = 55.56ns |
| 53 | | SPIx_CTARn_BR(0) // Baud rate (min 50ns) = 55.56ns | ||
| 54 | }; | 51 | }; |
| 55 | 52 | ||
| 56 | static GFXINLINE void acquire_bus(GDisplay *g) { | 53 | static GFXINLINE void acquire_bus(GDisplay *g) { |
| 57 | (void) g; | 54 | (void)g; |
| 58 | // Only the LCD is using the SPI bus, so no need to acquire | 55 | // Only the LCD is using the SPI bus, so no need to acquire |
| 59 | // spiAcquireBus(&SPID1); | 56 | // spiAcquireBus(&SPID1); |
| 60 | spiSelect(&SPID1); | 57 | spiSelect(&SPID1); |
| 61 | } | 58 | } |
| 62 | 59 | ||
| 63 | static GFXINLINE void release_bus(GDisplay *g) { | 60 | static GFXINLINE void release_bus(GDisplay *g) { |
| 64 | (void) g; | 61 | (void)g; |
| 65 | // Only the LCD is using the SPI bus, so no need to release | 62 | // Only the LCD is using the SPI bus, so no need to release |
| 66 | //spiReleaseBus(&SPID1); | 63 | // spiReleaseBus(&SPID1); |
| 67 | spiUnselect(&SPID1); | 64 | spiUnselect(&SPID1); |
| 68 | } | 65 | } |
| 69 | 66 | ||
| 70 | static GFXINLINE void init_board(GDisplay *g) { | 67 | static GFXINLINE void init_board(GDisplay *g) { |
| 71 | (void) g; | 68 | (void)g; |
| 72 | palSetPadModeNamed(A0, PAL_MODE_OUTPUT_PUSHPULL); | 69 | palSetPadModeNamed(A0, PAL_MODE_OUTPUT_PUSHPULL); |
| 73 | palSetPad(ST7565_GPIOPORT, ST7565_A0_PIN); | 70 | palSetPad(ST7565_GPIOPORT, ST7565_A0_PIN); |
| 74 | palSetPadModeNamed(RST, PAL_MODE_OUTPUT_PUSHPULL); | 71 | palSetPadModeNamed(RST, PAL_MODE_OUTPUT_PUSHPULL); |
| @@ -82,31 +79,23 @@ static GFXINLINE void init_board(GDisplay *g) { | |||
| 82 | release_bus(g); | 79 | release_bus(g); |
| 83 | } | 80 | } |
| 84 | 81 | ||
| 85 | static GFXINLINE void post_init_board(GDisplay *g) { | 82 | static GFXINLINE void post_init_board(GDisplay *g) { (void)g; } |
| 86 | (void) g; | ||
| 87 | } | ||
| 88 | 83 | ||
| 89 | static GFXINLINE void setpin_reset(GDisplay *g, bool_t state) { | 84 | static GFXINLINE void setpin_reset(GDisplay *g, bool_t state) { |
| 90 | (void) g; | 85 | (void)g; |
| 91 | if (state) { | 86 | if (state) { |
| 92 | palClearPad(ST7565_GPIOPORT, ST7565_RST_PIN); | 87 | palClearPad(ST7565_GPIOPORT, ST7565_RST_PIN); |
| 93 | } | 88 | } else { |
| 94 | else { | ||
| 95 | palSetPad(ST7565_GPIOPORT, ST7565_RST_PIN); | 89 | palSetPad(ST7565_GPIOPORT, ST7565_RST_PIN); |
| 96 | } | 90 | } |
| 97 | } | 91 | } |
| 98 | 92 | ||
| 99 | static GFXINLINE void enter_data_mode(GDisplay *g) { | 93 | static GFXINLINE void enter_data_mode(GDisplay *g) { palSetPad(ST7565_GPIOPORT, ST7565_A0_PIN); } |
| 100 | palSetPad(ST7565_GPIOPORT, ST7565_A0_PIN); | ||
| 101 | } | ||
| 102 | |||
| 103 | static GFXINLINE void enter_cmd_mode(GDisplay *g) { | ||
| 104 | palClearPad(ST7565_GPIOPORT, ST7565_A0_PIN); | ||
| 105 | } | ||
| 106 | 94 | ||
| 95 | static GFXINLINE void enter_cmd_mode(GDisplay *g) { palClearPad(ST7565_GPIOPORT, ST7565_A0_PIN); } | ||
| 107 | 96 | ||
| 108 | static GFXINLINE void write_data(GDisplay *g, uint8_t* data, uint16_t length) { | 97 | static GFXINLINE void write_data(GDisplay *g, uint8_t *data, uint16_t length) { |
| 109 | (void) g; | 98 | (void)g; |
| 110 | spiSend(&SPID1, length, data); | 99 | spiSend(&SPID1, length, data); |
| 111 | } | 100 | } |
| 112 | 101 | ||
diff --git a/drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c b/drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c index c38194b06..fde320981 100644 --- a/drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c +++ b/drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c | |||
| @@ -9,82 +9,89 @@ | |||
| 9 | 9 | ||
| 10 | #if GFX_USE_GDISP | 10 | #if GFX_USE_GDISP |
| 11 | 11 | ||
| 12 | #define GDISP_DRIVER_VMT GDISPVMT_ST7565_QMK | 12 | # define GDISP_DRIVER_VMT GDISPVMT_ST7565_QMK |
| 13 | #include "gdisp_lld_config.h" | 13 | # include "gdisp_lld_config.h" |
| 14 | #include "src/gdisp/gdisp_driver.h" | 14 | # include "src/gdisp/gdisp_driver.h" |
| 15 | 15 | ||
| 16 | #include "board_st7565.h" | 16 | # include "board_st7565.h" |
| 17 | 17 | ||
| 18 | /*===========================================================================*/ | 18 | /*===========================================================================*/ |
| 19 | /* Driver local definitions. */ | 19 | /* Driver local definitions. */ |
| 20 | /*===========================================================================*/ | 20 | /*===========================================================================*/ |
| 21 | 21 | ||
| 22 | #ifndef GDISP_SCREEN_HEIGHT | 22 | # ifndef GDISP_SCREEN_HEIGHT |
| 23 | #define GDISP_SCREEN_HEIGHT LCD_HEIGHT | 23 | # define GDISP_SCREEN_HEIGHT LCD_HEIGHT |
| 24 | #endif | 24 | # endif |
| 25 | #ifndef GDISP_SCREEN_WIDTH | 25 | # ifndef GDISP_SCREEN_WIDTH |
| 26 | #define GDISP_SCREEN_WIDTH LCD_WIDTH | 26 | # define GDISP_SCREEN_WIDTH LCD_WIDTH |
| 27 | #endif | 27 | # endif |
| 28 | #ifndef GDISP_INITIAL_CONTRAST | 28 | # ifndef GDISP_INITIAL_CONTRAST |
| 29 | #define GDISP_INITIAL_CONTRAST 35 | 29 | # define GDISP_INITIAL_CONTRAST 35 |
| 30 | #endif | 30 | # endif |
| 31 | #ifndef GDISP_INITIAL_BACKLIGHT | 31 | # ifndef GDISP_INITIAL_BACKLIGHT |
| 32 | #define GDISP_INITIAL_BACKLIGHT 100 | 32 | # define GDISP_INITIAL_BACKLIGHT 100 |
| 33 | #endif | 33 | # endif |
| 34 | 34 | ||
| 35 | #define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER<<0) | 35 | # define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER << 0) |
| 36 | 36 | ||
| 37 | #include "st7565.h" | 37 | # include "st7565.h" |
| 38 | 38 | ||
| 39 | /*===========================================================================*/ | 39 | /*===========================================================================*/ |
| 40 | /* Driver config defaults for backward compatibility. */ | 40 | /* Driver config defaults for backward compatibility. */ |
| 41 | /*===========================================================================*/ | 41 | /*===========================================================================*/ |
| 42 | #ifndef ST7565_LCD_BIAS | 42 | # ifndef ST7565_LCD_BIAS |
| 43 | #define ST7565_LCD_BIAS ST7565_LCD_BIAS_7 | 43 | # define ST7565_LCD_BIAS ST7565_LCD_BIAS_7 |
| 44 | #endif | 44 | # endif |
| 45 | #ifndef ST7565_ADC | 45 | # ifndef ST7565_ADC |
| 46 | #define ST7565_ADC ST7565_ADC_NORMAL | 46 | # define ST7565_ADC ST7565_ADC_NORMAL |
| 47 | #endif | 47 | # endif |
| 48 | #ifndef ST7565_COM_SCAN | 48 | # ifndef ST7565_COM_SCAN |
| 49 | #define ST7565_COM_SCAN ST7565_COM_SCAN_INC | 49 | # define ST7565_COM_SCAN ST7565_COM_SCAN_INC |
| 50 | #endif | 50 | # endif |
| 51 | #ifndef ST7565_PAGE_ORDER | 51 | # ifndef ST7565_PAGE_ORDER |
| 52 | #define ST7565_PAGE_ORDER 0,1,2,3 | 52 | # define ST7565_PAGE_ORDER 0, 1, 2, 3 |
| 53 | #endif | 53 | # endif |
| 54 | 54 | ||
| 55 | /*===========================================================================*/ | 55 | /*===========================================================================*/ |
| 56 | /* Driver local functions. */ | 56 | /* Driver local functions. */ |
| 57 | /*===========================================================================*/ | 57 | /*===========================================================================*/ |
| 58 | 58 | ||
| 59 | typedef struct{ | 59 | typedef struct { |
| 60 | bool_t buffer2; | 60 | bool_t buffer2; |
| 61 | uint8_t data_pos; | 61 | uint8_t data_pos; |
| 62 | uint8_t data[16]; | 62 | uint8_t data[16]; |
| 63 | uint8_t ram[GDISP_SCREEN_HEIGHT * GDISP_SCREEN_WIDTH / 8]; | 63 | uint8_t ram[GDISP_SCREEN_HEIGHT * GDISP_SCREEN_WIDTH / 8]; |
| 64 | }PrivData; | 64 | } PrivData; |
| 65 | 65 | ||
| 66 | // Some common routines and macros | 66 | // Some common routines and macros |
| 67 | #define PRIV(g) ((PrivData*)g->priv) | 67 | # define PRIV(g) ((PrivData *)g->priv) |
| 68 | #define RAM(g) (PRIV(g)->ram) | 68 | # define RAM(g) (PRIV(g)->ram) |
| 69 | 69 | ||
| 70 | static GFXINLINE void write_cmd(GDisplay* g, uint8_t cmd) { | 70 | static GFXINLINE void write_cmd(GDisplay *g, uint8_t cmd) { PRIV(g)->data[PRIV(g)->data_pos++] = cmd; } |
| 71 | PRIV(g)->data[PRIV(g)->data_pos++] = cmd; | ||
| 72 | } | ||
| 73 | 71 | ||
| 74 | static GFXINLINE void flush_cmd(GDisplay* g) { | 72 | static GFXINLINE void flush_cmd(GDisplay *g) { |
| 75 | write_data(g, PRIV(g)->data, PRIV(g)->data_pos); | 73 | write_data(g, PRIV(g)->data, PRIV(g)->data_pos); |
| 76 | PRIV(g)->data_pos = 0; | 74 | PRIV(g)->data_pos = 0; |
| 77 | } | 75 | } |
| 78 | 76 | ||
| 79 | #define write_cmd2(g, cmd1, cmd2) { write_cmd(g, cmd1); write_cmd(g, cmd2); } | 77 | # define write_cmd2(g, cmd1, cmd2) \ |
| 80 | #define write_cmd3(g, cmd1, cmd2, cmd3) { write_cmd(g, cmd1); write_cmd(g, cmd2); write_cmd(g, cmd3); } | 78 | { \ |
| 79 | write_cmd(g, cmd1); \ | ||
| 80 | write_cmd(g, cmd2); \ | ||
| 81 | } | ||
| 82 | # define write_cmd3(g, cmd1, cmd2, cmd3) \ | ||
| 83 | { \ | ||
| 84 | write_cmd(g, cmd1); \ | ||
| 85 | write_cmd(g, cmd2); \ | ||
| 86 | write_cmd(g, cmd3); \ | ||
| 87 | } | ||
| 81 | 88 | ||
| 82 | // Some common routines and macros | 89 | // Some common routines and macros |
| 83 | #define delay(us) gfxSleepMicroseconds(us) | 90 | # define delay(us) gfxSleepMicroseconds(us) |
| 84 | #define delay_ms(ms) gfxSleepMilliseconds(ms) | 91 | # define delay_ms(ms) gfxSleepMilliseconds(ms) |
| 85 | 92 | ||
| 86 | #define xyaddr(x, y) ((x) + ((y)>>3)*GDISP_SCREEN_WIDTH) | 93 | # define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_SCREEN_WIDTH) |
| 87 | #define xybit(y) (1<<((y)&7)) | 94 | # define xybit(y) (1 << ((y)&7)) |
| 88 | 95 | ||
| 89 | /*===========================================================================*/ | 96 | /*===========================================================================*/ |
| 90 | /* Driver exported functions. */ | 97 | /* Driver exported functions. */ |
| @@ -99,8 +106,8 @@ static GFXINLINE void flush_cmd(GDisplay* g) { | |||
| 99 | 106 | ||
| 100 | LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { | 107 | LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { |
| 101 | // The private area is the display surface. | 108 | // The private area is the display surface. |
| 102 | g->priv = gfxAlloc(sizeof(PrivData)); | 109 | g->priv = gfxAlloc(sizeof(PrivData)); |
| 103 | PRIV(g)->buffer2 = false; | 110 | PRIV(g)->buffer2 = false; |
| 104 | PRIV(g)->data_pos = 0; | 111 | PRIV(g)->data_pos = 0; |
| 105 | 112 | ||
| 106 | // Initialise the board interface | 113 | // Initialise the board interface |
| @@ -139,22 +146,21 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { | |||
| 139 | release_bus(g); | 146 | release_bus(g); |
| 140 | 147 | ||
| 141 | /* Initialise the GDISP structure */ | 148 | /* Initialise the GDISP structure */ |
| 142 | g->g.Width = GDISP_SCREEN_WIDTH; | 149 | g->g.Width = GDISP_SCREEN_WIDTH; |
| 143 | g->g.Height = GDISP_SCREEN_HEIGHT; | 150 | g->g.Height = GDISP_SCREEN_HEIGHT; |
| 144 | g->g.Orientation = GDISP_ROTATE_0; | 151 | g->g.Orientation = GDISP_ROTATE_0; |
| 145 | g->g.Powermode = powerOff; | 152 | g->g.Powermode = powerOff; |
| 146 | g->g.Backlight = GDISP_INITIAL_BACKLIGHT; | 153 | g->g.Backlight = GDISP_INITIAL_BACKLIGHT; |
| 147 | g->g.Contrast = GDISP_INITIAL_CONTRAST; | 154 | g->g.Contrast = GDISP_INITIAL_CONTRAST; |
| 148 | return TRUE; | 155 | return TRUE; |
| 149 | } | 156 | } |
| 150 | 157 | ||
| 151 | #if GDISP_HARDWARE_FLUSH | 158 | # if GDISP_HARDWARE_FLUSH |
| 152 | LLDSPEC void gdisp_lld_flush(GDisplay *g) { | 159 | LLDSPEC void gdisp_lld_flush(GDisplay *g) { |
| 153 | unsigned p; | 160 | unsigned p; |
| 154 | 161 | ||
| 155 | // Don't flush if we don't need it. | 162 | // Don't flush if we don't need it. |
| 156 | if (!(g->flags & GDISP_FLG_NEEDFLUSH)) | 163 | if (!(g->flags & GDISP_FLG_NEEDFLUSH)) return; |
| 157 | return; | ||
| 158 | 164 | ||
| 159 | acquire_bus(g); | 165 | acquire_bus(g); |
| 160 | enter_cmd_mode(g); | 166 | enter_cmd_mode(g); |
| @@ -166,7 +172,7 @@ LLDSPEC void gdisp_lld_flush(GDisplay *g) { | |||
| 166 | write_cmd(g, ST7565_RMW); | 172 | write_cmd(g, ST7565_RMW); |
| 167 | flush_cmd(g); | 173 | flush_cmd(g); |
| 168 | enter_data_mode(g); | 174 | enter_data_mode(g); |
| 169 | write_data(g, RAM(g) + (p*GDISP_SCREEN_WIDTH), GDISP_SCREEN_WIDTH); | 175 | write_data(g, RAM(g) + (p * GDISP_SCREEN_WIDTH), GDISP_SCREEN_WIDTH); |
| 170 | enter_cmd_mode(g); | 176 | enter_cmd_mode(g); |
| 171 | } | 177 | } |
| 172 | unsigned line = (PRIV(g)->buffer2 ? 32 : 0); | 178 | unsigned line = (PRIV(g)->buffer2 ? 32 : 0); |
| @@ -177,30 +183,30 @@ LLDSPEC void gdisp_lld_flush(GDisplay *g) { | |||
| 177 | 183 | ||
| 178 | g->flags &= ~GDISP_FLG_NEEDFLUSH; | 184 | g->flags &= ~GDISP_FLG_NEEDFLUSH; |
| 179 | } | 185 | } |
| 180 | #endif | 186 | # endif |
| 181 | 187 | ||
| 182 | #if GDISP_HARDWARE_DRAWPIXEL | 188 | # if GDISP_HARDWARE_DRAWPIXEL |
| 183 | LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) { | 189 | LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) { |
| 184 | coord_t x, y; | 190 | coord_t x, y; |
| 185 | 191 | ||
| 186 | switch(g->g.Orientation) { | 192 | switch (g->g.Orientation) { |
| 187 | default: | 193 | default: |
| 188 | case GDISP_ROTATE_0: | 194 | case GDISP_ROTATE_0: |
| 189 | x = g->p.x; | 195 | x = g->p.x; |
| 190 | y = g->p.y; | 196 | y = g->p.y; |
| 191 | break; | 197 | break; |
| 192 | case GDISP_ROTATE_90: | 198 | case GDISP_ROTATE_90: |
| 193 | x = g->p.y; | 199 | x = g->p.y; |
| 194 | y = GDISP_SCREEN_HEIGHT-1 - g->p.x; | 200 | y = GDISP_SCREEN_HEIGHT - 1 - g->p.x; |
| 195 | break; | 201 | break; |
| 196 | case GDISP_ROTATE_180: | 202 | case GDISP_ROTATE_180: |
| 197 | x = GDISP_SCREEN_WIDTH-1 - g->p.x; | 203 | x = GDISP_SCREEN_WIDTH - 1 - g->p.x; |
| 198 | y = GDISP_SCREEN_HEIGHT-1 - g->p.y; | 204 | y = GDISP_SCREEN_HEIGHT - 1 - g->p.y; |
| 199 | break; | 205 | break; |
| 200 | case GDISP_ROTATE_270: | 206 | case GDISP_ROTATE_270: |
| 201 | x = GDISP_SCREEN_HEIGHT-1 - g->p.y; | 207 | x = GDISP_SCREEN_HEIGHT - 1 - g->p.y; |
| 202 | y = g->p.x; | 208 | y = g->p.x; |
| 203 | break; | 209 | break; |
| 204 | } | 210 | } |
| 205 | if (gdispColor2Native(g->p.color) != Black) | 211 | if (gdispColor2Native(g->p.color) != Black) |
| 206 | RAM(g)[xyaddr(x, y)] |= xybit(y); | 212 | RAM(g)[xyaddr(x, y)] |= xybit(y); |
| @@ -208,53 +214,52 @@ LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) { | |||
| 208 | RAM(g)[xyaddr(x, y)] &= ~xybit(y); | 214 | RAM(g)[xyaddr(x, y)] &= ~xybit(y); |
| 209 | g->flags |= GDISP_FLG_NEEDFLUSH; | 215 | g->flags |= GDISP_FLG_NEEDFLUSH; |
| 210 | } | 216 | } |
| 211 | #endif | 217 | # endif |
| 212 | 218 | ||
| 213 | #if GDISP_HARDWARE_PIXELREAD | 219 | # if GDISP_HARDWARE_PIXELREAD |
| 214 | LLDSPEC color_t gdisp_lld_get_pixel_color(GDisplay *g) { | 220 | LLDSPEC color_t gdisp_lld_get_pixel_color(GDisplay *g) { |
| 215 | coord_t x, y; | 221 | coord_t x, y; |
| 216 | 222 | ||
| 217 | switch(g->g.Orientation) { | 223 | switch (g->g.Orientation) { |
| 218 | default: | 224 | default: |
| 219 | case GDISP_ROTATE_0: | 225 | case GDISP_ROTATE_0: |
| 220 | x = g->p.x; | 226 | x = g->p.x; |
| 221 | y = g->p.y; | 227 | y = g->p.y; |
| 222 | break; | 228 | break; |
| 223 | case GDISP_ROTATE_90: | 229 | case GDISP_ROTATE_90: |
| 224 | x = g->p.y; | 230 | x = g->p.y; |
| 225 | y = GDISP_SCREEN_HEIGHT-1 - g->p.x; | 231 | y = GDISP_SCREEN_HEIGHT - 1 - g->p.x; |
| 226 | break; | 232 | break; |
| 227 | case GDISP_ROTATE_180: | 233 | case GDISP_ROTATE_180: |
| 228 | x = GDISP_SCREEN_WIDTH-1 - g->p.x; | 234 | x = GDISP_SCREEN_WIDTH - 1 - g->p.x; |
| 229 | y = GDISP_SCREEN_HEIGHT-1 - g->p.y; | 235 | y = GDISP_SCREEN_HEIGHT - 1 - g->p.y; |
| 230 | break; | 236 | break; |
| 231 | case GDISP_ROTATE_270: | 237 | case GDISP_ROTATE_270: |
| 232 | x = GDISP_SCREEN_HEIGHT-1 - g->p.y; | 238 | x = GDISP_SCREEN_HEIGHT - 1 - g->p.y; |
| 233 | y = g->p.x; | 239 | y = g->p.x; |
| 234 | break; | 240 | break; |
| 235 | } | 241 | } |
| 236 | return (RAM(g)[xyaddr(x, y)] & xybit(y)) ? White : Black; | 242 | return (RAM(g)[xyaddr(x, y)] & xybit(y)) ? White : Black; |
| 237 | } | 243 | } |
| 238 | #endif | 244 | # endif |
| 239 | 245 | ||
| 240 | LLDSPEC void gdisp_lld_blit_area(GDisplay *g) { | 246 | LLDSPEC void gdisp_lld_blit_area(GDisplay *g) { |
| 241 | uint8_t* buffer = (uint8_t*)g->p.ptr; | 247 | uint8_t *buffer = (uint8_t *)g->p.ptr; |
| 242 | int linelength = g->p.cx; | 248 | int linelength = g->p.cx; |
| 243 | for (int i = 0; i < g->p.cy; i++) { | 249 | for (int i = 0; i < g->p.cy; i++) { |
| 244 | unsigned dstx = g->p.x; | 250 | unsigned dstx = g->p.x; |
| 245 | unsigned dsty = g->p.y + i; | 251 | unsigned dsty = g->p.y + i; |
| 246 | unsigned srcx = g->p.x1; | 252 | unsigned srcx = g->p.x1; |
| 247 | unsigned srcy = g->p.y1 + i; | 253 | unsigned srcy = g->p.y1 + i; |
| 248 | unsigned srcbit = srcy * g->p.x2 + srcx; | 254 | unsigned srcbit = srcy * g->p.x2 + srcx; |
| 249 | for(int j=0; j < linelength; j++) { | 255 | for (int j = 0; j < linelength; j++) { |
| 250 | uint8_t src = buffer[srcbit / 8]; | 256 | uint8_t src = buffer[srcbit / 8]; |
| 251 | uint8_t bit = 7-(srcbit % 8); | 257 | uint8_t bit = 7 - (srcbit % 8); |
| 252 | uint8_t bitset = (src >> bit) & 1; | 258 | uint8_t bitset = (src >> bit) & 1; |
| 253 | uint8_t* dst = &(RAM(g)[xyaddr(dstx, dsty)]); | 259 | uint8_t *dst = &(RAM(g)[xyaddr(dstx, dsty)]); |
| 254 | if (bitset) { | 260 | if (bitset) { |
| 255 | *dst |= xybit(dsty); | 261 | *dst |= xybit(dsty); |
| 256 | } | 262 | } else { |
| 257 | else { | ||
| 258 | *dst &= ~xybit(dsty); | 263 | *dst &= ~xybit(dsty); |
| 259 | } | 264 | } |
| 260 | dstx++; | 265 | dstx++; |
| @@ -264,66 +269,64 @@ LLDSPEC void gdisp_lld_blit_area(GDisplay *g) { | |||
| 264 | g->flags |= GDISP_FLG_NEEDFLUSH; | 269 | g->flags |= GDISP_FLG_NEEDFLUSH; |
| 265 | } | 270 | } |
| 266 | 271 | ||
| 267 | #if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL | 272 | # if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL |
| 268 | LLDSPEC void gdisp_lld_control(GDisplay *g) { | 273 | LLDSPEC void gdisp_lld_control(GDisplay *g) { |
| 269 | switch(g->p.x) { | 274 | switch (g->p.x) { |
| 270 | case GDISP_CONTROL_POWER: | 275 | case GDISP_CONTROL_POWER: |
| 271 | if (g->g.Powermode == (powermode_t)g->p.ptr) | 276 | if (g->g.Powermode == (powermode_t)g->p.ptr) return; |
| 272 | return; | 277 | switch ((powermode_t)g->p.ptr) { |
| 273 | switch((powermode_t)g->p.ptr) { | 278 | case powerOff: |
| 274 | case powerOff: | 279 | case powerSleep: |
| 275 | case powerSleep: | 280 | case powerDeepSleep: |
| 276 | case powerDeepSleep: | 281 | acquire_bus(g); |
| 277 | acquire_bus(g); | 282 | enter_cmd_mode(g); |
| 278 | enter_cmd_mode(g); | 283 | write_cmd(g, ST7565_DISPLAY_OFF); |
| 279 | write_cmd(g, ST7565_DISPLAY_OFF); | 284 | flush_cmd(g); |
| 280 | flush_cmd(g); | 285 | release_bus(g); |
| 281 | release_bus(g); | 286 | break; |
| 282 | break; | 287 | case powerOn: |
| 283 | case powerOn: | 288 | acquire_bus(g); |
| 284 | acquire_bus(g); | 289 | enter_cmd_mode(g); |
| 285 | enter_cmd_mode(g); | 290 | write_cmd(g, ST7565_DISPLAY_ON); |
| 286 | write_cmd(g, ST7565_DISPLAY_ON); | 291 | flush_cmd(g); |
| 287 | flush_cmd(g); | 292 | release_bus(g); |
| 288 | release_bus(g); | 293 | break; |
| 289 | break; | 294 | default: |
| 290 | default: | 295 | return; |
| 296 | } | ||
| 297 | g->g.Powermode = (powermode_t)g->p.ptr; | ||
| 291 | return; | 298 | return; |
| 292 | } | ||
| 293 | g->g.Powermode = (powermode_t)g->p.ptr; | ||
| 294 | return; | ||
| 295 | 299 | ||
| 296 | case GDISP_CONTROL_ORIENTATION: | 300 | case GDISP_CONTROL_ORIENTATION: |
| 297 | if (g->g.Orientation == (orientation_t)g->p.ptr) | 301 | if (g->g.Orientation == (orientation_t)g->p.ptr) return; |
| 298 | return; | 302 | switch ((orientation_t)g->p.ptr) { |
| 299 | switch((orientation_t)g->p.ptr) { | 303 | /* Rotation is handled by the drawing routines */ |
| 300 | /* Rotation is handled by the drawing routines */ | 304 | case GDISP_ROTATE_0: |
| 301 | case GDISP_ROTATE_0: | 305 | case GDISP_ROTATE_180: |
| 302 | case GDISP_ROTATE_180: | 306 | g->g.Height = GDISP_SCREEN_HEIGHT; |
| 303 | g->g.Height = GDISP_SCREEN_HEIGHT; | 307 | g->g.Width = GDISP_SCREEN_WIDTH; |
| 304 | g->g.Width = GDISP_SCREEN_WIDTH; | 308 | break; |
| 305 | break; | 309 | case GDISP_ROTATE_90: |
| 306 | case GDISP_ROTATE_90: | 310 | case GDISP_ROTATE_270: |
| 307 | case GDISP_ROTATE_270: | 311 | g->g.Height = GDISP_SCREEN_WIDTH; |
| 308 | g->g.Height = GDISP_SCREEN_WIDTH; | 312 | g->g.Width = GDISP_SCREEN_HEIGHT; |
| 309 | g->g.Width = GDISP_SCREEN_HEIGHT; | 313 | break; |
| 310 | break; | 314 | default: |
| 311 | default: | 315 | return; |
| 312 | return; | ||
| 313 | } | 316 | } |
| 314 | g->g.Orientation = (orientation_t)g->p.ptr; | 317 | g->g.Orientation = (orientation_t)g->p.ptr; |
| 315 | return; | 318 | return; |
| 316 | 319 | ||
| 317 | case GDISP_CONTROL_CONTRAST: | 320 | case GDISP_CONTROL_CONTRAST: |
| 318 | g->g.Contrast = (unsigned)g->p.ptr & 63; | 321 | g->g.Contrast = (unsigned)g->p.ptr & 63; |
| 319 | acquire_bus(g); | 322 | acquire_bus(g); |
| 320 | enter_cmd_mode(g); | 323 | enter_cmd_mode(g); |
| 321 | write_cmd2(g, ST7565_CONTRAST, g->g.Contrast); | 324 | write_cmd2(g, ST7565_CONTRAST, g->g.Contrast); |
| 322 | flush_cmd(g); | 325 | flush_cmd(g); |
| 323 | release_bus(g); | 326 | release_bus(g); |
| 324 | return; | 327 | return; |
| 325 | } | 328 | } |
| 326 | } | 329 | } |
| 327 | #endif // GDISP_NEED_CONTROL | 330 | # endif // GDISP_NEED_CONTROL |
| 328 | 331 | ||
| 329 | #endif // GFX_USE_GDISP | 332 | #endif // GFX_USE_GDISP |
diff --git a/drivers/ugfx/gdisp/st7565/gdisp_lld_config.h b/drivers/ugfx/gdisp/st7565/gdisp_lld_config.h index 4446bd38b..9ab5daac1 100644 --- a/drivers/ugfx/gdisp/st7565/gdisp_lld_config.h +++ b/drivers/ugfx/gdisp/st7565/gdisp_lld_config.h | |||
| @@ -14,14 +14,14 @@ | |||
| 14 | /* Driver hardware support. */ | 14 | /* Driver hardware support. */ |
| 15 | /*===========================================================================*/ | 15 | /*===========================================================================*/ |
| 16 | 16 | ||
| 17 | #define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing | 17 | # define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing |
| 18 | #define GDISP_HARDWARE_DRAWPIXEL TRUE | 18 | # define GDISP_HARDWARE_DRAWPIXEL TRUE |
| 19 | #define GDISP_HARDWARE_PIXELREAD TRUE | 19 | # define GDISP_HARDWARE_PIXELREAD TRUE |
| 20 | #define GDISP_HARDWARE_CONTROL TRUE | 20 | # define GDISP_HARDWARE_CONTROL TRUE |
| 21 | #define GDISP_HARDWARE_BITFILLS TRUE | 21 | # define GDISP_HARDWARE_BITFILLS TRUE |
| 22 | 22 | ||
| 23 | #define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO | 23 | # define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO |
| 24 | 24 | ||
| 25 | #endif /* GFX_USE_GDISP */ | 25 | #endif /* GFX_USE_GDISP */ |
| 26 | 26 | ||
| 27 | #endif /* _GDISP_LLD_CONFIG_H */ | 27 | #endif /* _GDISP_LLD_CONFIG_H */ |
diff --git a/drivers/ugfx/gdisp/st7565/st7565.h b/drivers/ugfx/gdisp/st7565/st7565.h index 24924ff05..3c77a8856 100644 --- a/drivers/ugfx/gdisp/st7565/st7565.h +++ b/drivers/ugfx/gdisp/st7565/st7565.h | |||
| @@ -8,32 +8,32 @@ | |||
| 8 | #ifndef _ST7565_H | 8 | #ifndef _ST7565_H |
| 9 | #define _ST7565_H | 9 | #define _ST7565_H |
| 10 | 10 | ||
| 11 | #define ST7565_CONTRAST 0x81 | 11 | #define ST7565_CONTRAST 0x81 |
| 12 | #define ST7565_ALLON_NORMAL 0xA4 | 12 | #define ST7565_ALLON_NORMAL 0xA4 |
| 13 | #define ST7565_ALLON 0xA5 | 13 | #define ST7565_ALLON 0xA5 |
| 14 | #define ST7565_POSITIVE_DISPLAY 0xA6 | 14 | #define ST7565_POSITIVE_DISPLAY 0xA6 |
| 15 | #define ST7565_INVERT_DISPLAY 0xA7 | 15 | #define ST7565_INVERT_DISPLAY 0xA7 |
| 16 | #define ST7565_DISPLAY_OFF 0xAE | 16 | #define ST7565_DISPLAY_OFF 0xAE |
| 17 | #define ST7565_DISPLAY_ON 0xAF | 17 | #define ST7565_DISPLAY_ON 0xAF |
| 18 | 18 | ||
| 19 | #define ST7565_LCD_BIAS_7 0xA3 | 19 | #define ST7565_LCD_BIAS_7 0xA3 |
| 20 | #define ST7565_LCD_BIAS_9 0xA2 | 20 | #define ST7565_LCD_BIAS_9 0xA2 |
| 21 | 21 | ||
| 22 | #define ST7565_ADC_NORMAL 0xA0 | 22 | #define ST7565_ADC_NORMAL 0xA0 |
| 23 | #define ST7565_ADC_REVERSE 0xA1 | 23 | #define ST7565_ADC_REVERSE 0xA1 |
| 24 | 24 | ||
| 25 | #define ST7565_COM_SCAN_INC 0xC0 | 25 | #define ST7565_COM_SCAN_INC 0xC0 |
| 26 | #define ST7565_COM_SCAN_DEC 0xC8 | 26 | #define ST7565_COM_SCAN_DEC 0xC8 |
| 27 | 27 | ||
| 28 | #define ST7565_START_LINE 0x40 | 28 | #define ST7565_START_LINE 0x40 |
| 29 | #define ST7565_PAGE 0xB0 | 29 | #define ST7565_PAGE 0xB0 |
| 30 | #define ST7565_COLUMN_MSB 0x10 | 30 | #define ST7565_COLUMN_MSB 0x10 |
| 31 | #define ST7565_COLUMN_LSB 0x00 | 31 | #define ST7565_COLUMN_LSB 0x00 |
| 32 | #define ST7565_RMW 0xE0 | 32 | #define ST7565_RMW 0xE0 |
| 33 | 33 | ||
| 34 | #define ST7565_RESISTOR_RATIO 0x20 | 34 | #define ST7565_RESISTOR_RATIO 0x20 |
| 35 | #define ST7565_POWER_CONTROL 0x28 | 35 | #define ST7565_POWER_CONTROL 0x28 |
| 36 | 36 | ||
| 37 | #define ST7565_RESET 0xE2 | 37 | #define ST7565_RESET 0xE2 |
| 38 | 38 | ||
| 39 | #endif /* _ST7565_H */ | 39 | #endif /* _ST7565_H */ |
