Skip to content

Commit

Permalink
Style compliance
Browse files Browse the repository at this point in the history
  • Loading branch information
stellar-aria committed Jun 14, 2023
1 parent 547a76f commit 7837138
Show file tree
Hide file tree
Showing 19 changed files with 91 additions and 119 deletions.
12 changes: 6 additions & 6 deletions src/daisy_patch.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ 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 */
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*/
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
Expand Down
4 changes: 2 additions & 2 deletions src/daisy_seed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void DaisySeed::Init(bool boost)
led_config.pin = Pin(SEED_LED_PORT, SEED_LED_PIN);
led_config.mode = GPIO::Mode::OUTPUT;

testpoint_config.pin = Pin(SEED_TEST_POINT_PORT, SEED_TEST_POINT_PIN);
testpoint_config.pin = Pin(SEED_TEST_POINT_PORT, SEED_TEST_POINT_PIN);
testpoint_config.mode = GPIO::Mode::OUTPUT;

auto memory = System::GetProgramMemoryRegion();
Expand Down Expand Up @@ -235,7 +235,7 @@ void DaisySeed::SetTestPoint(bool state)
testpoint.Write(state);
}

const SaiHandle& DaisySeed::AudioSaiHandle() const
const SaiHandle &DaisySeed::AudioSaiHandle() const
{
return sai_1_handle_;
}
Expand Down
1 change: 1 addition & 0 deletions src/dev/codec_ak4556.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Ak4556
/** Deinitialization function for Ak4556
** */
void DeInit();

private:
GPIO reset_;
};
Expand Down
6 changes: 3 additions & 3 deletions src/dev/lcd_hd44780.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ Based on: HD44780-Stm32HAL by Olivier Van den Eede (https://github.com/4ilo/HD44
#define OPT_B 0x01 // Turn on cursor blink

#define FUNCTION_SET 0x20
#define OPT_DL 0x10 // Set interface data length
#define OPT_N 0x08 // Set number of display lines
#define OPT_F 0x04 // Set alternate font
#define OPT_DL 0x10 // Set interface data length
#define OPT_N 0x08 // Set number of display lines
#define OPT_F 0x04 // Set alternate font
#define SETCGRAM_ADDR 0x040
#define SET_DDRAM_ADDR 0x80 // Set DDRAM address

Expand Down
6 changes: 3 additions & 3 deletions src/dev/leddriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ class LedDriverPca9685
*/
void Init(I2CHandle i2c,
const uint8_t (&addresses)[numDrivers],
DmaBuffer dma_buffer_a,
DmaBuffer dma_buffer_b,
Pin oe_pin = Pin(PORTX, 0))
DmaBuffer dma_buffer_a,
DmaBuffer dma_buffer_b,
Pin oe_pin = Pin(PORTX, 0))
{
i2c_ = i2c;
draw_buffer_ = dma_buffer_a;
Expand Down
12 changes: 6 additions & 6 deletions src/hid/led.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ class Led
inline void SetSampleRate(float sample_rate) { samplerate_ = sample_rate; }

private:
size_t pwm_cnt_, pwm_thresh_;
float bright_;
float pwm_;
float samplerate_;
bool invert_, on_, off_;
GPIO hw_pin_;
size_t pwm_cnt_, pwm_thresh_;
float bright_;
float pwm_;
float samplerate_;
bool invert_, on_, off_;
GPIO hw_pin_;
};

} // namespace daisy
Expand Down
5 changes: 1 addition & 4 deletions src/hid/rgb_led.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#include "hid/rgb_led.h"
using namespace daisy;
void RgbLed::Init(Pin red,
Pin green,
Pin blue,
bool invert)
void RgbLed::Init(Pin red, Pin green, Pin blue, bool invert)
{
r_.Init(red, invert);
g_.Init(green, invert);
Expand Down
2 changes: 1 addition & 1 deletion src/hid/switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void Switch::Debounce()

// shift over, and introduce new state.
const bool new_val = hw_gpio_.Read();
state_ = (state_ << 1) | (flip_ ? !new_val : new_val);
state_ = (state_ << 1) | (flip_ ? !new_val : new_val);
// Set time at which button was pressed
if(state_ == 0x7f)
rising_edge_time_ = System::GetNow();
Expand Down
8 changes: 6 additions & 2 deletions src/hid/switch.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ class Switch
\param pol switch polarity -- Default: POLARITY_INVERTED
\param pu switch pull up/down -- Default: PULL_UP
*/
void Init(Pin pin, float update_rate, Type t, Polarity pol, GPIO::Pull pu = GPIO::Pull::PULLUP);
void Init(Pin pin,
float update_rate,
Type t,
Polarity pol,
GPIO::Pull pu = GPIO::Pull::PULLUP);

/**
Simplified Init.
Expand Down Expand Up @@ -71,7 +75,7 @@ class Switch

/** \return true if the button is held down, without debouncing */
inline bool RawState()
{
{
const bool raw = hw_gpio_.Read();
return flip_ ? !raw : raw;
}
Expand Down
12 changes: 5 additions & 7 deletions src/per/adc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static int get_num_mux_pins_required(int num_mux_ch)
return 0;
}
static void
write_mux_value(uint8_t chn, uint8_t idx, uint8_t num_mux_pins_to_write);
write_mux_value(uint8_t chn, uint8_t idx, uint8_t num_mux_pins_to_write);
static const uint32_t adc_channel_from_pin(Pin pin);

static const uint32_t adc_channel_from_pin(Pin pin)
Expand Down Expand Up @@ -339,8 +339,9 @@ void AdcHandle::Init(AdcChannelConfig* cfg,
}

// init adc channel sequence
sConfig.Channel = adc_channel_from_pin(adc.pin_cfg[i].pin_.GetConfig().pin);
sConfig.Rank = dsy_adc_rank_map[i];
sConfig.Channel
= adc_channel_from_pin(adc.pin_cfg[i].pin_.GetConfig().pin);
sConfig.Rank = dsy_adc_rank_map[i];
if(HAL_ADC_ConfigChannel(&adc.hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
Expand Down Expand Up @@ -502,10 +503,7 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* adcHandle)

extern "C"
{
void DMA1_Stream2_IRQHandler(void)
{
HAL_DMA_IRQHandler(&adc.hdma_adc1);
}
void DMA1_Stream2_IRQHandler(void) { HAL_DMA_IRQHandler(&adc.hdma_adc1); }

void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{
Expand Down
36 changes: 18 additions & 18 deletions src/per/dac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class DacHandle::Impl
DacHandle::Result Init(const DacHandle::Config &config);
const DacHandle::Config &GetConfig() const { return config_; }
DacHandle::Result
Start(uint16_t *buffer, size_t size, DacHandle::DacCallback cb);
DacHandle::Result Start(uint16_t *buffer_1,
uint16_t *buffer_2,
Start(uint16_t *buffer, size_t size, DacHandle::DacCallback cb);
DacHandle::Result Start(uint16_t * buffer_1,
uint16_t * buffer_2,
size_t size,
DacHandle::DacCallback cb);
DacHandle::Result Stop();
Expand All @@ -45,13 +45,13 @@ class DacHandle::Impl

DAC_HandleTypeDef hal_dac_; /**< ST HAL DAC Handle*/
DMA_HandleTypeDef
hal_dac_dma_[2]; /**< ST HAL DMA Hande (one per available channel) */
hal_dac_dma_[2]; /**< ST HAL DMA Hande (one per available channel) */
TIM_HandleTypeDef hal_tim_;

private:
DacHandle::Config config_; /**< Config Struct for initialization */
size_t buff_size_;
uint16_t *buff_[2];
uint16_t * buff_[2];
DacHandle::DacCallback callback_;
GPIO d1, d2;
};
Expand Down Expand Up @@ -110,9 +110,9 @@ DacHandle::Result DacHandle::Impl::Init(const DacHandle::Config &config)
// Base tim freq is PClk2 * 2 (200/240MHz depending on system configuration).
tim_base_freq = System::
GetPClk2Freq(); // 100MHz (or 120MHz) depending on CPU Freq.
target_freq = config_.target_samplerate == 0
? 48000
: config_.target_samplerate;
target_freq = config_.target_samplerate == 0
? 48000
: config_.target_samplerate;
period = tim_base_freq / target_freq;
hal_tim_.Init.Period = period;
hal_tim_.Init.Prescaler = 1;
Expand Down Expand Up @@ -159,11 +159,11 @@ DacHandle::Impl::Start(uint16_t *buffer, size_t size, DacHandle::DacCallback cb)
{
if(config_.mode != Mode::DMA || config_.chn == Channel::BOTH)
return Result::ERR;
callback_ = cb;
buff_[0] = buffer;
buff_size_ = size;
uint32_t bd = config_.bitdepth == BitDepth::BITS_8 ? DAC_ALIGN_8B_R
: DAC_ALIGN_12B_R;
callback_ = cb;
buff_[0] = buffer;
buff_size_ = size;
uint32_t bd = config_.bitdepth == BitDepth::BITS_8 ? DAC_ALIGN_8B_R
: DAC_ALIGN_12B_R;
uint32_t chn = config_.chn == Channel::ONE ? DAC_CHANNEL_1 : DAC_CHANNEL_2;
HAL_DAC_Start_DMA(&hal_dac_, chn, (uint32_t *)buff_[0], size, bd);
HAL_TIM_Base_Start(&hal_tim_);
Expand All @@ -172,8 +172,8 @@ DacHandle::Impl::Start(uint16_t *buffer, size_t size, DacHandle::DacCallback cb)

/** Not fully implemented -- I had the intention of setting up both DACs to work from a single callback, which
** it seems like will require a bit more setup in the Init (basically set it to dual mode). */
DacHandle::Result DacHandle::Impl::Start(uint16_t *buffer_1,
uint16_t *buffer_2,
DacHandle::Result DacHandle::Impl::Start(uint16_t * buffer_1,
uint16_t * buffer_2,
size_t size,
DacHandle::DacCallback cb)
{
Expand All @@ -189,7 +189,7 @@ DacHandle::Result DacHandle::Impl::Start(uint16_t *buffer_1,
buff_[1] = buffer_2;
buff_size_ = size;
bd = config_.bitdepth == BitDepth::BITS_8 ? DAC_ALIGN_8B_R
: DAC_ALIGN_12B_R;
: DAC_ALIGN_12B_R;

// Start the DACs and then start the time source.
HAL_DAC_Start_DMA(&hal_dac_, DAC_CHANNEL_1, (uint32_t *)buff_[0], size, bd);
Expand Down Expand Up @@ -444,8 +444,8 @@ DacHandle::Start(uint16_t *buffer, size_t size, DacHandle::DacCallback cb)
return pimpl_->Start(buffer, size, cb);
}

DacHandle::Result DacHandle::Start(uint16_t *buffer_1,
uint16_t *buffer_2,
DacHandle::Result DacHandle::Start(uint16_t * buffer_1,
uint16_t * buffer_2,
size_t size,
DacHandle::DacCallback cb)
{
Expand Down
2 changes: 1 addition & 1 deletion src/per/gpio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ extern "C"

void dsy_gpio_init(const dsy_gpio *p)
{
GPIO_TypeDef *port;
GPIO_TypeDef * port;
GPIO_InitTypeDef ginit;
switch(p->mode)
{
Expand Down
6 changes: 3 additions & 3 deletions src/per/i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ class I2CHandle
Peripheral periph; /**< & */
struct
{
Pin scl; /**< & */
Pin sda; /**< & */
} pin_config; /**< & */
Pin scl; /**< & */
Pin sda; /**< & */
} pin_config; /**< & */

Speed speed; /**< & */
Mode mode; /**< & */
Expand Down
14 changes: 7 additions & 7 deletions src/per/qspi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ QSPIHandle::Impl::Write(uint32_t address, uint32_t size, uint8_t* buffer)
NumOfPage = size / flash_page_size;
NumOfSingle = size % flash_page_size;

if(Addr == 0) /*!< Address is QSPI_PAGESIZE aligned */
if(Addr == 0) /*!< Address is QSPI_PAGESIZE aligned */
{
if(NumOfPage == 0) /*!< NumByteToWrite < QSPI_PAGESIZE */
{
Expand All @@ -274,7 +274,7 @@ QSPIHandle::Impl::Write(uint32_t address, uint32_t size, uint8_t* buffer)
WritePage(address, QSPI_DataNum, buffer, false);
}
}
else /*!< Address is not QSPI_PAGESIZE aligned */
else /*!< Address is not QSPI_PAGESIZE aligned */
{
if(NumOfPage == 0) /*!< Size < QSPI_PAGESIZE */
{
Expand Down Expand Up @@ -922,11 +922,11 @@ extern "C" void HAL_QSPI_MspInit(QSPI_HandleTypeDef* qspiHandle)
__HAL_RCC_GPIOB_CLK_ENABLE();
// Seems the same for all pin outs so far.
uint8_t af_config[qspi_impl.GetNumPins()] = {GPIO_AF10_QUADSPI,
GPIO_AF10_QUADSPI,
GPIO_AF9_QUADSPI,
GPIO_AF9_QUADSPI,
GPIO_AF9_QUADSPI,
GPIO_AF10_QUADSPI};
GPIO_AF10_QUADSPI,
GPIO_AF9_QUADSPI,
GPIO_AF9_QUADSPI,
GPIO_AF9_QUADSPI,
GPIO_AF10_QUADSPI};
GPIO_TypeDef* port;
for(uint8_t i = 0; i < qspi_impl.GetNumPins(); i++)
{
Expand Down
24 changes: 12 additions & 12 deletions src/per/sai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,10 @@ void SaiHandle::Impl::InitDma(PeripheralBlock block)
hsai = &sai_a_handle_;
hdma = &sai_a_dma_handle_;
dir = config_.a_dir == Config::Direction::RECEIVE
? DMA_PERIPH_TO_MEMORY
: DMA_MEMORY_TO_PERIPH;
req = sai_idx == int(Config::Peripheral::SAI_1) ? DMA_REQUEST_SAI1_A
: DMA_REQUEST_SAI2_A;
? DMA_PERIPH_TO_MEMORY
: DMA_MEMORY_TO_PERIPH;
req = sai_idx == int(Config::Peripheral::SAI_1) ? DMA_REQUEST_SAI1_A
: DMA_REQUEST_SAI2_A;

if(sai_idx == int(Config::Peripheral::SAI_1))
hdma->Instance = DMA1_Stream0;
Expand All @@ -245,10 +245,10 @@ void SaiHandle::Impl::InitDma(PeripheralBlock block)
hsai = &sai_b_handle_;
hdma = &sai_b_dma_handle_;
dir = config_.b_dir == Config::Direction::RECEIVE
? DMA_PERIPH_TO_MEMORY
: DMA_MEMORY_TO_PERIPH;
req = sai_idx == int(Config::Peripheral::SAI_1) ? DMA_REQUEST_SAI1_B
: DMA_REQUEST_SAI2_B;
? DMA_PERIPH_TO_MEMORY
: DMA_MEMORY_TO_PERIPH;
req = sai_idx == int(Config::Peripheral::SAI_1) ? DMA_REQUEST_SAI1_B
: DMA_REQUEST_SAI2_B;

if(sai_idx == int(Config::Peripheral::SAI_1))
hdma->Instance = DMA1_Stream1;
Expand Down Expand Up @@ -365,10 +365,10 @@ void SaiHandle::Impl::InitPins()
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_TypeDef* port;
Pin cfg[] = {config_.pin_config.fs,
config_.pin_config.mclk,
config_.pin_config.sck,
config_.pin_config.sa,
config_.pin_config.sb};
config_.pin_config.mclk,
config_.pin_config.sck,
config_.pin_config.sa,
config_.pin_config.sb};
// Special Case checks
Pin sck_af_pin = Pin(PORTA, 2);
is_master = (config_.a_sync == Config::Sync::MASTER
Expand Down
3 changes: 1 addition & 2 deletions src/per/spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -818,8 +818,7 @@ static pin_alt_spi* pins_periphs_spi[] = {
spi6_pins_sclk, spi6_pins_miso, spi6_pins_mosi, spi6_pins_nss,
};

SpiHandle::Result
checkPinMatchSpi(GPIO_InitTypeDef* init, Pin pin, int p_num)
SpiHandle::Result checkPinMatchSpi(GPIO_InitTypeDef* init, Pin pin, int p_num)
{
for(int i = 0; i < 3; i++)
{
Expand Down
Loading

0 comments on commit 7837138

Please sign in to comment.