Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
luftaquila committed Aug 8, 2024
1 parent f441d40 commit 64138dc
Show file tree
Hide file tree
Showing 12 changed files with 167 additions and 251 deletions.
8 changes: 4 additions & 4 deletions device/firmware/Core/Inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ void Error_Handler(void);
#define AIN_HV_CURRENT_GPIO_Port GPIOA
#define AIN_LV_VOLTAGE_Pin GPIO_PIN_2
#define AIN_LV_VOLTAGE_GPIO_Port GPIOA
#define DBG_TX_Pin GPIO_PIN_10
#define DBG_TX_GPIO_Port GPIOB
#define DBG_RX_Pin GPIO_PIN_11
#define DBG_RX_GPIO_Port GPIOB
#define RF_SCK_Pin GPIO_PIN_13
#define RF_SCK_GPIO_Port GPIOB
#define RF_MISO_Pin GPIO_PIN_14
#define RF_MISO_GPIO_Port GPIOB
#define RF_MOSI_Pin GPIO_PIN_15
#define RF_MOSI_GPIO_Port GPIOB
#define CONS_TX_Pin GPIO_PIN_9
#define CONS_TX_GPIO_Port GPIOA
#define CONS_RX_Pin GPIO_PIN_10
#define CONS_RX_GPIO_Port GPIOA
#define SD_SCK_Pin GPIO_PIN_3
#define SD_SCK_GPIO_Port GPIOB
#define SD_MISO_Pin GPIO_PIN_4
Expand Down
2 changes: 1 addition & 1 deletion device/firmware/Core/Inc/tusb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ extern "C" {
#endif

#ifndef CFG_TUSB_DEBUG
#define CFG_TUSB_DEBUG 0
#define CFG_TUSB_DEBUG 2
#endif

// Enable Device stack
Expand Down
4 changes: 2 additions & 2 deletions device/firmware/Core/Inc/usart.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ extern "C" {

/* USER CODE END Includes */

extern UART_HandleTypeDef huart1;
extern UART_HandleTypeDef huart3;

/* USER CODE BEGIN Private defines */

/* USER CODE END Private defines */

void MX_USART1_UART_Init(void);
void MX_USART3_UART_Init(void);

/* USER CODE BEGIN Prototypes */

Expand Down
12 changes: 4 additions & 8 deletions device/firmware/Core/Src/energymeter_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,11 @@
#include "energymeter.h"
#include "energymeter_usb.h"

#define APP_TX_DATA_SIZE 1024
#define APP_RX_DATA_SIZE 1024

/******************************************************************************
* global variables
*****************************************************************************/
/* USB CDC receive flag and buffer */
uint32_t usb_flag = FALSE;
// extern uint8_t UserRxBufferFS[];
// extern uint8_t UserTxBufferFS[];
uint8_t UserRxBufferFS[APP_RX_DATA_SIZE];
uint8_t UserTxBufferFS[APP_TX_DATA_SIZE];
uint8_t UserTxBufferFS_2[APP_TX_DATA_SIZE];

/* USB CDC command from the host system */
typedef enum {
Expand Down Expand Up @@ -109,6 +101,7 @@ void mode_usb(void) {
continue;
}

#ifdef DISABLED
/**************************************************************************
* PROTOCOL: CMD string (starts with $) +
* one space (ASCII 0x20), if additional parameter(s) exist +
Expand Down Expand Up @@ -145,11 +138,13 @@ void mode_usb(void) {
else if (USB_COMMAND(CMD_DELETE_ONE)) {
usb_delete_one(UserRxBufferFS + strlen(cmd[CMD_DELETE_ONE]) + 1);
}
#endif

usb_flag = FALSE;
}
}

#ifdef DISABLED
/******************************************************************************
* set commanded device id to flash
* PROTOCOL:
Expand Down Expand Up @@ -466,3 +461,4 @@ void usb_delete_one(uint8_t *buf) {

USB_RESPONSE(RESP_OK);
}
#endif
7 changes: 5 additions & 2 deletions device/firmware/Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ void SystemClock_Config(void);

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */

int _write(int file, uint8_t *ptr, int len) {
HAL_UART_Transmit(&huart3, (uint8_t *)ptr, (uint16_t)len, 100);
return (len);
}
/* USER CODE END 0 */

/**
Expand Down Expand Up @@ -103,9 +106,9 @@ int main(void)
MX_SPI1_Init();
MX_SPI2_Init();
MX_TIM1_Init();
MX_USART1_UART_Init();
MX_FATFS_Init();
MX_USB_PCD_Init();
MX_USART3_UART_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */

Expand Down
Loading

0 comments on commit 64138dc

Please sign in to comment.