-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from esp-cpp/feature/cross-compatibility
feat(compat): update hal to work across v0 and v1
- Loading branch information
Showing
37 changed files
with
198 additions
and
147 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,29 @@ | ||
#pragma once | ||
|
||
#if CONFIG_HARDWARE_V0 | ||
#include <cstdint> | ||
|
||
#include "mcp23x17.hpp" | ||
using InputDriver = espp::Mcp23x17; | ||
static constexpr uint16_t START_PIN = (1<<0) << 0; // start pin is on port a of the MCP23x17 | ||
static constexpr uint16_t SELECT_PIN = (1<<1) << 0; // select pin is on port a of the MCP23x17 | ||
static constexpr uint16_t UP_PIN = (1<<0) << 8; // up pin is on port b of the MCP23x17 | ||
static constexpr uint16_t DOWN_PIN = (1<<1) << 8; // down pin is on port b of the MCP23x17 | ||
static constexpr uint16_t LEFT_PIN = (1<<2) << 8; // left pin is on port b of the MCP23x17 | ||
static constexpr uint16_t RIGHT_PIN = (1<<3) << 8; // right pin is on port b of the MCP23x17 | ||
static constexpr uint16_t A_PIN = (1<<4) << 8; // a pin is on port b of the MCP23x17 | ||
static constexpr uint16_t B_PIN = (1<<5) << 8; // b pin is on port b of the MCP23x17 | ||
static constexpr uint16_t X_PIN = (1<<6) << 8; // x pin is on port b of the MCP23x17 | ||
static constexpr uint16_t Y_PIN = (1<<7) << 8; // y pin is on port b of the MCP23x17 | ||
static constexpr uint16_t BAT_ALERT_PIN = 0; // battery alert pin doesn't exist on the MCP23x17 | ||
static constexpr uint16_t VOL_UP_PIN = 0; // volume up pin doesn't exist on the MCP23x17 | ||
static constexpr uint16_t VOL_DOWN_PIN = 0; // volume down pin doesn't exist on the MCP23x17 | ||
static constexpr uint16_t DIRECTION_MASK = (UP_PIN | DOWN_PIN | LEFT_PIN | RIGHT_PIN | A_PIN | B_PIN | X_PIN | Y_PIN | START_PIN | SELECT_PIN); | ||
static constexpr uint16_t INTERRUPT_MASK = (START_PIN | SELECT_PIN); | ||
static constexpr uint16_t INVERT_MASK = (UP_PIN | DOWN_PIN | LEFT_PIN | RIGHT_PIN | A_PIN | B_PIN | X_PIN | Y_PIN | START_PIN | SELECT_PIN ); // pins are active low so invert them | ||
static constexpr uint8_t PORT_0_DIRECTION_MASK = DIRECTION_MASK & 0xFF; | ||
static constexpr uint8_t PORT_1_DIRECTION_MASK = (DIRECTION_MASK >> 8) & 0xFF; | ||
static constexpr uint8_t PORT_0_INTERRUPT_MASK = INTERRUPT_MASK & 0xFF; | ||
static constexpr uint8_t PORT_1_INTERRUPT_MASK = (INTERRUPT_MASK >> 8) & 0xFF; | ||
#endif // CONFIG_HARDWARE_V0 | ||
|
||
class EmuV0 { | ||
public: | ||
static constexpr uint16_t START_PIN = (1<<0) << 0; // start pin is on port a of the MCP23x17 | ||
static constexpr uint16_t SELECT_PIN = (1<<1) << 0; // select pin is on port a of the MCP23x17 | ||
static constexpr uint16_t UP_PIN = (1<<0) << 8; // up pin is on port b of the MCP23x17 | ||
static constexpr uint16_t DOWN_PIN = (1<<1) << 8; // down pin is on port b of the MCP23x17 | ||
static constexpr uint16_t LEFT_PIN = (1<<2) << 8; // left pin is on port b of the MCP23x17 | ||
static constexpr uint16_t RIGHT_PIN = (1<<3) << 8; // right pin is on port b of the MCP23x17 | ||
static constexpr uint16_t A_PIN = (1<<4) << 8; // a pin is on port b of the MCP23x17 | ||
static constexpr uint16_t B_PIN = (1<<5) << 8; // b pin is on port b of the MCP23x17 | ||
static constexpr uint16_t X_PIN = (1<<6) << 8; // x pin is on port b of the MCP23x17 | ||
static constexpr uint16_t Y_PIN = (1<<7) << 8; // y pin is on port b of the MCP23x17 | ||
static constexpr uint16_t BAT_ALERT_PIN = 0; // battery alert pin doesn't exist on the MCP23x17 | ||
static constexpr uint16_t VOL_UP_PIN = 0; // volume up pin doesn't exist on the MCP23x17 | ||
static constexpr uint16_t VOL_DOWN_PIN = 0; // volume down pin doesn't exist on the MCP23x17 | ||
static constexpr uint16_t DIRECTION_MASK = (UP_PIN | DOWN_PIN | LEFT_PIN | RIGHT_PIN | A_PIN | B_PIN | X_PIN | Y_PIN | START_PIN | SELECT_PIN); | ||
static constexpr uint16_t INTERRUPT_MASK = (START_PIN | SELECT_PIN); | ||
static constexpr uint16_t INVERT_MASK = (UP_PIN | DOWN_PIN | LEFT_PIN | RIGHT_PIN | A_PIN | B_PIN | X_PIN | Y_PIN | START_PIN | SELECT_PIN ); // pins are active low so invert them | ||
static constexpr uint8_t PORT_0_DIRECTION_MASK = DIRECTION_MASK & 0xFF; | ||
static constexpr uint8_t PORT_1_DIRECTION_MASK = (DIRECTION_MASK >> 8) & 0xFF; | ||
static constexpr uint8_t PORT_0_INTERRUPT_MASK = INTERRUPT_MASK & 0xFF; | ||
static constexpr uint8_t PORT_1_INTERRUPT_MASK = (INTERRUPT_MASK >> 8) & 0xFF; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,37 @@ | ||
#pragma once | ||
|
||
#if CONFIG_HARDWARE_V1 | ||
#include <cstdint> | ||
|
||
#include "aw9523.hpp" | ||
using InputDriver = espp::Aw9523; | ||
static constexpr gpio_num_t VBAT_SENSE_PIN = GPIO_NUM_14; // battery sense pin is on GPIO 14 | ||
static constexpr gpio_num_t AW9523_INT_PIN = GPIO_NUM_21; // interrupt pin is on GPIO 21 | ||
static constexpr uint16_t UP_PIN = (1<<0) << 0; // up pin is on port 0 of the AW9523 | ||
static constexpr uint16_t DOWN_PIN = (1<<1) << 0; // down pin is on port 0 of the AW9523 | ||
static constexpr uint16_t LEFT_PIN = (1<<2) << 0; // left pin is on port 0 of the AW9523 | ||
static constexpr uint16_t RIGHT_PIN = (1<<3) << 0; // right pin is on port 0 of the AW9523 | ||
static constexpr uint16_t A_PIN = (1<<4) << 0; // a pin is on port 0 of the AW9523 | ||
static constexpr uint16_t B_PIN = (1<<5) << 0; // b pin is on port 0 of the AW9523 | ||
static constexpr uint16_t X_PIN = (1<<6) << 0; // x pin is on port 0 of the AW9523 | ||
static constexpr uint16_t Y_PIN = (1<<7) << 0; // y pin is on port 0 of the AW9523 | ||
static constexpr uint16_t START_PIN = (1<<0) << 8; // start pin is on port 1 of the AW9523 | ||
static constexpr uint16_t SELECT_PIN = (1<<1) << 8; // select pin is on port 1 of the AW9523 | ||
static constexpr uint16_t BAT_ALERT_PIN = (1<<3) << 8; // battery alert pin is on port 1 of the AW9523 | ||
static constexpr uint16_t VOL_UP_PIN = (1<<4) << 8; // volume up pin is on port 1 of the AW9523 | ||
static constexpr uint16_t VOL_DOWN_PIN = (1<<5) << 8; // volume down pin is on port 1 of the AW9523 | ||
static constexpr uint16_t DIRECTION_MASK = (UP_PIN | DOWN_PIN | LEFT_PIN | RIGHT_PIN | A_PIN | B_PIN | X_PIN | Y_PIN | START_PIN | SELECT_PIN | BAT_ALERT_PIN | VOL_UP_PIN | VOL_DOWN_PIN); | ||
static constexpr uint16_t INTERRUPT_MASK = (BAT_ALERT_PIN); | ||
static constexpr uint16_t INVERT_MASK = (UP_PIN | DOWN_PIN | LEFT_PIN | RIGHT_PIN | A_PIN | B_PIN | X_PIN | Y_PIN | START_PIN | SELECT_PIN | BAT_ALERT_PIN | VOL_UP_PIN | VOL_DOWN_PIN); // pins are active low so invert them | ||
static constexpr uint8_t PORT_0_DIRECTION_MASK = DIRECTION_MASK & 0xFF; | ||
static constexpr uint8_t PORT_1_DIRECTION_MASK = (DIRECTION_MASK >> 8) & 0xFF; | ||
static constexpr uint8_t PORT_0_INTERRUPT_MASK = INTERRUPT_MASK & 0xFF; | ||
static constexpr uint8_t PORT_1_INTERRUPT_MASK = (INTERRUPT_MASK >> 8) & 0xFF; | ||
#include "oneshot_adc.hpp" | ||
|
||
class EmuV1 { | ||
public: | ||
using InputDriver = espp::Aw9523; | ||
static constexpr gpio_num_t VBAT_SENSE_PIN = GPIO_NUM_14; // battery sense pin is on GPIO 14 | ||
static constexpr gpio_num_t AW9523_INT_PIN = GPIO_NUM_21; // interrupt pin is on GPIO 21 | ||
static constexpr uint16_t UP_PIN = (1<<0) << 0; // up pin is on port 0 of the AW9523 | ||
static constexpr uint16_t DOWN_PIN = (1<<1) << 0; // down pin is on port 0 of the AW9523 | ||
static constexpr uint16_t LEFT_PIN = (1<<2) << 0; // left pin is on port 0 of the AW9523 | ||
static constexpr uint16_t RIGHT_PIN = (1<<3) << 0; // right pin is on port 0 of the AW9523 | ||
static constexpr uint16_t A_PIN = (1<<4) << 0; // a pin is on port 0 of the AW9523 | ||
static constexpr uint16_t B_PIN = (1<<5) << 0; // b pin is on port 0 of the AW9523 | ||
static constexpr uint16_t X_PIN = (1<<6) << 0; // x pin is on port 0 of the AW9523 | ||
static constexpr uint16_t Y_PIN = (1<<7) << 0; // y pin is on port 0 of the AW9523 | ||
static constexpr uint16_t START_PIN = (1<<0) << 8; // start pin is on port 1 of the AW9523 | ||
static constexpr uint16_t SELECT_PIN = (1<<1) << 8; // select pin is on port 1 of the AW9523 | ||
static constexpr uint16_t BAT_ALERT_PIN = (1<<3) << 8; // battery alert pin is on port 1 of the AW9523 | ||
static constexpr uint16_t VOL_UP_PIN = (1<<4) << 8; // volume up pin is on port 1 of the AW9523 | ||
static constexpr uint16_t VOL_DOWN_PIN = (1<<5) << 8; // volume down pin is on port 1 of the AW9523 | ||
static constexpr uint16_t DIRECTION_MASK = (UP_PIN | DOWN_PIN | LEFT_PIN | RIGHT_PIN | A_PIN | B_PIN | X_PIN | Y_PIN | START_PIN | SELECT_PIN | BAT_ALERT_PIN | VOL_UP_PIN | VOL_DOWN_PIN); | ||
static constexpr uint16_t INTERRUPT_MASK = (BAT_ALERT_PIN); | ||
static constexpr uint16_t INVERT_MASK = (UP_PIN | DOWN_PIN | LEFT_PIN | RIGHT_PIN | A_PIN | B_PIN | X_PIN | Y_PIN | START_PIN | SELECT_PIN | BAT_ALERT_PIN | VOL_UP_PIN | VOL_DOWN_PIN); // pins are active low so invert them | ||
static constexpr uint8_t PORT_0_DIRECTION_MASK = DIRECTION_MASK & 0xFF; | ||
static constexpr uint8_t PORT_1_DIRECTION_MASK = (DIRECTION_MASK >> 8) & 0xFF; | ||
static constexpr uint8_t PORT_0_INTERRUPT_MASK = INTERRUPT_MASK & 0xFF; | ||
static constexpr uint8_t PORT_1_INTERRUPT_MASK = (INTERRUPT_MASK >> 8) & 0xFF; | ||
|
||
// ADC for the battery voltage, it's on ADC2_CH3, which is IO14 | ||
static constexpr adc_unit_t BATTERY_ADC_UNIT = ADC_UNIT_2; | ||
static constexpr adc_channel_t BATTERY_ADC_CHANNEL = ADC_CHANNEL_3; | ||
#endif // CONFIG_HARDWARE_V1 | ||
// ADC for the battery voltage, it's on ADC2_CH3, which is IO14 | ||
static constexpr adc_unit_t BATTERY_ADC_UNIT = ADC_UNIT_2; | ||
static constexpr adc_channel_t BATTERY_ADC_CHANNEL = ADC_CHANNEL_3; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.