From b30e50835739b22e67b24ad7390a48605740f452 Mon Sep 17 00:00:00 2001 From: Sebastian Renner Date: Mon, 15 Jul 2019 13:23:15 +0200 Subject: [PATCH] F7 template working --- templates/f7/Src/main.c | 52 ++++++++++------------------------------------------ templates/f7/middleware.py | 2 +- 2 files changed, 11 insertions(+), 43 deletions(-) diff --git a/templates/f7/Src/main.c b/templates/f7/Src/main.c index 8db2e62..ab1a4e8 100644 --- a/templates/f7/Src/main.c +++ b/templates/f7/Src/main.c @@ -24,7 +24,7 @@ #include "crypto_aead.h" #include "api.h" -#define DEBUG +//#define DEBUG #define MAX_LEN 1400 #ifdef DEBUG @@ -79,7 +79,6 @@ PCD_HandleTypeDef hpcd_USB_OTG_FS; /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void MX_GPIO_Init(void); -static void MX_USB_OTG_FS_PCD_Init(void); static void MX_USART2_Init(void); static void read_variable_serial(unsigned char action); static void write_variable_serial(unsigned char target[], uint32_t len); @@ -178,8 +177,10 @@ int main(void) /* MCU Configuration--------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ - HAL_Init(); + LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR); + LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SYSCFG); + NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); /* USER CODE BEGIN Init */ /* USER CODE END Init */ @@ -190,21 +191,23 @@ int main(void) /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ + SEGGER_RTT_Init(); /* Initialize all configured peripherals */ MX_GPIO_Init(); - MX_USB_OTG_FS_PCD_Init(); MX_USART2_Init(); /* USER CODE BEGIN 2 */ /* USER CODE END 2 */ - /* Infinite loop */ /* USER CODE BEGIN WHILE */ unsigned char rcv; int res; while (1) { + #ifdef DEBUG + dbg_printf("Starting to read form serial.."); + #endif read_serial(&rcv, 1); #ifdef DEBUG dbg_printf("Received action: %c\n", rcv); @@ -237,9 +240,9 @@ int main(void) dbg_printf("p: "); for (int i = 0; i < nplen; i++) dbg_printf("%02x", npub[i]); dbg_printf("\n"); dbg_printf("k: "); for (int i = 0; i < klen; i++) dbg_printf("%02x", k[i]); dbg_printf("\n"); #endif - //LL_GPIO_TogglePin(GPIOB, LL_GPIO_PIN_14); + LL_GPIO_TogglePin(GPIOB, LL_GPIO_PIN_14); res = crypto_aead_encrypt(c, &clen, m, mlen, ad, adlen, nsec, npub, k); - //LL_GPIO_TogglePin(GPIOB, LL_GPIO_PIN_14); + LL_GPIO_TogglePin(GPIOB, LL_GPIO_PIN_14); break; default: @@ -358,41 +361,6 @@ static void MX_USART2_Init(void) } /** - * @brief USB_OTG_FS Initialization Function - * @param None - * @retval None - */ -static void MX_USB_OTG_FS_PCD_Init(void) -{ - - /* USER CODE BEGIN USB_OTG_FS_Init 0 */ - - /* USER CODE END USB_OTG_FS_Init 0 */ - - /* USER CODE BEGIN USB_OTG_FS_Init 1 */ - - /* USER CODE END USB_OTG_FS_Init 1 */ - hpcd_USB_OTG_FS.Instance = USB_OTG_FS; - hpcd_USB_OTG_FS.Init.dev_endpoints = 6; - hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; - hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; - hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; - hpcd_USB_OTG_FS.Init.Sof_enable = ENABLE; - hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; - hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; - hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; - hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; - if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN USB_OTG_FS_Init 2 */ - - /* USER CODE END USB_OTG_FS_Init 2 */ - -} - -/** * @brief GPIO Initialization Function * @param None * @retval None diff --git a/templates/f7/middleware.py b/templates/f7/middleware.py index c5e3e1b..1365bb9 100755 --- a/templates/f7/middleware.py +++ b/templates/f7/middleware.py @@ -7,7 +7,7 @@ import struct import serial import subprocess -DBG='1' +DBG='' ser = serial.Serial('/dev/ttyUSB0', 115200) -- libgit2 0.26.0