Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global GPIO/Pin Migration #584

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
5f40712
Update DaisySeed to use GPIO
stellar-aria May 27, 2023
f13f0fa
Update DaisyPatch to use GPIO
stellar-aria May 27, 2023
82b0689
Update daisy::patch_sm to use GPIO
stellar-aria May 27, 2023
4f9d07a
Update DaisyField to use GPIO
stellar-aria May 27, 2023
6279643
Update LED and RGBLed to use GPIO and Pin
stellar-aria May 27, 2023
4e42d1c
Update AK4556 CODEC to use GPIO and Pin
stellar-aria May 28, 2023
4833816
Update HD44780 driver to use GPIO and Pin
stellar-aria May 28, 2023
c83c10c
Update PCA9685 driver to use GPIO and Pin
stellar-aria May 28, 2023
5035b71
Update SSD130X driver to use GPIO and Pin
stellar-aria May 28, 2023
afb38c9
Move SR595 Driver into daisy namespace
stellar-aria May 28, 2023
95319e3
Update SR595 driver to use GPIO and Pin
stellar-aria May 28, 2023
dc614a2
Update 4021 driver with GPIO and Pin
stellar-aria May 28, 2023
e1d6ce2
Update Encoder to use GPIO and Pin
stellar-aria May 28, 2023
ee05043
Update Switch driver to use GPIO and Pin
stellar-aria May 28, 2023
a15d57d
Update Switch3 to use GPIO and Pin
stellar-aria May 28, 2023
1499c64
Add Init() to GPIO for 0-parameter initialization
stellar-aria May 28, 2023
f8fbeb6
Update ADC to use GPIO and Pin
stellar-aria May 28, 2023
89d0cbe
Update system to use GPIO and Pin
stellar-aria May 28, 2023
25a1f5c
Update multi-peripheral SPI driver with GPIO/Pin
stellar-aria May 28, 2023
3d0ca18
Update Midi to use Pin
stellar-aria May 28, 2023
66b678f
Update TLV493D to use Pin
stellar-aria May 28, 2023
a163e0a
Update MCP23x17 and MAX11300 to use Pin
stellar-aria May 28, 2023
9967424
Update DAC driver to use GPIO and Pin
stellar-aria May 29, 2023
2e3e75a
Update I2C driver to use GPIO and Pin
stellar-aria May 29, 2023
d90db67
Update UART to use GPIO and Pin
stellar-aria May 29, 2023
660d5f0
Update SPI peripheral to use GPIO and Pin
stellar-aria May 29, 2023
5a9d717
Update SAI peripheral to use GPIO and Pin
stellar-aria May 29, 2023
8b8c9e1
Update QSPI peripheral to use GPIO and Pin
stellar-aria May 29, 2023
547a76f
Update outdated documentation
stellar-aria May 29, 2023
7837138
Style compliance
stellar-aria Jun 14, 2023
6567ad7
Merge upstream/master
stellar-aria Jun 19, 2023
4c71f54
Merge remote-tracking branch 'upstream/master' into feature/global-gp…
stellar-aria Dec 19, 2023
dc3bc5a
Merge remote-tracking branch 'upstream/master' into feature/global-gp…
stellar-aria Feb 21, 2024
0f4bbe0
Fix ResetToBootloader (merge error)
stellar-aria Feb 21, 2024
71a56b4
Replace old dsy_gpio in DaisySeed with modern GPIO
beserge Feb 26, 2024
ba8248d
Move patch_sm to modern GPIO
beserge Feb 26, 2024
25a0b1c
Rip up all old GPIO usage
beserge Feb 26, 2024
e5fae4d
Remove hal_map.c from build systems
beserge Feb 27, 2024
708fd71
Reintroduce dsy_gpio_pin + implicit conversion to daisy::Pin
beserge Feb 27, 2024
eb3b268
Fix unit tests
beserge Feb 27, 2024
2830cee
Initialize DaisySeed::seedgpio using constexpr pins from header
beserge Feb 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ add_library(${TARGET} STATIC
${MODULE_DIR}/per/sai.cpp
${MODULE_DIR}/per/sdmmc.cpp
${MODULE_DIR}/util/bsp_sd_diskio.c
${MODULE_DIR}/util/hal_map.c
${MODULE_DIR}/util/oled_fonts.c
${MODULE_DIR}/util/sd_diskio.c
${MODULE_DIR}/util/usbh_diskio.c
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ per/gpio \
per/sai \
per/sdmmc \
util/bsp_sd_diskio \
util/hal_map \
util/oled_fonts \
util/sd_diskio \
util/unique_id \
Expand Down
1 change: 1 addition & 0 deletions src/daisy.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "hid/rgb_led.h"
#include "dev/sr_595.h"
#include "dev/apds9960.h"
#include "dev/codec_ak4556.h"
#include "dev/codec_pcm3060.h"
#include "dev/codec_wm8731.h"
#include "dev/dps310.h"
Expand Down
122 changes: 44 additions & 78 deletions src/daisy_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,74 +167,6 @@ FORCE_INLINE int32_t f2s32(float x)
return (int32_t)(x * F2S32_SCALE);
}


/** Enums and a simple struct for defining a hardware pin on the MCU
* These correlate with the stm32 datasheet, and are used to configure
* the hardware.
*
* This along with the dsy_gpio_pin class should no longer be used.
* They are available for backwards compatability.
*
* Please use GPIOPort enum and the Pin struct instead.
*/
typedef enum
{
DSY_GPIOA, /**< & */
DSY_GPIOB, /**< & */
DSY_GPIOC, /**< & */
DSY_GPIOD, /**< & */
DSY_GPIOE, /**< & */
DSY_GPIOF, /**< & */
DSY_GPIOG, /**< & */
DSY_GPIOH, /**< & */
DSY_GPIOI, /**< & */
DSY_GPIOJ, /**< & */
DSY_GPIOK, /**< & */
DSY_GPIOX, /** This is a non-existant port for unsupported bits of hardware. */
DSY_GPIO_LAST, /** Final enum member */
} dsy_gpio_port;

/** Hardware define pins
*
* The dsy_gpio_pin struct should no longer be used, and is only available for
* backwards compatability.
*
* Please use Pin struct instead.
*/
typedef struct
{
dsy_gpio_port port; /**< & */
uint8_t pin; /**< number 0-15 */
} dsy_gpio_pin;

/** Helper for creating pins from port/pin combos easily
*
* The dsy_gpio_pin struct should no longer be used, and is only available for
* backwards compatability.
*
* Please use Pin struct instead.
*/
FORCE_INLINE dsy_gpio_pin dsy_pin(dsy_gpio_port port, uint8_t pin)
{
dsy_gpio_pin p;
p.port = port;
p.pin = pin;
return p;
}

/** Helper for testing sameness of two dsy_gpio_pins
* \return 1 if same, 0 if different
*
* The dsy_gpio_pin struct should no longer be used, and is only available for
* backwards compatability.
*
* Please use Pin struct instead.
*/
FORCE_INLINE uint8_t dsy_pin_cmp(dsy_gpio_pin *a, dsy_gpio_pin *b)
{
return ((a->port == b->port) && (a->pin == b->pin));
}

#ifdef __cplusplus

namespace daisy
Expand Down Expand Up @@ -284,19 +216,53 @@ struct Pin

/** @brief comparison operator for checking inequality between Pin objects */
constexpr bool operator!=(const Pin &rhs) const { return !operator==(rhs); }
};


/** @brief conversion operation for converting to the old-style representation
* of a pin.
*
* This allows the new Pin type to be used in place of the older, dsy_gpio_pin
* type.
*/
constexpr operator dsy_gpio_pin() const
/** Enums and a simple struct for defining a hardware pin on the MCU
* These correlate with the stm32 datasheet, and are used to configure
* the hardware.
*
* This along with the dsy_gpio_pin class should no longer be used.
* They are available for backwards compatability.
*
* Please use GPIOPort enum and the Pin struct instead.
*/
typedef enum
{
DSY_GPIOA, /**< & */
DSY_GPIOB, /**< & */
DSY_GPIOC, /**< & */
DSY_GPIOD, /**< & */
DSY_GPIOE, /**< & */
DSY_GPIOF, /**< & */
DSY_GPIOG, /**< & */
DSY_GPIOH, /**< & */
DSY_GPIOI, /**< & */
DSY_GPIOJ, /**< & */
DSY_GPIOK, /**< & */
DSY_GPIOX, /** This is a non-existant port for unsupported bits of hardware. */
DSY_GPIO_LAST, /** Final enum member */
} dsy_gpio_port;

/** Hardware define pins
*
* The dsy_gpio_pin struct should no longer be used, and is only available for
* backwards compatability.
*
* Please use Pin struct instead.
*/
[[deprecated("Use daisy::Pin instead")]] typedef struct
{
dsy_gpio_port port; /**< & */
uint8_t pin; /**< number 0-15 */

constexpr operator Pin() const
{
return dsy_gpio_pin{.port = static_cast<dsy_gpio_port>(port),
.pin = pin};
return Pin(static_cast<GPIOPort>(port), pin);
}
};

} dsy_gpio_pin;

} // namespace daisy

Expand Down
5 changes: 1 addition & 4 deletions src/daisy_field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,7 @@ void DaisyField::Init(bool boost)
// Gate In
gate_in.Init(PIN_GATE_IN);
// Gate Out
gate_out.mode = DSY_GPIO_MODE_OUTPUT_PP;
gate_out.pull = DSY_GPIO_NOPULL;
gate_out.pin = PIN_GATE_OUT;
dsy_gpio_init(&gate_out);
gate_out.Init(PIN_GATE_OUT, GPIO::Mode::OUTPUT);

//midi
MidiUartHandler::Config midi_config;
Expand Down
2 changes: 1 addition & 1 deletion src/daisy_field.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class DaisyField

DaisySeed seed;
OledDisplay<SSD130x4WireSpi128x64Driver> display;
dsy_gpio gate_out;
GPIO gate_out;
GateIn gate_in;
LedDriverPca9685<2, true> led_driver;
Switch sw[SW_LAST];
Expand Down
9 changes: 2 additions & 7 deletions src/daisy_patch.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "daisy_patch.h"
#include "dev/codec_ak4556.h"

using namespace daisy;

Expand Down Expand Up @@ -216,8 +215,7 @@ void DaisyPatch::InitAudio()

// Reset Pin for AK4556
// Built-in AK4556 was reset during Seed Init
dsy_gpio_pin codec_reset_pin = PIN_AK4556_RESET;
Ak4556::Init(codec_reset_pin);
codec.Init(PIN_AK4556_RESET);

// Reinit Audio for _both_ codecs...
AudioHandle::Config cfg;
Expand Down Expand Up @@ -286,10 +284,7 @@ void DaisyPatch::InitEncoder()
void DaisyPatch::InitGates()
{
// Gate Output
gate_output.pin = PIN_GATE_OUT;
gate_output.mode = DSY_GPIO_MODE_OUTPUT_PP;
gate_output.pull = DSY_GPIO_NOPULL;
dsy_gpio_init(&gate_output);
gate_output.Init(PIN_GATE_OUT, GPIO::Mode::OUTPUT);

// Gate Inputs
gate_input[GATE_IN_1].Init(PIN_GATE_IN_1);
Expand Down
13 changes: 7 additions & 6 deletions src/daisy_patch.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,16 @@ class DaisyPatch
/* These are exposed for the user to access and manipulate directly
Helper functions above provide easier access to much of what they are capable of.
*/
DaisySeed seed; /**< Seed object */
Encoder encoder; /**< Encoder object */
AnalogControl controls[CTRL_LAST]; /**< Array of controls*/
GateIn gate_input[GATE_IN_LAST]; /**< Gate inputs */
MidiUartHandler midi; /**< Handles midi*/
DaisySeed seed; /**< Seed object */
Ak4556 codec; /**< Patch's second CODEC */
Encoder encoder; /**< Encoder object */
AnalogControl controls[CTRL_LAST]; /**< Array of controls*/
GateIn gate_input[GATE_IN_LAST]; /**< Gate inputs */
MidiUartHandler midi; /**< Handles midi*/
OledDisplay<SSD130x4WireSpi128x64Driver> display; /**< & */

// TODO: Add class for Gate output
dsy_gpio gate_output; /**< & */
GPIO gate_output; /**< & */


private:
Expand Down
21 changes: 5 additions & 16 deletions src/daisy_patch_sm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,23 +330,12 @@ namespace patch_sm
}

/** Fixed-function Digital I/O */
user_led.mode = DSY_GPIO_MODE_OUTPUT_PP;
user_led.pull = DSY_GPIO_NOPULL;
user_led.pin = PIN_USER_LED;
dsy_gpio_init(&user_led);
//gate_in_1.Init((dsy_gpio_pin *)&DaisyPatchSM::B10);
user_led.Init(PIN_USER_LED, GPIO::Mode::OUTPUT);
gate_in_1.Init(B10);
gate_in_2.Init(B9);

gate_out_1.mode = DSY_GPIO_MODE_OUTPUT_PP;
gate_out_1.pull = DSY_GPIO_NOPULL;
gate_out_1.pin = B5;
dsy_gpio_init(&gate_out_1);

gate_out_2.mode = DSY_GPIO_MODE_OUTPUT_PP;
gate_out_2.pull = DSY_GPIO_NOPULL;
gate_out_2.pin = B6;
dsy_gpio_init(&gate_out_2);
gate_out_1.Init(B5, GPIO::Mode::OUTPUT);
gate_out_2.Init(B6, GPIO::Mode::OUTPUT);

/** DAC init */
pimpl_->InitDac();
Expand Down Expand Up @@ -453,7 +442,7 @@ namespace patch_sm

float DaisyPatchSM::GetAdcValue(int idx) { return controls[idx].Value(); }

dsy_gpio_pin DaisyPatchSM::GetPin(const PinBank bank, const int idx)
Pin DaisyPatchSM::GetPin(const PinBank bank, const int idx)
{
if(idx <= 0 || idx > 10)
return DUMMYPIN;
Expand All @@ -473,7 +462,7 @@ namespace patch_sm
pimpl_->WriteCvOut(channel, voltage);
}

void DaisyPatchSM::SetLed(bool state) { dsy_gpio_write(&user_led, state); }
void DaisyPatchSM::SetLed(bool state) { user_led.Write(state); }

bool DaisyPatchSM::ValidateSDRAM()
{
Expand Down
6 changes: 3 additions & 3 deletions src/daisy_patch_sm.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ namespace patch_sm
* \param idx pin number between 1 and 10 for each of the pins on each header.
* \deprecated please use the Pin definitions in daisy::patch_sm instead
*/
dsy_gpio_pin GetPin(const PinBank bank, const int idx);
Pin GetPin(const PinBank bank, const int idx);

/** Starts the DAC for the CV Outputs
*
Expand Down Expand Up @@ -251,10 +251,10 @@ namespace patch_sm
DacHandle dac;

/** Dedicated Function Pins */
dsy_gpio user_led;
GPIO user_led;
AnalogControl controls[ADC_LAST];
GateIn gate_in_1, gate_in_2;
dsy_gpio gate_out_1, gate_out_2;
GPIO gate_out_1, gate_out_2;


/** Pin Accessors for the DaisyPatchSM hardware
Expand Down
Loading
Loading