--- /dev/null
+export
+
+#always set COMDIR (common sources, makefiles, libraries) first
+COMDIR := ../com
+
+#set optimize/debug symbols options
+OPTIMIZE := -O3 -g
+
+#set std libs to be linked
+STDLIBS := -lm
+
+#include common project header
+include $(COMDIR)/pj/pjhdr.mk
+
+#include target/os/lib specific header
+include $(COMDIR)/pj/f767-nucleo-hal.mk
+#SYSTEM := /usr/local/gcc-arm-none-eabi-4_8-2014q3/bin/arm-none-eabi
+#SYSTEM := /usr/local/gcc-arm-none-eabi-4_9-2015q2/bin/arm-none-eabi
+#SYSTEM := /usr/local/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi
+#SYSTEM := /usr/local/gcc-arm-none-eabi-5_2-2015q4/bin/arm-none-eabi
+
+
+#include stm32cube header
+include $(COMDIR)/pj/cube-hal.mk
+
+#include libraries
+INCLIBS := inc
+
+include $(LIBDIR)/libstm32f7xxhal.mk
+
+#include common sources
+INCLIBS := src
+
+include $(CSRCDIR)/syscalls.mk
+
+#start making
+INCLIBS := mk
+
+#set ocd command (interface/target)
+include $(COMDIR)/pj/oocd-stm32f7xx.mk
+OCD = $(OCD-nucleo)
+
+#add sources
+SRCS_C := $(wildcard $(SRCDIR)/*.c)
+SRCS_S := $(wildcard $(SRCDIR)/*.s)
+
+#include common project makefile
+include $(COMDIR)/pj/pj.mk
--- /dev/null
+/**\r
+ ******************************************************************************\r
+ * File Name : dma.h\r
+ * Description : This file contains all the function prototypes for\r
+ * the dma.c file\r
+ ******************************************************************************\r
+ *\r
+ * COPYRIGHT(c) 2016 STMicroelectronics\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without modification,\r
+ * are permitted provided that the following conditions are met:\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors\r
+ * may be used to endorse or promote products derived from this software\r
+ * without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ ******************************************************************************\r
+ */\r
+/* Define to prevent recursive inclusion -------------------------------------*/\r
+#ifndef __dma_H\r
+#define __dma_H\r
+\r
+#ifdef __cplusplus\r
+ extern "C" {\r
+#endif\r
+\r
+/* Includes ------------------------------------------------------------------*/\r
+#include "stm32f7xx_hal.h"\r
+\r
+/* DMA memory to memory transfer handles -------------------------------------*/\r
+extern void Error_Handler(void);\r
+\r
+/* USER CODE BEGIN Includes */\r
+\r
+/* USER CODE END Includes */\r
+\r
+/* USER CODE BEGIN Private defines */\r
+\r
+/* USER CODE END Private defines */\r
+\r
+void MX_DMA_Init(void);\r
+\r
+/* USER CODE BEGIN Prototypes */\r
+\r
+/* USER CODE END Prototypes */\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* __dma_H */\r
+\r
+/**\r
+ * @}\r
+ */\r
+\r
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r
--- /dev/null
+/**\r
+ ******************************************************************************\r
+ * File Name : gpio.h\r
+ * Description : This file contains all the functions prototypes for \r
+ * the gpio \r
+ ******************************************************************************\r
+ *\r
+ * COPYRIGHT(c) 2016 STMicroelectronics\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without modification,\r
+ * are permitted provided that the following conditions are met:\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors\r
+ * may be used to endorse or promote products derived from this software\r
+ * without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ ******************************************************************************\r
+ */\r
+\r
+/* Define to prevent recursive inclusion -------------------------------------*/\r
+#ifndef __gpio_H\r
+#define __gpio_H\r
+#ifdef __cplusplus\r
+ extern "C" {\r
+#endif\r
+\r
+/* Includes ------------------------------------------------------------------*/\r
+#include "stm32f7xx_hal.h"\r
+\r
+/* USER CODE BEGIN Includes */\r
+\r
+/* USER CODE END Includes */\r
+\r
+/* USER CODE BEGIN Private defines */\r
+\r
+/* USER CODE END Private defines */\r
+\r
+void MX_GPIO_Init(void);\r
+\r
+/* USER CODE BEGIN Prototypes */\r
+\r
+/* USER CODE END Prototypes */\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+#endif /*__ pinoutConfig_H */\r
+\r
+/**\r
+ * @}\r
+ */\r
+\r
+/**\r
+ * @}\r
+ */\r
+\r
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r
--- /dev/null
+/**\r
+ ******************************************************************************\r
+ * File Name : mxconstants.h\r
+ * Description : This file contains the common defines of the application\r
+ ******************************************************************************\r
+ *\r
+ * COPYRIGHT(c) 2016 STMicroelectronics\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without modification,\r
+ * are permitted provided that the following conditions are met:\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors\r
+ * may be used to endorse or promote products derived from this software\r
+ * without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ ******************************************************************************\r
+ */\r
+/* Define to prevent recursive inclusion -------------------------------------*/\r
+#ifndef __MXCONSTANT_H\r
+#define __MXCONSTANT_H\r
+ /* Includes ------------------------------------------------------------------*/\r
+\r
+/* USER CODE BEGIN Includes */\r
+\r
+/* USER CODE END Includes */\r
+\r
+/* Private define ------------------------------------------------------------*/\r
+\r
+#define User_Blue_Button_Pin GPIO_PIN_13\r
+#define User_Blue_Button_GPIO_Port GPIOC\r
+#define MCO_Pin GPIO_PIN_0\r
+#define MCO_GPIO_Port GPIOH\r
+#define RMII_MDC_Pin GPIO_PIN_1\r
+#define RMII_MDC_GPIO_Port GPIOC\r
+#define RMII_REF_CLK_Pin GPIO_PIN_1\r
+#define RMII_REF_CLK_GPIO_Port GPIOA\r
+#define RMII_MDIO_Pin GPIO_PIN_2\r
+#define RMII_MDIO_GPIO_Port GPIOA\r
+#define RMII_CRS_DV_Pin GPIO_PIN_7\r
+#define RMII_CRS_DV_GPIO_Port GPIOA\r
+#define RMII_RXD0_Pin GPIO_PIN_4\r
+#define RMII_RXD0_GPIO_Port GPIOC\r
+#define RMII_RXD1_Pin GPIO_PIN_5\r
+#define RMII_RXD1_GPIO_Port GPIOC\r
+#define LD1_Pin GPIO_PIN_0\r
+#define LD1_GPIO_Port GPIOB\r
+#define RMII_TXD1_Pin GPIO_PIN_13\r
+#define RMII_TXD1_GPIO_Port GPIOB\r
+#define LD3_Pin GPIO_PIN_14\r
+#define LD3_GPIO_Port GPIOB\r
+#define STLK_RX_Pin GPIO_PIN_8\r
+#define STLK_RX_GPIO_Port GPIOD\r
+#define STLK_TX_Pin GPIO_PIN_9\r
+#define STLK_TX_GPIO_Port GPIOD\r
+#define USB_PowerSwitchOn_Pin GPIO_PIN_6\r
+#define USB_PowerSwitchOn_GPIO_Port GPIOG\r
+#define USB_OverCurrent_Pin GPIO_PIN_7\r
+#define USB_OverCurrent_GPIO_Port GPIOG\r
+#define USB_SOF_Pin GPIO_PIN_8\r
+#define USB_SOF_GPIO_Port GPIOA\r
+#define USB_VBUS_Pin GPIO_PIN_9\r
+#define USB_VBUS_GPIO_Port GPIOA\r
+#define USB_ID_Pin GPIO_PIN_10\r
+#define USB_ID_GPIO_Port GPIOA\r
+#define USB_DM_Pin GPIO_PIN_11\r
+#define USB_DM_GPIO_Port GPIOA\r
+#define USB_DP_Pin GPIO_PIN_12\r
+#define USB_DP_GPIO_Port GPIOA\r
+#define TMS_Pin GPIO_PIN_13\r
+#define TMS_GPIO_Port GPIOA\r
+#define TCK_Pin GPIO_PIN_14\r
+#define TCK_GPIO_Port GPIOA\r
+#define RMII_TX_EN_Pin GPIO_PIN_11\r
+#define RMII_TX_EN_GPIO_Port GPIOG\r
+#define RMII_TXD0_Pin GPIO_PIN_13\r
+#define RMII_TXD0_GPIO_Port GPIOG\r
+#define SW0_Pin GPIO_PIN_3\r
+#define SW0_GPIO_Port GPIOB\r
+#define LD2_Pin GPIO_PIN_7\r
+#define LD2_GPIO_Port GPIOB\r
+/* USER CODE BEGIN Private defines */\r
+\r
+/* USER CODE END Private defines */\r
+\r
+/**\r
+ * @}\r
+ */ \r
+\r
+/**\r
+ * @}\r
+*/ \r
+\r
+#endif /* __MXCONSTANT_H */\r
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r
--- /dev/null
+/**\r
+ ******************************************************************************\r
+ * @file stm32f7xx_hal_conf.h\r
+ * @brief HAL configuration file.\r
+ ******************************************************************************\r
+ * @attention\r
+ *\r
+ * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without modification,\r
+ * are permitted provided that the following conditions are met:\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors\r
+ * may be used to endorse or promote products derived from this software\r
+ * without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ ******************************************************************************\r
+ */ \r
+\r
+/* Define to prevent recursive inclusion -------------------------------------*/\r
+#ifndef __STM32F7xx_HAL_CONF_H\r
+#define __STM32F7xx_HAL_CONF_H\r
+\r
+#ifdef __cplusplus\r
+ extern "C" {\r
+#endif\r
+\r
+#include "mxconstants.h" \r
+\r
+/* Exported types ------------------------------------------------------------*/\r
+/* Exported constants --------------------------------------------------------*/\r
+\r
+/* ########################## Module Selection ############################## */\r
+/**\r
+ * @brief This is the list of modules to be used in the HAL driver \r
+ */\r
+#define HAL_MODULE_ENABLED \r
+\r
+/* #define HAL_ADC_MODULE_ENABLED */\r
+/* #define HAL_CAN_MODULE_ENABLED */\r
+/* #define HAL_CEC_MODULE_ENABLED */\r
+/* #define HAL_CRC_MODULE_ENABLED */\r
+/* #define HAL_CRYP_MODULE_ENABLED */\r
+/* #define HAL_DAC_MODULE_ENABLED */\r
+/* #define HAL_DCMI_MODULE_ENABLED */\r
+/* #define HAL_DMA2D_MODULE_ENABLED */\r
+/* #define HAL_ETH_MODULE_ENABLED */\r
+/* #define HAL_NAND_MODULE_ENABLED */\r
+/* #define HAL_NOR_MODULE_ENABLED */\r
+/* #define HAL_SRAM_MODULE_ENABLED */\r
+/* #define HAL_SDRAM_MODULE_ENABLED */\r
+/* #define HAL_HASH_MODULE_ENABLED */\r
+/* #define HAL_I2S_MODULE_ENABLED */\r
+/* #define HAL_IWDG_MODULE_ENABLED */\r
+/* #define HAL_LPTIM_MODULE_ENABLED */\r
+/* #define HAL_LTDC_MODULE_ENABLED */\r
+/* #define HAL_QSPI_MODULE_ENABLED */\r
+/* #define HAL_RNG_MODULE_ENABLED */\r
+/* #define HAL_RTC_MODULE_ENABLED */\r
+/* #define HAL_SAI_MODULE_ENABLED */\r
+/* #define HAL_SD_MODULE_ENABLED */\r
+/* #define HAL_SPDIFRX_MODULE_ENABLED */\r
+/* #define HAL_SPI_MODULE_ENABLED */\r
+/* #define HAL_TIM_MODULE_ENABLED */\r
+#define HAL_UART_MODULE_ENABLED\r
+/* #define HAL_USART_MODULE_ENABLED */\r
+/* #define HAL_IRDA_MODULE_ENABLED */\r
+/* #define HAL_SMARTCARD_MODULE_ENABLED */\r
+/* #define HAL_WWDG_MODULE_ENABLED */\r
+/* #define HAL_PCD_MODULE_ENABLED */\r
+/* #define HAL_HCD_MODULE_ENABLED */\r
+/* #define HAL_DFSDM_MODULE_ENABLED */\r
+/* #define HAL_DSI_MODULE_ENABLED */\r
+/* #define HAL_JPEG_MODULE_ENABLED */\r
+/* #define HAL_MDIOS_MODULE_ENABLED */\r
+#define HAL_GPIO_MODULE_ENABLED\r
+#define HAL_DMA_MODULE_ENABLED\r
+#define HAL_RCC_MODULE_ENABLED\r
+#define HAL_FLASH_MODULE_ENABLED\r
+#define HAL_PWR_MODULE_ENABLED\r
+#define HAL_I2C_MODULE_ENABLED\r
+#define HAL_CORTEX_MODULE_ENABLED\r
+\r
+/* ########################## HSE/HSI Values adaptation ##################### */\r
+/**\r
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.\r
+ * This value is used by the RCC HAL module to compute the system frequency\r
+ * (when HSE is used as system clock source, directly or through the PLL). \r
+ */\r
+#if !defined (HSE_VALUE) \r
+ #define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */\r
+#endif /* HSE_VALUE */\r
+\r
+#if !defined (HSE_STARTUP_TIMEOUT)\r
+ #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */\r
+#endif /* HSE_STARTUP_TIMEOUT */\r
+\r
+/**\r
+ * @brief Internal High Speed oscillator (HSI) value.\r
+ * This value is used by the RCC HAL module to compute the system frequency\r
+ * (when HSI is used as system clock source, directly or through the PLL). \r
+ */\r
+#if !defined (HSI_VALUE)\r
+ #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/\r
+#endif /* HSI_VALUE */\r
+\r
+/**\r
+ * @brief Internal Low Speed oscillator (LSI) value.\r
+ */\r
+#if !defined (LSI_VALUE) \r
+ #define LSI_VALUE ((uint32_t)40000U) /*!< LSI Typical Value in Hz*/\r
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz\r
+ The real value may vary depending on the variations\r
+ in voltage and temperature. */\r
+/**\r
+ * @brief External Low Speed oscillator (LSE) value.\r
+ */\r
+#if !defined (LSE_VALUE)\r
+ #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */\r
+#endif /* LSE_VALUE */\r
+\r
+#if !defined (LSE_STARTUP_TIMEOUT)\r
+ #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */\r
+#endif /* LSE_STARTUP_TIMEOUT */\r
+\r
+/**\r
+ * @brief External clock source for I2S peripheral\r
+ * This value is used by the I2S HAL module to compute the I2S clock source \r
+ * frequency, this source is inserted directly through I2S_CKIN pad. \r
+ */\r
+#if !defined (EXTERNAL_CLOCK_VALUE)\r
+ #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the Internal oscillator in Hz*/\r
+#endif /* EXTERNAL_CLOCK_VALUE */\r
+\r
+/* Tip: To avoid modifying this file each time you need to use different HSE,\r
+ === you can define the HSE value in your toolchain compiler preprocessor. */\r
+\r
+/* ########################### System Configuration ######################### */\r
+/**\r
+ * @brief This is the HAL system configuration section\r
+ */ \r
+#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */\r
+#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */\r
+#define USE_RTOS 0U\r
+#define PREFETCH_ENABLE 1U\r
+#define ART_ACCLERATOR_ENABLE 1U /* To enable instruction cache and prefetch */\r
+\r
+/* ########################## Assert Selection ############################## */\r
+/**\r
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the \r
+ * HAL drivers code\r
+ */\r
+/* #define USE_FULL_ASSERT 1 */\r
+\r
+/* ################## Ethernet peripheral configuration ##################### */\r
+\r
+/* Section 1 : Ethernet peripheral configuration */\r
+\r
+/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */\r
+#define MAC_ADDR0 2U\r
+#define MAC_ADDR1 0U\r
+#define MAC_ADDR2 0U\r
+#define MAC_ADDR3 0U\r
+#define MAC_ADDR4 0U\r
+#define MAC_ADDR5 0U\r
+\r
+/* Definition of the Ethernet driver buffers size and count */ \r
+#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */\r
+#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */\r
+#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */\r
+#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */\r
+\r
+/* Section 2: PHY configuration section */\r
+\r
+/* DP83848_PHY_ADDRESS Address*/ \r
+#define DP83848_PHY_ADDRESS 0x01U\r
+/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ \r
+#define PHY_RESET_DELAY ((uint32_t)0x000000FFU)\r
+/* PHY Configuration delay */\r
+#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU)\r
+\r
+#define PHY_READ_TO ((uint32_t)0x0000FFFFU)\r
+#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU)\r
+\r
+/* Section 3: Common PHY Registers */\r
+\r
+#define PHY_BCR ((uint16_t)0x00U) /*!< Transceiver Basic Control Register */\r
+#define PHY_BSR ((uint16_t)0x01U) /*!< Transceiver Basic Status Register */\r
+ \r
+#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */\r
+#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */\r
+#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */\r
+#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */\r
+#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */\r
+#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */\r
+#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */\r
+#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */\r
+#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */\r
+#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */\r
+\r
+#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */\r
+#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */\r
+#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */\r
+ \r
+/* Section 4: Extended PHY Registers */\r
+\r
+#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */\r
+#define PHY_MICR ((uint16_t)0x11U) /*!< MII Interrupt Control Register */\r
+#define PHY_MISR ((uint16_t)0x12U) /*!< MII Interrupt Status and Misc. Control Register */\r
+ \r
+#define PHY_LINK_STATUS ((uint16_t)0x0001U) /*!< PHY Link mask */\r
+#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */\r
+#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */\r
+\r
+#define PHY_MICR_INT_EN ((uint16_t)0x0002U) /*!< PHY Enable interrupts */\r
+#define PHY_MICR_INT_OE ((uint16_t)0x0001U) /*!< PHY Enable output interrupt events */\r
+\r
+#define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020U) /*!< Enable Interrupt on change of link status */\r
+#define PHY_LINK_INTERRUPT ((uint16_t)0x2000U) /*!< PHY link status interrupt mask */\r
+\r
+/* ################## SPI peripheral configuration ########################## */\r
+\r
+/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver\r
+* Activated: CRC code is present inside driver\r
+* Deactivated: CRC code cleaned from driver\r
+*/\r
+\r
+#define USE_SPI_CRC 0U\r
+\r
+/* Includes ------------------------------------------------------------------*/\r
+/**\r
+ * @brief Include module's header file \r
+ */\r
+\r
+#ifdef HAL_RCC_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_rcc.h"\r
+#endif /* HAL_RCC_MODULE_ENABLED */\r
+\r
+#ifdef HAL_GPIO_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_gpio.h"\r
+#endif /* HAL_GPIO_MODULE_ENABLED */\r
+\r
+#ifdef HAL_DMA_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_dma.h"\r
+#endif /* HAL_DMA_MODULE_ENABLED */\r
+ \r
+#ifdef HAL_CORTEX_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_cortex.h"\r
+#endif /* HAL_CORTEX_MODULE_ENABLED */\r
+\r
+#ifdef HAL_ADC_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_adc.h"\r
+#endif /* HAL_ADC_MODULE_ENABLED */\r
+\r
+#ifdef HAL_CAN_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_can.h"\r
+#endif /* HAL_CAN_MODULE_ENABLED */\r
+\r
+#ifdef HAL_CEC_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_cec.h"\r
+#endif /* HAL_CEC_MODULE_ENABLED */\r
+\r
+#ifdef HAL_CRC_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_crc.h"\r
+#endif /* HAL_CRC_MODULE_ENABLED */\r
+\r
+#ifdef HAL_CRYP_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_cryp.h" \r
+#endif /* HAL_CRYP_MODULE_ENABLED */\r
+\r
+#ifdef HAL_DMA2D_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_dma2d.h"\r
+#endif /* HAL_DMA2D_MODULE_ENABLED */\r
+\r
+#ifdef HAL_DAC_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_dac.h"\r
+#endif /* HAL_DAC_MODULE_ENABLED */\r
+\r
+#ifdef HAL_DCMI_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_dcmi.h"\r
+#endif /* HAL_DCMI_MODULE_ENABLED */\r
+\r
+#ifdef HAL_ETH_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_eth.h"\r
+#endif /* HAL_ETH_MODULE_ENABLED */\r
+\r
+#ifdef HAL_FLASH_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_flash.h"\r
+#endif /* HAL_FLASH_MODULE_ENABLED */\r
+ \r
+#ifdef HAL_SRAM_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_sram.h"\r
+#endif /* HAL_SRAM_MODULE_ENABLED */\r
+\r
+#ifdef HAL_NOR_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_nor.h"\r
+#endif /* HAL_NOR_MODULE_ENABLED */\r
+\r
+#ifdef HAL_NAND_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_nand.h"\r
+#endif /* HAL_NAND_MODULE_ENABLED */\r
+\r
+#ifdef HAL_SDRAM_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_sdram.h"\r
+#endif /* HAL_SDRAM_MODULE_ENABLED */ \r
+\r
+#ifdef HAL_HASH_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_hash.h"\r
+#endif /* HAL_HASH_MODULE_ENABLED */\r
+\r
+#ifdef HAL_I2C_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_i2c.h"\r
+#endif /* HAL_I2C_MODULE_ENABLED */\r
+\r
+#ifdef HAL_I2S_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_i2s.h"\r
+#endif /* HAL_I2S_MODULE_ENABLED */\r
+\r
+#ifdef HAL_IWDG_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_iwdg.h"\r
+#endif /* HAL_IWDG_MODULE_ENABLED */\r
+\r
+#ifdef HAL_LPTIM_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_lptim.h"\r
+#endif /* HAL_LPTIM_MODULE_ENABLED */\r
+\r
+#ifdef HAL_LTDC_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_ltdc.h"\r
+#endif /* HAL_LTDC_MODULE_ENABLED */\r
+\r
+#ifdef HAL_PWR_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_pwr.h"\r
+#endif /* HAL_PWR_MODULE_ENABLED */\r
+\r
+#ifdef HAL_QSPI_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_qspi.h"\r
+#endif /* HAL_QSPI_MODULE_ENABLED */\r
+\r
+#ifdef HAL_RNG_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_rng.h"\r
+#endif /* HAL_RNG_MODULE_ENABLED */\r
+\r
+#ifdef HAL_RTC_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_rtc.h"\r
+#endif /* HAL_RTC_MODULE_ENABLED */\r
+\r
+#ifdef HAL_SAI_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_sai.h"\r
+#endif /* HAL_SAI_MODULE_ENABLED */\r
+\r
+#ifdef HAL_SD_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_sd.h"\r
+#endif /* HAL_SD_MODULE_ENABLED */\r
+\r
+#ifdef HAL_SPDIFRX_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_spdifrx.h"\r
+#endif /* HAL_SPDIFRX_MODULE_ENABLED */\r
+\r
+#ifdef HAL_SPI_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_spi.h"\r
+#endif /* HAL_SPI_MODULE_ENABLED */\r
+\r
+#ifdef HAL_TIM_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_tim.h"\r
+#endif /* HAL_TIM_MODULE_ENABLED */\r
+\r
+#ifdef HAL_UART_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_uart.h"\r
+#endif /* HAL_UART_MODULE_ENABLED */\r
+\r
+#ifdef HAL_USART_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_usart.h"\r
+#endif /* HAL_USART_MODULE_ENABLED */\r
+\r
+#ifdef HAL_IRDA_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_irda.h"\r
+#endif /* HAL_IRDA_MODULE_ENABLED */\r
+\r
+#ifdef HAL_SMARTCARD_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_smartcard.h"\r
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */\r
+\r
+#ifdef HAL_WWDG_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_wwdg.h"\r
+#endif /* HAL_WWDG_MODULE_ENABLED */\r
+\r
+#ifdef HAL_PCD_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_pcd.h"\r
+#endif /* HAL_PCD_MODULE_ENABLED */\r
+\r
+#ifdef HAL_HCD_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_hcd.h"\r
+#endif /* HAL_HCD_MODULE_ENABLED */\r
+\r
+#ifdef HAL_DFSDM_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_dfsdm.h"\r
+#endif /* HAL_DFSDM_MODULE_ENABLED */\r
+\r
+#ifdef HAL_DSI_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_dsi.h"\r
+#endif /* HAL_DSI_MODULE_ENABLED */\r
+\r
+#ifdef HAL_JPEG_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_jpeg.h"\r
+#endif /* HAL_JPEG_MODULE_ENABLED */\r
+\r
+#ifdef HAL_MDIOS_MODULE_ENABLED\r
+ #include "stm32f7xx_hal_mdios.h"\r
+#endif /* HAL_MDIOS_MODULE_ENABLED */ \r
+/* Exported macro ------------------------------------------------------------*/\r
+#ifdef USE_FULL_ASSERT\r
+/**\r
+ * @brief The assert_param macro is used for function's parameters check.\r
+ * @param expr: If expr is false, it calls assert_failed function\r
+ * which reports the name of the source file and the source\r
+ * line number of the call that failed. \r
+ * If expr is true, it returns no value.\r
+ * @retval None\r
+ */\r
+ #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))\r
+/* Exported functions ------------------------------------------------------- */\r
+ void assert_failed(uint8_t* file, uint32_t line);\r
+#else\r
+ #define assert_param(expr) ((void)0)\r
+#endif /* USE_FULL_ASSERT */\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* __STM32F7xx_HAL_CONF_H */\r
+ \r
+\r
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r
--- /dev/null
+/**\r
+ ******************************************************************************\r
+ * @file stm32f7xx_it.h\r
+ * @brief This file contains the headers of the interrupt handlers.\r
+ ******************************************************************************\r
+ *\r
+ * COPYRIGHT(c) 2016 STMicroelectronics\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without modification,\r
+ * are permitted provided that the following conditions are met:\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors\r
+ * may be used to endorse or promote products derived from this software\r
+ * without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ ******************************************************************************\r
+ */\r
+\r
+/* Define to prevent recursive inclusion -------------------------------------*/\r
+#ifndef __STM32F7xx_IT_H\r
+#define __STM32F7xx_IT_H\r
+\r
+#ifdef __cplusplus\r
+ extern "C" {\r
+#endif \r
+\r
+/* Includes ------------------------------------------------------------------*/\r
+/* Exported types ------------------------------------------------------------*/\r
+/* Exported constants --------------------------------------------------------*/\r
+/* Exported macro ------------------------------------------------------------*/\r
+/* Exported functions ------------------------------------------------------- */\r
+\r
+void SysTick_Handler(void);\r
+void DMA1_Stream3_IRQHandler(void);\r
+void USART3_IRQHandler(void);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* __STM32F7xx_IT_H */\r
+\r
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r
--- /dev/null
+/**\r
+ ******************************************************************************\r
+ * File Name : USART.h\r
+ * Description : This file provides code for the configuration\r
+ * of the USART instances.\r
+ ******************************************************************************\r
+ *\r
+ * COPYRIGHT(c) 2016 STMicroelectronics\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without modification,\r
+ * are permitted provided that the following conditions are met:\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors\r
+ * may be used to endorse or promote products derived from this software\r
+ * without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ ******************************************************************************\r
+ */\r
+/* Define to prevent recursive inclusion -------------------------------------*/\r
+#ifndef __usart_H\r
+#define __usart_H\r
+#ifdef __cplusplus\r
+ extern "C" {\r
+#endif\r
+\r
+/* Includes ------------------------------------------------------------------*/\r
+#include "stm32f7xx_hal.h"\r
+\r
+/* USER CODE BEGIN Includes */\r
+\r
+/* USER CODE END Includes */\r
+\r
+extern UART_HandleTypeDef huart3;\r
+\r
+/* USER CODE BEGIN Private defines */\r
+\r
+/* USER CODE END Private defines */\r
+\r
+extern void Error_Handler(void);\r
+\r
+void MX_USART3_UART_Init(void);\r
+\r
+/* USER CODE BEGIN Prototypes */\r
+\r
+/* USER CODE END Prototypes */\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+#endif /*__ usart_H */\r
+\r
+/**\r
+ * @}\r
+ */\r
+\r
+/**\r
+ * @}\r
+ */\r
+\r
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r
--- /dev/null
+/**\r
+ ******************************************************************************\r
+ * File Name : dma.c\r
+ * Description : This file provides code for the configuration\r
+ * of all the requested memory to memory DMA transfers.\r
+ ******************************************************************************\r
+ *\r
+ * COPYRIGHT(c) 2016 STMicroelectronics\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without modification,\r
+ * are permitted provided that the following conditions are met:\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors\r
+ * may be used to endorse or promote products derived from this software\r
+ * without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ ******************************************************************************\r
+ */\r
+/* Includes ------------------------------------------------------------------*/\r
+#include "dma.h"\r
+\r
+/* USER CODE BEGIN 0 */\r
+\r
+/* USER CODE END 0 */\r
+\r
+/*----------------------------------------------------------------------------*/\r
+/* Configure DMA */\r
+/*----------------------------------------------------------------------------*/\r
+\r
+/* USER CODE BEGIN 1 */\r
+\r
+/* USER CODE END 1 */\r
+\r
+/** \r
+ * Enable DMA controller clock\r
+ */\r
+void MX_DMA_Init(void) \r
+{\r
+ /* DMA controller clock enable */\r
+ __HAL_RCC_DMA1_CLK_ENABLE();\r
+\r
+ /* DMA interrupt init */\r
+ /* DMA1_Stream3_IRQn interrupt configuration */\r
+ HAL_NVIC_SetPriority(DMA1_Stream3_IRQn, 2, 0);\r
+ HAL_NVIC_EnableIRQ(DMA1_Stream3_IRQn);\r
+\r
+}\r
+\r
+/* USER CODE BEGIN 2 */\r
+\r
+/* USER CODE END 2 */\r
+\r
+/**\r
+ * @}\r
+ */\r
+\r
+/**\r
+ * @}\r
+ */\r
+\r
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r
--- /dev/null
+/**\r
+ ******************************************************************************\r
+ * File Name : gpio.c\r
+ * Description : This file provides code for the configuration\r
+ * of all used GPIO pins.\r
+ ******************************************************************************\r
+ *\r
+ * COPYRIGHT(c) 2016 STMicroelectronics\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without modification,\r
+ * are permitted provided that the following conditions are met:\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors\r
+ * may be used to endorse or promote products derived from this software\r
+ * without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ ******************************************************************************\r
+ */\r
+\r
+/* Includes ------------------------------------------------------------------*/\r
+#include "gpio.h"\r
+/* USER CODE BEGIN 0 */\r
+\r
+/* USER CODE END 0 */\r
+\r
+/*----------------------------------------------------------------------------*/\r
+/* Configure GPIO */\r
+/*----------------------------------------------------------------------------*/\r
+/* USER CODE BEGIN 1 */\r
+\r
+/* USER CODE END 1 */\r
+\r
+/** Configure pins as \r
+ * Analog \r
+ * Input \r
+ * Output\r
+ * EVENT_OUT\r
+ * EXTI\r
+ * Free pins are configured automatically as Analog (this feature is enabled through \r
+ * the Code Generation settings)\r
+ PC1 ------> ETH_MDC\r
+ PA1 ------> ETH_REF_CLK\r
+ PA2 ------> ETH_MDIO\r
+ PA7 ------> ETH_CRS_DV\r
+ PC4 ------> ETH_RXD0\r
+ PC5 ------> ETH_RXD1\r
+ PB13 ------> ETH_TXD1\r
+ PA8 ------> USB_OTG_FS_SOF\r
+ PA9 ------> USB_OTG_FS_VBUS\r
+ PA10 ------> USB_OTG_FS_ID\r
+ PA11 ------> USB_OTG_FS_DM\r
+ PA12 ------> USB_OTG_FS_DP\r
+ PG11 ------> ETH_TX_EN\r
+ PG13 ------> ETH_TXD0\r
+*/\r
+void MX_GPIO_Init(void)\r
+{\r
+\r
+ GPIO_InitTypeDef GPIO_InitStruct;\r
+\r
+ /* GPIO Ports Clock Enable */\r
+ __HAL_RCC_GPIOE_CLK_ENABLE();\r
+ __HAL_RCC_GPIOC_CLK_ENABLE();\r
+ __HAL_RCC_GPIOF_CLK_ENABLE();\r
+ __HAL_RCC_GPIOH_CLK_ENABLE();\r
+ __HAL_RCC_GPIOA_CLK_ENABLE();\r
+ __HAL_RCC_GPIOB_CLK_ENABLE();\r
+ __HAL_RCC_GPIOG_CLK_ENABLE();\r
+ __HAL_RCC_GPIOD_CLK_ENABLE();\r
+\r
+ /*Configure GPIO pins : PE2 PE3 PE4 PE5 \r
+ PE6 PE7 PE8 PE9 \r
+ PE10 PE11 PE12 PE13 \r
+ PE14 PE15 PE0 PE1 */\r
+ GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5 \r
+ |GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9 \r
+ |GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13 \r
+ |GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1;\r
+ GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;\r
+ GPIO_InitStruct.Pull = GPIO_NOPULL;\r
+ HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);\r
+\r
+ /*Configure GPIO pin : PtPin */\r
+ GPIO_InitStruct.Pin = User_Blue_Button_Pin;\r
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;\r
+ GPIO_InitStruct.Pull = GPIO_NOPULL;\r
+ HAL_GPIO_Init(User_Blue_Button_GPIO_Port, &GPIO_InitStruct);\r
+\r
+ /*Configure GPIO pins : PF0 PF1 PF2 PF3 \r
+ PF4 PF5 PF6 PF7 \r
+ PF8 PF9 PF10 PF11 \r
+ PF12 PF13 PF14 PF15 */\r
+ GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 \r
+ |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7 \r
+ |GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11 \r
+ |GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;\r
+ GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;\r
+ GPIO_InitStruct.Pull = GPIO_NOPULL;\r
+ HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);\r
+\r
+ /*Configure GPIO pins : PC0 PC2 PC3 PC6 \r
+ PC7 PC8 PC9 PC10 \r
+ PC11 PC12 */\r
+ GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_6 \r
+ |GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 \r
+ |GPIO_PIN_11|GPIO_PIN_12;\r
+ GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;\r
+ GPIO_InitStruct.Pull = GPIO_NOPULL;\r
+ HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);\r
+\r
+ /*Configure GPIO pins : PCPin PCPin PCPin */\r
+ GPIO_InitStruct.Pin = RMII_MDC_Pin|RMII_RXD0_Pin|RMII_RXD1_Pin;\r
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;\r
+ GPIO_InitStruct.Pull = GPIO_NOPULL;\r
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;\r
+ GPIO_InitStruct.Alternate = GPIO_AF11_ETH;\r
+ HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);\r
+\r
+ /*Configure GPIO pins : PA0 PA3 PA4 PA5 \r
+ PA6 PA15 */\r
+ GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5 \r
+ |GPIO_PIN_6|GPIO_PIN_15;\r
+ GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;\r
+ GPIO_InitStruct.Pull = GPIO_NOPULL;\r
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);\r
+\r
+ /*Configure GPIO pins : PAPin PAPin PAPin */\r
+ GPIO_InitStruct.Pin = RMII_REF_CLK_Pin|RMII_MDIO_Pin|RMII_CRS_DV_Pin;\r
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;\r
+ GPIO_InitStruct.Pull = GPIO_NOPULL;\r
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;\r
+ GPIO_InitStruct.Alternate = GPIO_AF11_ETH;\r
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);\r
+\r
+ /*Configure GPIO pins : PBPin PBPin PBPin */\r
+ GPIO_InitStruct.Pin = LD1_Pin|LD3_Pin|LD2_Pin;\r
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;\r
+ GPIO_InitStruct.Pull = GPIO_NOPULL;\r
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;\r
+ HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);\r
+\r
+ /*Configure GPIO pins : PB1 PB2 PB10 PB11 \r
+ PB12 PB15 PB4 PB5 \r
+ PB6 PB8 PB9 */\r
+ GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_10|GPIO_PIN_11 \r
+ |GPIO_PIN_12|GPIO_PIN_15|GPIO_PIN_4|GPIO_PIN_5 \r
+ |GPIO_PIN_6|GPIO_PIN_8|GPIO_PIN_9;\r
+ GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;\r
+ GPIO_InitStruct.Pull = GPIO_NOPULL;\r
+ HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);\r
+\r
+ /*Configure GPIO pins : PG0 PG1 PG2 PG3 \r
+ PG4 PG5 PG8 PG9 \r
+ PG10 PG12 PG14 PG15 */\r
+ GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 \r
+ |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_8|GPIO_PIN_9 \r
+ |GPIO_PIN_10|GPIO_PIN_12|GPIO_PIN_14|GPIO_PIN_15;\r
+ GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;\r
+ GPIO_InitStruct.Pull = GPIO_NOPULL;\r
+ HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);\r
+\r
+ /*Configure GPIO pin : PtPin */\r
+ GPIO_InitStruct.Pin = RMII_TXD1_Pin;\r
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;\r
+ GPIO_InitStruct.Pull = GPIO_NOPULL;\r
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;\r
+ GPIO_InitStruct.Alternate = GPIO_AF11_ETH;\r
+ HAL_GPIO_Init(RMII_TXD1_GPIO_Port, &GPIO_InitStruct);\r
+\r
+ /*Configure GPIO pins : PD10 PD11 PD12 PD13 \r
+ PD14 PD15 PD0 PD1 \r
+ PD2 PD3 PD4 PD5 \r
+ PD6 PD7 */\r
+ GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13 \r
+ |GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1 \r
+ |GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5 \r
+ |GPIO_PIN_6|GPIO_PIN_7;\r
+ GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;\r
+ GPIO_InitStruct.Pull = GPIO_NOPULL;\r
+ HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);\r
+\r
+ /*Configure GPIO pin : PtPin */\r
+ GPIO_InitStruct.Pin = USB_PowerSwitchOn_Pin;\r
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;\r
+ GPIO_InitStruct.Pull = GPIO_NOPULL;\r
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;\r
+ HAL_GPIO_Init(USB_PowerSwitchOn_GPIO_Port, &GPIO_InitStruct);\r
+\r
+ /*Configure GPIO pin : PtPin */\r
+ GPIO_InitStruct.Pin = USB_OverCurrent_Pin;\r
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;\r
+ GPIO_InitStruct.Pull = GPIO_NOPULL;\r
+ HAL_GPIO_Init(USB_OverCurrent_GPIO_Port, &GPIO_InitStruct);\r
+\r
+ /*Configure GPIO pins : PAPin PAPin PAPin PAPin */\r
+ GPIO_InitStruct.Pin = USB_SOF_Pin|USB_ID_Pin|USB_DM_Pin|USB_DP_Pin;\r
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;\r
+ GPIO_InitStruct.Pull = GPIO_NOPULL;\r
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;\r
+ GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;\r
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);\r
+\r
+ /*Configure GPIO pin : PtPin */\r
+ GPIO_InitStruct.Pin = USB_VBUS_Pin;\r
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;\r
+ GPIO_InitStruct.Pull = GPIO_NOPULL;\r
+ HAL_GPIO_Init(USB_VBUS_GPIO_Port, &GPIO_InitStruct);\r
+\r
+ /*Configure GPIO pins : PGPin PGPin */\r
+ GPIO_InitStruct.Pin = RMII_TX_EN_Pin|RMII_TXD0_Pin;\r
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;\r
+ GPIO_InitStruct.Pull = GPIO_NOPULL;\r
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;\r
+ GPIO_InitStruct.Alternate = GPIO_AF11_ETH;\r
+ HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);\r
+\r
+ /*Configure GPIO pin Output Level */\r
+ HAL_GPIO_WritePin(GPIOB, LD1_Pin|LD3_Pin|LD2_Pin, GPIO_PIN_RESET);\r
+\r
+ /*Configure GPIO pin Output Level */\r
+ HAL_GPIO_WritePin(USB_PowerSwitchOn_GPIO_Port, USB_PowerSwitchOn_Pin, GPIO_PIN_RESET);\r
+\r
+}\r
+\r
+/* USER CODE BEGIN 2 */\r
+\r
+/* USER CODE END 2 */\r
+\r
+/**\r
+ * @}\r
+ */\r
+\r
+/**\r
+ * @}\r
+ */\r
+\r
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r
--- /dev/null
+/**\r
+ ******************************************************************************\r
+ * File Name : main.c\r
+ * Description : Main program body\r
+ ******************************************************************************\r
+ *\r
+ * COPYRIGHT(c) 2016 STMicroelectronics\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without modification,\r
+ * are permitted provided that the following conditions are met:\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors\r
+ * may be used to endorse or promote products derived from this software\r
+ * without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ ******************************************************************************\r
+ */\r
+/* Includes ------------------------------------------------------------------*/\r
+#include "stm32f7xx_hal.h"\r
+#include "dma.h"\r
+#include "usart.h"\r
+#include "gpio.h"\r
+\r
+/* USER CODE BEGIN Includes */\r
+\r
+/* USER CODE END Includes */\r
+\r
+/* Private variables ---------------------------------------------------------*/\r
+\r
+/* USER CODE BEGIN PV */\r
+/* Private variables ---------------------------------------------------------*/\r
+\r
+/* USER CODE END PV */\r
+\r
+/* Private function prototypes -----------------------------------------------*/\r
+void SystemClock_Config(void);\r
+void Error_Handler(void);\r
+\r
+/* USER CODE BEGIN PFP */\r
+/* Private function prototypes -----------------------------------------------*/\r
+\r
+/* USER CODE END PFP */\r
+\r
+/* USER CODE BEGIN 0 */\r
+\r
+/* USER CODE END 0 */\r
+\r
+int main(void)\r
+{\r
+\r
+ /* USER CODE BEGIN 1 */\r
+\r
+ /* USER CODE END 1 */\r
+\r
+ /* MCU Configuration----------------------------------------------------------*/\r
+\r
+ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */\r
+ HAL_Init();\r
+\r
+ /* Configure the system clock */\r
+ SystemClock_Config();\r
+\r
+ /* Initialize all configured peripherals */\r
+ MX_GPIO_Init();\r
+ MX_DMA_Init();\r
+ MX_USART3_UART_Init();\r
+\r
+ /* USER CODE BEGIN 2 */\r
+\r
+ /* USER CODE END 2 */\r
+\r
+ /* Infinite loop */\r
+ /* USER CODE BEGIN WHILE */\r
+ while (1)\r
+ {\r
+ /* USER CODE END WHILE */\r
+\r
+ /* USER CODE BEGIN 3 */\r
+\r
+ }\r
+ /* USER CODE END 3 */\r
+\r
+}\r
+\r
+/** System Clock Configuration\r
+*/\r
+void SystemClock_Config(void)\r
+{\r
+\r
+ RCC_OscInitTypeDef RCC_OscInitStruct;\r
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;\r
+ RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;\r
+\r
+ __HAL_RCC_PWR_CLK_ENABLE();\r
+\r
+ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);\r
+\r
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;\r
+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;\r
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;\r
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;\r
+ RCC_OscInitStruct.PLL.PLLM = 4;\r
+ RCC_OscInitStruct.PLL.PLLN = 200;\r
+ RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;\r
+ RCC_OscInitStruct.PLL.PLLQ = 2;\r
+ if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)\r
+ {\r
+ Error_Handler();\r
+ }\r
+\r
+ if (HAL_PWREx_EnableOverDrive() != HAL_OK)\r
+ {\r
+ Error_Handler();\r
+ }\r
+\r
+ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK\r
+ |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;\r
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;\r
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;\r
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;\r
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;\r
+ if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_6) != HAL_OK)\r
+ {\r
+ Error_Handler();\r
+ }\r
+\r
+ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USART3;\r
+ PeriphClkInitStruct.Usart3ClockSelection = RCC_USART3CLKSOURCE_PCLK1;\r
+ if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)\r
+ {\r
+ Error_Handler();\r
+ }\r
+\r
+ HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);\r
+\r
+ HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);\r
+\r
+ /* SysTick_IRQn interrupt configuration */\r
+ HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);\r
+}\r
+\r
+/* USER CODE BEGIN 4 */\r
+\r
+/* USER CODE END 4 */\r
+\r
+/**\r
+ * @brief This function is executed in case of error occurrence.\r
+ * @param None\r
+ * @retval None\r
+ */\r
+void Error_Handler(void)\r
+{\r
+ /* USER CODE BEGIN Error_Handler */\r
+ /* User can add his own implementation to report the HAL error return state */\r
+ while(1) \r
+ {\r
+ }\r
+ /* USER CODE END Error_Handler */ \r
+}\r
+\r
+#ifdef USE_FULL_ASSERT\r
+\r
+/**\r
+ * @brief Reports the name of the source file and the source line number\r
+ * where the assert_param error has occurred.\r
+ * @param file: pointer to the source file name\r
+ * @param line: assert_param error line source number\r
+ * @retval None\r
+ */\r
+void assert_failed(uint8_t* file, uint32_t line)\r
+{\r
+ /* USER CODE BEGIN 6 */\r
+ /* User can add his own implementation to report the file name and line number,\r
+ ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */\r
+ /* USER CODE END 6 */\r
+\r
+}\r
+\r
+#endif\r
+\r
+/**\r
+ * @}\r
+ */ \r
+\r
+/**\r
+ * @}\r
+*/ \r
+\r
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r
--- /dev/null
+/**\r
+ ******************************************************************************\r
+ * File Name : stm32f7xx_hal_msp.c\r
+ * Description : This file provides code for the MSP Initialization \r
+ * and de-Initialization codes.\r
+ ******************************************************************************\r
+ *\r
+ * COPYRIGHT(c) 2016 STMicroelectronics\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without modification,\r
+ * are permitted provided that the following conditions are met:\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors\r
+ * may be used to endorse or promote products derived from this software\r
+ * without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ ******************************************************************************\r
+ */\r
+/* Includes ------------------------------------------------------------------*/\r
+#include "stm32f7xx_hal.h"\r
+\r
+extern void Error_Handler(void);\r
+/* USER CODE BEGIN 0 */\r
+\r
+/* USER CODE END 0 */\r
+\r
+/**\r
+ * Initializes the Global MSP.\r
+ */\r
+void HAL_MspInit(void)\r
+{\r
+ /* USER CODE BEGIN MspInit 0 */\r
+\r
+ /* USER CODE END MspInit 0 */\r
+\r
+ HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);\r
+\r
+ /* System interrupt init*/\r
+ /* MemoryManagement_IRQn interrupt configuration */\r
+ HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0);\r
+ /* BusFault_IRQn interrupt configuration */\r
+ HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0);\r
+ /* UsageFault_IRQn interrupt configuration */\r
+ HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0);\r
+ /* SVCall_IRQn interrupt configuration */\r
+ HAL_NVIC_SetPriority(SVCall_IRQn, 0, 0);\r
+ /* DebugMonitor_IRQn interrupt configuration */\r
+ HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0);\r
+ /* PendSV_IRQn interrupt configuration */\r
+ HAL_NVIC_SetPriority(PendSV_IRQn, 0, 0);\r
+ /* SysTick_IRQn interrupt configuration */\r
+ HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);\r
+\r
+ /* USER CODE BEGIN MspInit 1 */\r
+\r
+ /* USER CODE END MspInit 1 */\r
+}\r
+\r
+/* USER CODE BEGIN 1 */\r
+\r
+/* USER CODE END 1 */\r
+\r
+/**\r
+ * @}\r
+ */\r
+\r
+/**\r
+ * @}\r
+ */\r
+\r
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r
--- /dev/null
+/**\r
+ ******************************************************************************\r
+ * @file stm32f7xx_it.c\r
+ * @brief Interrupt Service Routines.\r
+ ******************************************************************************\r
+ *\r
+ * COPYRIGHT(c) 2016 STMicroelectronics\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without modification,\r
+ * are permitted provided that the following conditions are met:\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors\r
+ * may be used to endorse or promote products derived from this software\r
+ * without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ ******************************************************************************\r
+ */\r
+/* Includes ------------------------------------------------------------------*/\r
+#include "stm32f7xx_hal.h"\r
+#include "stm32f7xx.h"\r
+#include "stm32f7xx_it.h"\r
+\r
+/* USER CODE BEGIN 0 */\r
+\r
+/* USER CODE END 0 */\r
+\r
+/* External variables --------------------------------------------------------*/\r
+extern DMA_HandleTypeDef hdma_usart3_tx;\r
+extern UART_HandleTypeDef huart3;\r
+\r
+/******************************************************************************/\r
+/* Cortex-M7 Processor Interruption and Exception Handlers */ \r
+/******************************************************************************/\r
+\r
+/**\r
+* @brief This function handles System tick timer.\r
+*/\r
+void SysTick_Handler(void)\r
+{\r
+ /* USER CODE BEGIN SysTick_IRQn 0 */\r
+\r
+ /* USER CODE END SysTick_IRQn 0 */\r
+ HAL_IncTick();\r
+ HAL_SYSTICK_IRQHandler();\r
+ /* USER CODE BEGIN SysTick_IRQn 1 */\r
+\r
+ /* USER CODE END SysTick_IRQn 1 */\r
+}\r
+\r
+/******************************************************************************/\r
+/* STM32F7xx Peripheral Interrupt Handlers */\r
+/* Add here the Interrupt Handlers for the used peripherals. */\r
+/* For the available peripheral interrupt handler names, */\r
+/* please refer to the startup file (startup_stm32f7xx.s). */\r
+/******************************************************************************/\r
+\r
+/**\r
+* @brief This function handles DMA1 stream3 global interrupt.\r
+*/\r
+void DMA1_Stream3_IRQHandler(void)\r
+{\r
+ /* USER CODE BEGIN DMA1_Stream3_IRQn 0 */\r
+\r
+ /* USER CODE END DMA1_Stream3_IRQn 0 */\r
+ HAL_DMA_IRQHandler(&hdma_usart3_tx);\r
+ /* USER CODE BEGIN DMA1_Stream3_IRQn 1 */\r
+\r
+ /* USER CODE END DMA1_Stream3_IRQn 1 */\r
+}\r
+\r
+/**\r
+* @brief This function handles USART3 global interrupt.\r
+*/\r
+void USART3_IRQHandler(void)\r
+{\r
+ /* USER CODE BEGIN USART3_IRQn 0 */\r
+\r
+ /* USER CODE END USART3_IRQn 0 */\r
+ HAL_UART_IRQHandler(&huart3);\r
+ /* USER CODE BEGIN USART3_IRQn 1 */\r
+\r
+ /* USER CODE END USART3_IRQn 1 */\r
+}\r
+\r
+/* USER CODE BEGIN 1 */\r
+\r
+/* USER CODE END 1 */\r
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r
--- /dev/null
+/**\r
+ ******************************************************************************\r
+ * File Name : USART.c\r
+ * Description : This file provides code for the configuration\r
+ * of the USART instances.\r
+ ******************************************************************************\r
+ *\r
+ * COPYRIGHT(c) 2016 STMicroelectronics\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without modification,\r
+ * are permitted provided that the following conditions are met:\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors\r
+ * may be used to endorse or promote products derived from this software\r
+ * without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ ******************************************************************************\r
+ */\r
+\r
+/* Includes ------------------------------------------------------------------*/\r
+#include "usart.h"\r
+\r
+#include "gpio.h"\r
+#include "dma.h"\r
+\r
+/* USER CODE BEGIN 0 */\r
+\r
+/* USER CODE END 0 */\r
+\r
+UART_HandleTypeDef huart3;\r
+DMA_HandleTypeDef hdma_usart3_tx;\r
+\r
+/* USART3 init function */\r
+\r
+void MX_USART3_UART_Init(void)\r
+{\r
+\r
+ huart3.Instance = USART3;\r
+ huart3.Init.BaudRate = 115200;\r
+ huart3.Init.WordLength = UART_WORDLENGTH_8B;\r
+ huart3.Init.StopBits = UART_STOPBITS_1;\r
+ huart3.Init.Parity = UART_PARITY_NONE;\r
+ huart3.Init.Mode = UART_MODE_TX_RX;\r
+ huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;\r
+ huart3.Init.OverSampling = UART_OVERSAMPLING_16;\r
+ huart3.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;\r
+ huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;\r
+ if (HAL_UART_Init(&huart3) != HAL_OK)\r
+ {\r
+ Error_Handler();\r
+ }\r
+\r
+}\r
+\r
+void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)\r
+{\r
+\r
+ GPIO_InitTypeDef GPIO_InitStruct;\r
+ if(uartHandle->Instance==USART3)\r
+ {\r
+ /* USER CODE BEGIN USART3_MspInit 0 */\r
+\r
+ /* USER CODE END USART3_MspInit 0 */\r
+ /* Peripheral clock enable */\r
+ __HAL_RCC_USART3_CLK_ENABLE();\r
+ \r
+ /**USART3 GPIO Configuration \r
+ PD8 ------> USART3_TX\r
+ PD9 ------> USART3_RX \r
+ */\r
+ GPIO_InitStruct.Pin = STLK_RX_Pin|STLK_TX_Pin;\r
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;\r
+ GPIO_InitStruct.Pull = GPIO_PULLUP;\r
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;\r
+ GPIO_InitStruct.Alternate = GPIO_AF7_USART3;\r
+ HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);\r
+\r
+ /* Peripheral DMA init*/\r
+ \r
+ hdma_usart3_tx.Instance = DMA1_Stream3;\r
+ hdma_usart3_tx.Init.Channel = DMA_CHANNEL_4;\r
+ hdma_usart3_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;\r
+ hdma_usart3_tx.Init.PeriphInc = DMA_PINC_DISABLE;\r
+ hdma_usart3_tx.Init.MemInc = DMA_MINC_ENABLE;\r
+ hdma_usart3_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;\r
+ hdma_usart3_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;\r
+ hdma_usart3_tx.Init.Mode = DMA_NORMAL;\r
+ hdma_usart3_tx.Init.Priority = DMA_PRIORITY_LOW;\r
+ hdma_usart3_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;\r
+ if (HAL_DMA_Init(&hdma_usart3_tx) != HAL_OK)\r
+ {\r
+ Error_Handler();\r
+ }\r
+\r
+ __HAL_LINKDMA(uartHandle,hdmatx,hdma_usart3_tx);\r
+\r
+ /* Peripheral interrupt init */\r
+ HAL_NVIC_SetPriority(USART3_IRQn, 2, 0);\r
+ HAL_NVIC_EnableIRQ(USART3_IRQn);\r
+ /* USER CODE BEGIN USART3_MspInit 1 */\r
+\r
+ /* USER CODE END USART3_MspInit 1 */\r
+ }\r
+}\r
+\r
+void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)\r
+{\r
+\r
+ if(uartHandle->Instance==USART3)\r
+ {\r
+ /* USER CODE BEGIN USART3_MspDeInit 0 */\r
+\r
+ /* USER CODE END USART3_MspDeInit 0 */\r
+ /* Peripheral clock disable */\r
+ __HAL_RCC_USART3_CLK_DISABLE();\r
+ \r
+ /**USART3 GPIO Configuration \r
+ PD8 ------> USART3_TX\r
+ PD9 ------> USART3_RX \r
+ */\r
+ HAL_GPIO_DeInit(GPIOD, STLK_RX_Pin|STLK_TX_Pin);\r
+\r
+ /* Peripheral DMA DeInit*/\r
+ HAL_DMA_DeInit(uartHandle->hdmatx);\r
+\r
+ /* Peripheral interrupt Deinit*/\r
+ HAL_NVIC_DisableIRQ(USART3_IRQn);\r
+\r
+ }\r
+ /* USER CODE BEGIN USART3_MspDeInit 1 */\r
+\r
+ /* USER CODE END USART3_MspDeInit 1 */\r
+} \r
+\r
+/* USER CODE BEGIN 1 */\r
+\r
+/* USER CODE END 1 */\r
+\r
+/**\r
+ * @}\r
+ */\r
+\r
+/**\r
+ * @}\r
+ */\r
+\r
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r
--- /dev/null
+#MicroXplorer Configuration settings - do not modify
+CORTEX_M7.CPU_DCache=Disabled
+CORTEX_M7.CPU_ICache=Disabled
+CORTEX_M7.FlashInterface=TCM_Enabled
+CORTEX_M7.IPParameters=FlashInterface,CPU_ICache,CPU_DCache
+Dma.Request0=USART3_TX
+Dma.RequestsNb=1
+Dma.USART3_TX.0.Direction=DMA_MEMORY_TO_PERIPH
+Dma.USART3_TX.0.FIFOMode=DMA_FIFOMODE_DISABLE
+Dma.USART3_TX.0.Instance=DMA1_Stream3
+Dma.USART3_TX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE
+Dma.USART3_TX.0.MemInc=DMA_MINC_ENABLE
+Dma.USART3_TX.0.Mode=DMA_NORMAL
+Dma.USART3_TX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
+Dma.USART3_TX.0.PeriphInc=DMA_PINC_DISABLE
+Dma.USART3_TX.0.Priority=DMA_PRIORITY_LOW
+Dma.USART3_TX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode
+File.Version=6
+KeepUserPlacement=true
+Mcu.Family=STM32F7
+Mcu.IP0=CORTEX_M7
+Mcu.IP1=DMA
+Mcu.IP2=NVIC
+Mcu.IP3=RCC
+Mcu.IP4=SYS
+Mcu.IP5=USART3
+Mcu.IPNb=6
+Mcu.Name=STM32F767Z(G-I)Tx
+Mcu.Package=LQFP144
+Mcu.Pin0=PC13
+Mcu.Pin1=PC14/OSC32_IN
+Mcu.Pin10=PC5
+Mcu.Pin11=PB0
+Mcu.Pin12=PB13
+Mcu.Pin13=PB14
+Mcu.Pin14=PD8
+Mcu.Pin15=PD9
+Mcu.Pin16=PG6
+Mcu.Pin17=PG7
+Mcu.Pin18=PA8
+Mcu.Pin19=PA9
+Mcu.Pin2=PC15/OSC32_OUT
+Mcu.Pin20=PA10
+Mcu.Pin21=PA11
+Mcu.Pin22=PA12
+Mcu.Pin23=PA13
+Mcu.Pin24=PA14
+Mcu.Pin25=PG11
+Mcu.Pin26=PG13
+Mcu.Pin27=PB3
+Mcu.Pin28=PB7
+Mcu.Pin29=VP_SYS_VS_Systick
+Mcu.Pin3=PH0/OSC_IN
+Mcu.Pin4=PH1/OSC_OUT
+Mcu.Pin5=PC1
+Mcu.Pin6=PA1
+Mcu.Pin7=PA2
+Mcu.Pin8=PA7
+Mcu.Pin9=PC4
+Mcu.PinsNb=30
+Mcu.UserConstants=
+Mcu.UserName=STM32F767ZITx
+MxCube.Version=4.15.1
+MxDb.Version=DB.4.0.151
+NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false
+NVIC.DMA1_Stream3_IRQn=true\:2\:0\:true\:false\:true
+NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false
+NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false
+NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false
+NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false
+NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:false
+NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
+NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false
+NVIC.SysTick_IRQn=true\:0\:0\:true\:false\:true
+NVIC.USART3_IRQn=true\:2\:0\:true\:false\:true
+NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false
+PA1.GPIOParameters=GPIO_Label
+PA1.GPIO_Label=RMII_REF_CLK [LAN8742A-CZ-TR_REFCLK0]
+PA1.Locked=true
+PA1.Signal=ETH_REF_CLK
+PA10.GPIOParameters=GPIO_Label
+PA10.GPIO_Label=USB_ID
+PA10.Locked=true
+PA10.Signal=USB_OTG_FS_ID
+PA11.GPIOParameters=GPIO_Label
+PA11.GPIO_Label=USB_DM
+PA11.Locked=true
+PA11.Signal=USB_OTG_FS_DM
+PA12.GPIOParameters=GPIO_Label
+PA12.GPIO_Label=USB_DP
+PA12.Locked=true
+PA12.Signal=USB_OTG_FS_DP
+PA13.GPIOParameters=GPIO_Label
+PA13.GPIO_Label=TMS
+PA13.Locked=true
+PA13.Mode=Serial_Wire
+PA13.Signal=SYS_JTMS-SWDIO
+PA14.GPIOParameters=GPIO_Label
+PA14.GPIO_Label=TCK
+PA14.Locked=true
+PA14.Mode=Serial_Wire
+PA14.Signal=SYS_JTCK-SWCLK
+PA2.GPIOParameters=GPIO_Label
+PA2.GPIO_Label=RMII_MDIO [LAN8742A-CZ-TR_MDIO]
+PA2.Locked=true
+PA2.Signal=ETH_MDIO
+PA7.GPIOParameters=GPIO_Label
+PA7.GPIO_Label=RMII_CRS_DV [LAN8742A-CZ-TR_CRS_DV]
+PA7.Locked=true
+PA7.Signal=ETH_CRS_DV
+PA8.GPIOParameters=GPIO_Label
+PA8.GPIO_Label=USB_SOF [TP1]
+PA8.Locked=true
+PA8.Signal=USB_OTG_FS_SOF
+PA9.GPIOParameters=GPIO_Label
+PA9.GPIO_Label=USB_VBUS
+PA9.Locked=true
+PA9.Signal=USB_OTG_FS_VBUS
+PB0.GPIOParameters=GPIO_Label
+PB0.GPIO_Label=LD1 [Green]
+PB0.Locked=true
+PB0.Signal=GPIO_Output
+PB13.GPIOParameters=GPIO_Label
+PB13.GPIO_Label=RMII_TXD1 [LAN8742A-CZ-TR_TXD1]
+PB13.Locked=true
+PB13.Signal=ETH_TXD1
+PB14.GPIOParameters=GPIO_Label
+PB14.GPIO_Label=LD3 [Red]
+PB14.Locked=true
+PB14.Signal=GPIO_Output
+PB3.GPIOParameters=GPIO_Label
+PB3.GPIO_Label=SW0
+PB3.Locked=true
+PB3.Signal=SYS_JTDO-SWO
+PB7.GPIOParameters=GPIO_Label
+PB7.GPIO_Label=LD2 [Blue]
+PB7.Locked=true
+PB7.Signal=GPIO_Output
+PC1.GPIOParameters=GPIO_Label
+PC1.GPIO_Label=RMII_MDC [LAN8742A-CZ-TR_MDC]
+PC1.Locked=true
+PC1.Signal=ETH_MDC
+PC13.GPIOParameters=GPIO_Label
+PC13.GPIO_Label=User Blue Button [B1]
+PC13.Locked=true
+PC13.Signal=GPIO_Input
+PC14/OSC32_IN.Locked=true
+PC14/OSC32_IN.Signal=RCC_OSC32_IN
+PC15/OSC32_OUT.Locked=true
+PC15/OSC32_OUT.Signal=RCC_OSC32_OUT
+PC4.GPIOParameters=GPIO_Label
+PC4.GPIO_Label=RMII_RXD0 [LAN8742A-CZ-TR_RXD0]
+PC4.Locked=true
+PC4.Signal=ETH_RXD0
+PC5.GPIOParameters=GPIO_Label
+PC5.GPIO_Label=RMII_RXD1 [LAN8742A-CZ-TR_RXD1]
+PC5.Locked=true
+PC5.Signal=ETH_RXD1
+PCC.Checker=false
+PCC.Line=STM32F7x7
+PCC.MCU=STM32F767Z(G-I)Tx
+PCC.MXVersion=4.15.1
+PCC.PartNumber=STM32F767ZITx
+PCC.Seq0=0
+PCC.Series=STM32F7
+PCC.Temperature=25
+PCC.Vdd=3.6
+PD8.GPIOParameters=GPIO_Label
+PD8.GPIO_Label=STLK_RX [STM32F103CBT6_PA3]
+PD8.Locked=true
+PD8.Mode=Asynchronous
+PD8.Signal=USART3_TX
+PD9.GPIOParameters=GPIO_Label
+PD9.GPIO_Label=STLK_TX [STM32F103CBT6_PA2]
+PD9.Locked=true
+PD9.Mode=Asynchronous
+PD9.Signal=USART3_RX
+PG11.GPIOParameters=GPIO_Label
+PG11.GPIO_Label=RMII_TX_EN [LAN8742A-CZ-TR_TXEN]
+PG11.Locked=true
+PG11.Signal=ETH_TX_EN
+PG13.GPIOParameters=GPIO_Label
+PG13.GPIO_Label=RMII_TXD0 [LAN8742A-CZ-TR_TXD0]
+PG13.Locked=true
+PG13.Signal=ETH_TXD0
+PG6.GPIOParameters=GPIO_Label
+PG6.GPIO_Label=USB_PowerSwitchOn [STMPS2151STR_EN]
+PG6.Locked=true
+PG6.Signal=GPIO_Output
+PG7.GPIOParameters=GPIO_Label
+PG7.GPIO_Label=USB_OverCurrent [STMPS2151STR_FAULT]
+PG7.Locked=true
+PG7.Signal=GPIO_Input
+PH0/OSC_IN.GPIOParameters=GPIO_Label
+PH0/OSC_IN.GPIO_Label=MCO [STM32F103CBT6_PA8]
+PH0/OSC_IN.Locked=true
+PH0/OSC_IN.Mode=HSE-External-Oscillator
+PH0/OSC_IN.Signal=RCC_OSC_IN
+PH1/OSC_OUT.Locked=true
+PH1/OSC_OUT.Mode=HSE-External-Oscillator
+PH1/OSC_OUT.Signal=RCC_OSC_OUT
+ProjectManager.AskForMigrate=true
+ProjectManager.BackupPrevious=false
+ProjectManager.CompilerOptimize=2
+ProjectManager.ComputerToolchain=false
+ProjectManager.CoupleFile=true
+ProjectManager.DeletePrevious=true
+ProjectManager.DeviceId=STM32F767ZITx
+ProjectManager.FirmwarePackage=STM32Cube FW_F7 V1.4.0
+ProjectManager.FreePins=true
+ProjectManager.HalAssertFull=false
+ProjectManager.HeapSize=0x200
+ProjectManager.KeepUserCode=false
+ProjectManager.LastFirmware=true
+ProjectManager.LibraryCopy=2
+ProjectManager.PreviousToolchain=SW4STM32
+ProjectManager.ProjectBuild=false
+ProjectManager.ProjectFileName=nucleo-f767-blinky.ioc
+ProjectManager.ProjectName=nucleo-f767-blinky
+ProjectManager.StackSize=0x400
+ProjectManager.TargetToolchain=SW4STM32
+ProjectManager.ToolChainLocation=/home/mg/ws1/stm32-templ1/nucleo-f767-blinky/cube/nucleo-f767-blinky
+ProjectManager.UnderRoot=true
+ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false,2-MX_DMA_Init-DMA-false,3-MX_USART3_UART_Init-USART3-false
+RCC.48MHZClocksFreq_Value=24000000
+RCC.ADC12outputFreq_Value=72000000
+RCC.ADC34outputFreq_Value=72000000
+RCC.AHBFreq_Value=200000000
+RCC.APB1CLKDivider=RCC_HCLK_DIV4
+RCC.APB1Freq_Value=50000000
+RCC.APB1TimFreq_Value=100000000
+RCC.APB2CLKDivider=RCC_HCLK_DIV2
+RCC.APB2Freq_Value=100000000
+RCC.APB2TimFreq_Value=200000000
+RCC.CECFreq_Value=32786.88524590164
+RCC.CortexFreq_Value=200000000
+RCC.DFSDMAudioFreq_Value=192000000
+RCC.DFSDMFreq_Value=100000000
+RCC.EthernetFreq_Value=200000000
+RCC.FCLKCortexFreq_Value=200000000
+RCC.FamilyName=M
+RCC.HCLKFreq_Value=200000000
+RCC.HSE_VALUE=8000000
+RCC.HSI_VALUE=16000000
+RCC.I2C1Freq_Value=50000000
+RCC.I2C2Freq_Value=50000000
+RCC.I2C3Freq_Value=50000000
+RCC.I2C4Freq_Value=50000000
+RCC.I2SClocksFreq_Value=48000000
+RCC.I2SFreq_Value=192000000
+RCC.IPParameters=48MHZClocksFreq_Value,ADC12outputFreq_Value,ADC34outputFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CECFreq_Value,CortexFreq_Value,DFSDMAudioFreq_Value,DFSDMFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SClocksFreq_Value,I2SFreq_Value,LCDTFTFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LSE_VALUE,LSI_VALUE,MCO1PinFreq_Value,MCO2PinFreq_Value,MCOFreq_Value,PLLCLKFreq_Value,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLMCOFreq_Value,PLLMUL,PLLN,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLRFreq_Value,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,PLLSourceVirtual,PRESCALERUSB,RNGFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SAI1Freq_Value,SAI2Freq_Value,SDMMC2Freq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,SYSCLKSourceVirtual,TIM15Freq_Value,TIM16Freq_Value,TIM17Freq_Value,TIM1Freq_Value,TIM20Freq_Value,TIM2Freq_Value,TIM3Freq_Value,TIM8Freq_Value,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutput2Freq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value,VcooutputI2S,WatchDogFreq_Value
+RCC.LCDTFTFreq_Value=96000000
+RCC.LCDTFToutputFreq_Value=24000000
+RCC.LPTIM1Freq_Value=50000000
+RCC.LSE_VALUE=32768
+RCC.LSI_VALUE=40000
+RCC.MCO1PinFreq_Value=16000000
+RCC.MCO2PinFreq_Value=200000000
+RCC.MCOFreq_Value=72000000
+RCC.PLLCLKFreq_Value=200000000
+RCC.PLLI2SPCLKFreq_Value=192000000
+RCC.PLLI2SQCLKFreq_Value=192000000
+RCC.PLLI2SRCLKFreq_Value=192000000
+RCC.PLLI2SRoutputFreq_Value=192000000
+RCC.PLLM=4
+RCC.PLLMCOFreq_Value=72000000
+RCC.PLLMUL=RCC_PLL_MUL9
+RCC.PLLN=200
+RCC.PLLQCLKFreq_Value=200000000
+RCC.PLLQoutputFreq_Value=200000000
+RCC.PLLRFreq_Value=200000000
+RCC.PLLSAIPCLKFreq_Value=192000000
+RCC.PLLSAIQCLKFreq_Value=192000000
+RCC.PLLSAIRCLKFreq_Value=192000000
+RCC.PLLSAIoutputFreq_Value=192000000
+RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE
+RCC.PRESCALERUSB=RCC_USBCLKSOURCE_PLL_DIV1_5
+RCC.RNGFreq_Value=200000000
+RCC.RTCFreq_Value=40000
+RCC.RTCHSEDivFreq_Value=4000000
+RCC.SAI1Freq_Value=192000000
+RCC.SAI2Freq_Value=192000000
+RCC.SDMMC2Freq_Value=200000000
+RCC.SDMMCFreq_Value=200000000
+RCC.SPDIFRXFreq_Value=192000000
+RCC.SYSCLKFreq_VALUE=200000000
+RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
+RCC.SYSCLKSourceVirtual=RCC_SYSCLKSOURCE_PLLCLK
+RCC.TIM15Freq_Value=72000000
+RCC.TIM16Freq_Value=72000000
+RCC.TIM17Freq_Value=72000000
+RCC.TIM1Freq_Value=72000000
+RCC.TIM20Freq_Value=72000000
+RCC.TIM2Freq_Value=72000000
+RCC.TIM3Freq_Value=72000000
+RCC.TIM8Freq_Value=72000000
+RCC.UART4Freq_Value=50000000
+RCC.UART5Freq_Value=50000000
+RCC.UART7Freq_Value=50000000
+RCC.UART8Freq_Value=50000000
+RCC.USART1Freq_Value=100000000
+RCC.USART2Freq_Value=50000000
+RCC.USART3Freq_Value=50000000
+RCC.USART6Freq_Value=100000000
+RCC.USBFreq_Value=200000000
+RCC.VCOI2SOutputFreq_Value=384000000
+RCC.VCOInputFreq_Value=2000000
+RCC.VCOOutput2Freq_Value=8000000
+RCC.VCOOutputFreq_Value=400000000
+RCC.VCOSAIOutputFreq_Value=384000000
+RCC.VcooutputI2S=48000000
+RCC.WatchDogFreq_Value=40000
+USART3.IPParameters=WordLength
+USART3.WordLength=UART_WORDLENGTH_8B
+VP_SYS_VS_Systick.Mode=SysTick
+VP_SYS_VS_Systick.Signal=SYS_VS_Systick
+board=NUCLEO-F767ZI
+boardIOC=true
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "mTaskSymbols.h"
+#include "interpret.h"
+#include "misc.h"
+#include "task.h"
+#include "sds.h"
+
+#ifdef ARDUINO
+#define trace(op, ...) ;
+#else
+#define trace(op, ...) printf("pc: %d, sp: %d, op: " op, pc, sp, ##__VA_ARGS__);
+#endif
+
+void run_task(struct task *t)
+{
+ uint8_t *program = t->bc;
+ int plen = t->tlen;
+ int pc = 0;
+ int sp = 0;
+ char stack[STACKSIZE] = {0};
+ printf("Running task with length: %d\n", plen);
+ while(pc != plen){
+ printf("program: %d\n", program[pc]);
+ printf("stack: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
+ stack[0], stack[1], stack[2], stack[3], stack[4],
+ stack[5], stack[6], stack[7], stack[8], stack[9]);
+
+ switch(program[pc++]){
+ case BCNOP: trace("nop\n");
+ break;
+ case BCLAB: trace("label: 0x%02x!!!!!!\n", program[pc]);
+ pc++;
+ break;
+ case BCPUSH: trace("push %d\n", program[pc]*265+program[pc+1]);
+ stack[sp++] = program[pc]*265 + program[pc+1];
+ pc+=2;
+ break;
+ case BCPOP: trace("pop\n");
+ sp--;
+ break;
+ case BCSDSSTORE: trace("sds store: %d\n", program[pc]);
+ sds_store(program[pc++], stack[--sp]);
+ break;
+ case BCSDSFETCH: trace("sds fetch: %d\n", program[pc]);
+ stack[sp++] = sds_fetch(program[pc++]);
+ break;
+ case BCSDSPUBLISH: trace("sds publish %d\n", program[pc]);
+ sds_publish(program[pc++]);
+ break;
+ case BCNOT: trace("not\n");
+ stack[sp] = stack[sp] > 0 ? 0 : 1;
+ break;
+ case BCADD: trace("add\n");
+ stack[sp-2] = stack[sp-1] + stack[sp-2];
+ sp -= 1;
+ break;
+ case BCSUB: trace("sub\n");
+ stack[sp-2] = stack[sp-1] - stack[sp-2];
+ sp -= 1;
+ break;
+ case BCMUL: trace("mul\n");
+ stack[sp-2] = stack[sp-1] * stack[sp-2];
+ sp -= 1;
+ break;
+ case BCDIV: trace("div\n");
+ stack[sp-2] = stack[sp-1] / stack[sp-2];
+ sp -= 1;
+ break;
+ case BCAND: trace("and\n");
+ stack[sp-2] = stack[sp-1] && stack[sp-2];
+ sp -= 1;
+ break;
+ case BCOR: trace("or\n");
+ stack[sp-2] = stack[sp-1] || stack[sp-2];
+ sp -= 1;
+ break;
+ case BCEQ: trace("eq\n");
+ stack[sp-2] = stack[sp-1] == stack[sp-2];
+ sp -= 1;
+ break;
+ case BCNEQ: trace("neq\n");
+ stack[sp-2] = stack[sp-1] != stack[sp-2];
+ sp -= 1;
+ break;
+ case BCLES: trace("les\n");
+ stack[sp-2] = stack[sp-1] < stack[sp-2];
+ sp -= 1;
+ break;
+ case BCGRE: trace("gre\n");
+ stack[sp-2] = stack[sp-1] > stack[sp-2];
+ sp -= 1;
+ break;
+ case BCLEQ: trace("leq\n");
+ stack[sp-2] = stack[sp-1] <= stack[sp-2];
+ sp -= 1;
+ break;
+ case BCGEQ: trace("geq\n");
+ stack[sp-2] = stack[sp-1] >= stack[sp-2];
+ sp -= 1;
+ break;
+ case BCJMP: trace("jmp to %d\n", program[pc]);
+ pc = program[pc]-1;
+ break;
+ case BCJMPT: trace("jmpt to %d\n", program[pc]);
+ pc = stack[--sp] ? program[pc]-1 : pc+1;
+ break;
+ case BCJMPF: trace("jmpf to %d\n", program[pc]);
+ pc = stack[--sp] ? pc+1 : program[pc]-1;
+ break;
+ case BCSERIALAVAIL: trace("SerialAvailable()\n");
+ break;
+ case BCSERIALPRINT: trace("SerialPrint()\n");
+ break;
+ case BCSERIALPRINTLN: trace("SerialPrintln()\n");
+ break;
+ case BCSERIALREAD: trace("SerialRead()\n");
+ break;
+ case BCSERIALPARSEINT: trace("SerialParseInt()\n");
+ break;
+ case BCANALOGREAD: trace("AnalogRead(%d)\n", program[pc]);
+ pc++;
+ break;
+ case BCANALOGWRITE: trace("AnalogWrite(%d)\n", program[pc]);
+ pc++;
+ break;
+ case BCDIGITALREAD: trace("DigitalRead(%d)\n", program[pc]);
+ pc++;
+ break;
+ case BCDIGITALWRITE: trace("DigitalWrite(%d)\n", program[pc]);
+ pc++;
+ break;
+ default:
+ trace("unrecognized\n");
+ die("Unrecognized command: %d\n", program[pc-1]);
+ }
+ }
+ debug("Task terminated\n");
+}
--- /dev/null
+#ifndef INTEPRET_H
+#define INTEPRET_H
+
+#define STACKSIZE 1024
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "task.h"
+
+void run_task(struct task *task);
+
+#endif
--- /dev/null
+#ifndef MTASK_H
+#define MTASK_H
+#define BCNOP 1
+#define BCLAB 2
+#define BCPUSH 3
+#define BCPOP 4
+#define BCSDSSTORE 5
+#define BCSDSFETCH 6
+#define BCSDSPUBLISH 7
+#define BCNOT 8
+#define BCADD 9
+#define BCSUB 10
+#define BCMUL 11
+#define BCDIV 12
+#define BCAND 13
+#define BCOR 14
+#define BCEQ 15
+#define BCNEQ 16
+#define BCLES 17
+#define BCGRE 18
+#define BCLEQ 19
+#define BCGEQ 20
+#define BCJMP 21
+#define BCJMPT 22
+#define BCJMPF 23
+#define BCSERIALAVAIL 24
+#define BCSERIALPRINT 25
+#define BCSERIALPRINTLN 26
+#define BCSERIALREAD 27
+#define BCSERIALPARSEINT 28
+#define BCANALOGREAD 29
+#define BCANALOGWRITE 30
+#define BCDIGITALREAD 31
+#define BCDIGITALWRITE 32
+#define BCTEST 33
+#endif
--- /dev/null
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef STM32F767xx
+#include "stm32f7xx_hal.h"
+#include "gpio.h"
+#include "usart.h"
+#else
+#include <stdio.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <signal.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+#endif
+
+#include "interpret.h"
+#include "mTaskSymbols.h"
+#include "sds.h"
+#include "task.h"
+#include "misc.h"
+
+#define MSG_GET_TASK 't'
+#define MSG_DEL_TASK 'd'
+#define MSG_SDS_SPEC 's'
+#define MSG_SDS_UPD 'u'
+
+void _exit(int i){
+ while(1);
+}
+
+//Globals
+#ifdef STM32F767xx
+volatile char uartf = 0;
+#else
+struct timeval tv1;
+int sock_fd = -1;
+int fd = -1;
+int *argc;
+char **argv;
+#endif
+uint8_t bt;
+
+#define SET_LED_RED GPIOB->BSRR = GPIO_PIN_14
+#define RESET_LED_RED GPIOB->BSRR = GPIO_PIN_14 << 16
+
+#define SET_LED_BLUE GPIOB->BSRR = GPIO_PIN_7
+#define RESET_LED_BLUE GPIOB->BSRR = GPIO_PIN_7 << 16
+
+#define SET_LED_GREEN GPIOB->BSRR = GPIO_PIN_0
+#define RESET_LED_GREEN GPIOB->BSRR = GPIO_PIN_0 << 16
+
+long millis() {
+#ifdef STM32F767xx
+ return HAL_GetTick();
+#else
+ if (gettimeofday(&tv1, NULL) == -1)
+ pdie("gettimeofday");
+ return tv1.tv_sec*1000 + tv1.tv_usec/1000;
+#endif
+}
+
+bool input_available(){
+#ifdef STM32F767xx
+ return true;
+#else
+ struct timeval tv;
+ fd_set fds;
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ FD_ZERO(&fds);
+ FD_SET(fd, &fds);
+ if (select(fd+1, &fds, NULL, NULL, &tv) == -1)
+ pdie("select");
+ return FD_ISSET(fd, &fds);
+#endif
+}
+
+uint8_t read_byte()
+{
+#ifdef STM32F767xx
+ HAL_UART_Receive(&huart3, &bt, 1, 1000);
+ return 0;
+#else
+ read(fd, &bt, 1);
+ return bt;
+#endif
+}
+
+void write_byte(uint8_t b)
+{
+#ifdef STM32F767xx
+ HAL_UART_Transmit_DMA(&huart3, &b, 1);
+#else
+ write(fd, &b, 1);
+#endif
+}
+
+void delay(int ms)
+{
+#ifdef STM32F767xx
+ HAL_Delay(ms);
+#else
+ usleep(ms*1000);
+#endif
+}
+
+#ifndef STM32F767xx
+void killHandler(int i)
+{
+ printf("%i caught, Bye...\n", i);
+ exit(1);
+}
+#endif
+
+#ifdef STM32F767xx
+void HAL_UART_TxCpltCallback(UART_HandleTypeDef *UartHandle)
+{
+ uartf=1;
+}
+#endif
+
+void read_message()
+{
+ //Find next task
+ uint8_t c = read_byte();
+ debug("Receiving input: %c\n", c);
+ switch(c){
+ case MSG_SDS_SPEC:
+ debug("Receiving an sds\n");
+ sds_register();
+ break;
+ case MSG_SDS_UPD:
+ debug("Receiving an sds\n");
+ //TODO do something with the return value
+ sds_update();
+ break;
+ case MSG_DEL_TASK:
+ debug("Receiving a delete task request\n");
+ task_delete();
+ break;
+ case MSG_GET_TASK:
+ debug("Receiving a task\n");
+ c = task_register();
+ break;
+ case '\n':
+ break;
+ default:
+ debug("Unknown message: %X\n", c);
+ }
+}
+
+void usage(FILE *o, char *arg0){
+ fprintf(o, "Usage: %s [opts]\n\nOptions\n"
+ "-p PORT Custom port number, default: 8123\n" , arg0);
+}
+
+void setup()
+{
+#ifdef STM32F767xx
+#else
+ int port = 8123, opti = 1;
+ //Register signal handler
+ if(signal(SIGINT, killHandler) == SIG_ERR){
+ die("Couldn't register signal handler...\n");
+ }
+ if(signal(SIGTERM, killHandler) == SIG_ERR){
+ die("Couldn't register signal handler...\n");
+ }
+ //Command line arguments
+ while(opti < *argc){
+ if(strcmp((*argv)+opti, "-h") == 0){
+ usage(stdout, argv[0]);
+ exit(EXIT_SUCCESS);
+ } else if(strcmp(argv[opti], "-p") == 0 && opti+1<*argc){
+ port = atoi(argv[++opti]);
+ if(port < 1)
+ die("Port numbers are > 1\n");
+ } else {
+ usage(stderr, argv[0]);
+ exit(EXIT_FAILURE);
+ }
+ opti++;
+ }
+
+ //Open file descriptors
+ struct sockaddr_in sa;
+
+ memset(&sa, 0, sizeof(sa));
+ sa.sin_family = AF_INET;
+ sa.sin_addr.s_addr = INADDR_ANY;
+ sa.sin_port = htons(port);
+
+ if((sock_fd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
+ pdie("socket");
+ if(bind(sock_fd, (struct sockaddr*)&sa, sizeof(sa)) == -1)
+ pdie("bind");
+ if(listen(sock_fd, 10) == -1)
+ pdie("listen");
+
+ printf("Listening on %d\n", port);
+ fflush(stdout);
+ if((fd = accept(sock_fd, (struct sockaddr*)NULL, NULL)) == -1)
+ pdie("accept");
+#endif
+
+ //Initialize systems
+ sds_init();
+ task_init();
+}
+
+void loop()
+{
+ int ct;
+ long cyclestart;
+ struct task *curtask;
+ if(input_available())
+ read_message();
+ //Run tasks
+ cyclestart = millis();
+ for(ct = 0; ct<MAXTASKS; ct++){
+ //See whether the task is even in use
+ if((curtask = task_get(ct)) == NULL){
+// debug("Task %d not implemented\n", ct);
+ continue;
+ }
+ //See whether the task interval has passed
+ if(cyclestart-curtask->lastrun < curtask->interval){
+// debug("Task %d not scheduled\n", ct);
+ continue;
+ }
+#ifdef DEBUG
+ printf("Current task to run: %d\n", ct);
+ getchar();
+#endif
+ run_task(curtask);
+ }
+ debug("Waiting for 500ms\n");
+ delay(500);
+ debug("done waiting\n");
+ write_byte('\n');
+}
+
+#ifdef STM32F767xx
+int main1(void)
+#else
+int main(int ac, char *av[])
+#endif
+{
+#ifndef STM32F767xx
+ argc = ∾
+ argv = av;
+#endif
+ setup();
+
+ write_byte('\n');
+
+ while(true){
+ //Check for new tasks
+ loop();
+ }
+ return 0;
+}
--- /dev/null
+#ifndef MAIN_H
+#define MAIN_H
+
+#include <stdint.h>
+
+uint8_t read_byte();
+void write_byte(uint8_t b);
+#endif
--- /dev/null
+#ifndef MISC_H
+#define MISC_H
+#include "main.h"
+
+#define read16() 256*read_byte() + read_byte()
+#ifdef ARDUINO
+#define debug(s, ...) ;
+#define pdie(s) ;
+#define die(s, ...) ;
+#else
+
+#ifdef DEBUG
+#define debug(s, ...) printf(s, ##__VA_ARGS__);
+#else
+#define debug(s, ...) ;
+#endif
+
+#define pdie(s) {perror(s); exit(1);}
+#define die(s, ...) {fprintf(stderr, s, ##__VA_ARGS__); exit(1);}
+#endif
+
+#endif
--- /dev/null
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef ARDUINO
+#include <unistd.h>
+#include <stdio.h>
+#endif
+
+#include "main.h"
+#include "interpret.h"
+#include "misc.h"
+#include "sds.h"
+
+struct sds sdss[MAXSDSS];
+uint8_t c;
+
+void sds_init()
+{
+ memset(&sdss, 0, sizeof(struct sds)*MAXSDSS);
+}
+
+void sds_register()
+{
+ uint8_t cs;
+ for(cs = 0; cs<MAXSDSS; cs++)
+ if(!sdss[cs].used)
+ break;
+
+ if(cs == MAXSDSS)
+ die("Trying to add too much tasks...\n");
+
+ memset(&sdss[cs], 0, sizeof(struct sds));
+ //Read identifier
+ sdss[cs].id = read16();
+ //Read value
+ sdss[cs].value = read16();
+
+ debug("\nReceived sds %d: %d\n", sdss[cs].id, sdss[cs].value);
+ sdss[cs].used = true;
+}
+
+bool sds_update()
+{
+ uint8_t cs, id;
+ //Read identifier
+ id = read_byte();
+
+ for(cs = 0; cs<MAXSDSS; cs++){
+ if(!sdss[cs].used)
+ continue;
+ if(sdss[cs].id == id){
+ //Read value
+ sdss[cs].value = read16();
+ return true;
+ }
+ }
+ return false;
+}
+
+void sds_publish(int id)
+{
+ uint8_t cs;
+ for(cs = 0; cs<MAXSDSS; cs++){
+ if(sdss[cs].used && sdss[cs].id == id){
+ debug("Publish %d=%d\n", sdss[cs].id, sdss[cs].value);
+ write_byte('u');
+ write_byte(0);
+ write_byte(sdss[cs].id);
+ write_byte(sdss[cs].value/265);
+ write_byte(sdss[cs].value%265);
+ return;
+ }
+ }
+ debug("SDS identifier unknown: %d\n", id);
+}
+
+int sds_fetch(int id)
+{
+ uint8_t cs;
+ for(cs = 0; cs<MAXSDSS; cs++)
+ if(sdss[cs].used && sdss[cs].id == id)
+ return sdss[cs].value;
+ debug("SDS identifier unknown: %d\n", id);
+ return 0;
+}
+
+void sds_store(int id, int val)
+{
+ uint8_t cs;
+ for(cs = 0; cs<MAXSDSS; cs++) {
+ if(sdss[cs].used && sdss[cs].id == id){
+ sdss[cs].value = val;
+ return;
+ }
+ }
+ debug("SDS identifier unknown: %d\n", id);
+}
--- /dev/null
+#ifndef SDS_H
+#define SDS_H
+
+#include <stdbool.h>
+
+#define MAXSDSS 100
+
+struct sds {
+ int id;
+ int value;
+ bool used;
+};
+
+void sds_init();
+void sds_register();
+bool sds_update();
+void sds_publish(int id);
+int sds_fetch(int id);
+void sds_store(int id, int val);
+
+#endif
--- /dev/null
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef ARDUINO
+#include <Arduino.h>
+#include <HardwareSerial.h>
+#else
+#include <unistd.h>
+#include <stdio.h>
+#endif
+
+#include "misc.h"
+#include "task.h"
+
+struct task tasks[MAXTASKS];
+
+void task_init()
+{
+ memset(&tasks, 0, sizeof(struct task)*MAXTASKS);
+}
+
+int task_register()
+{
+ uint8_t ct;
+
+ for(ct = 0; ct<MAXTASKS; ct++)
+ if(!tasks[ct].used)
+ break;
+ if(ct == MAXTASKS)
+ die("Trying to add too much tasks...\n");
+
+ memset(&tasks[ct], 0, sizeof(struct task));
+ //Read interval
+ tasks[ct].interval = read16();
+ //Read tasklength
+ tasks[ct].tlen = read16();
+
+ if(tasks[ct].tlen > MAXTASKSIZE)
+ die("Task is too long: %d\n", tasks[ct].tlen);
+ //Read task bytecode
+ for(unsigned int i = 0; i<tasks[ct].tlen; i++){
+ tasks[ct].bc[i] = read_byte();
+ debug("t[][%i]: 0x%02x %d\n", i,
+ tasks[ct].bc[i], tasks[ct].bc[i]);
+ }
+ //Return the task number for later removal
+ debug("Received a task of length %d\n", tasks[ct].tlen);
+ tasks[ct].used = true;
+ return ct;
+}
+
+void task_delete()
+{
+ tasks[read_byte()].used = false;
+}
+
+struct task *task_get(int num)
+{
+ return tasks[num].used ? &tasks[num] : NULL;
+}
--- /dev/null
+#ifndef TASK_H
+#define TASK_H
+
+#define MAXTASKS 5
+#define MAXTASKSIZE 1024
+
+#include <stdint.h>
+#include <stdbool.h>
+
+struct task {
+ uint8_t bc[MAXTASKSIZE];
+ uint16_t tlen;
+ uint16_t interval;
+ long lastrun;
+ bool used;
+};
+
+void task_init();
+int task_register();
+void task_delete();
+struct task *task_get(int num);
+
+#endif