不含stm32 底层的代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
MyStm32Code/device/Inc/temperature.h

165 lines
3.7 KiB

/*
加入队列 处理
*/
#ifndef __TEMPERATURE_H
#define __TEMPERATURE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "FreeRTOS.h"
#include "task.h"
#include "main.h"
#include "cmsis_os.h"
#include "usart.h"
#include "elog.h"
#include <string.h>
#include "bsp_uart.h"
#define TEMP_USE_MAX485 0
#define TEMP_USE_MAX3160_232 0
#define TEMP_USE_MAX3160_485 1
#define TEMP_Rcv_Buf_Size 9
#define TEMP_Command_Number 1
static void TEMP_MAX3160_232(void)
{
HAL_GPIO_WritePin(SEL_232_485_GPIO_Port,SEL_232_485_Pin, RESET);
HAL_GPIO_WritePin(HDPLX_GPIO_Port,HDPLX_Pin, RESET);
}
typedef enum
{
TEMP_Event_Ready ,
TEMP_Event_Test,
TEMP_Event_Test_OK ,
TEMP_Event_Get_Data,
TEMP_Event_Check_Data ,
} Module_TEMP_Event_TypeDef;
typedef enum
{
TEMP_State_Waiting ,
TEMP_State_Test ,
TEMP_State_Test_Start ,
TEMP_State_Testing ,
TEMP_State_Test_OK ,
TEMP_State_Ready ,
TEMP_State_Get_DATA ,
TEMP_State_Get_DATA_Wait ,
TEMP_State_Get_DATA_OK,
TEMP_State_Get_DATA_Check ,
TEMP_State_Stop ,
TEMP_State_Timeout ,
TEMP_State_Error ,
} Module_TEMP_State_TypeDef;
extern UART_HELPER_TypeDef *temp_uart_helper;
typedef struct
{
int (*init)(void);
void (*port)(void);
int (*test)(void);
void (*start)(void);
void (*stop)(void);
osMessageQueueId_t transQueue; // 队列可选
volatile Module_TEMP_State_TypeDef state;
uint8_t data_ok; /* 接收数据完整可以处理 */
uint8_t result_buf[1024];
uint8_t size_received;
uint64_t timebase_ticks;
uint64_t timeout_ticks;
uint8_t event_flag;
Record_Trans_Rcv_TypeDef transRecord[3];
// uint64_t timebase;
// uint16_t timeout_ms;
// volatile uint8_t send_flag; /* 发送标志位 */
// Uart_Status_TypeDef send_status; /* 发送状态 1:正在发送 busy,0:发送ok,*/
// Uart_Status_TypeDef status; /* 发送状态 1:正在发送 busy,0:发送ok,*/
// uint8_t command_seq ; /* 命令序号 */
// uint8_t mode; /* 0 : normal , 1 : get wavelength , 2 : get sn */
// uint8_t vipersn_buf[15];
// uint8_t TEMP_Wavelength_Buf[2][ TEMP_Rcv_Buf_Size ];
// uint8_t TEMP_Data_Buf[2][ TEMP_Rcv_Buf_Size ];
}TEMP_TypeDef;
extern TEMP_TypeDef temp ;
int TEMP_Init( void );
void TEMP_Task( void);
void TEMP_Port( void);
int TEMP_Test( );
void TEMP_Start( );
void TEMP_Stop( );
void TEMP_Set_Sendbuf( uint8_t * buf, uint16_t size );
void TEMP_Set_Rcvbuf( uint8_t * buf, uint16_t size );
void TEMP_Set_Timeout_ms( uint64_t ms_ticks );
int TEMP_Validate( );
int TEMP_Transmit();
int TEMP_Receive();
void TEMP_Trans_GPIO(void) ;
void TEMP_Trans_Cplt_GPIO(void) ;
int TEMP_CallBack( TEMP_TypeDef *pPH, uint8_t *buf, uint16_t size );
#ifdef __cplusplus
}
#endif
#endif
/*
temp.init();
temp.port();
temp.test();
uint64_t ticks = osKernelGetTickCount();
while ( temp.state != PH_State_Ready )
{
if ( ( osKernelGetTickCount() -ticks) > 3000 )
{
log_e(" pH test error.... ") ;
break;
}
}
log_w(" pH test ok.... ") ;
// osMessageQueueId_t TestQQueueueueHandle;
// osMessageQueueId_t osMessageQueueNew (uint32_t msg_count, uint32_t msg_size, const osMessageQueueAttr_t *attr);
// osMessageQueueGet(TestQueueHandle,osWaitForever);
// osStatus_t osMessageQueueGet ( osMessageQueueId_t mq_id,
// void * msg_ptr, //储存读取结果的变量地址
// uint8_t * msg_prio, // ==NULL
// uint32_t timeout //阻塞超时时间
// );
// osStatus_t osMessageQueuePut ( osMessageQueueId_t mq_id,
// const void * msg_ptr, //储存写入内容的变量地址
// uint8_t msg_prio, //==0U
// uint32_t timeout //阻塞超时时间
// );
*/