From 6f749f0198656a76526bc28206e62fd07454f917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sat, 16 Dec 2017 23:11:14 +0100 Subject: [PATCH] uhhh --- .../Class/CDC/Inc/usbd_cdc_if_template.h | 53 ---- .../Class/CDC/Src/usbd_cdc_if_template.c | 226 ------------------ .../Class/MSC/Inc/usbd_msc_storage_template.h | 105 -------- .../Class/MSC/Src/usbd_msc_storage_template.c | 188 --------------- .../Core/Inc/usbd_conf_template.h | 169 ------------- .../Core/Src/usbd_conf_template.c | 212 ---------------- USB/usb_device.c | 21 +- framework/settings.c | 4 +- gex_hooks.c | 20 +- platform/debug_uart.c | 1 + platform/status_led.c | 30 ++- platform/status_led.h | 5 + 12 files changed, 60 insertions(+), 974 deletions(-) delete mode 100644 USB/STM32_USB_Device_Library/Class/CDC/Inc/usbd_cdc_if_template.h delete mode 100644 USB/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc_if_template.c delete mode 100644 USB/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_storage_template.h delete mode 100644 USB/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_storage_template.c delete mode 100644 USB/STM32_USB_Device_Library/Core/Inc/usbd_conf_template.h delete mode 100644 USB/STM32_USB_Device_Library/Core/Src/usbd_conf_template.c diff --git a/USB/STM32_USB_Device_Library/Class/CDC/Inc/usbd_cdc_if_template.h b/USB/STM32_USB_Device_Library/Class/CDC/Inc/usbd_cdc_if_template.h deleted file mode 100644 index 806b2cb..0000000 --- a/USB/STM32_USB_Device_Library/Class/CDC/Inc/usbd_cdc_if_template.h +++ /dev/null @@ -1,53 +0,0 @@ -/** - ****************************************************************************** - * @file usbd_cdc_if_template.h - * @author MCD Application Team - * @version V2.4.2 - * @date 11-December-2015 - * @brief Header for usbd_cdc_if_template.c file. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT 2015 STMicroelectronics

- * - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __USBD_CDC_IF_TEMPLATE_H -#define __USBD_CDC_IF_TEMPLATE_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "usbd_cdc.h" - -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ - -extern USBD_CDC_ItfTypeDef USBD_CDC_Template_fops; - -/* Exported macro ------------------------------------------------------------*/ -/* Exported functions ------------------------------------------------------- */ - -#ifdef __cplusplus -} -#endif - -#endif /* __USBD_CDC_IF_TEMPLATE_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/USB/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc_if_template.c b/USB/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc_if_template.c deleted file mode 100644 index 5bb153a..0000000 --- a/USB/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc_if_template.c +++ /dev/null @@ -1,226 +0,0 @@ -/** - ****************************************************************************** - * @file usbd_cdc_if_template.c - * @author MCD Application Team - * @version V2.4.2 - * @date 11-December-2015 - * @brief Generic media access Layer. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT 2015 STMicroelectronics

- * - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "usbd_cdc_if_template.h" - -/** @addtogroup STM32_USB_DEVICE_LIBRARY - * @{ - */ - - -/** @defgroup USBD_CDC - * @brief usbd core module - * @{ - */ - -/** @defgroup USBD_CDC_Private_TypesDefinitions - * @{ - */ -/** - * @} - */ - - -/** @defgroup USBD_CDC_Private_Defines - * @{ - */ -/** - * @} - */ - - -/** @defgroup USBD_CDC_Private_Macros - * @{ - */ - -/** - * @} - */ - - -/** @defgroup USBD_CDC_Private_FunctionPrototypes - * @{ - */ - -static int8_t TEMPLATE_Init (void); -static int8_t TEMPLATE_DeInit (void); -static int8_t TEMPLATE_Control (uint8_t cmd, uint8_t* pbuf, uint16_t length); -static int8_t TEMPLATE_Receive (uint8_t* pbuf, uint32_t *Len); - -USBD_CDC_ItfTypeDef USBD_CDC_Template_fops = -{ - TEMPLATE_Init, - TEMPLATE_DeInit, - TEMPLATE_Control, - TEMPLATE_Receive -}; - -USBD_CDC_LineCodingTypeDef linecoding = - { - 115200, /* baud rate*/ - 0x00, /* stop bits-1*/ - 0x00, /* parity - none*/ - 0x08 /* nb. of bits 8*/ - }; - -/* Private functions ---------------------------------------------------------*/ - -/** - * @brief TEMPLATE_Init - * Initializes the CDC media low layer - * @param None - * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL - */ -static int8_t TEMPLATE_Init(void) -{ - /* - Add your initialization code here - */ - return (0); -} - -/** - * @brief TEMPLATE_DeInit - * DeInitializes the CDC media low layer - * @param None - * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL - */ -static int8_t TEMPLATE_DeInit(void) -{ - /* - Add your deinitialization code here - */ - return (0); -} - - -/** - * @brief TEMPLATE_Control - * Manage the CDC class requests - * @param Cmd: Command code - * @param Buf: Buffer containing command data (request parameters) - * @param Len: Number of data to be sent (in bytes) - * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL - */ -static int8_t TEMPLATE_Control (uint8_t cmd, uint8_t* pbuf, uint16_t length) -{ - switch (cmd) - { - case CDC_SEND_ENCAPSULATED_COMMAND: - /* Add your code here */ - break; - - case CDC_GET_ENCAPSULATED_RESPONSE: - /* Add your code here */ - break; - - case CDC_SET_COMM_FEATURE: - /* Add your code here */ - break; - - case CDC_GET_COMM_FEATURE: - /* Add your code here */ - break; - - case CDC_CLEAR_COMM_FEATURE: - /* Add your code here */ - break; - - case CDC_SET_LINE_CODING: - linecoding.bitrate = (uint32_t)(pbuf[0] | (pbuf[1] << 8) |\ - (pbuf[2] << 16) | (pbuf[3] << 24)); - linecoding.format = pbuf[4]; - linecoding.paritytype = pbuf[5]; - linecoding.datatype = pbuf[6]; - - /* Add your code here */ - break; - - case CDC_GET_LINE_CODING: - pbuf[0] = (uint8_t)(linecoding.bitrate); - pbuf[1] = (uint8_t)(linecoding.bitrate >> 8); - pbuf[2] = (uint8_t)(linecoding.bitrate >> 16); - pbuf[3] = (uint8_t)(linecoding.bitrate >> 24); - pbuf[4] = linecoding.format; - pbuf[5] = linecoding.paritytype; - pbuf[6] = linecoding.datatype; - - /* Add your code here */ - break; - - case CDC_SET_CONTROL_LINE_STATE: - /* Add your code here */ - break; - - case CDC_SEND_BREAK: - /* Add your code here */ - break; - - default: - break; - } - - return (0); -} - -/** - * @brief TEMPLATE_Receive - * Data received over USB OUT endpoint are sent over CDC interface - * through this function. - * - * @note - * This function will issue a NAK packet on any OUT packet received on - * USB endpoint untill exiting this function. If you exit this function - * before transfer is complete on CDC interface (ie. using DMA controller) - * it will result in receiving more data while previous ones are still - * not sent. - * - * @param Buf: Buffer of data to be received - * @param Len: Number of data received (in bytes) - * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL - */ -static int8_t TEMPLATE_Receive (uint8_t* Buf, uint32_t *Len) -{ - - return (0); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ - diff --git a/USB/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_storage_template.h b/USB/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_storage_template.h deleted file mode 100644 index 877a7d2..0000000 --- a/USB/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_storage_template.h +++ /dev/null @@ -1,105 +0,0 @@ -/** - ****************************************************************************** - * @file usbd_msc_storage.h - * @author MCD Application Team - * @version V2.4.2 - * @date 11-December-2015 - * @brief Header file for the usbd_msc_storage.c file - ****************************************************************************** - * @attention - * - *

© COPYRIGHT 2015 STMicroelectronics

- * - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __USBD_MSC_STORAGE_H -#define __USBD_MSC_STORAGE_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "usbd_msc.h" - -/** @addtogroup STM32_USB_DEVICE_LIBRARY - * @{ - */ - -/** @defgroup USBD_STORAGE - * @brief header file for the usbd_msc_storage.c file - * @{ - */ - -/** @defgroup USBD_STORAGE_Exported_Defines - * @{ - */ -/** - * @} - */ - - -/** @defgroup USBD_STORAGE_Exported_Types - * @{ - */ - - -/** - * @} - */ - - - -/** @defgroup USBD_STORAGE_Exported_Macros - * @{ - */ - -/** - * @} - */ - -/** @defgroup USBD_STORAGE_Exported_Variables - * @{ - */ -extern USBD_StorageTypeDef USBD_MSC_Template_fops; -/** - * @} - */ - -/** @defgroup USBD_STORAGE_Exported_FunctionsPrototype - * @{ - */ - - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __USBD_MSC_STORAGE_H */ - -/** - * @} - */ - -/** -* @} -*/ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/USB/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_storage_template.c b/USB/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_storage_template.c deleted file mode 100644 index 5e05535..0000000 --- a/USB/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_storage_template.c +++ /dev/null @@ -1,188 +0,0 @@ -/** - ****************************************************************************** - * @file usbd_msc_storage_template.c - * @author MCD Application Team - * @version V2.4.2 - * @date 11-December-2015 - * @brief Memory management layer - ****************************************************************************** - * @attention - * - *

© COPYRIGHT 2015 STMicroelectronics

- * - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************** - */ - - -/* Includes ------------------------------------------------------------------*/ -#include "usbd_msc_storage_template.h" - - -/* Private typedef -----------------------------------------------------------*/ -/* Private define ------------------------------------------------------------*/ -/* Private macro -------------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ -/* Private function prototypes -----------------------------------------------*/ -/* Extern function prototypes ------------------------------------------------*/ -/* Private functions ---------------------------------------------------------*/ - -#define STORAGE_LUN_NBR 1 -#define STORAGE_BLK_NBR 0x10000 -#define STORAGE_BLK_SIZ 0x200 - -int8_t STORAGE_Init (uint8_t lun); - -int8_t STORAGE_GetCapacity (uint8_t lun, - uint32_t *block_num, - uint16_t *block_size); - -int8_t STORAGE_IsReady (uint8_t lun); - -int8_t STORAGE_IsWriteProtected (uint8_t lun); - -int8_t STORAGE_Read (uint8_t lun, - uint8_t *buf, - uint32_t blk_addr, - uint16_t blk_len); - -int8_t STORAGE_Write (uint8_t lun, - uint8_t *buf, - uint32_t blk_addr, - uint16_t blk_len); - -int8_t STORAGE_GetMaxLun (void); - -/* USB Mass storage Standard Inquiry Data */ -int8_t STORAGE_Inquirydata[] = {//36 - - /* LUN 0 */ - 0x00, - 0x80, - 0x02, - 0x02, - (STANDARD_INQUIRY_DATA_LEN - 5), - 0x00, - 0x00, - 0x00, - 'S', 'T', 'M', ' ', ' ', ' ', ' ', ' ', /* Manufacturer : 8 bytes */ - 'P', 'r', 'o', 'd', 'u', 'c', 't', ' ', /* Product : 16 Bytes */ - ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', - '0', '.', '0' ,'1', /* Version : 4 Bytes */ -}; - -USBD_StorageTypeDef USBD_MSC_Template_fops = -{ - STORAGE_Init, - STORAGE_GetCapacity, - STORAGE_IsReady, - STORAGE_IsWriteProtected, - STORAGE_Read, - STORAGE_Write, - STORAGE_GetMaxLun, - STORAGE_Inquirydata, - -}; -/******************************************************************************* -* Function Name : Read_Memory -* Description : Handle the Read operation from the microSD card. -* Input : None. -* Output : None. -* Return : None. -*******************************************************************************/ -int8_t STORAGE_Init (uint8_t lun) -{ - return (0); -} - -/******************************************************************************* -* Function Name : Read_Memory -* Description : Handle the Read operation from the STORAGE card. -* Input : None. -* Output : None. -* Return : None. -*******************************************************************************/ -int8_t STORAGE_GetCapacity (uint8_t lun, uint32_t *block_num, uint16_t *block_size) -{ - *block_num = STORAGE_BLK_NBR; - *block_size = STORAGE_BLK_SIZ; - return (0); -} - -/******************************************************************************* -* Function Name : Read_Memory -* Description : Handle the Read operation from the STORAGE card. -* Input : None. -* Output : None. -* Return : None. -*******************************************************************************/ -int8_t STORAGE_IsReady (uint8_t lun) -{ - return (0); -} - -/******************************************************************************* -* Function Name : Read_Memory -* Description : Handle the Read operation from the STORAGE card. -* Input : None. -* Output : None. -* Return : None. -*******************************************************************************/ -int8_t STORAGE_IsWriteProtected (uint8_t lun) -{ - return 0; -} - -/******************************************************************************* -* Function Name : Read_Memory -* Description : Handle the Read operation from the STORAGE card. -* Input : None. -* Output : None. -* Return : None. -*******************************************************************************/ -int8_t STORAGE_Read (uint8_t lun, - uint8_t *buf, - uint32_t blk_addr, - uint16_t blk_len) -{ - return 0; -} -/******************************************************************************* -* Function Name : Write_Memory -* Description : Handle the Write operation to the STORAGE card. -* Input : None. -* Output : None. -* Return : None. -*******************************************************************************/ -int8_t STORAGE_Write (uint8_t lun, - uint8_t *buf, - uint32_t blk_addr, - uint16_t blk_len) -{ - return (0); -} -/******************************************************************************* -* Function Name : Write_Memory -* Description : Handle the Write operation to the STORAGE card. -* Input : None. -* Output : None. -* Return : None. -*******************************************************************************/ -int8_t STORAGE_GetMaxLun (void) -{ - return (STORAGE_LUN_NBR - 1); -} - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ - diff --git a/USB/STM32_USB_Device_Library/Core/Inc/usbd_conf_template.h b/USB/STM32_USB_Device_Library/Core/Inc/usbd_conf_template.h deleted file mode 100644 index c089136..0000000 --- a/USB/STM32_USB_Device_Library/Core/Inc/usbd_conf_template.h +++ /dev/null @@ -1,169 +0,0 @@ -/** - ****************************************************************************** - * @file usbd_conf_template.h - * @author MCD Application Team - * @version V2.4.2 - * @date 11-December-2015 - * @brief Header file for the usbd_conf_template.c file - ****************************************************************************** - * @attention - * - *

© COPYRIGHT 2015 STMicroelectronics

- * - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __USBD_CONF_TEMPLATE_H -#define __USBD_CONF_TEMPLATE_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32fxxx.h" /* replace 'stm32xxx' with your HAL driver header filename, ex: stm32f4xx.h */ -#include -#include -#include - -/** @addtogroup STM32_USB_DEVICE_LIBRARY - * @{ - */ - -/** @defgroup USBD_CONF - * @brief USB device low level driver configuration file - * @{ - */ - -/** @defgroup USBD_CONF_Exported_Defines - * @{ - */ - -#define USBD_MAX_NUM_INTERFACES 1 -#define USBD_MAX_NUM_CONFIGURATION 1 -#define USBD_MAX_STR_DESC_SIZ 0x100 -#define USBD_SUPPORT_USER_STRING 0 -#define USBD_SELF_POWERED 1 -#define USBD_DEBUG_LEVEL 2 - -/* MSC Class Config */ -#define MSC_MEDIA_PACKET 8192 - -/* CDC Class Config */ -#define USBD_CDC_INTERVAL 2000 - - /* DFU Class Config */ -#define USBD_DFU_MAX_ITF_NUM 1 -#define USBD_DFU_XFERS_IZE 1024 - - /* AUDIO Class Config */ -#define USBD_AUDIO_FREQ 22100 - -/** @defgroup USBD_Exported_Macros - * @{ - */ - - /* Memory management macros */ -#define USBD_malloc malloc -#define USBD_free free -#define USBD_memset memset -#define USBD_memcpy memcpy - - /* DEBUG macros */ - - -#if (USBD_DEBUG_LEVEL > 0) -#define USBD_UsrLog(...) printf(__VA_ARGS__);\ - printf("\n"); -#else -#define USBD_UsrLog(...) -#endif - - -#if (USBD_DEBUG_LEVEL > 1) - -#define USBD_ErrLog(...) printf("ERROR: ") ;\ - printf(__VA_ARGS__);\ - printf("\n"); -#else -#define USBD_ErrLog(...) -#endif - - -#if (USBD_DEBUG_LEVEL > 2) -#define USBD_DbgLog(...) printf("DEBUG : ") ;\ - printf(__VA_ARGS__);\ - printf("\n"); -#else -#define USBD_DbgLog(...) -#endif - -/** - * @} - */ - - - -/** - * @} - */ - - -/** @defgroup USBD_CONF_Exported_Types - * @{ - */ -/** - * @} - */ - - -/** @defgroup USBD_CONF_Exported_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup USBD_CONF_Exported_Variables - * @{ - */ -/** - * @} - */ - -/** @defgroup USBD_CONF_Exported_FunctionsPrototype - * @{ - */ -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __USBD_CONF_TEMPLATE_H */ - - -/** - * @} - */ - -/** - * @} - */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ - diff --git a/USB/STM32_USB_Device_Library/Core/Src/usbd_conf_template.c b/USB/STM32_USB_Device_Library/Core/Src/usbd_conf_template.c deleted file mode 100644 index e61553a..0000000 --- a/USB/STM32_USB_Device_Library/Core/Src/usbd_conf_template.c +++ /dev/null @@ -1,212 +0,0 @@ -/** - ****************************************************************************** - * @file usbd_conf_template.c - * @author MCD Application Team - * @version V2.4.2 - * @date 11-December-2015 - * @brief USB Device configuration and interface file - * This template should be copied to the user folder, renamed and customized - * following user needs. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT 2015 STMicroelectronics

- * - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "usbd_core.h" -/* Private typedef -----------------------------------------------------------*/ -/* Private define ------------------------------------------------------------*/ -/* Private macro -------------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ -/* Private function prototypes -----------------------------------------------*/ -/* Private functions ---------------------------------------------------------*/ -/** - * @brief Initializes the Low Level portion of the Device driver. - * @param pdev: Device handle - * @retval USBD Status - */ -USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) -{ - return USBD_OK; -} - -/** - * @brief De-Initializes the Low Level portion of the Device driver. - * @param pdev: Device handle - * @retval USBD Status - */ -USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev) -{ - return USBD_OK; -} - -/** - * @brief Starts the Low Level portion of the Device driver. - * @param pdev: Device handle - * @retval USBD Status - */ -USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev) -{ - return USBD_OK; -} - -/** - * @brief Stops the Low Level portion of the Device driver. - * @param pdev: Device handle - * @retval USBD Status - */ -USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev) -{ - return USBD_OK; -} - -/** - * @brief Opens an endpoint of the Low Level Driver. - * @param pdev: Device handle - * @param ep_addr: Endpoint Number - * @param ep_type: Endpoint Type - * @param ep_mps: Endpoint Max Packet Size - * @retval USBD Status - */ -USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, - uint8_t ep_addr, - uint8_t ep_type, - uint16_t ep_mps) -{ - return USBD_OK; -} - -/** - * @brief Closes an endpoint of the Low Level Driver. - * @param pdev: Device handle - * @param ep_addr: Endpoint Number - * @retval USBD Status - */ -USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) -{ - return USBD_OK; -} - -/** - * @brief Flushes an endpoint of the Low Level Driver. - * @param pdev: Device handle - * @param ep_addr: Endpoint Number - * @retval USBD Status - */ -USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) -{ - return USBD_OK; -} - -/** - * @brief Sets a Stall condition on an endpoint of the Low Level Driver. - * @param pdev: Device handle - * @param ep_addr: Endpoint Number - * @retval USBD Status - */ -USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) -{ - return USBD_OK; -} - -/** - * @brief Clears a Stall condition on an endpoint of the Low Level Driver. - * @param pdev: Device handle - * @param ep_addr: Endpoint Number - * @retval USBD Status - */ -USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) -{ - return USBD_OK; -} - -/** - * @brief Returns Stall condition. - * @param pdev: Device handle - * @param ep_addr: Endpoint Number - * @retval Stall (1: Yes, 0: No) - */ -uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) -{ - return 0; -} - -/** - * @brief Assigns a USB address to the device. - * @param pdev: Device handle - * @param ep_addr: Endpoint Number - * @retval USBD Status - */ -USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr) -{ - return USBD_OK; -} - -/** - * @brief Transmits data over an endpoint. - * @param pdev: Device handle - * @param ep_addr: Endpoint Number - * @param pbuf: Pointer to data to be sent - * @param size: Data size - * @retval USBD Status - */ -USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, - uint8_t ep_addr, - uint8_t *pbuf, - uint16_t size) -{ - return USBD_OK; -} - -/** - * @brief Prepares an endpoint for reception. - * @param pdev: Device handle - * @param ep_addr: Endpoint Number - * @param pbuf: Pointer to data to be received - * @param size: Data size - * @retval USBD Status - */ -USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, - uint8_t ep_addr, - uint8_t *pbuf, - uint16_t size) -{ - return USBD_OK; -} - -/** - * @brief Returns the last transferred packet size. - * @param pdev: Device handle - * @param ep_addr: Endpoint Number - * @retval Recived Data Size - */ -uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr) -{ - return 0; -} - -/** - * @brief Delays routine for the USB Device Library. - * @param Delay: Delay in ms - * @retval None - */ -void USBD_LL_Delay(uint32_t Delay) -{ -} -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ - diff --git a/USB/usb_device.c b/USB/usb_device.c index a85de0e..a0d2d8f 100644 --- a/USB/usb_device.c +++ b/USB/usb_device.c @@ -89,17 +89,26 @@ void MX_USB_DEVICE_Init(void) /** * @brief This function handles USB low priority or CAN RX0 interrupts. */ -void USB_LP_CAN1_RX0_IRQHandler(void) + +// Function from F103 +void USB_LP_CAN1_RX0_IRQHandler(void) __attribute__((alias("USB_IRQHandler"))); + +/** +* @brief This function handles USB global interrupt / USB wake-up interrupt through EXTI line 18. +*/ + +// Function from F072 +void USB_IRQHandler(void) { - /* USER CODE BEGIN USB_LP_CAN1_RX0_IRQn 0 */ + /* USER CODE BEGIN USB_IRQn 0 */ - /* USER CODE END USB_LP_CAN1_RX0_IRQn 0 */ + /* USER CODE END USB_IRQn 0 */ HAL_PCD_IRQHandler(&hpcd_USB_FS); - /* USER CODE BEGIN USB_LP_CAN1_RX0_IRQn 1 */ + /* USER CODE BEGIN USB_IRQn 1 */ - /* USER CODE END USB_LP_CAN1_RX0_IRQn 1 */ + /* USER CODE END USB_IRQn 1 */ } -/* USER CODE END USB_IRQ */ + /** * @} diff --git a/framework/settings.c b/framework/settings.c index 00f3ddf..f4c2cc9 100644 --- a/framework/settings.c +++ b/framework/settings.c @@ -14,8 +14,6 @@ void settings_load(void) { - dbg("Loading settings"); - uint8_t *buffer = (uint8_t *) SETTINGS_FLASH_ADDR; PayloadParser pp = pp_start(buffer, SETTINGS_BLOCK_SIZE, NULL); @@ -38,6 +36,8 @@ void settings_load(void) dbg("!! Unit settings failed to load"); return; } + + dbg("System settings loaded OK"); } diff --git a/gex_hooks.c b/gex_hooks.c index 25f0043..2aa49b1 100644 --- a/gex_hooks.c +++ b/gex_hooks.c @@ -18,13 +18,31 @@ void GEX_MsTick(void) TF_Tick(comm); StatusLed_Tick(); } - +extern void HardFault_Handler(void); /** * Early init, even before RTOS starts */ void GEX_PreInit(void) { + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOD_CLK_ENABLE(); +#if PORTS_COUNT>4 + __HAL_RCC_GPIOE_CLK_ENABLE(); +#endif +#if PORTS_COUNT>5 + __HAL_RCC_GPIOF_CLK_ENABLE(); +#endif + + // TODO remove this + LL_GPIO_SetPinMode(GPIOC, LL_GPIO_PIN_7, LL_GPIO_MODE_OUTPUT); + LL_GPIO_SetPinOutputType(GPIOC, LL_GPIO_PIN_7, LL_GPIO_OUTPUT_PUSHPULL); + LL_GPIO_SetPinSpeed(GPIOC, LL_GPIO_PIN_7, LL_GPIO_SPEED_FREQ_LOW); + + StatusLed_PreInit(); DebugUart_PreInit(); + dbg("\r\n\033[37;1m*** GEX "GEX_VERSION" on "GEX_PLATFORM" ***\033[m"); dbg("Build "__DATE__" "__TIME__"\r\n"); diff --git a/platform/debug_uart.c b/platform/debug_uart.c index f00577a..2e5a0c3 100644 --- a/platform/debug_uart.c +++ b/platform/debug_uart.c @@ -39,6 +39,7 @@ void DebugUart_PreInit(void) #if GEX_PLAT_F072_DISCOVERY LL_USART_SetBaudRate(USART2, SystemCoreClock, LL_USART_OVERSAMPLING_16, 115200); // This is not great, let's hope it's like this on all platforms... + LL_GPIO_SetAFPin_0_7(GPIOA, LL_GPIO_PIN_2, LL_GPIO_AF_1); #elif GEX_PLAT_F103_BLUEPILL LL_USART_SetBaudRate(USART2, SystemCoreClock/2, 115200); // This is not great, let's hope it's like this on all platforms... #else diff --git a/platform/status_led.c b/platform/status_led.c index e68491c..56eaf8c 100644 --- a/platform/status_led.c +++ b/platform/status_led.c @@ -12,6 +12,22 @@ static uint32_t indicators[_INDICATOR_COUNT]; static GPIO_TypeDef *led_periph; static uint32_t led_llpin; +/** Early init */ +void StatusLed_PreInit(void) +{ + bool suc = true; + // Resolve pin + led_periph = plat_port2periph(STATUS_LED_PORT, &suc); + led_llpin = plat_pin2ll(STATUS_LED_PIN, &suc); + + // Configure for output + LL_GPIO_SetPinMode(led_periph, led_llpin, LL_GPIO_MODE_OUTPUT); + LL_GPIO_SetPinOutputType(led_periph, led_llpin, LL_GPIO_OUTPUT_PUSHPULL); + LL_GPIO_SetPinSpeed(led_periph, led_llpin, LL_GPIO_SPEED_FREQ_LOW); + + assert_param(suc); +} + /** Set up the LED */ void StatusLed_Init(void) { @@ -23,16 +39,6 @@ void StatusLed_Init(void) suc &= rsc_claim(&UNIT_SYSTEM, rsc); assert_param(suc); - - // Resolve pin - led_periph = plat_port2periph(STATUS_LED_PORT, &suc); - led_llpin = plat_pin2ll(STATUS_LED_PIN, &suc); - assert_param(suc); - - // Configure for output - LL_GPIO_SetPinMode(led_periph, led_llpin, LL_GPIO_MODE_OUTPUT); - LL_GPIO_SetPinOutputType(led_periph, led_llpin, LL_GPIO_OUTPUT_PUSHPULL); - LL_GPIO_SetPinSpeed(led_periph, led_llpin, LL_GPIO_SPEED_FREQ_LOW); } /** Set indicator ON */ @@ -42,7 +48,7 @@ void StatusLed_On(enum GEX_StatusIndicator indicator) if (indicator == STATUS_FAULT) { // Persistent light - GPIOC->ODR |= 1<<13; + LL_GPIO_SetOutputPin(led_periph, led_llpin); } } @@ -86,5 +92,5 @@ void StatusLed_Tick(void) void StatusLed_Heartbeat(void) { // TODO fixme - GPIOC->ODR ^= 1<<13; + LL_GPIO_TogglePin(led_periph, led_llpin); } diff --git a/platform/status_led.h b/platform/status_led.h index 55a15c0..6635df6 100644 --- a/platform/status_led.h +++ b/platform/status_led.h @@ -19,6 +19,11 @@ enum GEX_StatusIndicator { _INDICATOR_COUNT }; +/** + * Early init + */ +void StatusLed_PreInit(void); + /** * Initialize the statis LED(s) */