Commit b30e5083 by Sebastian Renner

F7 template working

parent e1aa1c3c
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "crypto_aead.h" #include "crypto_aead.h"
#include "api.h" #include "api.h"
#define DEBUG //#define DEBUG
#define MAX_LEN 1400 #define MAX_LEN 1400
#ifdef DEBUG #ifdef DEBUG
...@@ -79,7 +79,6 @@ PCD_HandleTypeDef hpcd_USB_OTG_FS; ...@@ -79,7 +79,6 @@ PCD_HandleTypeDef hpcd_USB_OTG_FS;
/* Private function prototypes -----------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void); void SystemClock_Config(void);
static void MX_GPIO_Init(void); static void MX_GPIO_Init(void);
static void MX_USB_OTG_FS_PCD_Init(void);
static void MX_USART2_Init(void); static void MX_USART2_Init(void);
static void read_variable_serial(unsigned char action); static void read_variable_serial(unsigned char action);
static void write_variable_serial(unsigned char target[], uint32_t len); static void write_variable_serial(unsigned char target[], uint32_t len);
...@@ -178,8 +177,10 @@ int main(void) ...@@ -178,8 +177,10 @@ int main(void)
/* MCU Configuration--------------------------------------------------------*/ /* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */ /* 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 BEGIN Init */
/* USER CODE END Init */ /* USER CODE END Init */
...@@ -190,21 +191,23 @@ int main(void) ...@@ -190,21 +191,23 @@ int main(void)
/* USER CODE BEGIN SysInit */ /* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */ /* USER CODE END SysInit */
SEGGER_RTT_Init();
/* Initialize all configured peripherals */ /* Initialize all configured peripherals */
MX_GPIO_Init(); MX_GPIO_Init();
MX_USB_OTG_FS_PCD_Init();
MX_USART2_Init(); MX_USART2_Init();
/* USER CODE BEGIN 2 */ /* USER CODE BEGIN 2 */
/* USER CODE END 2 */ /* USER CODE END 2 */
/* Infinite loop */ /* Infinite loop */
/* USER CODE BEGIN WHILE */ /* USER CODE BEGIN WHILE */
unsigned char rcv; unsigned char rcv;
int res; int res;
while (1) { while (1) {
#ifdef DEBUG
dbg_printf("Starting to read form serial..");
#endif
read_serial(&rcv, 1); read_serial(&rcv, 1);
#ifdef DEBUG #ifdef DEBUG
dbg_printf("Received action: %c\n", rcv); dbg_printf("Received action: %c\n", rcv);
...@@ -237,9 +240,9 @@ int main(void) ...@@ -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("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"); dbg_printf("k: "); for (int i = 0; i < klen; i++) dbg_printf("%02x", k[i]); dbg_printf("\n");
#endif #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); 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; break;
default: default:
...@@ -358,41 +361,6 @@ static void MX_USART2_Init(void) ...@@ -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 * @brief GPIO Initialization Function
* @param None * @param None
* @retval None * @retval None
......
...@@ -7,7 +7,7 @@ import struct ...@@ -7,7 +7,7 @@ import struct
import serial import serial
import subprocess import subprocess
DBG='1' DBG=''
ser = serial.Serial('/dev/ttyUSB0', 115200) ser = serial.Serial('/dev/ttyUSB0', 115200)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment