3.24_433_TX版本:项目去UI化,删除OLED/菜单/按键,TX已验证,RX待验证
删除内容: - 删除OLED显示相关代码(u8g2库、I2C接口) - 删除按键输入相关代码(key.c) - 删除菜单系统(MultMenu整个目录) - 删除USB CDC功能(USB_DEVICE目录) - 删除旧的E32演示代码(e32_demo.c/h) 保留内容: - Driver_RF433核心驱动(已封装完整) - rf433_tx_app.c(TX应用层,独立无UI依赖) - rf433_rx_app.c(RX应用层,独立无UI依赖) - GPIO LED指示功能(LED_TX/LED_RX)
This commit is contained in:
@ -1,139 +0,0 @@
|
||||
#ifndef _E32_DEMO_H_
|
||||
#define _E32_DEMO_H_
|
||||
|
||||
#include "e32_hal.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
OFF = 0x00,
|
||||
ON = 0x01,
|
||||
}on_off_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
RADIO_RATE_2400 = 0x02,
|
||||
RADIO_RATE_4800 = 0x03,
|
||||
RADIO_RATE_9600 = 0x04,
|
||||
RADIO_RATE_19200 = 0x05,
|
||||
RADIO_RATE_38400 = 0x06,
|
||||
RADIO_RATE_62500 = 0x07,
|
||||
}radio_rate_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
UART_8N1 = 0x00,
|
||||
UART_8O1 = 0x01,
|
||||
UART_8E1 = 0x02,
|
||||
}uart_parity_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
UART_RATE_1200 = 0x00,
|
||||
UART_RATE_2400 = 0x01,
|
||||
UART_RATE_4800 = 0x02,
|
||||
UART_RATE_9600 = 0x03,
|
||||
UART_RATE_19200 = 0x04 ,
|
||||
UART_RATE_38400 = 0x05,
|
||||
UART_RATE_57600 = 0x06,
|
||||
UART_RATE_115200= 0x07,
|
||||
}uart_rate_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
WOR_PERIOD_250MS = 0x00,
|
||||
WOR_PERIOD_500MS = 0x01,
|
||||
WOR_PERIOD_750MS = 0x02,
|
||||
WOR_PERIOD_1000MS = 0x03,
|
||||
WOR_PERIOD_1250MS = 0x04,
|
||||
WOR_PERIOD_1500MS = 0x05,
|
||||
WOR_PERIOD_1750MS = 0x06,
|
||||
WOR_PERIOD_2000MS = 0x07,
|
||||
}wor_period_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TX_POWER_DBM_30 = 0x00,
|
||||
TX_POWER_DBM_27 = 0x01,
|
||||
TX_POWER_DBM_24 = 0x02,
|
||||
TX_POWER_DBM_21 = 0x03,
|
||||
}transmit_power_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* 00H<30>ǹ̶<C7B9><CCB6><EFBFBD>HEAD<41><44><EFBFBD><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD> */
|
||||
|
||||
/* ======== <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD>üĴ<C3BC><C4B4><EFBFBD> 01H ======== */
|
||||
struct
|
||||
{
|
||||
uint8_t address_h; /* ģ<><C4A3><EFBFBD><EFBFBD>ַ (<28>û<EFBFBD><C3BB><EFBFBD><EFBFBD>üĴ<C3BC><C4B4><EFBFBD><EFBFBD><EFBFBD>ַ: 01H<31><48>02H) <20><>ͬ<EFBFBD><CDAC>ַ<EFBFBD><D6B7>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD>ֱ<EFBFBD>ӻ<EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>(<28>㲥<EFBFBD><E3B2A5>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>); 65535Ϊ<35>㲥<EFBFBD><E3B2A5>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ⱥ<EFBFBD><C8BA><EFBFBD><EFBFBD>Ϣ */
|
||||
}register_1;
|
||||
|
||||
/* ======== <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD>üĴ<C3BC><C4B4><EFBFBD> 02H ======== */
|
||||
struct
|
||||
{
|
||||
uint8_t address_l;
|
||||
}register_2;
|
||||
|
||||
/* ======== <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD>üĴ<C3BC><C4B4><EFBFBD> 03H ======== */
|
||||
union {
|
||||
uint8_t value;
|
||||
struct
|
||||
{
|
||||
radio_rate_t radio_rate : 3; /* <20><><EFBFBD>߿<EFBFBD><DFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ַ: 03H Bit2-0) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD>ߣ<EFBFBD><DFA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD>죬<EFBFBD><ECA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><C8BB>½<EFBFBD><C2BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊͨ<CEAA>ž<EFBFBD><C5BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
uart_rate_t uart_baud_rate : 3; /* <20><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD> (<28>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ַ: 03H Bit7-5) <20><><EFBFBD><EFBFBD>ģʽ(ģʽ2)ǿ<>ƹ̶<C6B9><CCB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ9600<30><30><EFBFBD><EFBFBD><EFBFBD>ഫ<EFBFBD><E0B4AB>ģʽʱΪ<CAB1>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ô<EFBFBD><C3B4>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD> */
|
||||
uart_parity_t uart_parity : 2; /* <20><><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ַ: 03H Bit4-3) */
|
||||
}field;
|
||||
}register_3;
|
||||
|
||||
/* ======== <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD>üĴ<C3BC><C4B4><EFBFBD> 04H ======== */
|
||||
struct
|
||||
{
|
||||
uint8_t channel; /* <20>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD><EFBFBD> (<28>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ַ: 04H) <20><><EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>йأ<D0B9><D8A3>ز<EFBFBD>Ƶ<EFBFBD><C6B5> = <20>ŵ<EFBFBD>0<EFBFBD><30>ʼƵ<CABC><C6B5> + (1MHz x <20>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD><EFBFBD>) */
|
||||
}register_4;
|
||||
|
||||
/* ======== <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD>üĴ<C3BC><C4B4><EFBFBD> 05H ======== */
|
||||
union {
|
||||
uint8_t value;
|
||||
struct
|
||||
{
|
||||
transmit_power_t tx_power : 2; /* <20><><EFBFBD>书<EFBFBD><E4B9A6> (<28>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ַ: 05H Bit1-0) <20><>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD>Ĺ<EFBFBD><C4B9>ʷֵ<CAB7><D6B5><EFBFBD>һ<EFBFBD>£<EFBFBD><C2A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>Ҫ<EFBFBD>ο<EFBFBD>ģ<EFBFBD><C4A3><EFBFBD>ֲ<EFBFBD> */
|
||||
on_off_t packet_fec : 1; /* ǰ<><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FEC (<28>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ַ: 05H Bit2 ) ˫<><CBAB>˫<EFBFBD>˱<EFBFBD><CBB1><EFBFBD>һ<EFBFBD>£<EFBFBD><C2A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD>š<EFBFBD><C5A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F3A3ACBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿ(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Ҳ<EFBFBD><D2B2><EFBFBD>ӳ<EFBFBD> */
|
||||
wor_period_t wake_on_radio_period : 3; /* <20><><EFBFBD>л<EFBFBD><D0BB><EFBFBD>WOR<4F><52><EFBFBD><EFBFBD> (<28>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ַ: 05H Bit2-0) <20>շ<EFBFBD>˫<EFBFBD><CBAB><EFBFBD>趨<EFBFBD><E8B6A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׳<EFBFBD><D7B3><EFBFBD><EFBFBD><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
on_off_t reserve : 1; /* <20><><EFBFBD><EFBFBD> IO<49><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ*/
|
||||
on_off_t specify_target : 1; /* ָ<><D6B8>Ŀ<EFBFBD>괫<EFBFBD>䣬Ҳ<E4A3AC>ж<EFBFBD><D0B6><EFBFBD>ģʽ (<28>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ַ: 05H Bit7 ) <20><><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>ŵ<EFBFBD> */
|
||||
}field;
|
||||
}register_5;
|
||||
|
||||
}e32_register_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
REQUEST_CMD_CONFIG = 0x00,
|
||||
REQUEST_CMD_NAME ,
|
||||
REQUEST_CMD_VERSION ,
|
||||
}request_cmd_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t address_h;
|
||||
uint8_t address_l;
|
||||
uint8_t channel;
|
||||
uint8_t data[237];//<2F><><EFBFBD>㴫<EFBFBD><E3B4AB>(ָ<><D6B8>Ŀ<EFBFBD><C4BF>)<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2>ó<EFBFBD><C3B3><EFBFBD>237<33>ֽڣ<D6BD><DAA3><EFBFBD><EFBFBD><EFBFBD><F2B3ACB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻᶪʧ
|
||||
}e32_specify_target_buffer_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t command;
|
||||
uint8_t config[20];
|
||||
}e32_hex_cmd_buffer_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint8_t opt_buffer[1024];
|
||||
e32_hex_cmd_buffer_t hex_cmd;
|
||||
e32_specify_target_buffer_t target;
|
||||
}e32_opt_buffer_t;
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
#ifndef _E32_HAL_H_
|
||||
#define _E32_HAL_H_
|
||||
|
||||
#define E32_USE_GPIO_AUX 1 // 0:<3A><>ʹ<EFBFBD>û<C3BB><F2B2BBBC><EFBFBD>AUX״̬<D7B4><CCAC><EFBFBD><EFBFBD> 1:<3A><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>AUX<55><58><EFBFBD><EFBFBD>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
WORK_MODE_TRANSPARENT = 0x00,
|
||||
WORK_MODE_WAKE_ON_RADIO_MASTER = 0x01,
|
||||
WORK_MODE_WAKE_ON_RADIO_SLAVE = 0x02,
|
||||
WORK_MODE_CONFIG_AND_SLEEP = 0x03,
|
||||
}work_mode_t;
|
||||
|
||||
void e32_hal_uart_tx( uint8_t *buffer , uint16_t length );
|
||||
void e32_hal_aux_wait(void);
|
||||
void e32_hal_reset(void);
|
||||
void e32_hal_work_mode( work_mode_t mode);
|
||||
|
||||
#endif
|
||||
@ -1,31 +0,0 @@
|
||||
#ifndef _FIFO_H_
|
||||
#define _FIFO_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FIFO_OK = 0x00,
|
||||
FIFO_ERROR_NULL,
|
||||
FIFO_ERROR_LENGTH,
|
||||
FIFO_ERROR_FULL,
|
||||
FIFO_ERROR_EMPTY,
|
||||
}fifo_error_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t in;
|
||||
uint32_t out;
|
||||
uint32_t size;
|
||||
uint8_t* buffer;
|
||||
} fifo_t;
|
||||
|
||||
|
||||
fifo_error_t fifo_create( fifo_t *fifo , uint8_t *buffer, uint32_t size );
|
||||
fifo_error_t fifo_clear( fifo_t *fifo );
|
||||
fifo_error_t fifo_write( fifo_t *fifo, uint8_t *buffer, uint32_t length );
|
||||
fifo_error_t fifo_read( fifo_t *fifo, uint8_t *buffer, uint32_t length );
|
||||
fifo_error_t fifo_get_length( fifo_t *fifo , uint32_t *length);
|
||||
fifo_error_t fifo_get_remain_length( fifo_t *fifo , uint32_t *length);
|
||||
|
||||
#endif
|
||||
@ -1,52 +0,0 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file i2c.h
|
||||
* @brief This file contains all the function prototypes for
|
||||
* the i2c.c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2024 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __I2C_H__
|
||||
#define __I2C_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
extern I2C_HandleTypeDef hi2c2;
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
void MX_I2C2_Init(void);
|
||||
|
||||
/* USER CODE BEGIN Prototypes */
|
||||
|
||||
/* USER CODE END Prototypes */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __I2C_H__ */
|
||||
|
||||
@ -33,19 +33,10 @@ extern "C" {
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include "application.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
extern uint8_t my_usb_rx_data[ ];
|
||||
extern uint16_t my_usb_rx_num ;
|
||||
typedef enum
|
||||
{
|
||||
KEY_NAME_UP = 0,
|
||||
KEY_NAME_DOWN ,
|
||||
KEY_NAME_ENTER,
|
||||
}key_name_t;
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
@ -76,50 +67,21 @@ void Error_Handler(void);
|
||||
#define AUX_GPIO_Port GPIOB
|
||||
#define LED_TX_Pin GPIO_PIN_15
|
||||
#define LED_TX_GPIO_Port GPIOA
|
||||
#define BUZZER_PWM_Pin GPIO_PIN_3
|
||||
#define BUZZER_PWM_GPIO_Port GPIOB
|
||||
#define KEY_UP_Pin GPIO_PIN_4
|
||||
#define KEY_UP_GPIO_Port GPIOB
|
||||
#define USB_CTRL_Pin GPIO_PIN_5
|
||||
#define USB_CTRL_GPIO_Port GPIOB
|
||||
#define LED_RX_Pin GPIO_PIN_6
|
||||
#define LED_RX_GPIO_Port GPIOB
|
||||
#define KEY_ENTER_Pin GPIO_PIN_7
|
||||
#define KEY_ENTER_GPIO_Port GPIOB
|
||||
#define KEY_DOWN_Pin GPIO_PIN_9
|
||||
#define KEY_DOWN_GPIO_Port GPIOB
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
void usb_printf(const char *format, ...);
|
||||
|
||||
void gpio_usb_ctrl_on(void);
|
||||
void gpio_usb_ctrl_off(void);
|
||||
void gpio_led_tx_on(void);
|
||||
void gpio_led_tx_off(void);
|
||||
void gpio_led_rx_on(void);
|
||||
void gpio_led_rx_off(void);
|
||||
|
||||
void buzzer_on(void);
|
||||
void buzzer_off(void);
|
||||
void buzzer_button_press(void);
|
||||
|
||||
bool key_check_press( key_name_t name );
|
||||
void key_set_continue( key_name_t name , bool enable );
|
||||
void key_timer_1ms_interrupt_callback(void);
|
||||
|
||||
void systick_interrupt_1ms_callback(void);
|
||||
void systick_set_user_timeout( uint32_t time_ms );
|
||||
uint32_t systick_get_user_timeout(void);
|
||||
|
||||
void uart1_reconfig( uint32_t rate );
|
||||
void uart1_rx_timeout_1ms_callback(void);
|
||||
void uart1_wait_response_blocked( uint8_t * buffer, uint16_t *length );
|
||||
bool uart1_check_rx_done( uint8_t *buffer , uint32_t *length );
|
||||
|
||||
void e32_demo_read_device_name( char *buffer , uint8_t *length );
|
||||
void e32_demo_read_fireware_version( char *buffer , uint8_t *length);
|
||||
void e32_demo_menu_config( menu_config_t *config );
|
||||
void e32_demo_transmit( uint8_t *buffer , uint16_t length );
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
/*
|
||||
* @Author: JFeng 2834294740@qq.com
|
||||
* @Date: 2023-06-30 12:08:24
|
||||
* @LastEditors: JFeng 2834294740@qq.com
|
||||
* @LastEditTime: 2023-07-14 20:12:55
|
||||
* @FilePath: \MY_GUI\HARDWARE\stm32_u8g2.h
|
||||
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
||||
*/
|
||||
#ifndef __STM32_U8G2_H
|
||||
#define __STM32_U8G2_H
|
||||
|
||||
#include "main.h"
|
||||
#include "u8g2.h"
|
||||
|
||||
void u8g2Init(u8g2_t *u8g2);
|
||||
|
||||
#endif
|
||||
@ -29,13 +29,6 @@ extern "C" {
|
||||
#include "main.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
typedef enum {
|
||||
FUNC_NONE = 0,
|
||||
FUNC_FEATURE1,
|
||||
FUNC_FEATURE2
|
||||
} uart_feature;
|
||||
extern uart_feature current_feature;
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
extern UART_HandleTypeDef huart1;
|
||||
@ -47,7 +40,6 @@ extern UART_HandleTypeDef huart1;
|
||||
void MX_USART1_UART_Init(void);
|
||||
|
||||
/* USER CODE BEGIN Prototypes */
|
||||
void usb_receive_to_tx_send( void );
|
||||
/* USER CODE END Prototypes */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -1,292 +0,0 @@
|
||||
#include "e32_demo.h"
|
||||
#include "main.h"
|
||||
#include "application.h"
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
* ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
static e32_opt_buffer_t e32_buffer;
|
||||
|
||||
/**
|
||||
* ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡָ<C8A1><D6B8>
|
||||
*/
|
||||
static const uint8_t request_config[3]={0xC1,0xC1,0xC1};
|
||||
|
||||
/**
|
||||
* ATָ<54><D6B8> <20><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>
|
||||
*/
|
||||
static const char request_name[]="AT+DEVTYPE=?";
|
||||
|
||||
/**
|
||||
* ATָ<54><D6B8> <20><>ȡ<EFBFBD>̼<EFBFBD><CCBC>汾
|
||||
*/
|
||||
static const char request_version[]="AT+FWCODE=?";
|
||||
|
||||
/**
|
||||
* E32-433T30S Ĭ<><C4AC><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>
|
||||
*/
|
||||
static const e32_register_t register_default =
|
||||
{
|
||||
.register_1 = {
|
||||
.address_h = 0x00,
|
||||
},
|
||||
.register_2 = {
|
||||
.address_l = 0x00,
|
||||
},
|
||||
.register_3.field = {
|
||||
.radio_rate = RADIO_RATE_2400,
|
||||
.uart_baud_rate = UART_RATE_9600,
|
||||
.uart_parity = UART_8N1,
|
||||
},
|
||||
.register_4 = {
|
||||
.channel = 0x17,
|
||||
},
|
||||
.register_5.field = {
|
||||
.tx_power = TX_POWER_DBM_30,
|
||||
.packet_fec = ON,
|
||||
.wake_on_radio_period = WOR_PERIOD_250MS,
|
||||
.reserve = OFF,
|
||||
.specify_target = OFF,
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief <20><>ģ<EFBFBD><C4A3>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>ָ<EFBFBD><D6B8>
|
||||
*
|
||||
* @param config <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
*/
|
||||
static void e32_send_config_command( const e32_register_t *config )
|
||||
{
|
||||
/* <20><>1<EFBFBD>ֽڣ<D6BD><DAA3><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
||||
C0<43><30><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
e32_buffer.hex_cmd.command = 0xC0;
|
||||
|
||||
/* <20><>2~6<>ֽڿ<D6BD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD> */
|
||||
memcpy( e32_buffer.hex_cmd.config , (uint8_t*)config , sizeof(e32_register_t));
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>д<EFBFBD><D0B4> */
|
||||
e32_hal_uart_tx( (uint8_t*)&e32_buffer, sizeof(e32_register_t) + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief <20><>ģ<EFBFBD><C4A3>д<EFBFBD><D0B4><EFBFBD><EFBFBD>ѯָ<D1AF><D6B8>
|
||||
*
|
||||
* @param cmd <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>
|
||||
*/
|
||||
static void e32_send_request_command( request_cmd_t cmd )
|
||||
{
|
||||
switch( cmd )
|
||||
{
|
||||
/* <20><>ȡ<EFBFBD><C8A1><EFBFBD>ò<EFBFBD><C3B2><EFBFBD> */
|
||||
case REQUEST_CMD_CONFIG:
|
||||
e32_hal_uart_tx( (uint8_t*)request_config, sizeof(request_config));
|
||||
break;
|
||||
|
||||
/* <20><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD> */
|
||||
case REQUEST_CMD_NAME:
|
||||
e32_hal_uart_tx( (uint8_t*)request_name, strlen(request_name));
|
||||
break;
|
||||
|
||||
/* <20><>ȡ<EFBFBD>̼<EFBFBD><CCBC>汾 */
|
||||
case REQUEST_CMD_VERSION:
|
||||
e32_hal_uart_tx( (uint8_t*)request_version, strlen(request_version));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief (<28><>ѯָ<D1AF><D6B8><EFBFBD><EFBFBD>)ģ<><C4A3>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD>
|
||||
*
|
||||
* @param cmd <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>
|
||||
* @param buffer ָ<><D6B8>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD>
|
||||
* @param length Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
* @return bool <20><>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>true; <20><><EFBFBD><EFBFBD>false<73><65>
|
||||
*/
|
||||
static bool e32_response_command_check( request_cmd_t cmd , uint8_t *buffer , uint8_t length )
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
switch( cmd )
|
||||
{
|
||||
/* <20><>ȡ<EFBFBD><C8A1><EFBFBD>ò<EFBFBD><C3B2><EFBFBD> */
|
||||
case REQUEST_CMD_CONFIG:
|
||||
|
||||
/* <20><><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>6<EFBFBD>ֽ<EFBFBD>*/
|
||||
if( length == 6 )
|
||||
{
|
||||
/* <20><><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD> ֡ͷ<D6A1><CDB7><EFBFBD><EFBFBD>Ϊ0xC1 */
|
||||
if( buffer[0] == 0xC1)
|
||||
{
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* <20><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD> */
|
||||
case REQUEST_CMD_NAME:
|
||||
/* <20><><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD> */
|
||||
if( strncmp( "DEVTYPE=", (char*)buffer, 8) == 0 )
|
||||
{
|
||||
ret = true;
|
||||
}
|
||||
break;
|
||||
|
||||
/* <20><>ȡ<EFBFBD>̼<EFBFBD><CCBC>汾 */
|
||||
case REQUEST_CMD_VERSION:
|
||||
/* <20><><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD> */
|
||||
if( strncmp( "FWCODE=", (char*)buffer, 7) == 0 )
|
||||
{
|
||||
ret = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief <20><>ģ<EFBFBD>鴮<EFBFBD><E9B4AE>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @note <20><>ע<EFBFBD><D7A2>ģ<EFBFBD>鹤<EFBFBD><E9B9A4>ģʽ
|
||||
* @param buffer ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD>
|
||||
* @param length д<>볤<EFBFBD><EBB3A4>
|
||||
*/
|
||||
void e32_demo_transmit( uint8_t *buffer , uint16_t length )
|
||||
{
|
||||
/* <20><><EFBFBD><EFBFBD>д<EFBFBD><D0B4> */
|
||||
e32_hal_uart_tx( buffer, length);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief (<28><>ѡ) ʾ<><CABE><EFBFBD><EFBFBD><EFBFBD>ζ<EFBFBD>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @note ģ<><C4A3>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
* @param buffer ģ<><C4A3>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param length ģ<><C4A3>Ӧ<EFBFBD><EFBFBD>
|
||||
*/
|
||||
void e32_demo_read_device_name( char *buffer , uint8_t *length )
|
||||
{
|
||||
uint16_t opt_length;
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>ģʽ<C4A3><CABD>֧<EFBFBD>ִ<EFBFBD><D6B4><EFBFBD>9600<30><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
uart1_reconfig(9600);
|
||||
|
||||
/* <20>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ */
|
||||
e32_hal_work_mode( WORK_MODE_CONFIG_AND_SLEEP );
|
||||
|
||||
/* <20><><EFBFBD>Ͳ<EFBFBD>ѯָ<D1AF><D6B8> <20><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8> */
|
||||
e32_send_request_command( REQUEST_CMD_NAME );
|
||||
|
||||
/* <20>ȴ<EFBFBD>ģ<EFBFBD><C4A3>Ӧ<EFBFBD><D3A6> */
|
||||
uart1_wait_response_blocked( (uint8_t*)buffer , &opt_length );
|
||||
|
||||
/* Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD> */
|
||||
if( e32_response_command_check( REQUEST_CMD_NAME, (uint8_t*)buffer , opt_length ) != true )
|
||||
{
|
||||
/* Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD>ȷ */
|
||||
while(1);
|
||||
}
|
||||
|
||||
*length = opt_length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief (<28><>ѡ) ʾ<><CABE><EFBFBD><EFBFBD><EFBFBD>ζ<EFBFBD>ȡ<EFBFBD>豸<EFBFBD>̼<EFBFBD><CCBC>汾
|
||||
*
|
||||
* @note ģ<><C4A3>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
* @param buffer ģ<><C4A3>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param length ģ<><C4A3>Ӧ<EFBFBD><EFBFBD>
|
||||
*/
|
||||
void e32_demo_read_fireware_version( char *buffer , uint8_t *length )
|
||||
{
|
||||
uint16_t opt_length;
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>ģʽ<C4A3><CABD>֧<EFBFBD>ִ<EFBFBD><D6B4><EFBFBD>9600<30><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
uart1_reconfig(9600);
|
||||
|
||||
/* <20>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ */
|
||||
e32_hal_work_mode( WORK_MODE_CONFIG_AND_SLEEP );
|
||||
|
||||
/* <20><><EFBFBD>Ͳ<EFBFBD>ѯָ<D1AF><D6B8> <20><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8> */
|
||||
e32_send_request_command( REQUEST_CMD_VERSION );
|
||||
|
||||
/* <20>ȴ<EFBFBD>ģ<EFBFBD><C4A3>Ӧ<EFBFBD><D3A6> */
|
||||
uart1_wait_response_blocked( (uint8_t*)buffer , &opt_length );
|
||||
|
||||
/* Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD> */
|
||||
if( e32_response_command_check( REQUEST_CMD_VERSION, (uint8_t*)buffer , opt_length ) != true )
|
||||
{
|
||||
/* Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD>ȷ */
|
||||
while(1);
|
||||
}
|
||||
|
||||
*length = opt_length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ʹ<><CAB9><EFBFBD><EFBFBD>ʾ<EFBFBD>˵<EFBFBD><CBB5>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
|
||||
*
|
||||
* @param config <20>˵<EFBFBD><CBB5><EFBFBD><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
*/
|
||||
void e32_demo_menu_config( menu_config_t *config )
|
||||
{
|
||||
uint16_t opt_length;
|
||||
e32_register_t register_write;
|
||||
transmit_power_t power_select;
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>Ĭ<EFBFBD>ϼĴ<CFBC><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
memcpy( (uint8_t*)®ister_write , (uint8_t*)®ister_default , sizeof(e32_register_t) );
|
||||
/* <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA> */
|
||||
switch( config->tx_power )
|
||||
{
|
||||
case 27:
|
||||
power_select = TX_POWER_DBM_27;
|
||||
break;
|
||||
|
||||
case 24:
|
||||
power_select = TX_POWER_DBM_24;
|
||||
break;
|
||||
|
||||
case 21:
|
||||
power_select = TX_POWER_DBM_21;
|
||||
break;
|
||||
|
||||
default:
|
||||
power_select = TX_POWER_DBM_30;
|
||||
break;
|
||||
}
|
||||
|
||||
/* <20><EFBFBD><DEB8>û<EFBFBD><C3BB><EFBFBD><EFBFBD>õIJ<C3B5><C4B2><EFBFBD> */
|
||||
register_write.register_5.field.tx_power = power_select; //<2F><><EFBFBD><EFBFBD>
|
||||
register_write.register_3.field.radio_rate = (radio_rate_t)config->rate_mode; //<2F><><EFBFBD><EFBFBD>
|
||||
register_write.register_4.channel = config->channel; //<2F>ŵ<EFBFBD>
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>ģʽ<C4A3><CABD>֧<EFBFBD>ִ<EFBFBD><D6B4><EFBFBD>9600<30><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
uart1_reconfig(9600);
|
||||
|
||||
/* <20>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ */
|
||||
e32_hal_work_mode( WORK_MODE_CONFIG_AND_SLEEP );
|
||||
|
||||
/* <20><>ģ<EFBFBD>鴮<EFBFBD><E9B4AE>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
e32_send_config_command( ®ister_write );
|
||||
|
||||
/* <20>ȴ<EFBFBD>ģ<EFBFBD><C4A3>Ӧ<EFBFBD><D3A6> */
|
||||
uart1_wait_response_blocked( e32_buffer.opt_buffer , &opt_length );
|
||||
|
||||
// /* Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD> ָ<><D6B8>ͷ<EFBFBD><CDB7>ΪC1 */
|
||||
// if( e32_buffer.opt_buffer[0] != 0xC1 )
|
||||
// {
|
||||
// /* ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD>FF FF FF <20><>ʾָ<CABE><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
// while(1);
|
||||
// }
|
||||
|
||||
///@todo <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/* <20>л<EFBFBD><D0BB><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><CDB8>ģʽ<C4A3><CABD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD> */
|
||||
uart1_reconfig(9600);
|
||||
|
||||
/* <20>ص<EFBFBD><EFBFBD><CDB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ */
|
||||
e32_hal_work_mode( WORK_MODE_TRANSPARENT );
|
||||
}
|
||||
|
||||
@ -1,123 +0,0 @@
|
||||
#include "e32_hal.h"
|
||||
|
||||
/**
|
||||
* <20>뵥Ƭ<EBB5A5><C6AC>ƽ̨<C6BD>й<EFBFBD>
|
||||
*/
|
||||
#include "main.h"
|
||||
#include "gpio.h"
|
||||
#include "usart.h"
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD>ڷ<EFBFBD><DAB7>ͽӿ<CDBD>
|
||||
*
|
||||
* @param buffer <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param length <20><><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD>
|
||||
*/
|
||||
void e32_hal_uart_tx( uint8_t *buffer , uint16_t length )
|
||||
{
|
||||
HAL_UART_Transmit( &huart1, buffer, length, 0xFFFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ģ<><C4A3>æ״̬<D7B4>ȴ<EFBFBD>
|
||||
*/
|
||||
void e32_hal_aux_wait(void)
|
||||
{
|
||||
if( HAL_GPIO_ReadPin( AUX_GPIO_Port , AUX_Pin ) == GPIO_PIN_RESET )
|
||||
{
|
||||
/* <20>ȵ<EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AUX<55><58><EFBFBD>ŵ<EFBFBD>Ϊæ<CEAA><C3A6><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD> */
|
||||
while( HAL_GPIO_ReadPin( AUX_GPIO_Port , AUX_Pin ) == GPIO_PIN_RESET )
|
||||
{
|
||||
///@todo <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD>Ǽ<EFBFBD><C7BC><EFBFBD><EFBFBD>ԣ<EFBFBD>AUX<55><58><EFBFBD>к<EFBFBD><D0BA><EFBFBD><EFBFBD>Ե<EFBFBD>1~2ms */
|
||||
HAL_Delay(2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ģ<>鸴λ
|
||||
*/
|
||||
void e32_hal_reset(void)
|
||||
{
|
||||
HAL_GPIO_WritePin( RESET_GPIO_Port, RESET_Pin, GPIO_PIN_RESET );
|
||||
|
||||
HAL_Delay(1);
|
||||
|
||||
HAL_GPIO_WritePin( RESET_GPIO_Port, RESET_Pin, GPIO_PIN_SET );
|
||||
|
||||
#if E32_USE_GPIO_AUX
|
||||
/* ע<><D7A2> Ӳ<><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>AUX<55><58><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ȴ<EFBFBD>һ<EFBFBD><D2BB>ʱ<EFBFBD><CAB1><EFBFBD>ٿ<EFBFBD>ʼAUX<55><58><EFBFBD><EFBFBD> */
|
||||
HAL_Delay(10);
|
||||
|
||||
e32_hal_aux_wait();
|
||||
#else
|
||||
// /* E32-V2 (V8.1) <20>汾<EFBFBD><E6B1BE><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ϳ<EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>AT+FWCODE=?<3F><>ȡ<EFBFBD>汾<EFBFBD><E6B1BE>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7> 7393-x-xx */
|
||||
// e32_delay_ms(1200);
|
||||
|
||||
/* E32-V2 (V8.2) <20>汾
|
||||
<20><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>AT+FWCODE=?<3F><>ȡ<EFBFBD>汾<EFBFBD><E6B1BE>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7> 7459-x-xx */
|
||||
e32_delay_ms(30);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ģ<><C4A3>ģʽ<C4A3>л<EFBFBD>
|
||||
*
|
||||
* @param mode <20><><EFBFBD><EFBFBD>ģʽ
|
||||
*/
|
||||
void e32_hal_work_mode( work_mode_t mode)
|
||||
{
|
||||
|
||||
#if E32_USE_GPIO_AUX
|
||||
e32_hal_aux_wait();
|
||||
#endif
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
/* ģʽ0<CABD><30> һ<><D2BB>ģʽ (M0=0 M1=0) */
|
||||
case WORK_MODE_TRANSPARENT:
|
||||
HAL_GPIO_WritePin( M0_GPIO_Port, M0_Pin, GPIO_PIN_RESET );
|
||||
HAL_GPIO_WritePin( M1_GPIO_Port, M1_Pin, GPIO_PIN_RESET );
|
||||
break;
|
||||
|
||||
/* ģʽ1<CABD><31> <20><><EFBFBD><EFBFBD>ģʽ (M0=1 M1=0) */
|
||||
case WORK_MODE_WAKE_ON_RADIO_MASTER:
|
||||
HAL_GPIO_WritePin( M0_GPIO_Port, M0_Pin, GPIO_PIN_SET );
|
||||
HAL_GPIO_WritePin( M1_GPIO_Port, M1_Pin, GPIO_PIN_RESET );
|
||||
break;
|
||||
|
||||
/* ģʽ2<CABD><32> ʡ<><CAA1>ģʽ (M0=0 M1=1) */
|
||||
case WORK_MODE_WAKE_ON_RADIO_SLAVE:
|
||||
HAL_GPIO_WritePin( M0_GPIO_Port, M0_Pin, GPIO_PIN_RESET );
|
||||
HAL_GPIO_WritePin( M1_GPIO_Port, M1_Pin, GPIO_PIN_SET );
|
||||
break;
|
||||
|
||||
/* ģʽ3<CABD><33> <20><><EFBFBD><EFBFBD>ģʽ (M0=1 M1=1) */
|
||||
case WORK_MODE_CONFIG_AND_SLEEP:
|
||||
HAL_GPIO_WritePin( M0_GPIO_Port, M0_Pin, GPIO_PIN_SET );
|
||||
HAL_GPIO_WritePin( M1_GPIO_Port, M1_Pin, GPIO_PIN_SET );
|
||||
break;
|
||||
|
||||
default:
|
||||
while(1); //ģʽ<C4A3><CABD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
#if E32_USE_GPIO_AUX
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB><EFBFBD> ģ<><C4A3><EFBFBD><EFBFBD>ʱAUX<55><58><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD>Ҫ<EFBFBD>Ե<EFBFBD><D4B5>ٽ<EFBFBD><D9BD>м<EFBFBD><D0BC><EFBFBD> */
|
||||
HAL_Delay(5);
|
||||
e32_hal_aux_wait();
|
||||
#else
|
||||
|
||||
/* <20><><EFBFBD>ﱣ<EFBFBD><EFB1A3>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ȷ<EFBFBD><C8B7>ģʽ<C4A3>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD> */
|
||||
e32_delay_ms(50);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
168
Core/Src/fifo.c
168
Core/Src/fifo.c
@ -1,168 +0,0 @@
|
||||
#include "fifo.h"
|
||||
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
|
||||
|
||||
fifo_error_t fifo_create( fifo_t *fifo , uint8_t *buffer, uint32_t size )
|
||||
{
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if( (fifo == 0) || (buffer == 0) || (size == 0) )
|
||||
{
|
||||
return FIFO_ERROR_NULL;
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2^n) */
|
||||
if( size & (size - 1) )
|
||||
{
|
||||
return FIFO_ERROR_LENGTH;
|
||||
}
|
||||
|
||||
/* Ĭ<><C4AC> */
|
||||
fifo->size = size;
|
||||
fifo->buffer = buffer;
|
||||
fifo->in = 0;
|
||||
fifo->out = 0;
|
||||
|
||||
return FIFO_OK;
|
||||
}
|
||||
|
||||
fifo_error_t fifo_clear( fifo_t *fifo )
|
||||
{
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if( fifo == 0 )
|
||||
{
|
||||
return FIFO_ERROR_NULL;
|
||||
}
|
||||
|
||||
fifo->in = 0;
|
||||
fifo->out = 0;
|
||||
|
||||
return FIFO_OK;
|
||||
}
|
||||
|
||||
|
||||
fifo_error_t fifo_write( fifo_t *fifo, uint8_t *buffer, uint32_t length )
|
||||
{
|
||||
uint32_t i, j;
|
||||
uint32_t end_length, org_length;
|
||||
uint8_t *fifo_buffer;
|
||||
|
||||
/* <20><>¼ԭʼ<D4AD>û<EFBFBD>д<EFBFBD>볤<EFBFBD><EBB3A4> */
|
||||
org_length = length;
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>FIFOʣ<4F><CAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
length = MIN( length, fifo->size - fifo->in + fifo->out );
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>FIFO<46><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĩβ<C4A9>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㹻λ<E3B9BB><CEBB> */
|
||||
end_length = MIN( length, fifo->size - ( fifo->in & ( fifo->size - 1 ) ) );
|
||||
|
||||
/* <20>ҵ<EFBFBD>FIFO<46><4F>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ */
|
||||
fifo_buffer = fifo->buffer + ( fifo->in & ( fifo->size - 1 ) );
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>FIFOĩβ<C4A9><CEB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8>Ƶ<EFBFBD>FIFO<46><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĩβ */
|
||||
for( i = 0; i < end_length; i++ )
|
||||
{
|
||||
*( fifo_buffer++ ) = *( buffer++ );
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
j = length - end_length;
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD>࣬<EFBFBD><E0A3AC><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>FIFO<46><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>*/
|
||||
if ( j > 0 )
|
||||
{
|
||||
fifo_buffer = fifo->buffer;
|
||||
|
||||
for( i = 0; i < j; i++ )
|
||||
{
|
||||
*( fifo_buffer++ ) = *( buffer++ );
|
||||
}
|
||||
}
|
||||
|
||||
/* <20><>¼<EFBFBD>ѽ<EFBFBD><D1BD><EFBFBD>FIFO<46>ij<EFBFBD><C4B3><EFBFBD> */
|
||||
fifo->in += length;
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FIFO<46><4F><EFBFBD>ݵij<DDB5><C4B3><EFBFBD>С<EFBFBD><D0A1><EFBFBD>û<EFBFBD>ʵ<EFBFBD><CAB5>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ݵij<DDB5><C4B3>ȣ<EFBFBD><C8A3>Ǿ<EFBFBD><C7BE><EFBFBD>FIFO<46><4F><EFBFBD><EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if( length < org_length )
|
||||
{
|
||||
return FIFO_ERROR_FULL;
|
||||
}
|
||||
|
||||
return FIFO_OK;
|
||||
}
|
||||
|
||||
fifo_error_t fifo_read( fifo_t *fifo, uint8_t *buffer, uint32_t length )
|
||||
{
|
||||
uint32_t i, j;
|
||||
uint32_t end_length, org_length;
|
||||
uint8_t *fifo_buffer;
|
||||
|
||||
/* <20><>¼ԭʼ<D4AD>û<EFBFBD><C3BB><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD> */
|
||||
org_length = length;
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>FIFO<46><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD> */
|
||||
length = MIN( length, fifo->in - fifo->out );
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>FIFOĩβ<C4A9><CEB2><EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD> */
|
||||
end_length = MIN( length, fifo->size - ( fifo->out & ( fifo->size - 1 ) ) );
|
||||
|
||||
/* <20>ҵ<EFBFBD>FIFOĩβ<C4A9><CEB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ */
|
||||
fifo_buffer = fifo->buffer + ( fifo->out & ( fifo->size - 1 ) );
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>FIFOĩβ<C4A9><CEB2><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3>ӣ<EFBFBD><D3A3><EFBFBD><EFBFBD><EFBFBD>FIFO<46>ڸ<EFBFBD><DAB8>Ƹ<EFBFBD><C6B8>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD> */
|
||||
for( i = 0; i < end_length; i++ )
|
||||
{
|
||||
*( buffer++ ) = *( fifo_buffer++ );
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
j = length - end_length;
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD>࣬<EFBFBD><E0A3AC><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>FIFO<46><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>*/
|
||||
if ( j > 0 )
|
||||
{
|
||||
fifo_buffer = fifo->buffer;
|
||||
|
||||
for( i = 0; i < j; i++ )
|
||||
{
|
||||
*( buffer++ ) = *( fifo_buffer++ ) ;
|
||||
}
|
||||
}
|
||||
|
||||
/* <20><>¼<EFBFBD>ѳ<EFBFBD><D1B3>ӵij<D3B5><C4B3><EFBFBD> */
|
||||
fifo->out += length;
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>FIFO<46><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>С<EFBFBD><D0A1><EFBFBD>û<EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>ݵij<DDB5><C4B3>ȣ<EFBFBD><C8A3>Ǿ<EFBFBD><C7BE><EFBFBD>FIFO<46><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if( length < org_length )
|
||||
{
|
||||
return FIFO_ERROR_EMPTY;
|
||||
}
|
||||
|
||||
return FIFO_OK;
|
||||
}
|
||||
|
||||
fifo_error_t fifo_get_length( fifo_t *fifo , uint32_t *length)
|
||||
{
|
||||
if( (fifo==0) || (length==0) )
|
||||
{
|
||||
return FIFO_ERROR_NULL;
|
||||
}
|
||||
|
||||
*length = fifo->in - fifo->out;
|
||||
|
||||
return FIFO_OK;
|
||||
}
|
||||
|
||||
fifo_error_t fifo_get_remain_length( fifo_t *fifo , uint32_t *length)
|
||||
{
|
||||
if( (fifo==0) || (length==0) )
|
||||
{
|
||||
return FIFO_ERROR_NULL;
|
||||
}
|
||||
|
||||
*length = fifo->size - ( fifo->in - fifo->out );
|
||||
|
||||
return FIFO_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -56,9 +56,6 @@ void MX_GPIO_Init(void)
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOB, M1_Pin|LED_RX_Pin, GPIO_PIN_SET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(USB_CTRL_GPIO_Port, USB_CTRL_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pins : PAPin PAPin PAPin */
|
||||
GPIO_InitStruct.Pin = RESET_Pin|M0_Pin|LED_TX_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
@ -66,8 +63,8 @@ void MX_GPIO_Init(void)
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PBPin PBPin PBPin */
|
||||
GPIO_InitStruct.Pin = M1_Pin|USB_CTRL_Pin|LED_RX_Pin;
|
||||
/*Configure GPIO pins : PBPin PBPin */
|
||||
GPIO_InitStruct.Pin = M1_Pin|LED_RX_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
@ -79,25 +76,9 @@ void MX_GPIO_Init(void)
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
HAL_GPIO_Init(AUX_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PBPin PBPin PBPin */
|
||||
GPIO_InitStruct.Pin = KEY_UP_Pin|KEY_ENTER_Pin|KEY_DOWN_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 2 */
|
||||
void gpio_usb_ctrl_on(void)
|
||||
{
|
||||
HAL_GPIO_WritePin( USB_CTRL_GPIO_Port , USB_CTRL_Pin , GPIO_PIN_SET );
|
||||
}
|
||||
|
||||
void gpio_usb_ctrl_off(void)
|
||||
{
|
||||
HAL_GPIO_WritePin( USB_CTRL_GPIO_Port , USB_CTRL_Pin , GPIO_PIN_RESET );
|
||||
}
|
||||
|
||||
void gpio_led_tx_on(void)
|
||||
{
|
||||
HAL_GPIO_WritePin( LED_TX_GPIO_Port, LED_TX_Pin, GPIO_PIN_RESET);
|
||||
|
||||
114
Core/Src/i2c.c
114
Core/Src/i2c.c
@ -1,114 +0,0 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file i2c.c
|
||||
* @brief This file provides code for the configuration
|
||||
* of the I2C instances.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2024 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "i2c.h"
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
I2C_HandleTypeDef hi2c2;
|
||||
|
||||
/* I2C2 init function */
|
||||
void MX_I2C2_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN I2C2_Init 0 */
|
||||
|
||||
/* USER CODE END I2C2_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN I2C2_Init 1 */
|
||||
|
||||
/* USER CODE END I2C2_Init 1 */
|
||||
hi2c2.Instance = I2C2;
|
||||
hi2c2.Init.ClockSpeed = 400000;
|
||||
hi2c2.Init.DutyCycle = I2C_DUTYCYCLE_2;
|
||||
hi2c2.Init.OwnAddress1 = 0;
|
||||
hi2c2.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
|
||||
hi2c2.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
|
||||
hi2c2.Init.OwnAddress2 = 0;
|
||||
hi2c2.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
|
||||
hi2c2.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
|
||||
if (HAL_I2C_Init(&hi2c2) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN I2C2_Init 2 */
|
||||
|
||||
/* USER CODE END I2C2_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
void HAL_I2C_MspInit(I2C_HandleTypeDef* i2cHandle)
|
||||
{
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
if(i2cHandle->Instance==I2C2)
|
||||
{
|
||||
/* USER CODE BEGIN I2C2_MspInit 0 */
|
||||
|
||||
/* USER CODE END I2C2_MspInit 0 */
|
||||
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
/**I2C2 GPIO Configuration
|
||||
PB10 ------> I2C2_SCL
|
||||
PB11 ------> I2C2_SDA
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/* I2C2 clock enable */
|
||||
__HAL_RCC_I2C2_CLK_ENABLE();
|
||||
/* USER CODE BEGIN I2C2_MspInit 1 */
|
||||
|
||||
/* USER CODE END I2C2_MspInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_I2C_MspDeInit(I2C_HandleTypeDef* i2cHandle)
|
||||
{
|
||||
|
||||
if(i2cHandle->Instance==I2C2)
|
||||
{
|
||||
/* USER CODE BEGIN I2C2_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END I2C2_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_I2C2_CLK_DISABLE();
|
||||
|
||||
/**I2C2 GPIO Configuration
|
||||
PB10 ------> I2C2_SCL
|
||||
PB11 ------> I2C2_SDA
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10);
|
||||
|
||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_11);
|
||||
|
||||
/* USER CODE BEGIN I2C2_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END I2C2_MspDeInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
122
Core/Src/key.c
122
Core/Src/key.c
@ -1,122 +0,0 @@
|
||||
#include "main.h"
|
||||
|
||||
#define KEY_SHORT_PRESS_TIME_MS 100
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t count ;
|
||||
bool continue_enable;
|
||||
bool is_press;
|
||||
bool is_continue;
|
||||
}key_config_t;
|
||||
|
||||
static key_config_t key_group[3] =
|
||||
{
|
||||
[ KEY_NAME_UP ] = {
|
||||
.count = 0,
|
||||
.is_press = 0,
|
||||
.continue_enable = false,
|
||||
.is_continue = false,
|
||||
},
|
||||
|
||||
[ KEY_NAME_DOWN ] = {
|
||||
.count = 0,
|
||||
.is_press = 0,
|
||||
.continue_enable = false,
|
||||
.is_continue = false,
|
||||
},
|
||||
|
||||
[ KEY_NAME_ENTER ] = {
|
||||
.count = 0,
|
||||
.is_press = 0,
|
||||
.continue_enable = false,
|
||||
.is_continue = false,
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
bool key_check_press( key_name_t name )
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
/* <20>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ״̬ */
|
||||
ret = key_group[name].is_press;
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>flash<73><68><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD>δ<EFBFBD><CEB4><EFBFBD> */
|
||||
key_group[name].is_press = false;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void key_set_continue( key_name_t name , bool enable )
|
||||
{
|
||||
key_group[name].continue_enable = enable;
|
||||
}
|
||||
|
||||
static inline void key_press( key_name_t name )
|
||||
{
|
||||
key_group[name].count ++;
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD>̰<EFBFBD><CCB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ʱ<EFBFBD><CAB1> */
|
||||
if( key_group[name].count > KEY_SHORT_PRESS_TIME_MS )
|
||||
{
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD> */
|
||||
if( key_group[name].continue_enable == false )
|
||||
{
|
||||
/* <20><><EFBFBD>ڵ<EFBFBD>һ<EFBFBD>ζ̰<CEB6><CCB0>´<EFBFBD><C2B4><EFBFBD><EFBFBD>ж<EFBFBD> */
|
||||
if( key_group[name].is_continue == false )
|
||||
{
|
||||
/* <20><>ֹ<EFBFBD>´δ<C2B4><CEB4><EFBFBD> ֱ<><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD> <20><><EFBFBD><EFBFBD>false*/
|
||||
key_group[name].is_continue = true;
|
||||
/* <20><>һ<EFBFBD>θ<EFBFBD><CEB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>±<EFBFBD>ʶ */
|
||||
key_group[name].is_press = true;
|
||||
}
|
||||
}
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD> */
|
||||
else
|
||||
{
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>±<EFBFBD>ʶ */
|
||||
key_group[name].is_press = true;
|
||||
/* <20><><EFBFBD>¼<EFBFBD>ʱ */
|
||||
key_group[name].count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void key_release( key_name_t name )
|
||||
{
|
||||
key_group[ name ].count = 0;
|
||||
key_group[ name ].is_continue = false;
|
||||
}
|
||||
|
||||
|
||||
void key_timer_1ms_interrupt_callback(void)
|
||||
{
|
||||
if( HAL_GPIO_ReadPin( KEY_UP_GPIO_Port, KEY_UP_Pin ) == RESET )
|
||||
{
|
||||
key_press( KEY_NAME_UP );
|
||||
}
|
||||
else
|
||||
{
|
||||
key_release( KEY_NAME_UP );
|
||||
}
|
||||
|
||||
if( HAL_GPIO_ReadPin( KEY_DOWN_GPIO_Port, KEY_DOWN_Pin ) == RESET )
|
||||
{
|
||||
key_press( KEY_NAME_DOWN );
|
||||
}
|
||||
else
|
||||
{
|
||||
key_release( KEY_NAME_DOWN );
|
||||
}
|
||||
|
||||
if( HAL_GPIO_ReadPin( KEY_ENTER_GPIO_Port, KEY_ENTER_Pin ) == RESET )
|
||||
{
|
||||
key_press( KEY_NAME_ENTER );
|
||||
}
|
||||
else
|
||||
{
|
||||
key_release( KEY_NAME_ENTER );
|
||||
}
|
||||
|
||||
}
|
||||
@ -20,13 +20,13 @@
|
||||
#include "main.h"
|
||||
#include "tim.h"
|
||||
#include "usart.h"
|
||||
#include "usb_device.h"
|
||||
#include "gpio.h"
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include "rf433.h"
|
||||
#include "rf433_config.h"
|
||||
#include "rf433_hal.h"
|
||||
|
||||
#if (RF433_MODE == RF433_MODE_TX) || (RF433_MODE == RF433_MODE_BOTH)
|
||||
#include "rf433_tx_app.h"
|
||||
@ -45,8 +45,6 @@
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PD */
|
||||
#include "usbd_cdc_if.h"
|
||||
extern uint8_t usb_rx_data;
|
||||
/* USER CODE END PD */
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
@ -97,15 +95,14 @@ int main(void)
|
||||
/* Initialize all configured peripherals */
|
||||
MX_GPIO_Init();
|
||||
MX_USART1_UART_Init();
|
||||
MX_USB_DEVICE_Init();
|
||||
MX_TIM2_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
/* 初始化RF433模块 - 使用默认配置 */
|
||||
rf433_init(NULL);
|
||||
|
||||
/* 启动UART接收 */
|
||||
HAL_UART_Receive_IT(&huart1, &usb_rx_data, 1);
|
||||
/* 初始化RF433模块 - 使用默认配置 */
|
||||
rf433_init(NULL);
|
||||
|
||||
/* 启动UART接收 - 使用rf433_hal中的临时变量 */
|
||||
HAL_UART_Receive_IT(&huart1, &rf433_uart_rx_tmp, 1);
|
||||
|
||||
/* 根据配置模式初始化TX/RX应用层 */
|
||||
#if (RF433_MODE == RF433_MODE_TX) || (RF433_MODE == RF433_MODE_BOTH)
|
||||
|
||||
@ -55,7 +55,6 @@
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
extern PCD_HandleTypeDef hpcd_USB_FS;
|
||||
extern UART_HandleTypeDef huart1;
|
||||
/* USER CODE BEGIN EV */
|
||||
/* USER CODE END EV */
|
||||
@ -183,7 +182,6 @@ void PendSV_Handler(void)
|
||||
void SysTick_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN SysTick_IRQn 0 */
|
||||
key_timer_1ms_interrupt_callback();
|
||||
systick_interrupt_1ms_callback();
|
||||
/* USER CODE END SysTick_IRQn 0 */
|
||||
HAL_IncTick();
|
||||
@ -199,20 +197,6 @@ void SysTick_Handler(void)
|
||||
/* please refer to the startup file (startup_stm32f1xx.s). */
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief This function handles USB low priority or CAN RX0 interrupts.
|
||||
*/
|
||||
void USB_LP_CAN1_RX0_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN USB_LP_CAN1_RX0_IRQn 0 */
|
||||
|
||||
/* USER CODE END USB_LP_CAN1_RX0_IRQn 0 */
|
||||
HAL_PCD_IRQHandler(&hpcd_USB_FS);
|
||||
/* USER CODE BEGIN USB_LP_CAN1_RX0_IRQn 1 */
|
||||
|
||||
/* USER CODE END USB_LP_CAN1_RX0_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles USART1 global interrupt.
|
||||
*/
|
||||
|
||||
@ -89,24 +89,12 @@ void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* tim_pwmHandle)
|
||||
void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle)
|
||||
{
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
if(timHandle->Instance==TIM2)
|
||||
{
|
||||
/* USER CODE BEGIN TIM2_MspPostInit 0 */
|
||||
|
||||
/* USER CODE END TIM2_MspPostInit 0 */
|
||||
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
/**TIM2 GPIO Configuration
|
||||
PB3 ------> TIM2_CH2
|
||||
*/
|
||||
GPIO_InitStruct.Pin = BUZZER_PWM_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(BUZZER_PWM_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
__HAL_AFIO_REMAP_TIM2_PARTIAL_1();
|
||||
|
||||
/* USER CODE BEGIN TIM2_MspPostInit 1 */
|
||||
|
||||
/* USER CODE END TIM2_MspPostInit 1 */
|
||||
@ -131,20 +119,4 @@ void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* tim_pwmHandle)
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
void buzzer_on(void)
|
||||
{
|
||||
HAL_TIM_PWM_Start( &htim2 , TIM_CHANNEL_2 );
|
||||
}
|
||||
|
||||
void buzzer_off(void)
|
||||
{
|
||||
HAL_TIM_PWM_Stop( &htim2 , TIM_CHANNEL_2 );
|
||||
}
|
||||
|
||||
void buzzer_button_press(void)
|
||||
{
|
||||
buzzer_on();
|
||||
HAL_Delay(50);
|
||||
buzzer_off();
|
||||
}
|
||||
/* USER CODE END 1 */
|
||||
|
||||
@ -1,121 +0,0 @@
|
||||
#include "u8g2_hal.h"
|
||||
#include "menuConfig.h"
|
||||
#include "i2c.h"
|
||||
|
||||
|
||||
#define HARDWARE_I2C
|
||||
#define OLED_I2C_DEV_ADDRESS 0x78
|
||||
|
||||
|
||||
#ifdef HARDWARE_I2C
|
||||
static uint8_t u8x8_byte_hw_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) {
|
||||
uint8_t* data = (uint8_t*) arg_ptr;
|
||||
switch(msg) {
|
||||
case U8X8_MSG_BYTE_SEND:
|
||||
while( arg_int-- > 0 ) {
|
||||
|
||||
///@todo <20><EFBFBD>
|
||||
/* ==================================== */
|
||||
I2C2->DR = *data++;
|
||||
while( __HAL_I2C_GET_FLAG(&hi2c2, I2C_FLAG_TXE) == RESET );
|
||||
/* ==================================== */
|
||||
}
|
||||
break;
|
||||
case U8X8_MSG_BYTE_INIT:
|
||||
/* add your custom code to init i2c subsystem */
|
||||
break;
|
||||
case U8X8_MSG_BYTE_SET_DC:
|
||||
/* ignored for i2c */
|
||||
break;
|
||||
case U8X8_MSG_BYTE_START_TRANSFER:
|
||||
|
||||
///@todo <20><EFBFBD>
|
||||
/* ==================================== */
|
||||
/* Wait until BUSY flag is reset */
|
||||
while( __HAL_I2C_GET_FLAG( &hi2c2, I2C_FLAG_BUSY ) == SET );
|
||||
/* Disable Pos */
|
||||
CLEAR_BIT( I2C2->CR1, I2C_CR1_POS );
|
||||
/* Generate Start */
|
||||
SET_BIT( I2C2->CR1, I2C_CR1_START );
|
||||
/* Wait until SB flag is set */
|
||||
while( __HAL_I2C_GET_FLAG( &hi2c2, I2C_FLAG_SB ) == RESET );
|
||||
/* Send slave address */
|
||||
I2C2->DR = I2C_7BIT_ADD_WRITE( OLED_I2C_DEV_ADDRESS );
|
||||
/* Wait until ADDR flag is set */
|
||||
while ( __HAL_I2C_GET_FLAG( &hi2c2, I2C_FLAG_ADDR) == RESET );
|
||||
/* Clear ADDR flag */
|
||||
__HAL_I2C_CLEAR_ADDRFLAG( &hi2c2 );
|
||||
/* Wait until TXE flag is set */
|
||||
while( __HAL_I2C_GET_FLAG(&hi2c2, I2C_FLAG_TXE) == RESET );
|
||||
/* ==================================== */
|
||||
|
||||
break;
|
||||
case U8X8_MSG_BYTE_END_TRANSFER:
|
||||
|
||||
///@todo <20><EFBFBD>
|
||||
/* ==================================== */
|
||||
/* Generate Stop */
|
||||
SET_BIT( I2C2->CR1, I2C_CR1_STOP );
|
||||
/* ==================================== */
|
||||
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
static uint8_t u8x8_gpio_and_delay_hw(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) {
|
||||
switch (msg) {
|
||||
case U8X8_MSG_DELAY_100NANO: // delay arg_int * 100 nano seconds
|
||||
break;
|
||||
case U8X8_MSG_DELAY_10MICRO: // delay arg_int * 10 micro seconds
|
||||
break;
|
||||
case U8X8_MSG_DELAY_MILLI: // delay arg_int * 1 milli second
|
||||
HAL_Delay(1);
|
||||
break;
|
||||
case U8X8_MSG_DELAY_I2C: // arg_int is the I2C speed in 100KHz, e.g. 4 = 400 KHz
|
||||
break; // arg_int=1: delay by 5us, arg_int = 4: delay by 1.25us
|
||||
case U8X8_MSG_GPIO_I2C_CLOCK: // arg_int=0: Output low at I2C clock pin
|
||||
break; // arg_int=1: Input dir with pullup high for I2C clock pin
|
||||
case U8X8_MSG_GPIO_I2C_DATA: // arg_int=0: Output low at I2C data pin
|
||||
break; // arg_int=1: Input dir with pullup high for I2C data pin
|
||||
case U8X8_MSG_GPIO_MENU_SELECT:
|
||||
u8x8_SetGPIOResult(u8x8, /* get menu select pin state */ 0);
|
||||
break;
|
||||
case U8X8_MSG_GPIO_MENU_NEXT:
|
||||
u8x8_SetGPIOResult(u8x8, /* get menu next pin state */ 0);
|
||||
break;
|
||||
case U8X8_MSG_GPIO_MENU_PREV:
|
||||
u8x8_SetGPIOResult(u8x8, /* get menu prev pin state */ 0);
|
||||
break;
|
||||
case U8X8_MSG_GPIO_MENU_HOME:
|
||||
u8x8_SetGPIOResult(u8x8, /* get menu home pin state */ 0);
|
||||
break;
|
||||
default:
|
||||
u8x8_SetGPIOResult(u8x8, 1); // default return value
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
//static void HardWare_I2C2_GPIOInit(void)
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void u8g2Init(u8g2_t *u8g2)
|
||||
{
|
||||
|
||||
#ifdef HARDWARE_I2C
|
||||
// HardWare_I2C2_GPIOInit();//<2F><><EFBFBD><EFBFBD>i2c.c<><63><EFBFBD><EFBFBD><EFBFBD>ɳ<EFBFBD>ʼ<EFBFBD><CABC>
|
||||
u8g2_Setup_ssd1306_i2c_128x64_noname_f(u8g2, U8G2_R0, u8x8_byte_hw_i2c, u8x8_gpio_and_delay_hw);
|
||||
#endif
|
||||
|
||||
u8g2_InitDisplay(u8g2);
|
||||
u8g2_SetPowerSave(u8g2, 0);
|
||||
u8g2_ClearBuffer(u8g2);
|
||||
}
|
||||
@ -22,11 +22,7 @@
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
#include <stdbool.h>
|
||||
#include "usbd_cdc_if.h"
|
||||
#include "rf433_hal.h"
|
||||
|
||||
uint8_t usb_rx_data;
|
||||
uart_feature current_feature = FUNC_FEATURE1;
|
||||
/* USER CODE END 0 */
|
||||
|
||||
UART_HandleTypeDef huart1;
|
||||
@ -149,16 +145,5 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
|
||||
}
|
||||
}
|
||||
|
||||
void usb_receive_to_tx_send( void )
|
||||
{
|
||||
HAL_Delay(1);
|
||||
if(usb_rx_complete)
|
||||
{
|
||||
HAL_UART_Transmit(&huart1,my_usb_rx_data, my_usb_rx_num ,500);
|
||||
memset(my_usb_rx_data, 0, my_usb_rx_num);
|
||||
my_usb_rx_num = 0;
|
||||
usb_rx_complete = 0;
|
||||
}
|
||||
}
|
||||
/* USER CODE END 1 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user