提交全部资料
This commit is contained in:
39
1.主程序源代码/User/inc/bsp_bat.h
Normal file
39
1.主程序源代码/User/inc/bsp_bat.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* @Date: 2025-06-26 09:38:45
|
||||
* @LastEditors: 路怀帅
|
||||
* @LastEditTime: 2025-07-05 11:31:57
|
||||
* @FilePath: \RVMDK(uv5)e:\个人项目\零距电子\安灯遥控器\Andon_Remote_Control\Andon_RTOS\User\inc\bsp_bat.h
|
||||
*/
|
||||
#ifndef __BAT_H
|
||||
#define __BAT_H
|
||||
|
||||
#include "main.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void (*Init)(void);
|
||||
uint8_t (*Read_State)(void);
|
||||
} BATClassStruct;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BAT_Charging = 0, // 电池充电中
|
||||
BAT_Full, // 电池充满
|
||||
BAT_Low, // 电池低电量
|
||||
BAT_Hight // 电池高电量
|
||||
|
||||
} BAT_State_Enum;
|
||||
|
||||
extern BATClassStruct BATClass;
|
||||
void Power_button_init(void);
|
||||
uint8_t Check_Power_buttun(void);
|
||||
|
||||
|
||||
typedef struct {
|
||||
void (* Init)(void);
|
||||
uint16_t (* GetValue)(uint8_t ADC_channelx);
|
||||
} ADC1ClassStruct;
|
||||
|
||||
extern ADC1ClassStruct ADC1Class;
|
||||
|
||||
#endif
|
||||
18
1.主程序源代码/User/inc/bsp_button.h
Normal file
18
1.主程序源代码/User/inc/bsp_button.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef __BUTTON_H__
|
||||
#define __BUTTON_H__
|
||||
|
||||
#include "stdint.h"
|
||||
#include "string.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
void user_button_init(void);
|
||||
extern uint8_t isLEDTog;
|
||||
extern uint8_t isSend;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __FLEXIBLE_BUTTON_H__ */
|
||||
10
1.主程序源代码/User/inc/bsp_chipid.h
Normal file
10
1.主程序源代码/User/inc/bsp_chipid.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef __CHIPID_H
|
||||
#define __CHIPID_H
|
||||
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
void Get_ChipID(void);
|
||||
void WDOG_Init(void);
|
||||
|
||||
#endif /* __CHIPID_H */
|
||||
69
1.主程序源代码/User/inc/bsp_led.h
Normal file
69
1.主程序源代码/User/inc/bsp_led.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* @Date: 2025-06-26 09:38:45
|
||||
* @LastEditors: 路怀帅
|
||||
* @LastEditTime: 2025-06-26 14:37:29
|
||||
* @FilePath: \Andon_Remote_Control\MDK_PROJECT\Drive\Led.h
|
||||
*/
|
||||
#ifndef __LED_H
|
||||
#define __LED_H
|
||||
|
||||
#include "main.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void (*Init)(void);
|
||||
void (*Set)(volatile uint8_t led_x);
|
||||
void (*GREEN_Toggle)(void);
|
||||
void (*RED_Toggle)(void);
|
||||
void (*BLUE_Toggle)(void);
|
||||
void (*YELLOW_Toggle)(void);
|
||||
|
||||
} LEDClassStruct;
|
||||
|
||||
#define RED_ON GPIO_ResetBits(GPIOA, GPIO_Pin_6)
|
||||
#define RED_OFF GPIO_SetBits(GPIOA, GPIO_Pin_6)
|
||||
#define RED_TOG GPIOA->BSRR = ((GPIOA->ODR & GPIO_Pin_6) << 16) | (~GPIOA->ODR & GPIO_Pin_6)
|
||||
#define GREEN_ON GPIO_ResetBits(GPIOA, GPIO_Pin_7)
|
||||
#define GREEN_OFF GPIO_SetBits(GPIOA, GPIO_Pin_7)
|
||||
#define GREEN_TOG GPIOA->BSRR = ((GPIOA->ODR & GPIO_Pin_7) << 16) | (~GPIOA->ODR & GPIO_Pin_7)
|
||||
|
||||
#define BLUE_ON GPIO_ResetBits(GPIOB, GPIO_Pin_0)
|
||||
#define BLUE_OFF GPIO_SetBits(GPIOB, GPIO_Pin_0)
|
||||
#define BLUE_TOG GPIOA->BSRR = ((GPIOB->ODR & GPIO_Pin_0) << 16) | (~GPIOB->ODR & GPIO_Pin_0)
|
||||
|
||||
#define ASR_Power_ON GPIO_SetBits(GPIOB, GPIO_Pin_8)
|
||||
#define ASR_Power_OFF GPIO_ResetBits(GPIOB, GPIO_Pin_8)
|
||||
|
||||
#define BOARD_Power_ON GPIO_SetBits(GPIOA, GPIO_Pin_1)
|
||||
#define BOARD_Power_OFF GPIO_ResetBits(GPIOA, GPIO_Pin_1)
|
||||
|
||||
#define LED_ALL_ON RED_ON;GREEN_ON;BLUE_ON
|
||||
#define LED_ALL_OFF RED_OFF;GREEN_OFF;BLUE_OFF
|
||||
|
||||
typedef enum
|
||||
{
|
||||
None = 0,
|
||||
CHANGE_Ing, // 充电中
|
||||
CHANGE_Full, // 充满
|
||||
UNLOCK_HighBat, // 解锁高电量
|
||||
UNLOCK_LowBat, // 解锁低电量
|
||||
SEND_Success, // 发送成功
|
||||
SEND_Fail, // 发送失败
|
||||
} LED_State_Enum;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BLACK = 0,
|
||||
GREEN,
|
||||
RED,
|
||||
BLUE,
|
||||
YELLOW,
|
||||
WHITE
|
||||
} LED_Color_Enum;
|
||||
|
||||
void ledBlinkTask(void);
|
||||
extern LEDClassStruct LEDClass;
|
||||
void ASR_Power_Init(void);
|
||||
void BOARD_Power_Init(void);
|
||||
|
||||
#endif
|
||||
27
1.主程序源代码/User/inc/bsp_mod.h
Normal file
27
1.主程序源代码/User/inc/bsp_mod.h
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
#ifndef __MOD_H
|
||||
#define __MOD_H
|
||||
|
||||
#include "main.h"
|
||||
|
||||
typedef void (*ToggleFunc)(void);
|
||||
typedef void (*DelayFunc)(uint32_t);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void (*Loop)(ToggleFunc toggle, DelayFunc delayFunc, uint8_t iterations, uint32_t delayTime);
|
||||
} MODClassStruct;
|
||||
|
||||
typedef struct {
|
||||
const char *e_val;
|
||||
const char *t_val;
|
||||
const char *r_val;
|
||||
const char *c_val;
|
||||
} LoraCommandParams;
|
||||
|
||||
extern MODClassStruct MODClass;
|
||||
extern LoraCommandParams cmd_params[];
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
0
1.主程序源代码/User/inc/bsp_sleep.h
Normal file
0
1.主程序源代码/User/inc/bsp_sleep.h
Normal file
21
1.主程序源代码/User/inc/bsp_usart.h
Normal file
21
1.主程序源代码/User/inc/bsp_usart.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef __USART_AS_H
|
||||
#define __USART_AS_H
|
||||
|
||||
#include "main.h"
|
||||
|
||||
typedef struct {
|
||||
void (* USART1_Init)(uint32_t baudRate);
|
||||
void (* USART2_Init)(uint32_t baudRate);
|
||||
void (* USART3_Init)(uint32_t baudRate);
|
||||
void (* USART_SendString1)(USART_TypeDef *USARTx, uint8_t *str, uint16_t len);
|
||||
void (* USART_SendString2)(USART_TypeDef* USARTx, uint8_t *str);
|
||||
} USARTClassStruct;
|
||||
|
||||
void Usart_SendString( USART_TypeDef * pUSARTx, char *str);
|
||||
|
||||
extern USARTClassStruct USARTClass;
|
||||
extern uint8_t Asr_Power_state;
|
||||
|
||||
extern uint8_t g_asrRxFlag;
|
||||
extern uint8_t Asr_recbuff[];
|
||||
#endif
|
||||
38
1.主程序源代码/User/inc/delay.h
Normal file
38
1.主程序源代码/User/inc/delay.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef __DELAY_H
|
||||
#define __DELAY_H
|
||||
#include "stm32f10x.h"
|
||||
|
||||
void delay_init(void);
|
||||
void delay_ms(u16 nms);
|
||||
void delay_us(u32 nus);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
121
1.主程序源代码/User/inc/flexible_button.h
Normal file
121
1.主程序源代码/User/inc/flexible_button.h
Normal file
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
* @File: flexible_button.h
|
||||
* @Author: MurphyZhao
|
||||
* @Date: 2018-09-29
|
||||
*
|
||||
* Copyright (c) 2018-2019 MurphyZhao <d2014zjt@163.com>
|
||||
* https://github.com/murphyzhao
|
||||
* All rights reserved.
|
||||
* License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Change logs:
|
||||
* Date Author Notes
|
||||
* 2018-09-29 MurphyZhao First add
|
||||
* 2019-08-02 MurphyZhao 迁移代码到 murphyzhao 仓库
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __FLEXIBLE_BUTTON_H__
|
||||
#define __FLEXIBLE_BUTTON_H__
|
||||
|
||||
#include "stdint.h"
|
||||
#include "string.h"
|
||||
|
||||
typedef void (*flex_button_response_callback)(void *);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FLEX_BTN_PRESS_DOWN = 0,
|
||||
FLEX_BTN_PRESS_CLICK,
|
||||
FLEX_BTN_PRESS_DOUBLE_CLICK,
|
||||
FLEX_BTN_PRESS_SHORT_START,
|
||||
FLEX_BTN_PRESS_SHORT_UP,
|
||||
FLEX_BTN_PRESS_LONG_START,
|
||||
FLEX_BTN_PRESS_LONG_UP,
|
||||
FLEX_BTN_PRESS_LONG_HOLD,
|
||||
FLEX_BTN_PRESS_LONG_HOLD_UP,
|
||||
FLEX_BTN_PRESS_MAX,
|
||||
FLEX_BTN_PRESS_NONE,
|
||||
} flex_button_event_t;
|
||||
|
||||
/**
|
||||
* flex_button_t
|
||||
*
|
||||
* @brief Button data structure
|
||||
* Below are members that need to user init before scan.
|
||||
*
|
||||
* @member pressed_logic_level: Logic level when the button is pressed.
|
||||
* Must be inited by 'flex_button_register' API
|
||||
* before start button scan.
|
||||
* @member debounce_tick: The time of button debounce.
|
||||
* The value is number of button scan cycles.
|
||||
* @member click_start_tick: The time of start click.
|
||||
* The value is number of button scan cycles.
|
||||
* @member short_press_start_tick: The time of short press start tick.
|
||||
* The value is number of button scan cycles.
|
||||
* @member long_press_start_tick: The time of long press start tick.
|
||||
* The value is number of button scan cycles.
|
||||
* @member long_hold_start_tick: The time of hold press start tick.
|
||||
* The value is number of button scan cycles.
|
||||
* @member usr_button_read: Read the logic level value of specified button.
|
||||
* @member cb: Button event callback function.
|
||||
* If use 'flex_button_event_read' api,
|
||||
* you don't need to initialize the 'cb' member.
|
||||
* @member next : Next button struct
|
||||
*/
|
||||
typedef struct flex_button
|
||||
{
|
||||
uint8_t pressed_logic_level : 1; /* need user to init */
|
||||
|
||||
/**
|
||||
* @event
|
||||
* The event of button in flex_button_evnt_t enum list.
|
||||
* Automatically initialized to the default value FLEX_BTN_PRESS_NONE
|
||||
* by 'flex_button_register' API.
|
||||
*/
|
||||
uint8_t event : 4;
|
||||
|
||||
/**
|
||||
* @status
|
||||
* Used to record the status of the button
|
||||
* Automatically initialized to the default value 0.
|
||||
*/
|
||||
uint8_t status : 3;
|
||||
uint16_t scan_cnt; /* default 0. Used to record the number of key scans */
|
||||
uint16_t click_cnt; /* default 0. Used to record the number of key click */
|
||||
|
||||
uint16_t debounce_tick;
|
||||
uint16_t click_start_tick;
|
||||
uint16_t short_press_start_tick;
|
||||
uint16_t long_press_start_tick;
|
||||
uint16_t long_hold_start_tick;
|
||||
|
||||
uint8_t (*usr_button_read)(void);
|
||||
flex_button_response_callback cb;
|
||||
struct flex_button *next;
|
||||
} flex_button_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
int8_t flex_button_register(flex_button_t *button);
|
||||
flex_button_event_t flex_button_event_read(flex_button_t *button);
|
||||
void flex_button_scan(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __FLEXIBLE_BUTTON_H__ */
|
||||
Reference in New Issue
Block a user