diff --git a/cpp/MAX7313.cpp b/cpp/MAX7313.cpp deleted file mode 100644 index 42aab03..0000000 --- a/cpp/MAX7313.cpp +++ /dev/null @@ -1,268 +0,0 @@ - -/** - * @note STILL IN DEVELOPMENT - * @file max3713.cpp - * @author Simon Burkhardt github.com/mnemocron - * @copyright MIT license - * @date 19 Jan 2018 - * @brief Object oriented C++ library for the MAX7313 port expander for STM32 HAL. - * @details - * @see github.com/mnemocron - * @see https://datasheets.maximintegrated.com/en/ds/MAX7313.pdf - * @see https://forum.arduino.cc/index.php?topic=9682.0 - */ - -#include "max7313.h" -#include "main.h" - -/** - * @brief MAX7313 constructor - * @param *wireIface a pointer to a HAL I2C_HandleTypeDef - * @param address of the chip on the I2C bus - */ -MAX7313::MAX7313(I2C_HandleTypeDef *wireIface, uint16_t address){ - this->wireIface = wireIface; - this->devAddress = address; - this->ioconfig[0] = 0xFF; // default input / 1=IN / 0=OUT - this->ioconfig[1] = 0xFF; // default input / 1=IN / 0=OUT - this->conf = 0x00; - for(uint8_t i=0; iintensity); i++){ - this->intensity[i] = 0xff; - } -} - -/** - * @brief Initalizer function - * @return 0 on success, 1 on I2C transmission error - * @pre all Inputs & Outputs must be declared before calling begin() - */ -uint8_t MAX7313::begin(){ - uint8_t ret = 0; - ret += this->write8(MAX7313_PORTS_CONF_00_07, this->ioconfig[0]); - ret += this->write8(MAX7313_PORTS_CONF_08_15, this->ioconfig[1]); - ret += this->write8(MAX7313_BLINK_PHASE_0_00_07, 0xff); - ret += this->write8(MAX7313_BLINK_PHASE_0_08_15, 0xff); - ret += this->write8(MAX7313_CONFIGURATION, this->conf); - ret += this->write8(MAX7313_OUT_INT_MA_16, 0xff); - if(ret) - return 1; - return 0; -} - -/** - * @brief enables data change interrupt on !INT/O16 pin - * @return 0 on success, 1 on I2C transmission error - * @see MAX7313 datasheet p.7 / p.13 - 15 - * @important The MAX7313 signals a data change interrupt with a falling edge on the !INT/O16 pin - * and will stay in LOW state as long as the interrput flag is not reset by reading input registers. - * You can use MAX7313::clearInterrupt() - */ -uint8_t MAX7313::enableInterrupt(){ - this->conf |= 0x08; - if(this->write8(MAX7313_CONFIGURATION, this->conf)) - return 1; - if(this->clearInterrupt()) - return 1; - return 0; -} - -/** - * @brief disables data change interrupt on !INT/O16 pin - * @return 0 on success, 1 on I2C transmission error - * @see MAX7313 datasheet p.7 / p.13 - 15 - */ -uint8_t MAX7313::disableInterrupt(){ - this->conf &= 0xF7; // clear bit 3 - if(this->write8(MAX7313_CONFIGURATION, this->conf)) - return 1; - return 0; -} - -/** - * @brief clear/validate the data change interrupt - * @details This method is used to clear an interrupt condition (!INT/O16 pin = LOW) - * by reading the input registers. The MAX7313 will pull the !INT/O16 pin HIGH - * and will be armed for another interrupt event. - * @return 0 on success, 1 on I2C transmission error, 2 if interrupts are not enabled - * @see https://github.com/mnemocron/MAX7313/issues/1 - */ -uint8_t MAX7313::clearInterrupt(){ - if(this->conf & 0x08){ - uint8_t devnull = 0; - if(this->read8(MAX7313_READ_IN_00_07, &devnull)) - return 1; - if(this->read8(MAX7313_READ_IN_08_15, &devnull)) - return 1; - } - return 0; -} - -/** - * @brief writes a single value into a MAX7313 register - * @param reg, the destination register's address - * @param val, the value for the destination register - */ -uint8_t MAX7313::write8(uint8_t reg, uint8_t val){ - /** - * @note This is a glue function, - * You can change the hardware-specific functions here, - * if you want to use this library with another compiler (eg. Arduino) - * @note This method writes one byte to the register address reg - */ - if(HAL_I2C_Mem_Write(this->wireIface, this->devAddress, reg, 1, &val, 1, 10) != HAL_OK) - return 1; - return 0; -} - -/** - * @brief reads a single value from a MAX7313 register - * @param reg, the destination register's address - * @param val, pointer to the location where the value shall be stored - * @return 0 on success, 1 on transmission error - */ -uint8_t MAX7313::read8(uint8_t reg, uint8_t *val){ - /** - * @note This is a glue function, - * You can change the hardware-specific functions here, - * if you want to use this library with another compiler (eg. Arduino) - * @note This method reads one byte from the register at address reg - */ - if(HAL_I2C_Mem_Read(this->wireIface, this->devAddress, reg, 1, val, 1, 10) != HAL_OK) - return 1; - return 0; -} - -/** - * @brief Constructor for a MAX7313 PWM Output - * @param chip, MAX7313 class object to which to assign the output - * @param port, the port number on the chip (0-15) - * @param polarity, set the output polarity 0 = active high / 1 = active low - */ -MAX7313Output::MAX7313Output(MAX7313 *chip, uint8_t port, uint8_t polarity=0){ - this->chip = chip; - /* is this */ - if(port < 16 && port > 0) // check port range - this->port = port; - else - this->port = 16; - /** @todo correct port range error handling => what happens if port = 16 is sent to MAX7313 - * port must not be 0 either, because of actual possible I/Os on port 0 */ - - (this->port > 7) ? this->chip->ioconfig[1] &= ~(1<<(this->port%8)) : this->chip->ioconfig[0] &= ~(1<<(this->port)); - if(port % 2) // odd numbered ports 1, 3, 5 ... - this->regmask = 0x0F; - else // even numbered ports 0, 2, 3 ... - this->regmask = 0xF0; - switch(port){ - case 0: - case 1: - this->regmask = 0x0F; - this->ioreg = MAX7313_OUT_INT_01_00; - break; - case 2: - case 3: - this->ioreg = MAX7313_OUT_INT_03_02; - break; - case 4: - case 5: - this->ioreg = MAX7313_OUT_INT_05_04; - break; - case 6: - case 7: - this->ioreg = MAX7313_OUT_INT_07_06; - break; - case 8: - case 9: - this->ioreg = MAX7313_OUT_INT_09_08; - break; - case 10: - case 11: - this->ioreg = MAX7313_OUT_INT_11_10; - break; - case 12: - case 13: - this->ioreg = MAX7313_OUT_INT_13_12; - break; - case 14: - case 15: - this->ioreg = MAX7313_OUT_INT_15_14; - break; - default: - this->ioreg = MAX7313_NO_PORT; - break; - } - this->polarity = polarity; - (this->polarity == 1) ? this->setIntensity(0xf) : this->setIntensity(0x0); - /** @todo check for transmission error in setIntensity */ - /** how to handle/return errors in constructor ? */ -} - -/** - * @brief Constructor for a MAX7313 Input - * @param chip, MAX7313 class object to which to assign the input - * @param port, the port number on the chip (0-15) - */ -MAX7313Input::MAX7313Input(MAX7313 *chip, uint8_t port){ - this->chip = chip; - this->port = port; - (this->port > 7) ? this->chip->ioconfig[1] |= (1<<(this->port%8)) : this->chip->ioconfig[0] |= (1<<(this->port)); - this->regmask = (1<<(port%8)); - if(port < 7) - this->ioreg = MAX7313_READ_IN_00_07; - else if(port < 16) - this->ioreg = MAX7313_READ_IN_08_15; - else - ioreg = MAX7313_NO_PORT; -} - -/** - * @brief set the intensity (brightness) on a MAX7313 Output - * @param intensity (0-15) - * @return 0 on success, 1 on I2C transmission error - */ -uint8_t MAX7313Output::setIntensity(uint8_t intensity){ - if(intensity > 0x0F) - intensity = 0x0F; - //if(intensity < 0) // unnecessary because unsigned int is never < 0 - // intensity = 0; - this->chip->intensity[this->port] = intensity; - uint8_t val; - /* [odd] [even] - register in max7313: xxxx xxxx - intensity[even] 0000 xxxx mask-> 0x0F - intensity[odd] xxxx 0000 shift-> <<4 mask-> 0xF0 - */ - // distinguish between active-high and active-low setting -> invert intensity value accordingly - if(!polarity){ // polarity = 0 - if(this->port % 2) // odd (1,3,5) => this + this-1 [MSB nibble] + [LSB nibble] - val = 0xF0-((this->chip->intensity[this->port]<<4)&0xF0) + 0x0F-(this->chip->intensity[this->port-1]&0x0F); - else // even (0,2,4) => this+1 + this - val = 0xF0-((this->chip->intensity[this->port+1]<<4)&0xF0) + 0x0F-(this->chip->intensity[this->port]&0x0F); - } else { - if(this->port % 2) // odd (1,3,5) => this + this-1 - val = ((this->chip->intensity[this->port]<<4)&0xF0) + (this->chip->intensity[this->port-1]&0x0F); - else // even (0,2,4) => this+1 + this - val = ((this->chip->intensity[this->port+1]<<4)&0xF0) + (this->chip->intensity[this->port]&0x0F); - } - - if(this->chip->write8(this->ioreg, val)) - return 1; - return 0; -} - -/** - * @brief read the digital input value form a MAX7313 Input - * @return 0 = digital LOW, 1 = digital HIGH - * @todo how to signal transmission error? => parameter = pointer to return value / return value = transmission success/error - */ -uint8_t MAX7313Input::read(){ - uint8_t ret = 0; - this->chip->read8(this->ioreg, &ret); - /** I haven't figured out how to correctly shift and bitmask the return value - * but since the return value in this case is only a 1-bit value it is not of great importance - * the if statement below works for 1-bit values */ - ret = ret&this->regmask; - //ret = ret>>(this->port); - if(ret) return 1; - return 0; -} diff --git a/cpp/MAX7313.hpp b/cpp/MAX7313.hpp deleted file mode 100644 index 350417b..0000000 --- a/cpp/MAX7313.hpp +++ /dev/null @@ -1,99 +0,0 @@ - -/** - * @note STILL IN DEVELOPMENT - * @file max3713.cpp - * @author Simon Burkhardt github.com/mnemocron - * @copyright MIT license - * @date 19 Jan 2018 - * @brief Object oriented C++ library for the MAX7313 port expander for STM32 HAL. - * @details - * @see github.com/mnemocron - * @see https://datasheets.maximintegrated.com/en/ds/MAX7313.pdf - * @see https://forum.arduino.cc/index.php?topic=9682.0 - * - * @todo documentation of individual methods - */ - -#ifndef _MAX7313_H -#define _MAX7313_H - -/** - * @note tested using STM32F373 - */ -#ifndef STM32F3XX_H -#include "stm32f3xx_hal.h" -#endif - -#ifndef STM32F3XX_HAL_I2C_H -#include "stm32f3xx_hal_i2c.h" -#endif - -/** - * @note datasheet p.13 table 2. Register Address Map - * @see https://datasheets.maximintegrated.com/en/ds/MAX7313.pdf - */ -#define MAX7313_READ_IN_00_07 0x00 -#define MAX7313_READ_IN_08_15 0x01 -#define MAX7313_BLINK_PHASE_0_00_07 0x02 -#define MAX7313_BLINK_PHASE_0_08_15 0x03 -#define MAX7313_PORTS_CONF_00_07 0x06 -#define MAX7313_PORTS_CONF_08_15 0x07 -#define MAX7313_BLINK_PHASE_1_00_07 0x0A -#define MAX7313_BLINK_PHASE_1_08_15 0x0B -#define MAX7313_OUT_INT_MA_16 0x0E -#define MAX7313_CONFIGURATION 0x0F -#define MAX7313_OUT_INT_01_00 0x10 -#define MAX7313_OUT_INT_03_02 0x11 -#define MAX7313_OUT_INT_05_04 0x12 -#define MAX7313_OUT_INT_07_06 0x13 -#define MAX7313_OUT_INT_09_08 0x14 -#define MAX7313_OUT_INT_11_10 0x15 -#define MAX7313_OUT_INT_13_12 0x16 -#define MAX7313_OUT_INT_15_14 0x17 -#define MAX7313_NO_PORT 0x88 // @todo check that this address is not within the address space of MAX7313 OR add check for NO_PORT befor writing to i2c bus - -class MAX7313 -{ - private: - uint16_t devAddress; - I2C_HandleTypeDef *wireIface; - uint8_t conf; - public: - uint8_t intensity[16]; - uint8_t ioconfig[2]; - uint8_t begin(); - - MAX7313(I2C_HandleTypeDef *wireIface, uint16_t address); - uint8_t write8(uint8_t reg, uint8_t val); - uint8_t read8(uint8_t reg, uint8_t *val); - uint8_t enableInterrupt(); - uint8_t disableInterrupt(); - uint8_t clearInterrupt(); -}; - -class MAX7313Output -{ - private: - MAX7313 *chip; - uint8_t port; - uint8_t ioreg; - uint8_t regmask; - uint8_t polarity; - public: - MAX7313Output(MAX7313 *chip, uint8_t port, uint8_t polarity); - uint8_t setIntensity(uint8_t intensity); -}; - -class MAX7313Input -{ - private: - MAX7313 *chip; - uint8_t port; - uint8_t ioreg; - uint8_t regmask; - public: - MAX7313Input(MAX7313 *chip, uint8_t port); - uint8_t read(); -}; - -#endif diff --git a/example/c/Src/main.c b/example/Src/main.c similarity index 100% rename from example/c/Src/main.c rename to example/Src/main.c diff --git a/example/c/Src/stm32f3xx_it.c b/example/Src/stm32f3xx_it.c similarity index 100% rename from example/c/Src/stm32f3xx_it.c rename to example/Src/stm32f3xx_it.c diff --git a/example/cpp/README.md b/example/cpp/README.md deleted file mode 100644 index b443a1a..0000000 --- a/example/cpp/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# C++ Example Code - ---- - -### Usage - -```cpp -/* USER CODE BEGIN Includes */ -#include "max7313.h" // include the library -``` - -```cpp -/* USER CODE BEGIN 0 */ -#define MAX7313_1 0x42 // 100 0010 - -MAX7313 ioDriver(&hi2c1, MAX7313_1); // declare new port expander chip on hi2c interface - -MAX7313Output LED_0 (&ioDriver_2, 8, 0); // new output on port 8, active HIGH -MAX7313Input Button_0 (&ioDriver_2, 2); // new input on port 8 -/* USER CODE END 0 */ - -int main(void) -{ - - /* USER CODE BEGIN 2 */ - ioDriver.begin(); // initialize the port expander chip - /* USER CODE END 2 */ - - /* Infinite loop */ - /* USER CODE BEGIN WHILE */ - while (1) - { - /* USER CODE END WHILE */ - - /* USER CODE BEGIN 3 */ - LED_0.setIntensity(15); // 15 = max brightness - HAL_Delay(500); - LED_0.setIntensity(0); // 0 = off - HAL_Delay(500); - } - /* USER CODE END 3 */ - -} -``` - -### Interrupts - -enable EXTI/GPIO interrupt with **falling edge** detection in the configuration and handle the respective interrupts in `stm32f3xx_it.c` - -```cpp - -/** -* @brief This function handles EXTI line[9:5] interrupts. -*/ -void EXTI9_5_IRQHandler(void) -{ - /* USER CODE BEGIN EXTI9_5_IRQn 0 */ - // handle data change interrupt - if(__HAL_GPIO_EXTI_GET_FLAG(GPIO_PIN_5)){ - // handle the interrupt, eg. read out the button value - // when an interrupt occurs, the interrupt must be reset on the port expander - // use .clearInterrupt() or just read out the input registers - } - - /* USER CODE END EXTI9_5_IRQn 0 */ - HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_5); - /* USER CODE BEGIN EXTI9_5_IRQn 1 */ - - /* USER CODE END EXTI9_5_IRQn 1 */ -} -``` - diff --git a/example/cpp/Src/main.c b/example/cpp/Src/main.c deleted file mode 100644 index 4435fd1..0000000 --- a/example/cpp/Src/main.c +++ /dev/null @@ -1,520 +0,0 @@ -/** - ****************************************************************************** - * File Name : main.c - * Description : Main program body - ****************************************************************************** - ** This notice applies to any and all portions of this file - * that are not between comment pairs USER CODE BEGIN and - * USER CODE END. Other portions of this file, whether - * inserted by the user or by software development tools - * are owned by their respective copyright owners. - * - * COPYRIGHT(c) 2017 STMicroelectronics - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ -/* Includes ------------------------------------------------------------------*/ -#include "main.h" -#include "stm32f3xx_hal.h" - -/* USER CODE BEGIN Includes */ -#include "max7313.h" - -/* USER CODE END Includes */ - -/* Private variables ---------------------------------------------------------*/ -I2C_HandleTypeDef hi2c1; -SMBUS_HandleTypeDef hsmbus2; - -SPI_HandleTypeDef hspi2; - -UART_HandleTypeDef huart1; -UART_HandleTypeDef huart2; - -PCD_HandleTypeDef hpcd_USB_FS; - -/* USER CODE BEGIN PV */ -/* Private variables ---------------------------------------------------------*/ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -void SystemClock_Config(void); -static void MX_GPIO_Init(void); -static void MX_USART1_UART_Init(void); -static void MX_USART2_UART_Init(void); -static void MX_I2C1_Init(void); -static void MX_I2C2_SMBUS_Init(void); -static void MX_SPI2_Init(void); -static void MX_USB_PCD_Init(void); - -/* USER CODE BEGIN PFP */ -/* Private function prototypes -----------------------------------------------*/ - -/* USER CODE END PFP */ - -/* USER CODE BEGIN 0 */ -#define MAX7313_1 0x42 // 100 0010 -#define MAX7313_2 0x44 // 100 0100 - -MAX7313 ioDriver_1(&hi2c1, MAX7313_1); -MAX7313 ioDriver_2(&hi2c1, MAX7313_2); - -MAX7313Output LED_Bat_0proz (&ioDriver_2, 7, 0); -MAX7313Output LED_Bat_10proz (&ioDriver_2, 8, 0); -MAX7313Output LED_Bat_20proz (&ioDriver_2, 9, 0); -MAX7313Output LED_Bat_30proz (&ioDriver_2,10, 0); -MAX7313Output LED_Bat_40proz (&ioDriver_2,14, 0); -MAX7313Output LED_Bat_50proz (&ioDriver_2,15, 0); -MAX7313Output LED_Bat_60proz (&ioDriver_1, 8, 0); -MAX7313Output LED_Bat_70proz (&ioDriver_1, 9, 0); -MAX7313Output LED_Bat_80proz (&ioDriver_1,13, 0); -MAX7313Output LED_Bat_90proz (&ioDriver_1,14, 0); -MAX7313Output LED_Bat_100proz(&ioDriver_1, 4, 0); -MAX7313Output LED_Bat_110proz(&ioDriver_1, 1, 0); -MAX7313Input Button_SW4(&ioDriver_2, 1); -MAX7313Input Button_SW3(&ioDriver_2, 2); -MAX7313Input Button_SW2(&ioDriver_2, 3); -MAX7313Input Button_SW1(&ioDriver_2, 4); - -uint8_t interrupt_val = 0; - -// Cled k(3); // Test if C++ libraries actually work - -/* USER CODE END 0 */ - -int main(void) -{ - - /* USER CODE BEGIN 1 */ - - /* USER CODE END 1 */ - - /* MCU Configuration----------------------------------------------------------*/ - - /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ - HAL_Init(); - - /* USER CODE BEGIN Init */ - - /* USER CODE END Init */ - - /* Configure the system clock */ - SystemClock_Config(); - - /* USER CODE BEGIN SysInit */ - - /* USER CODE END SysInit */ - - /* Initialize all configured peripherals */ - MX_GPIO_Init(); - MX_USART1_UART_Init(); - MX_USART2_UART_Init(); - MX_I2C1_Init(); - MX_I2C2_SMBUS_Init(); - MX_SPI2_Init(); - MX_USB_PCD_Init(); - - /* USER CODE BEGIN 2 */ - //ioDriver_2.enableInterrupt(); - ioDriver_1.begin(); - ioDriver_2.begin(); - ioDriver_2.enableInterrupt(); - - LED_Bat_0proz.setIntensity(1); - - /* USER CODE END 2 */ - - /* Infinite loop */ - /* USER CODE BEGIN WHILE */ - while (1) - { - /* USER CODE END WHILE */ - - /* USER CODE BEGIN 3 */ - HAL_Delay(250); - LED_Bat_100proz.setIntensity(0); - HAL_Delay(250); - LED_Bat_100proz.setIntensity(1); - - } - /* USER CODE END 3 */ - -} - -/** System Clock Configuration -*/ -void SystemClock_Config(void) -{ - - RCC_OscInitTypeDef RCC_OscInitStruct; - RCC_ClkInitTypeDef RCC_ClkInitStruct; - RCC_PeriphCLKInitTypeDef PeriphClkInit; - - /**Initializes the CPU, AHB and APB busses clocks - */ - RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSE; - RCC_OscInitStruct.HSEState = RCC_HSE_ON; - RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; - RCC_OscInitStruct.HSIState = RCC_HSI_ON; - RCC_OscInitStruct.HSICalibrationValue = 16; - RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; - RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; - RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL3; - if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) - { - _Error_Handler(__FILE__, __LINE__); - } - - /**Initializes the CPU, AHB and APB busses clocks - */ - RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK - |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; - RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; - RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; - RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; - RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; - - if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) - { - _Error_Handler(__FILE__, __LINE__); - } - - PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB|RCC_PERIPHCLK_USART1 - |RCC_PERIPHCLK_USART2|RCC_PERIPHCLK_I2C1 - |RCC_PERIPHCLK_I2C2; - PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2; - PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1; - PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_HSI; - PeriphClkInit.I2c2ClockSelection = RCC_I2C2CLKSOURCE_HSI; - PeriphClkInit.USBClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) - { - _Error_Handler(__FILE__, __LINE__); - } - - /**Configure the Systick interrupt time - */ - HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); - - /**Configure the Systick - */ - HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); - - /* SysTick_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); -} - -/* I2C1 init function */ -static void MX_I2C1_Init(void) -{ - - hi2c1.Instance = I2C1; - hi2c1.Init.Timing = 0x2000090E; - hi2c1.Init.OwnAddress1 = 0; - hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; - hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; - hi2c1.Init.OwnAddress2 = 0; - hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK; - hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; - hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; - if (HAL_I2C_Init(&hi2c1) != HAL_OK) - { - _Error_Handler(__FILE__, __LINE__); - } - - /**Configure Analogue filter - */ - if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK) - { - _Error_Handler(__FILE__, __LINE__); - } - - /**Configure Digital filter - */ - if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK) - { - _Error_Handler(__FILE__, __LINE__); - } - -} - -/* I2C2 init function */ -static void MX_I2C2_SMBUS_Init(void) -{ - - hsmbus2.Instance = I2C2; - hsmbus2.Init.Timing = 0x2000090E; - hsmbus2.Init.AnalogFilter = SMBUS_ANALOGFILTER_ENABLE; - hsmbus2.Init.OwnAddress1 = 2; - hsmbus2.Init.AddressingMode = SMBUS_ADDRESSINGMODE_7BIT; - hsmbus2.Init.DualAddressMode = SMBUS_DUALADDRESS_DISABLE; - hsmbus2.Init.OwnAddress2 = 0; - hsmbus2.Init.OwnAddress2Masks = SMBUS_OA2_NOMASK; - hsmbus2.Init.GeneralCallMode = SMBUS_GENERALCALL_DISABLE; - hsmbus2.Init.NoStretchMode = SMBUS_NOSTRETCH_DISABLE; - hsmbus2.Init.PacketErrorCheckMode = SMBUS_PEC_DISABLE; - hsmbus2.Init.PeripheralMode = SMBUS_PERIPHERAL_MODE_SMBUS_SLAVE; - hsmbus2.Init.SMBusTimeout = 0x00008061; - if (HAL_SMBUS_Init(&hsmbus2) != HAL_OK) - { - _Error_Handler(__FILE__, __LINE__); - } - - /**configuration Alert Mode - */ - if (HAL_SMBUS_EnableAlert_IT(&hsmbus2) != HAL_OK) - { - _Error_Handler(__FILE__, __LINE__); - } - -} - -/* SPI2 init function */ -static void MX_SPI2_Init(void) -{ - - /* SPI2 parameter configuration*/ - hspi2.Instance = SPI2; - hspi2.Init.Mode = SPI_MODE_MASTER; - hspi2.Init.Direction = SPI_DIRECTION_2LINES; - hspi2.Init.DataSize = SPI_DATASIZE_4BIT; - hspi2.Init.CLKPolarity = SPI_POLARITY_LOW; - hspi2.Init.CLKPhase = SPI_PHASE_1EDGE; - hspi2.Init.NSS = SPI_NSS_SOFT; - hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2; - hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB; - hspi2.Init.TIMode = SPI_TIMODE_DISABLE; - hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; - hspi2.Init.CRCPolynomial = 7; - hspi2.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE; - hspi2.Init.NSSPMode = SPI_NSS_PULSE_ENABLE; - if (HAL_SPI_Init(&hspi2) != HAL_OK) - { - _Error_Handler(__FILE__, __LINE__); - } - -} - -/* USART1 init function */ -static void MX_USART1_UART_Init(void) -{ - - huart1.Instance = USART1; - huart1.Init.BaudRate = 38400; - huart1.Init.WordLength = UART_WORDLENGTH_8B; - huart1.Init.StopBits = UART_STOPBITS_1; - huart1.Init.Parity = UART_PARITY_NONE; - huart1.Init.Mode = UART_MODE_TX_RX; - huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; - huart1.Init.OverSampling = UART_OVERSAMPLING_16; - huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; - huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; - if (HAL_UART_Init(&huart1) != HAL_OK) - { - _Error_Handler(__FILE__, __LINE__); - } - -} - -/* USART2 init function */ -static void MX_USART2_UART_Init(void) -{ - - huart2.Instance = USART2; - huart2.Init.BaudRate = 38400; - huart2.Init.WordLength = UART_WORDLENGTH_8B; - huart2.Init.StopBits = UART_STOPBITS_1; - huart2.Init.Parity = UART_PARITY_NONE; - huart2.Init.Mode = UART_MODE_TX_RX; - huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE; - huart2.Init.OverSampling = UART_OVERSAMPLING_16; - huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; - huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; - if (HAL_UART_Init(&huart2) != HAL_OK) - { - _Error_Handler(__FILE__, __LINE__); - } - -} - -/* USB init function */ -static void MX_USB_PCD_Init(void) -{ - - hpcd_USB_FS.Instance = USB; - hpcd_USB_FS.Init.dev_endpoints = 8; - hpcd_USB_FS.Init.speed = PCD_SPEED_FULL; - hpcd_USB_FS.Init.ep0_mps = DEP0CTL_MPS_64; - hpcd_USB_FS.Init.phy_itface = PCD_PHY_EMBEDDED; - hpcd_USB_FS.Init.low_power_enable = DISABLE; - hpcd_USB_FS.Init.battery_charging_enable = DISABLE; - if (HAL_PCD_Init(&hpcd_USB_FS) != HAL_OK) - { - _Error_Handler(__FILE__, __LINE__); - } - -} - -/** Configure pins as - * Analog - * Input - * Output - * EVENT_OUT - * EXTI -*/ -static void MX_GPIO_Init(void) -{ - - GPIO_InitTypeDef GPIO_InitStruct; - - /* GPIO Ports Clock Enable */ - __HAL_RCC_GPIOC_CLK_ENABLE(); - __HAL_RCC_GPIOF_CLK_ENABLE(); - __HAL_RCC_GPIOA_CLK_ENABLE(); - __HAL_RCC_GPIOB_CLK_ENABLE(); - __HAL_RCC_GPIOE_CLK_ENABLE(); - __HAL_RCC_GPIOD_CLK_ENABLE(); - - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOC, U23_RUN1_Pin|U23_RUN0_Pin, GPIO_PIN_RESET); - - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOB, SHD_MPPT_Pin|EN2_VccS_Pin|_5V_Power_On_Pin, GPIO_PIN_RESET); - - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(SS_GPIO_Port, SS_Pin, GPIO_PIN_RESET); - - /*Configure GPIO pins : U23_ALERT_Pin Alert_CM_Pin U61_PGOOD2_Pin */ - GPIO_InitStruct.Pin = U23_ALERT_Pin|Alert_CM_Pin|U61_PGOOD2_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /*Configure GPIO pins : U23_RUN1_Pin U23_RUN0_Pin */ - GPIO_InitStruct.Pin = U23_RUN1_Pin|U23_RUN0_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /*Configure GPIO pins : Solar_Voltage_Pin Stromverbrauch_DCDC_Pin Spannungsmessung_Batterie_Pin Mess_V_USB_Pin */ - GPIO_InitStruct.Pin = Solar_Voltage_Pin|Stromverbrauch_DCDC_Pin|Spannungsmessung_Batterie_Pin|Mess_V_USB_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /*Configure GPIO pin : Temp_Set_Pin */ - GPIO_InitStruct.Pin = Temp_Set_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(Temp_Set_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pins : SHD_MPPT_Pin EN2_VccS_Pin _5V_Power_On_Pin */ - GPIO_InitStruct.Pin = SHD_MPPT_Pin|EN2_VccS_Pin|_5V_Power_On_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /*Configure GPIO pin : Fault_MPPT_Pin */ - GPIO_InitStruct.Pin = Fault_MPPT_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(Fault_MPPT_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pin : SS_Pin */ - GPIO_InitStruct.Pin = SS_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(SS_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pin : U61_PGOOD1_Pin */ - GPIO_InitStruct.Pin = U61_PGOOD1_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(U61_PGOOD1_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pins : Interrupt_HMI2_Pin USB_Flag_Pin */ - GPIO_InitStruct.Pin = Interrupt_HMI2_Pin|USB_Flag_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /* EXTI interrupt init*/ - HAL_NVIC_SetPriority(EXTI9_5_IRQn, 3, 0); - HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); - -} - -/* USER CODE BEGIN 4 */ - -/* USER CODE END 4 */ - -/** - * @brief This function is executed in case of error occurrence. - * @param None - * @retval None - */ -void _Error_Handler(char * file, int line) -{ - /* USER CODE BEGIN Error_Handler_Debug */ - /* User can add his own implementation to report the HAL error return state */ - while(1) - { - } - /* USER CODE END Error_Handler_Debug */ -} - -#ifdef USE_FULL_ASSERT - -/** - * @brief Reports the name of the source file and the source line number - * where the assert_param error has occurred. - * @param file: pointer to the source file name - * @param line: assert_param error line source number - * @retval None - */ -void assert_failed(uint8_t* file, uint32_t line) -{ - /* USER CODE BEGIN 6 */ - /* User can add his own implementation to report the file name and line number, - ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ - /* USER CODE END 6 */ - -} - -#endif - -/** - * @} - */ - -/** - * @} -*/ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/example/cpp/Src/stm32f3xx_it.c b/example/cpp/Src/stm32f3xx_it.c deleted file mode 100644 index 43a0eae..0000000 --- a/example/cpp/Src/stm32f3xx_it.c +++ /dev/null @@ -1,237 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f3xx_it.c - * @brief Interrupt Service Routines. - ****************************************************************************** - * - * COPYRIGHT(c) 2017 STMicroelectronics - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ -/* Includes ------------------------------------------------------------------*/ -#include "stm32f3xx_hal.h" -#include "stm32f3xx.h" -#include "stm32f3xx_it.h" - -/* USER CODE BEGIN 0 */ -#include "max7313.h" -extern MAX7313 ioDriver_2; -extern MAX7313Input Button_SW4; -extern MAX7313Input Button_SW3; -extern MAX7313Input Button_SW2; -extern MAX7313Input Button_SW1; -extern MAX7313Output LED_Bat_60proz; -extern MAX7313Output LED_Bat_70proz; -extern MAX7313Output LED_Bat_80proz; -extern MAX7313Output LED_Bat_90proz; -extern uint8_t interrupt_val; -/* USER CODE END 0 */ - -/* External variables --------------------------------------------------------*/ - -/******************************************************************************/ -/* Cortex-M4 Processor Interruption and Exception Handlers */ -/******************************************************************************/ - -/** -* @brief This function handles Non maskable interrupt. -*/ -void NMI_Handler(void) -{ - /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ - - /* USER CODE END NonMaskableInt_IRQn 0 */ - /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ - - /* USER CODE END NonMaskableInt_IRQn 1 */ -} - -/** -* @brief This function handles Hard fault interrupt. -*/ -void HardFault_Handler(void) -{ - /* USER CODE BEGIN HardFault_IRQn 0 */ - - /* USER CODE END HardFault_IRQn 0 */ - while (1) - { - } - /* USER CODE BEGIN HardFault_IRQn 1 */ - - /* USER CODE END HardFault_IRQn 1 */ -} - -/** -* @brief This function handles Memory management fault. -*/ -void MemManage_Handler(void) -{ - /* USER CODE BEGIN MemoryManagement_IRQn 0 */ - - /* USER CODE END MemoryManagement_IRQn 0 */ - while (1) - { - } - /* USER CODE BEGIN MemoryManagement_IRQn 1 */ - - /* USER CODE END MemoryManagement_IRQn 1 */ -} - -/** -* @brief This function handles Prefetch fault, memory access fault. -*/ -void BusFault_Handler(void) -{ - /* USER CODE BEGIN BusFault_IRQn 0 */ - - /* USER CODE END BusFault_IRQn 0 */ - while (1) - { - } - /* USER CODE BEGIN BusFault_IRQn 1 */ - - /* USER CODE END BusFault_IRQn 1 */ -} - -/** -* @brief This function handles Undefined instruction or illegal state. -*/ -void UsageFault_Handler(void) -{ - /* USER CODE BEGIN UsageFault_IRQn 0 */ - - /* USER CODE END UsageFault_IRQn 0 */ - while (1) - { - } - /* USER CODE BEGIN UsageFault_IRQn 1 */ - - /* USER CODE END UsageFault_IRQn 1 */ -} - -/** -* @brief This function handles System service call via SWI instruction. -*/ -void SVC_Handler(void) -{ - /* USER CODE BEGIN SVCall_IRQn 0 */ - - /* USER CODE END SVCall_IRQn 0 */ - /* USER CODE BEGIN SVCall_IRQn 1 */ - - /* USER CODE END SVCall_IRQn 1 */ -} - -/** -* @brief This function handles Debug monitor. -*/ -void DebugMon_Handler(void) -{ - /* USER CODE BEGIN DebugMonitor_IRQn 0 */ - - /* USER CODE END DebugMonitor_IRQn 0 */ - /* USER CODE BEGIN DebugMonitor_IRQn 1 */ - - /* USER CODE END DebugMonitor_IRQn 1 */ -} - -/** -* @brief This function handles Pendable request for system service. -*/ -void PendSV_Handler(void) -{ - /* USER CODE BEGIN PendSV_IRQn 0 */ - - /* USER CODE END PendSV_IRQn 0 */ - /* USER CODE BEGIN PendSV_IRQn 1 */ - - /* USER CODE END PendSV_IRQn 1 */ -} - -/** -* @brief This function handles System tick timer. -*/ -void SysTick_Handler(void) -{ - /* USER CODE BEGIN SysTick_IRQn 0 */ - - /* USER CODE END SysTick_IRQn 0 */ - HAL_IncTick(); - HAL_SYSTICK_IRQHandler(); - /* USER CODE BEGIN SysTick_IRQn 1 */ - - /* USER CODE END SysTick_IRQn 1 */ -} - -/******************************************************************************/ -/* STM32F3xx Peripheral Interrupt Handlers */ -/* Add here the Interrupt Handlers for the used peripherals. */ -/* For the available peripheral interrupt handler names, */ -/* please refer to the startup file (startup_stm32f3xx.s). */ -/******************************************************************************/ - -/** -* @brief This function handles EXTI line[9:5] interrupts. -*/ -void EXTI9_5_IRQHandler(void) -{ - /* USER CODE BEGIN EXTI9_5_IRQn 0 */ - if(__HAL_GPIO_EXTI_GET_FLAG(Interrupt_HMI2_Pin)){ - ioDriver_2.clearInterrupt(); - if(Button_SW1.read()) - LED_Bat_60proz.setIntensity(0); - else - LED_Bat_60proz.setIntensity(1); - - if(Button_SW2.read()) - LED_Bat_70proz.setIntensity(0); - else - LED_Bat_70proz.setIntensity(1); - - if(Button_SW3.read()) - LED_Bat_80proz.setIntensity(0); - else - LED_Bat_80proz.setIntensity(1); - - if(Button_SW4.read()) - LED_Bat_90proz.setIntensity(0); - else - LED_Bat_90proz.setIntensity(1); - } - - /* USER CODE END EXTI9_5_IRQn 0 */ - HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_5); - HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_6); - HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_7); - /* USER CODE BEGIN EXTI9_5_IRQn 1 */ - - /* USER CODE END EXTI9_5_IRQn 1 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/example/cpp/stm32f3xx_example.ioc b/example/cpp/stm32f3xx_example.ioc deleted file mode 100644 index 4bf33fe..0000000 --- a/example/cpp/stm32f3xx_example.ioc +++ /dev/null @@ -1,293 +0,0 @@ -#MicroXplorer Configuration settings - do not modify -File.Version=6 -KeepUserPlacement=false -Mcu.Family=STM32F3 -Mcu.IP0=I2C1 -Mcu.IP1=I2C2 -Mcu.IP2=NVIC -Mcu.IP3=RCC -Mcu.IP4=SPI2 -Mcu.IP5=SYS -Mcu.IP6=USART1 -Mcu.IP7=USART2 -Mcu.IP8=USB -Mcu.IPNb=9 -Mcu.Name=STM32F373R(8-B-C)Tx -Mcu.Package=LQFP64 -Mcu.Pin0=PC14-OSC32_IN -Mcu.Pin1=PC15-OSC32_OUT -Mcu.Pin10=PA2 -Mcu.Pin11=PA3 -Mcu.Pin12=PA4 -Mcu.Pin13=PA5 -Mcu.Pin14=PA6 -Mcu.Pin15=PC4 -Mcu.Pin16=PC5 -Mcu.Pin17=PB0 -Mcu.Pin18=PB1 -Mcu.Pin19=PB2 -Mcu.Pin2=PF0-OSC_IN -Mcu.Pin20=PE8 -Mcu.Pin21=PB14 -Mcu.Pin22=PB15 -Mcu.Pin23=PD8 -Mcu.Pin24=PA8 -Mcu.Pin25=PA9 -Mcu.Pin26=PA10 -Mcu.Pin27=PA11 -Mcu.Pin28=PA12 -Mcu.Pin29=PC12 -Mcu.Pin3=PF1-OSC_OUT -Mcu.Pin30=PD2 -Mcu.Pin31=PB5 -Mcu.Pin32=PB6 -Mcu.Pin33=PB7 -Mcu.Pin34=PB8 -Mcu.Pin35=PB9 -Mcu.Pin36=VP_SYS_VS_Systick -Mcu.Pin4=PC0 -Mcu.Pin5=PC1 -Mcu.Pin6=PC2 -Mcu.Pin7=PC3 -Mcu.Pin8=PA0 -Mcu.Pin9=PA1 -Mcu.PinsNb=37 -Mcu.UserConstants= -Mcu.UserName=STM32F373R8Tx -MxCube.Version=4.22.1 -MxDb.Version=DB.4.0.221 -NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false -NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false -NVIC.EXTI9_5_IRQn=true\:3\:0\:true\:false\:true\:true -NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false -NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false -NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false -NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false -NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false -PA0.GPIOParameters=GPIO_Label -PA0.GPIO_Label=Solar Voltage -PA0.Locked=true -PA0.Signal=GPIO_Analog -PA1.GPIOParameters=GPIO_Label -PA1.GPIO_Label=Stromverbrauch DCDC -PA1.Locked=true -PA1.Signal=GPIO_Analog -PA10.Locked=true -PA10.Mode=SMBus-Alert-mode -PA10.Signal=I2C2_SDA -PA11.Mode=Device -PA11.Signal=USB_DM -PA12.Mode=Device -PA12.Signal=USB_DP -PA2.Locked=true -PA2.Mode=Asynchronous -PA2.Signal=USART2_TX -PA3.Locked=true -PA3.Mode=Asynchronous -PA3.Signal=USART2_RX -PA4.GPIOParameters=GPIO_Label -PA4.GPIO_Label=Spannungsmessung Batterie -PA4.Locked=true -PA4.Signal=GPIO_Analog -PA5.GPIOParameters=GPIO_Label -PA5.GPIO_Label=Mess_V_USB -PA5.Locked=true -PA5.Signal=GPIO_Analog -PA6.GPIOParameters=GPIO_Label -PA6.GPIO_Label=Temp_Set -PA6.Locked=true -PA6.Signal=GPXTI6 -PA8.Locked=true -PA8.Mode=SMBus-Alert-mode -PA8.Signal=I2C2_SMBA -PA9.Locked=true -PA9.Mode=SMBus-Alert-mode -PA9.Signal=I2C2_SCL -PB0.GPIOParameters=GPIO_Label -PB0.GPIO_Label=SHD MPPT -PB0.Locked=true -PB0.Signal=GPIO_Output -PB1.GPIOParameters=GPIO_Label -PB1.GPIO_Label=Fault MPPT -PB1.Locked=true -PB1.Signal=GPIO_Input -PB14.Locked=true -PB14.Mode=Full_Duplex_Master -PB14.Signal=SPI2_MISO -PB15.Locked=true -PB15.Mode=Full_Duplex_Master -PB15.Signal=SPI2_MOSI -PB2.GPIOParameters=GPIO_Label -PB2.GPIO_Label=EN2_VccS -PB2.Locked=true -PB2.Signal=GPIO_Output -PB5.GPIOParameters=GPIO_Label,GPIO_ModeDefaultEXTI -PB5.GPIO_Label=Interrupt HMI2 -PB5.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING -PB5.Locked=true -PB5.Signal=GPXTI5 -PB6.GPIOParameters=GPIO_Label -PB6.GPIO_Label=_5V-Power On -PB6.Locked=true -PB6.Signal=GPIO_Output -PB7.GPIOParameters=GPIO_Label -PB7.GPIO_Label=USB-Flag -PB7.Locked=true -PB7.Signal=GPXTI7 -PB8.GPIOParameters=GPIO_PuPdOD -PB8.GPIO_PuPdOD=GPIO_NOPULL -PB8.Locked=true -PB8.Mode=I2C -PB8.Signal=I2C1_SCL -PB9.GPIOParameters=GPIO_PuPdOD -PB9.GPIO_PuPdOD=GPIO_NOPULL -PB9.Locked=true -PB9.Mode=I2C -PB9.Signal=I2C1_SDA -PC0.GPIOParameters=GPIO_Label -PC0.GPIO_Label=U23_ALERT -PC0.Locked=true -PC0.Signal=GPXTI0 -PC1.GPIOParameters=GPIO_Label -PC1.GPIO_Label=U23_RUN1 -PC1.Locked=true -PC1.Signal=GPIO_Output -PC12.GPIOParameters=GPIO_Label -PC12.GPIO_Label=U61_PGOOD2 -PC12.Locked=true -PC12.Signal=GPXTI12 -PC14-OSC32_IN.Mode=LSE-External-Oscillator -PC14-OSC32_IN.Signal=RCC_OSC32_IN -PC15-OSC32_OUT.Mode=LSE-External-Oscillator -PC15-OSC32_OUT.Signal=RCC_OSC32_OUT -PC2.GPIOParameters=GPIO_Label -PC2.GPIO_Label=U23_RUN0 -PC2.Locked=true -PC2.Signal=GPIO_Output -PC3.GPIOParameters=GPIO_Label -PC3.GPIO_Label=Alert CM -PC3.Locked=true -PC3.Signal=GPXTI3 -PC4.Locked=true -PC4.Mode=Asynchronous -PC4.Signal=USART1_TX -PC5.Locked=true -PC5.Mode=Asynchronous -PC5.Signal=USART1_RX -PCC.Checker=false -PCC.Line=STM32F373 -PCC.MCU=STM32F373R(8-B-C)Tx -PCC.PartNumber=STM32F373R8Tx -PCC.Seq0=0 -PCC.Series=STM32F3 -PCC.Temperature=25 -PCC.Vdd=3.6 -PD2.GPIOParameters=GPIO_Label -PD2.GPIO_Label=U61_PGOOD1 -PD2.Locked=true -PD2.Signal=GPXTI2 -PD8.Locked=true -PD8.Mode=Full_Duplex_Master -PD8.Signal=SPI2_SCK -PE8.GPIOParameters=GPIO_Label -PE8.GPIO_Label=SS -PE8.Locked=true -PE8.Signal=GPIO_Output -PF0-OSC_IN.Mode=HSE-External-Oscillator -PF0-OSC_IN.Signal=RCC_OSC_IN -PF1-OSC_OUT.Mode=HSE-External-Oscillator -PF1-OSC_OUT.Signal=RCC_OSC_OUT -PinOutPanel.RotationAngle=0 -ProjectManager.AskForMigrate=true -ProjectManager.BackupPrevious=false -ProjectManager.CompilerOptimize=2 -ProjectManager.ComputerToolchain=false -ProjectManager.CoupleFile=false -ProjectManager.CustomerFirmwarePackage=C\:/Users/simon/STM32Cube/Repository/STM32Cube_FW_F3_V1.9.0 -ProjectManager.DefaultFWLocation=true -ProjectManager.DeletePrevious=true -ProjectManager.DeviceId=STM32F373R8Tx -ProjectManager.FirmwarePackage=STM32Cube FW_F3 V1.9.0 -ProjectManager.FreePins=false -ProjectManager.HalAssertFull=false -ProjectManager.HeapSize=0x200 -ProjectManager.KeepUserCode=true -ProjectManager.LastFirmware=true -ProjectManager.LibraryCopy=0 -ProjectManager.PreviousToolchain= -ProjectManager.ProjectBuild=false -ProjectManager.ProjectFileName=SmallWorldProject.ioc -ProjectManager.ProjectName=SmallWorldProject -ProjectManager.StackSize=0x400 -ProjectManager.TargetToolchain=MDK-ARM V5 -ProjectManager.ToolChainLocation= -ProjectManager.UnderRoot=false -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL,2-SystemClock_Config-RCC-false-HAL,3-MX_USART1_UART_Init-USART1-false-HAL,4-MX_USART2_UART_Init-USART2-false-HAL,5-MX_I2C1_Init-I2C1-false-HAL,6-MX_I2C2_SMBUS_Init-I2C2-false-HAL,7-MX_SPI2_Init-SPI2-false-HAL,8-MX_USB_PCD_Init-USB-false-HAL -RCC.ADCoutputFreq_Value=36000000 -RCC.AHBFreq_Value=72000000 -RCC.APB1CLKDivider=RCC_HCLK_DIV2 -RCC.APB1Freq_Value=36000000 -RCC.APB1TimFreq_Value=72000000 -RCC.APB2Freq_Value=72000000 -RCC.APB2TimFreq_Value=72000000 -RCC.CECFreq_Value=32786.88524590164 -RCC.CortexFreq_Value=72000000 -RCC.FCLKCortexFreq_Value=72000000 -RCC.FamilyName=M -RCC.HCLKFreq_Value=72000000 -RCC.HSEPLLFreq_Value=24000000 -RCC.HSE_VALUE=24000000 -RCC.HSICECFreq_Value=32786.88524590164 -RCC.HSIPLLFreq_Value=4000000 -RCC.HSI_VALUE=8000000 -RCC.I2C1Freq_Value=8000000 -RCC.I2CFreq_Value=8000000 -RCC.IPParameters=ADCoutputFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,CECFreq_Value,CortexFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSEPLLFreq_Value,HSE_VALUE,HSICECFreq_Value,HSIPLLFreq_Value,HSI_VALUE,I2C1Freq_Value,I2CFreq_Value,LSI_VALUE,MCOFreq_Value,PLLCLKFreq_Value,PLLMCOFreq_Value,PLLMUL,PRESCALERUSB,PWRFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SDADCoutputFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,TIM2Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USBFreq_Value,VCOOutput2Freq_Value -RCC.LSI_VALUE=40000 -RCC.MCOFreq_Value=72000000 -RCC.PLLCLKFreq_Value=72000000 -RCC.PLLMCOFreq_Value=36000000 -RCC.PLLMUL=RCC_PLL_MUL3 -RCC.PRESCALERUSB=RCC_USBCLKSOURCE_PLL_DIV1_5 -RCC.PWRFreq_Value=72000000 -RCC.RTCFreq_Value=40000 -RCC.RTCHSEDivFreq_Value=750000 -RCC.SDADCoutputFreq_Value=36000000 -RCC.SYSCLKFreq_VALUE=72000000 -RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK -RCC.TIM2Freq_Value=72000000 -RCC.USART1Freq_Value=72000000 -RCC.USART2Freq_Value=36000000 -RCC.USART3Freq_Value=36000000 -RCC.USBFreq_Value=48000000 -RCC.VCOOutput2Freq_Value=24000000 -SH.GPXTI0.0=GPIO_EXTI0 -SH.GPXTI0.ConfNb=1 -SH.GPXTI12.0=GPIO_EXTI12 -SH.GPXTI12.ConfNb=1 -SH.GPXTI2.0=GPIO_EXTI2 -SH.GPXTI2.ConfNb=1 -SH.GPXTI3.0=GPIO_EXTI3 -SH.GPXTI3.ConfNb=1 -SH.GPXTI5.0=GPIO_EXTI5 -SH.GPXTI5.ConfNb=1 -SH.GPXTI6.0=GPIO_EXTI6 -SH.GPXTI6.ConfNb=1 -SH.GPXTI7.0=GPIO_EXTI7 -SH.GPXTI7.ConfNb=1 -SPI2.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_2 -SPI2.CalculateBaudRate=18.0 MBits/s -SPI2.Direction=SPI_DIRECTION_2LINES -SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler -SPI2.Mode=SPI_MODE_MASTER -SPI2.VirtualType=VM_MASTER -USART1.IPParameters=VirtualMode-Asynchronous -USART1.VirtualMode-Asynchronous=VM_ASYNC -USART2.IPParameters=VirtualMode-Asynchronous -USART2.VirtualMode-Asynchronous=VM_ASYNC -VP_SYS_VS_Systick.Mode=SysTick -VP_SYS_VS_Systick.Signal=SYS_VS_Systick -board=SmallWorldProject diff --git a/c/MAX7313.h b/inc/MAX7313.h similarity index 100% rename from c/MAX7313.h rename to inc/MAX7313.h diff --git a/c/MAX7313.c b/src/MAX7313.c similarity index 100% rename from c/MAX7313.c rename to src/MAX7313.c