From 783713896168514969d2d3b894c2bb948b12cd09 Mon Sep 17 00:00:00 2001 From: Katherine Whitlock Date: Tue, 13 Jun 2023 23:42:39 -0400 Subject: [PATCH] Style compliance --- src/daisy_patch.h | 12 +++++------ src/daisy_seed.cpp | 4 ++-- src/dev/codec_ak4556.h | 1 + src/dev/lcd_hd44780.cpp | 6 +++--- src/dev/leddriver.h | 6 +++--- src/hid/led.h | 12 +++++------ src/hid/rgb_led.cpp | 5 +---- src/hid/switch.cpp | 2 +- src/hid/switch.h | 8 ++++++-- src/per/adc.cpp | 12 +++++------ src/per/dac.cpp | 36 ++++++++++++++++----------------- src/per/gpio.cpp | 2 +- src/per/i2c.h | 6 +++--- src/per/qspi.cpp | 14 ++++++------- src/per/sai.cpp | 24 +++++++++++----------- src/per/spi.cpp | 3 +-- src/per/uart.cpp | 45 +++++++++-------------------------------- src/per/uart.h | 6 +++--- src/sys/system.cpp | 6 +++--- 19 files changed, 91 insertions(+), 119 deletions(-) diff --git a/src/daisy_patch.h b/src/daisy_patch.h index 15d966775..a3f01d1ab 100644 --- a/src/daisy_patch.h +++ b/src/daisy_patch.h @@ -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 display; /**< & */ // TODO: Add class for Gate output diff --git a/src/daisy_seed.cpp b/src/daisy_seed.cpp index 10667b04b..02ca561fd 100644 --- a/src/daisy_seed.cpp +++ b/src/daisy_seed.cpp @@ -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(); @@ -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_; } diff --git a/src/dev/codec_ak4556.h b/src/dev/codec_ak4556.h index fcd86f128..ee8b11f29 100644 --- a/src/dev/codec_ak4556.h +++ b/src/dev/codec_ak4556.h @@ -27,6 +27,7 @@ class Ak4556 /** Deinitialization function for Ak4556 ** */ void DeInit(); + private: GPIO reset_; }; diff --git a/src/dev/lcd_hd44780.cpp b/src/dev/lcd_hd44780.cpp index 70720935d..24491f41a 100644 --- a/src/dev/lcd_hd44780.cpp +++ b/src/dev/lcd_hd44780.cpp @@ -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 diff --git a/src/dev/leddriver.h b/src/dev/leddriver.h index 8dbd7129d..9c70caeb9 100644 --- a/src/dev/leddriver.h +++ b/src/dev/leddriver.h @@ -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; diff --git a/src/hid/led.h b/src/hid/led.h index b34597726..543784dd0 100644 --- a/src/hid/led.h +++ b/src/hid/led.h @@ -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 diff --git a/src/hid/rgb_led.cpp b/src/hid/rgb_led.cpp index 32a642fcc..88959807e 100644 --- a/src/hid/rgb_led.cpp +++ b/src/hid/rgb_led.cpp @@ -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); diff --git a/src/hid/switch.cpp b/src/hid/switch.cpp index 6553edaa7..989d9f5aa 100644 --- a/src/hid/switch.cpp +++ b/src/hid/switch.cpp @@ -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(); diff --git a/src/hid/switch.h b/src/hid/switch.h index 1ea02d835..d0c14d14a 100644 --- a/src/hid/switch.h +++ b/src/hid/switch.h @@ -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. @@ -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; } diff --git a/src/per/adc.cpp b/src/per/adc.cpp index a7dd6c352..760a17b37 100644 --- a/src/per/adc.cpp +++ b/src/per/adc.cpp @@ -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) @@ -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(); @@ -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) { diff --git a/src/per/dac.cpp b/src/per/dac.cpp index 012e62059..4b620a62a 100644 --- a/src/per/dac.cpp +++ b/src/per/dac.cpp @@ -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(); @@ -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; }; @@ -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; @@ -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_); @@ -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) { @@ -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); @@ -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) { diff --git a/src/per/gpio.cpp b/src/per/gpio.cpp index f865259a6..4b8f0f02f 100644 --- a/src/per/gpio.cpp +++ b/src/per/gpio.cpp @@ -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) { diff --git a/src/per/i2c.h b/src/per/i2c.h index 4635c2229..140a82fd0 100644 --- a/src/per/i2c.h +++ b/src/per/i2c.h @@ -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; /**< & */ diff --git a/src/per/qspi.cpp b/src/per/qspi.cpp index 30fa0c652..ab268d9e6 100644 --- a/src/per/qspi.cpp +++ b/src/per/qspi.cpp @@ -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 */ { @@ -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 */ { @@ -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++) { diff --git a/src/per/sai.cpp b/src/per/sai.cpp index 8dacf9121..2014c8a15 100644 --- a/src/per/sai.cpp +++ b/src/per/sai.cpp @@ -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; @@ -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; @@ -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 diff --git a/src/per/spi.cpp b/src/per/spi.cpp index bac197c7a..e913d4c98 100644 --- a/src/per/spi.cpp +++ b/src/per/spi.cpp @@ -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++) { diff --git a/src/per/uart.cpp b/src/per/uart.cpp index 13194a530..f5c734969 100644 --- a/src/per/uart.cpp +++ b/src/per/uart.cpp @@ -964,42 +964,15 @@ void UART_IRQHandler(UartHandler::Impl* handle) extern "C" { - void USART1_IRQHandler() - { - UART_IRQHandler(&uart_handles[0]); - } - void USART2_IRQHandler() - { - UART_IRQHandler(&uart_handles[1]); - } - void USART3_IRQHandler() - { - UART_IRQHandler(&uart_handles[2]); - } - void UART4_IRQHandler() - { - UART_IRQHandler(&uart_handles[3]); - } - void UART5_IRQHandler() - { - UART_IRQHandler(&uart_handles[4]); - } - void USART6_IRQHandler() - { - UART_IRQHandler(&uart_handles[5]); - } - void UART7_IRQHandler() - { - UART_IRQHandler(&uart_handles[6]); - } - void UART8_IRQHandler() - { - UART_IRQHandler(&uart_handles[7]); - } - void LPUART1_IRQHandler() - { - UART_IRQHandler(&uart_handles[8]); - } + void USART1_IRQHandler() { UART_IRQHandler(&uart_handles[0]); } + void USART2_IRQHandler() { UART_IRQHandler(&uart_handles[1]); } + void USART3_IRQHandler() { UART_IRQHandler(&uart_handles[2]); } + void UART4_IRQHandler() { UART_IRQHandler(&uart_handles[3]); } + void UART5_IRQHandler() { UART_IRQHandler(&uart_handles[4]); } + void USART6_IRQHandler() { UART_IRQHandler(&uart_handles[5]); } + void UART7_IRQHandler() { UART_IRQHandler(&uart_handles[6]); } + void UART8_IRQHandler() { UART_IRQHandler(&uart_handles[7]); } + void LPUART1_IRQHandler() { UART_IRQHandler(&uart_handles[8]); } } void HalUartDmaRxStreamCallback(void) diff --git a/src/per/uart.h b/src/per/uart.h index 75baa6fc9..3daf06130 100644 --- a/src/per/uart.h +++ b/src/per/uart.h @@ -71,9 +71,9 @@ class UartHandler struct { - Pin tx; /**< & */ - Pin rx; /**< & */ - } pin_config; /**< & */ + Pin tx; /**< & */ + Pin rx; /**< & */ + } pin_config; /**< & */ Config() { diff --git a/src/sys/system.cpp b/src/sys/system.cpp index 1444e85da..ad1a74484 100644 --- a/src/sys/system.cpp +++ b/src/sys/system.cpp @@ -413,9 +413,9 @@ void System::ConfigureClocks() // New Timing PeriphClkInitStruct.PLL2.PLL2N = 12; // Max supported freq of FMC; PeriphClkInitStruct.PLL2.PLL2M = 1; - PeriphClkInitStruct.PLL2.PLL2P = 8; // 25MHz - PeriphClkInitStruct.PLL2.PLL2Q = 2; // 100MHz - PeriphClkInitStruct.PLL2.PLL2R = 1; // 200MHz + PeriphClkInitStruct.PLL2.PLL2P = 8; // 25MHz + PeriphClkInitStruct.PLL2.PLL2Q = 2; // 100MHz + PeriphClkInitStruct.PLL2.PLL2R = 1; // 200MHz PeriphClkInitStruct.PLL2.PLL2FRACN = 4096;