add evb_mx_plus support
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
#include "bh1750.h"
|
||||
#include "stm32l4xx.h"
|
||||
#include "i2c.h"
|
||||
|
||||
|
||||
float result_lx;
|
||||
uint8_t BUF[2];
|
||||
int result;
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Init_BH1750
|
||||
* ˵ <20><>: д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>BH1750
|
||||
* <20><> <20><>: <20><>
|
||||
* <20><> <20><> ֵ: <20><>
|
||||
***************************************************************/
|
||||
void Init_BH1750(void)
|
||||
{
|
||||
uint8_t t_Data = 0x01;
|
||||
HAL_I2C_Master_Transmit(&hi2c1,BH1750_Addr,&t_Data,1,0xff);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Start_BH1750
|
||||
* ˵ <20><>: <20><><EFBFBD><EFBFBD>BH1750
|
||||
* <20><> <20><>: <20><>
|
||||
* <20><> <20><> ֵ: <20><>
|
||||
***************************************************************/
|
||||
void Start_BH1750(void)
|
||||
{
|
||||
uint8_t t_Data = 0x10;
|
||||
HAL_I2C_Master_Transmit(&hi2c1,BH1750_Addr,&t_Data,1,0xff);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Convert_BH1750
|
||||
* ˵ <20><>: <20><>ֵת<D6B5><D7AA>
|
||||
* <20><> <20><>: <20><>
|
||||
* <20><> <20><> ֵ: <20><>ǿֵ
|
||||
***************************************************************/
|
||||
float Convert_BH1750(void)
|
||||
{
|
||||
Start_BH1750();
|
||||
HAL_Delay(180);
|
||||
HAL_I2C_Master_Receive(&hi2c1, BH1750_Addr+1,BUF,2,0xff);
|
||||
result=BUF[0];
|
||||
result=(result<<8)+BUF[1]; //<2F>ϳ<EFBFBD><CFB3><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
result_lx=(float)(result/1.2);
|
||||
return result_lx;
|
||||
}
|
||||
|
@@ -0,0 +1,39 @@
|
||||
#ifndef __BH1750_H__
|
||||
#define __BH1750_H__
|
||||
/* <20><><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD> ----------------------------------------------------------------*/
|
||||
#include "stm32l4xx_hal.h"
|
||||
|
||||
/* <20><><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD> ------------------------------------------------------------------*/
|
||||
/* <20>궨<EFBFBD><EAB6A8> --------------------------------------------------------------------*/
|
||||
#define I2C_OWN_ADDRESS 0x0A
|
||||
|
||||
#define BH1750_Addr 0x46
|
||||
#define BH1750_ON 0x01
|
||||
#define BH1750_CON 0x10
|
||||
#define BH1750_ONE 0x20
|
||||
#define BH1750_RSET 0x07
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: BH1750_Data_TypeDef
|
||||
* ˵ <20><>: BH1750<35>ṹ<EFBFBD><E1B9B9>
|
||||
* <20><> <20><>: <20><>
|
||||
* <20><> <20><> ֵ: <20><>
|
||||
***************************************************************/
|
||||
typedef struct
|
||||
{
|
||||
char Lux[5]; //<2F><>ǿ
|
||||
}BH1750_Data_TypeDef;
|
||||
|
||||
|
||||
|
||||
void Init_BH1750(void); //IO<49><4F>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
|
||||
void Start_BH1750(void); //<2F>ϵ磬<CFB5><E7A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼĴ<DDBC><C4B4><EFBFBD>
|
||||
//void Read_BH1750(void); //<2F><><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD>ȡ<EFBFBD>ڲ<EFBFBD><DAB2>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
float Convert_BH1750(void);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
199
board/TencentOS_tiny_EVB_MX_Plus/BSP/Hardware/DHT11/DHT11_BUS.c
Normal file
199
board/TencentOS_tiny_EVB_MX_Plus/BSP/Hardware/DHT11/DHT11_BUS.c
Normal file
@@ -0,0 +1,199 @@
|
||||
/* <20><><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD> ----------------------------------------------------------------*/
|
||||
/* <20><><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD> ----------------------------------------------------------------*/
|
||||
#include "DHT11_BUS.h"
|
||||
|
||||
/* ˽<><CBBD><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD> --------------------------------------------------------------*/
|
||||
/* ˽<>к궨<D0BA><EAB6A8> ----------------------------------------------------------------*/
|
||||
#define Delay_ms(x) HAL_Delay(x)
|
||||
/* ˽<>б<EFBFBD><D0B1><EFBFBD> ------------------------------------------------------------------*/
|
||||
/* <20><>չ<EFBFBD><D5B9><EFBFBD><EFBFBD> ------------------------------------------------------------------*/
|
||||
/* ˽<>к<EFBFBD><D0BA><EFBFBD>ԭ<EFBFBD><D4AD> --------------------------------------------------------------*/
|
||||
static void DHT11_Mode_IPU(void);
|
||||
static void DHT11_Mode_Out_PP(void);
|
||||
static uint8_t DHT11_ReadByte(void);
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> --------------------------------------------------------------------*/
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
|
||||
* <20><> <20><> ֵ: <20><>
|
||||
* ˵ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
static void DHT11_Delay(uint16_t time)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
while(time)
|
||||
{
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
|
||||
}
|
||||
time--;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: DHT11 <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
|
||||
* <20><> <20><> ֵ: <20><>
|
||||
* ˵ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
void DHT11_Init ( void )
|
||||
{
|
||||
DHT11_Dout_GPIO_CLK_ENABLE();
|
||||
|
||||
DHT11_Mode_Out_PP();
|
||||
|
||||
DHT11_Dout_HIGH(); // <20><><EFBFBD><EFBFBD>GPIO
|
||||
}
|
||||
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: ʹDHT11-DATA<54><41><EFBFBD>ű<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
|
||||
* <20><> <20><> ֵ: <20><>
|
||||
* ˵ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
static void DHT11_Mode_IPU(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>蹦<EFBFBD><E8B9A6>GPIO<49><4F><EFBFBD><EFBFBD> */
|
||||
GPIO_InitStruct.Pin = DHT11_Dout_PIN;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
HAL_GPIO_Init(DHT11_Dout_PORT, &GPIO_InitStruct);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: ʹDHT11-DATA<54><41><EFBFBD>ű<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
|
||||
* <20><> <20><> ֵ: <20><>
|
||||
* ˵ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
static void DHT11_Mode_Out_PP(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>蹦<EFBFBD><E8B9A6>GPIO<49><4F><EFBFBD><EFBFBD> */
|
||||
GPIO_InitStruct.Pin = DHT11_Dout_PIN;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(DHT11_Dout_PORT, &GPIO_InitStruct);
|
||||
}
|
||||
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>DHT11<31><31>ȡһ<C8A1><D2BB><EFBFBD>ֽڣ<D6BD>MSB<53><42><EFBFBD><EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
|
||||
* <20><> <20><> ֵ: <20><>
|
||||
* ˵ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
static uint8_t DHT11_ReadByte ( void )
|
||||
{
|
||||
uint8_t i, temp=0;
|
||||
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
/*ÿbit<69><74>50us<75>͵<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD>ÿ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ѯֱ<D1AF><D6B1><EFBFBD>ӻ<EFBFBD><D3BB><EFBFBD><EFBFBD><EFBFBD> <20><>50us <20>͵<EFBFBD>ƽ <20><><EFBFBD><EFBFBD>*/
|
||||
while(DHT11_Data_IN()==GPIO_PIN_RESET);
|
||||
|
||||
/*DHT11 <20><>26~28us<75>ĸߵ<C4B8>ƽ<EFBFBD><C6BD>ʾ<EFBFBD><CABE>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>70us<75>ߵ<EFBFBD>ƽ<EFBFBD><C6BD>ʾ<EFBFBD><CABE>1<EFBFBD><31><EFBFBD><EFBFBD>
|
||||
*ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> x us<75><73><EFBFBD>ĵ<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״ <20><>x <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ
|
||||
*/
|
||||
DHT11_Delay(40); //<2F><>ʱx us <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>伴<EFBFBD><E4BCB4>
|
||||
|
||||
if(DHT11_Data_IN()==GPIO_PIN_SET)/* x us<75><73><EFBFBD><EFBFBD>Ϊ<EFBFBD>ߵ<EFBFBD>ƽ<EFBFBD><C6BD>ʾ<EFBFBD><CABE><EFBFBD>ݡ<EFBFBD>1<EFBFBD><31> */
|
||||
{
|
||||
/* <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD>ĸߵ<C4B8>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD> */
|
||||
while(DHT11_Data_IN()==GPIO_PIN_SET);
|
||||
|
||||
temp|=(uint8_t)(0x01<<(7-i)); //<2F>ѵ<EFBFBD>7-iλ<69><CEBB>1<EFBFBD><31>MSB<53><42><EFBFBD><EFBFBD>
|
||||
}
|
||||
else // x us<75><73>Ϊ<EFBFBD>͵<EFBFBD>ƽ<EFBFBD><C6BD>ʾ<EFBFBD><CABE><EFBFBD>ݡ<EFBFBD>0<EFBFBD><30>
|
||||
{
|
||||
temp&=(uint8_t)~(0x01<<(7-i)); //<2F>ѵ<EFBFBD>7-iλ<69><CEBB>0<EFBFBD><30>MSB<53><42><EFBFBD><EFBFBD>
|
||||
}
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>Ϊ40bit<69><74><EFBFBD><EFBFBD>λ<EFBFBD>ȳ<EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: DHT11_Data:DHT11<31><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <20><> <20><> ֵ: ERROR<4F><52> <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
||||
* SUCCESS<53><53><EFBFBD><EFBFBD>ȡ<EFBFBD>ɹ<EFBFBD>
|
||||
* ˵ <20><><EFBFBD><EFBFBD>8bit ʪ<><CAAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD> + 8bit ʪ<><CAAA>С<EFBFBD><D0A1> + 8bit <20>¶<EFBFBD><C2B6><EFBFBD><EFBFBD><EFBFBD> + 8bit <20>¶<EFBFBD>С<EFBFBD><D0A1> + 8bit У<><D0A3><EFBFBD><EFBFBD>
|
||||
*/
|
||||
uint8_t DHT11_Read_TempAndHumidity(DHT11_Data_TypeDef *DHT11_Data)
|
||||
{
|
||||
uint8_t temp;
|
||||
uint16_t humi_temp;
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD>ģʽ*/
|
||||
DHT11_Mode_Out_PP();
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
DHT11_Dout_LOW();
|
||||
/*<2A><>ʱ18ms*/
|
||||
Delay_ms(18);
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ30us*/
|
||||
DHT11_Dout_HIGH();
|
||||
|
||||
DHT11_Delay(30); //<2F><>ʱ30us
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD> <20>жϴӻ<CFB4><D3BB><EFBFBD>Ӧ<EFBFBD>ź<EFBFBD>*/
|
||||
DHT11_Mode_IPU();
|
||||
|
||||
/*<2A>жϴӻ<CFB4><D3BB>Ƿ<EFBFBD><C7B7>е͵<D0B5>ƽ<EFBFBD><C6BD>Ӧ<EFBFBD>ź<EFBFBD> <20>粻<EFBFBD><E7B2BB>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
if(DHT11_Data_IN()==GPIO_PIN_RESET)
|
||||
{
|
||||
/*<2A><>ѯֱ<D1AF><D6B1><EFBFBD>ӻ<EFBFBD><D3BB><EFBFBD><EFBFBD><EFBFBD> <20><>80us <20>͵<EFBFBD>ƽ <20><>Ӧ<EFBFBD>źŽ<C5BA><C5BD><EFBFBD>*/
|
||||
while(DHT11_Data_IN()==GPIO_PIN_RESET);
|
||||
|
||||
/*<2A><>ѯֱ<D1AF><D6B1><EFBFBD>ӻ<EFBFBD><D3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 80us <20>ߵ<EFBFBD>ƽ <20><><EFBFBD><EFBFBD><EFBFBD>źŽ<C5BA><C5BD><EFBFBD>*/
|
||||
while(DHT11_Data_IN()==GPIO_PIN_SET);
|
||||
|
||||
cpu_cpsr_t up = tos_cpu_cpsr_save();
|
||||
|
||||
/*<2A><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
DHT11_Data->humi_high8bit= DHT11_ReadByte();
|
||||
DHT11_Data->humi_low8bit = DHT11_ReadByte();
|
||||
DHT11_Data->temp_high8bit= DHT11_ReadByte();
|
||||
DHT11_Data->temp_low8bit = DHT11_ReadByte();
|
||||
DHT11_Data->check_sum = DHT11_ReadByte();
|
||||
|
||||
tos_cpu_cpsr_restore(up);
|
||||
|
||||
/*<2A><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ÿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>ģʽ*/
|
||||
DHT11_Mode_Out_PP();
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
DHT11_Dout_HIGH();
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD>ݽ<EFBFBD><DDBD>д<EFBFBD><D0B4><EFBFBD> */
|
||||
humi_temp=DHT11_Data->humi_high8bit*100+DHT11_Data->humi_low8bit;
|
||||
DHT11_Data->humidity =(float)humi_temp/100;
|
||||
|
||||
humi_temp=DHT11_Data->temp_high8bit*100+DHT11_Data->temp_low8bit;
|
||||
DHT11_Data->temperature=(float)humi_temp/100;
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ȷ*/
|
||||
temp = DHT11_Data->humi_high8bit + DHT11_Data->humi_low8bit +
|
||||
DHT11_Data->temp_high8bit+ DHT11_Data->temp_low8bit;
|
||||
|
||||
if(DHT11_Data->check_sum==temp)
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
else
|
||||
return ERROR;
|
||||
}
|
||||
else
|
||||
return ERROR;
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,50 @@
|
||||
#ifndef __ONEWIRE_DHT11_H__
|
||||
#define __ONEWIRE_DHT11_H__
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD> ----------------------------------------------------------------*/
|
||||
#include "stm32l4xx_hal.h"
|
||||
#include "mcu_init.h"
|
||||
/* <20><><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD> ------------------------------------------------------------------*/
|
||||
/************************ DHT11 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD>******************************/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t humi_high8bit; //ԭʼ<D4AD><CABC><EFBFBD>ݣ<EFBFBD>ʪ<EFBFBD>ȸ<EFBFBD>8λ
|
||||
uint8_t humi_low8bit; //ԭʼ<D4AD><CABC><EFBFBD>ݣ<EFBFBD>ʪ<EFBFBD>ȵ<EFBFBD>8λ
|
||||
uint8_t temp_high8bit; //ԭʼ<D4AD><CABC><EFBFBD>ݣ<EFBFBD><DDA3>¶ȸ<C2B6>8λ
|
||||
uint8_t temp_low8bit; //ԭʼ<D4AD><CABC><EFBFBD>ݣ<EFBFBD><DDA3>¶ȸ<C2B6>8λ
|
||||
uint8_t check_sum; //У<><D0A3><EFBFBD><EFBFBD>
|
||||
float humidity; //ʵ<><CAB5>ʪ<EFBFBD><CAAA>
|
||||
float temperature; //ʵ<><CAB5><EFBFBD>¶<EFBFBD>
|
||||
} DHT11_Data_TypeDef;
|
||||
|
||||
|
||||
/* <20>궨<EFBFBD><EAB6A8> -------------------------------------------------------------------*/
|
||||
/*********************** DHT11 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŷ<EFBFBD><C5B6><EFBFBD> **************************/
|
||||
#define DHT11_Dout_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
|
||||
#define DHT11_Dout_PORT GPIOA
|
||||
#define DHT11_Dout_PIN GPIO_PIN_6
|
||||
|
||||
/*********************** DHT11 <20><><EFBFBD><EFBFBD><EFBFBD>궨<EFBFBD><EAB6A8> ****************************/
|
||||
#define DHT11_Dout_LOW() HAL_GPIO_WritePin(DHT11_Dout_PORT,DHT11_Dout_PIN,GPIO_PIN_RESET)
|
||||
#define DHT11_Dout_HIGH() HAL_GPIO_WritePin(DHT11_Dout_PORT,DHT11_Dout_PIN,GPIO_PIN_SET)
|
||||
#define DHT11_Data_IN() HAL_GPIO_ReadPin(DHT11_Dout_PORT,DHT11_Dout_PIN)
|
||||
|
||||
/***************************************************************
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: DHT11_Msg_TypeDef
|
||||
* ˵ <20><>: DHT11<31>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵĽṹ<C4BD><E1B9B9>
|
||||
* <20><> <20><>: <20><>
|
||||
* <20><> <20><> ֵ: <20><>
|
||||
***************************************************************/
|
||||
typedef struct
|
||||
{
|
||||
char temp[4];
|
||||
char hum[4];
|
||||
}DHT11_Msg_TypeDef;
|
||||
|
||||
/* <20><>չ<EFBFBD><D5B9><EFBFBD><EFBFBD> ------------------------------------------------------------------*/
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ------------------------------------------------------------------*/
|
||||
void DHT11_Init( void );
|
||||
uint8_t DHT11_Read_TempAndHumidity(DHT11_Data_TypeDef * DHT11_Data);
|
||||
|
||||
#endif /* __ONEWIRE_DHT11_H__ */
|
||||
|
292
board/TencentOS_tiny_EVB_MX_Plus/BSP/Hardware/E53_IA1/E53_IA1.c
Normal file
292
board/TencentOS_tiny_EVB_MX_Plus/BSP/Hardware/E53_IA1/E53_IA1.c
Normal file
@@ -0,0 +1,292 @@
|
||||
#include "E53_IA1.h"
|
||||
#include "stm32l4xx.h"
|
||||
#include "i2c.h"
|
||||
#include "string.h"
|
||||
|
||||
const int16_t POLYNOMIAL = 0x131;
|
||||
E53_IA1_Data_TypeDef E53_IA1_Data;
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: Init_BH1750
|
||||
* 说 明: 写命令初始化BH1750
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void Init_BH1750(void)
|
||||
{
|
||||
uint8_t t_Data = 0x01;
|
||||
HAL_I2C_Master_Transmit(&hi2c1,BH1750_Addr,&t_Data,1,0xff);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: Start_BH1750
|
||||
* 说 明: 启动BH1750
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void Start_BH1750(void)
|
||||
{
|
||||
uint8_t t_Data = 0x10;
|
||||
HAL_I2C_Master_Transmit(&hi2c1,BH1750_Addr,&t_Data,1,0xff);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: Convert_BH1750
|
||||
* 说 明: 数值转换
|
||||
* 参 数: 无
|
||||
* 返 回 值: 光强值
|
||||
***************************************************************/
|
||||
float Convert_BH1750(void)
|
||||
{
|
||||
float result_lx;
|
||||
uint8_t BUF[2];
|
||||
int result;
|
||||
Start_BH1750();
|
||||
HAL_Delay(180);
|
||||
HAL_I2C_Master_Receive(&hi2c1, BH1750_Addr+1,BUF,2,0xff);
|
||||
result=BUF[0];
|
||||
result=(result<<8)+BUF[1]; //Synthetic Digital Illumination Intensity Data
|
||||
result_lx=(float)(result/1.2);
|
||||
return result_lx;
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: SHT30_reset
|
||||
* 说 明: SHT30复位
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void SHT30_reset(void)
|
||||
{
|
||||
uint8_t SHT3X_Resetcommand_Buffer[2]={0x30,0xA2}; //soft reset
|
||||
HAL_I2C_Master_Transmit(&hi2c1,SHT30_Addr<<1,SHT3X_Resetcommand_Buffer,2,0x10);
|
||||
HAL_Delay(15);
|
||||
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: Init_SHT30
|
||||
* 说 明: 初始化SHT30,设置测量周期
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void Init_SHT30(void)
|
||||
{
|
||||
uint8_t SHT3X_Modecommand_Buffer[2]={0x22,0x36}; //periodic mode commands
|
||||
HAL_I2C_Master_Transmit(&hi2c1,SHT30_Addr<<1,SHT3X_Modecommand_Buffer,2,0x10); //send periodic mode commands
|
||||
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: SHT3x_CheckCrc
|
||||
* 说 明: 检查数据正确性
|
||||
* 参 数: data:读取到的数据
|
||||
nbrOfBytes:需要校验的数量
|
||||
checksum:读取到的校对比验值
|
||||
* 返 回 值: 校验结果,0-成功 1-失败
|
||||
***************************************************************/
|
||||
uint8_t SHT3x_CheckCrc(char data[], char nbrOfBytes, char checksum)
|
||||
{
|
||||
|
||||
char crc = 0xFF;
|
||||
char bit = 0;
|
||||
unsigned char byteCtr;
|
||||
|
||||
//calculates 8-Bit checksum with given polynomial
|
||||
for(byteCtr = 0; byteCtr < nbrOfBytes; ++byteCtr)
|
||||
{
|
||||
crc ^= (data[byteCtr]);
|
||||
for ( bit = 8; bit > 0; --bit)
|
||||
{
|
||||
if (crc & 0x80) crc = (crc << 1) ^ POLYNOMIAL;
|
||||
else crc = (crc << 1);
|
||||
}
|
||||
}
|
||||
|
||||
if(crc != checksum)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: SHT3x_CalcTemperatureC
|
||||
* 说 明: 温度计算
|
||||
* 参 数: u16sT:读取到的温度原始数据
|
||||
* 返 回 值: 计算后的温度数据
|
||||
***************************************************************/
|
||||
float SHT3x_CalcTemperatureC(unsigned short u16sT)
|
||||
{
|
||||
|
||||
float temperatureC = 0; // variable for result
|
||||
|
||||
u16sT &= ~0x0003; // clear bits [1..0] (status bits)
|
||||
//-- calculate temperature [℃] --
|
||||
temperatureC = (175 * (float)u16sT / 65535 - 45); //T = -45 + 175 * rawValue / (2^16-1)
|
||||
|
||||
return temperatureC;
|
||||
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: SHT3x_CalcRH
|
||||
* 说 明: 湿度计算
|
||||
* 参 数: u16sRH:读取到的湿度原始数据
|
||||
* 返 回 值: 计算后的湿度数据
|
||||
***************************************************************/
|
||||
float SHT3x_CalcRH(unsigned short u16sRH)
|
||||
{
|
||||
|
||||
float humidityRH = 0; // variable for result
|
||||
|
||||
u16sRH &= ~0x0003; // clear bits [1..0] (status bits)
|
||||
//-- calculate relative humidity [%RH] --
|
||||
humidityRH = (100 * (float)u16sRH / 65535); // RH = rawValue / (2^16-1) * 10
|
||||
|
||||
return humidityRH;
|
||||
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: Init_Motor
|
||||
* 说 明: 初始化Init_E53_IA1的马达
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void Init_Motor(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
|
||||
/* GPIO Ports Clock Enable */
|
||||
IA1_Motor_GPIO_CLK_ENABLE();
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(IA1_Motor_GPIO_Port, IA1_Motor_Pin, GPIO_PIN_RESET);
|
||||
E53_IA1_Data.MotorMode=0;
|
||||
/*Configure GPIO pin : PtPin */
|
||||
GPIO_InitStruct.Pin = IA1_Motor_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(IA1_Motor_GPIO_Port, &GPIO_InitStruct);
|
||||
}
|
||||
|
||||
void motor_control(char mode){
|
||||
if(mode==1)
|
||||
{
|
||||
E53_IA1_Data.MotorMode=1;
|
||||
HAL_GPIO_WritePin(IA1_Motor_GPIO_Port, IA1_Motor_Pin, GPIO_PIN_SET);
|
||||
}
|
||||
else if(mode==0)
|
||||
{
|
||||
E53_IA1_Data.MotorMode=0;
|
||||
HAL_GPIO_WritePin(IA1_Motor_GPIO_Port, IA1_Motor_Pin, GPIO_PIN_RESET);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void light_control(char mode){
|
||||
if(mode==1)
|
||||
{
|
||||
E53_IA1_Data.LightMode=1;
|
||||
HAL_GPIO_WritePin(IA1_Light_GPIO_Port, IA1_Light_Pin, GPIO_PIN_SET);
|
||||
}
|
||||
else if(mode==0)
|
||||
{
|
||||
E53_IA1_Data.LightMode=0;
|
||||
HAL_GPIO_WritePin(IA1_Light_GPIO_Port, IA1_Light_Pin, GPIO_PIN_RESET);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: Init_Light
|
||||
* 说 明: 初始化Init_E53_IA1的补光灯
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void Init_Light(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
|
||||
/* GPIO Ports Clock Enable */
|
||||
IA1_Light_GPIO_CLK_ENABLE();
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(IA1_Light_GPIO_Port, IA1_Light_Pin, GPIO_PIN_RESET);
|
||||
E53_IA1_Data.LightMode=0;
|
||||
/*Configure GPIO pin : PtPin */
|
||||
GPIO_InitStruct.Pin = IA1_Light_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(IA1_Light_GPIO_Port, &GPIO_InitStruct);
|
||||
}
|
||||
/***************************************************************
|
||||
* 函数名称: Init_E53_IA1
|
||||
* 说 明: 初始化Init_E53_IA1
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void Init_E53_IA1(void)
|
||||
{
|
||||
//printf("E53_sensor_board init!\n");
|
||||
MX_I2C1_Init();
|
||||
Init_BH1750();
|
||||
Init_SHT30();
|
||||
Init_Motor();
|
||||
Init_Light();
|
||||
memset((char *)&E53_IA1_Data,0,sizeof(E53_IA1_Data));
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: E53_IA1_Read_Data
|
||||
* 说 明: 测量光照强度、温度、湿度
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void E53_IA1_Read_Data(void)
|
||||
{
|
||||
|
||||
char data[3]; //data array for checksum verification
|
||||
unsigned short tmp = 0;
|
||||
uint16_t dat;
|
||||
uint8_t SHT3X_Fetchcommand_Bbuffer[2]={0xE0,0x00}; //read the measurement results
|
||||
uint8_t SHT3X_Data_Buffer[6]; //byte 0,1 is temperature byte 4,5 is humidity
|
||||
|
||||
E53_IA1_Data.Lux=Convert_BH1750(); //Read bh1750 sensor data
|
||||
|
||||
HAL_I2C_Master_Transmit(&hi2c1,SHT30_Addr<<1,SHT3X_Fetchcommand_Bbuffer,2,0x10); //Read sht30 sensor data
|
||||
HAL_I2C_Master_Receive(&hi2c1,(SHT30_Addr<<1)+1,SHT3X_Data_Buffer,6,0x10);
|
||||
|
||||
// /* check tem */
|
||||
data[0] = SHT3X_Data_Buffer[0];
|
||||
data[1] = SHT3X_Data_Buffer[1];
|
||||
data[2] = SHT3X_Data_Buffer[2];
|
||||
|
||||
tmp=SHT3x_CheckCrc(data, 2, data[2]);
|
||||
if( !tmp ) /* value is ture */
|
||||
{
|
||||
dat = ((uint16_t)data[0] << 8) | data[1];
|
||||
E53_IA1_Data.Temperature = SHT3x_CalcTemperatureC( dat );
|
||||
}
|
||||
|
||||
// /* check humidity */
|
||||
data[0] = SHT3X_Data_Buffer[3];
|
||||
data[1] = SHT3X_Data_Buffer[4];
|
||||
data[2] = SHT3X_Data_Buffer[5];
|
||||
|
||||
tmp=SHT3x_CheckCrc(data, 2, data[2]);
|
||||
if( !tmp ) /* value is ture */
|
||||
{
|
||||
dat = ((uint16_t)data[0] << 8) | data[1];
|
||||
E53_IA1_Data.Humidity = SHT3x_CalcRH( dat );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -0,0 +1,46 @@
|
||||
#ifndef __E53_IA1_H__
|
||||
#define __E53_IA1_H__
|
||||
/* 包含头文件 ----------------------------------------------------------------*/
|
||||
#include "stm32l4xx_hal.h"
|
||||
|
||||
/* 控制设备IO口定义 ------------------------------------------------------------*/
|
||||
|
||||
#define IA1_Motor_Pin GPIO_PIN_8
|
||||
#define IA1_Motor_GPIO_Port GPIOB
|
||||
#define IA1_Motor_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
||||
#define IA1_Light_Pin GPIO_PIN_0
|
||||
#define IA1_Light_GPIO_Port GPIOA
|
||||
#define IA1_Light_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
|
||||
|
||||
/* E53_IA1传感器数据类型定义 ------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
float Lux; //光照强度
|
||||
float Humidity; //湿度
|
||||
float Temperature; //温度
|
||||
char MotorMode;
|
||||
char LightMode;
|
||||
} E53_IA1_Data_TypeDef;
|
||||
|
||||
extern E53_IA1_Data_TypeDef E53_IA1_Data;
|
||||
|
||||
/* 寄存器宏定义 --------------------------------------------------------------------*/
|
||||
#define I2C_OWN_ADDRESS 0x0A
|
||||
|
||||
#define SHT30_Addr 0x44
|
||||
|
||||
#define BH1750_Addr 0x46
|
||||
#define BH1750_ON 0x01
|
||||
#define BH1750_CON 0x10
|
||||
#define BH1750_ONE 0x20
|
||||
#define BH1750_RSET 0x07
|
||||
|
||||
void Init_E53_IA1(void);
|
||||
void E53_IA1_Read_Data(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
302
board/TencentOS_tiny_EVB_MX_Plus/BSP/Hardware/E53_SF1/E53_SF1.c
Normal file
302
board/TencentOS_tiny_EVB_MX_Plus/BSP/Hardware/E53_SF1/E53_SF1.c
Normal file
@@ -0,0 +1,302 @@
|
||||
#include "E53_SF1.h"
|
||||
#include "stm32l4xx.h"
|
||||
#include "stm32l4xx_it.h"
|
||||
#include "main.h"
|
||||
|
||||
ADC_HandleTypeDef hadc1;
|
||||
TIM_HandleTypeDef htim16;
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: MX_TIM16_Init
|
||||
* 说 明: 初始化定时器16
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
/* TIM16 init function */
|
||||
void MX_TIM16_Init(void)
|
||||
{
|
||||
TIM_OC_InitTypeDef sConfigOC;
|
||||
TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig;
|
||||
|
||||
htim16.Instance = TIM16;
|
||||
htim16.Init.Prescaler = 79;
|
||||
htim16.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim16.Init.Period = 999;
|
||||
htim16.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
htim16.Init.RepetitionCounter = 0;
|
||||
htim16.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||
if (HAL_TIM_Base_Init(&htim16) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
if (HAL_TIM_PWM_Init(&htim16) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
sConfigOC.OCMode = TIM_OCMODE_PWM1;
|
||||
sConfigOC.Pulse = 499;
|
||||
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
|
||||
sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH;
|
||||
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
||||
sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
|
||||
sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;
|
||||
if (HAL_TIM_PWM_ConfigChannel(&htim16, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE;
|
||||
sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE;
|
||||
sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF;
|
||||
sBreakDeadTimeConfig.DeadTime = 0;
|
||||
sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE;
|
||||
sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH;
|
||||
sBreakDeadTimeConfig.BreakFilter = 0;
|
||||
sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE;
|
||||
if (HAL_TIMEx_ConfigBreakDeadTime(&htim16, &sBreakDeadTimeConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
HAL_TIM_MspPostInit(&htim16);
|
||||
|
||||
}
|
||||
/***************************************************************
|
||||
* 函数名称: HAL_TIM_Base_MspInit
|
||||
* 说 明: 使能定时器16时钟,设置时钟源
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||
{
|
||||
|
||||
if(tim_baseHandle->Instance==TIM16)
|
||||
{
|
||||
/* USER CODE BEGIN TIM16_MspInit 0 */
|
||||
|
||||
/* USER CODE END TIM16_MspInit 0 */
|
||||
/* TIM16 clock enable */
|
||||
__HAL_RCC_TIM16_CLK_ENABLE();
|
||||
/* USER CODE BEGIN TIM16_MspInit 1 */
|
||||
|
||||
/* USER CODE END TIM16_MspInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: HAL_TIM_MspPostInit
|
||||
* 说 明: 使能定时器16硬件初始化
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle)
|
||||
{
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
if(timHandle->Instance==TIM16)
|
||||
{
|
||||
/* USER CODE BEGIN TIM16_MspPostInit 0 */
|
||||
|
||||
/* USER CODE END TIM16_MspPostInit 0 */
|
||||
|
||||
/**TIM16 GPIO Configuration
|
||||
PB8 ------> TIM16_CH1
|
||||
*/
|
||||
GPIO_InitStruct.Pin = SF1_Beep_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF14_TIM16;
|
||||
HAL_GPIO_Init(SF1_Beep_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/* USER CODE BEGIN TIM16_MspPostInit 1 */
|
||||
|
||||
/* USER CODE END TIM16_MspPostInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: MX_ADC1_Init
|
||||
* 说 明: 初始化ADC1电压采集通道
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void MX_ADC1_Init(void)
|
||||
{
|
||||
ADC_ChannelConfTypeDef sConfig;
|
||||
|
||||
/**Common config
|
||||
*/
|
||||
hadc1.Instance = ADC1;
|
||||
hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
|
||||
hadc1.Init.Resolution = ADC_RESOLUTION_12B;
|
||||
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
|
||||
hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;
|
||||
hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
|
||||
hadc1.Init.LowPowerAutoWait = DISABLE;
|
||||
hadc1.Init.ContinuousConvMode = DISABLE;
|
||||
hadc1.Init.NbrOfConversion = 1;
|
||||
hadc1.Init.DiscontinuousConvMode = DISABLE;
|
||||
hadc1.Init.NbrOfDiscConversion = 1;
|
||||
hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
|
||||
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
|
||||
hadc1.Init.DMAContinuousRequests = DISABLE;
|
||||
hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED;
|
||||
hadc1.Init.OversamplingMode = DISABLE;
|
||||
if (HAL_ADC_Init(&hadc1) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/**Configure Regular Channel
|
||||
*/
|
||||
sConfig.Channel = ADC_CHANNEL_3;
|
||||
sConfig.Rank = ADC_REGULAR_RANK_1;
|
||||
sConfig.SamplingTime = ADC_SAMPLETIME_2CYCLES_5;
|
||||
sConfig.SingleDiff = ADC_SINGLE_ENDED;
|
||||
sConfig.OffsetNumber = ADC_OFFSET_NONE;
|
||||
sConfig.Offset = 0;
|
||||
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: HAL_ADC_MspInit
|
||||
* 说 明: 使能ADC时钟,设置时钟源
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void HAL_ADC_MspInit(ADC_HandleTypeDef* adcHandle)
|
||||
{
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
if(adcHandle->Instance==ADC1)
|
||||
{
|
||||
/* USER CODE BEGIN ADC1_MspInit 0 */
|
||||
|
||||
/* USER CODE END ADC1_MspInit 0 */
|
||||
/* ADC1 clock enable */
|
||||
__HAL_RCC_ADC_CLK_ENABLE();
|
||||
|
||||
/**ADC1 GPIO Configuration
|
||||
PC2 ------> ADC1_IN3
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_2;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
/* USER CODE BEGIN ADC1_MspInit 1 */
|
||||
|
||||
/* USER CODE END ADC1_MspInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: Init_Beep
|
||||
* 说 明: 初始化E53_SF1的蜂鸣器
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void Init_Beep(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
|
||||
/* GPIO Ports Clock Enable */
|
||||
SF1_Beep_GPIO_CLK_ENABLE();
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(SF1_Beep_GPIO_Port, SF1_Beep_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin : PtPin */
|
||||
GPIO_InitStruct.Pin = SF1_Beep_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(SF1_Beep_GPIO_Port, &GPIO_InitStruct);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: Init_LED
|
||||
* 说 明: 初始化E53_SF1的LED灯
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void Init_LED(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
|
||||
/* GPIO Ports Clock Enable */
|
||||
SF1_LED_GPIO_CLK_ENABLE();
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(SF1_LED_GPIO_Port, SF1_LED_Pin, GPIO_PIN_SET);
|
||||
|
||||
/*Configure GPIO pin : PtPin */
|
||||
GPIO_InitStruct.Pin = SF1_LED_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(SF1_LED_GPIO_Port, &GPIO_InitStruct);
|
||||
}
|
||||
/***************************************************************
|
||||
* 函数名称: Init_E53_SF1
|
||||
* 说 明: 初始化E53_SF1扩展板
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void Init_E53_SF1(void)
|
||||
{
|
||||
MX_ADC1_Init();
|
||||
Init_Beep();
|
||||
Init_LED();
|
||||
MX_TIM16_Init();
|
||||
}
|
||||
/***************************************************************
|
||||
* 函数名称: E53_SF1_Read_Data
|
||||
* 说 明: 获取烟雾传感器的数据
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void E53_SF1_Read_Data(void)
|
||||
{
|
||||
HAL_ADC_Start(&hadc1);
|
||||
HAL_ADC_PollForConversion(&hadc1, 50);
|
||||
E53_SF1_Data.Smoke_Value = HAL_ADC_GetValue(&hadc1);
|
||||
}
|
||||
/***************************************************************
|
||||
* 函数名称: E53SF1_LED_StatusSet
|
||||
* 说 明: E53SF1开发板上的LED灯的亮灭控制
|
||||
* 参 数: status,LED灯的状态
|
||||
* 非1,关灯
|
||||
* 1,开灯
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void E53SF1_LED_StatusSet(E53SF1_Status_ENUM status)
|
||||
{
|
||||
HAL_GPIO_WritePin(SF1_LED_GPIO_Port, SF1_LED_Pin, status != ON ? GPIO_PIN_RESET : GPIO_PIN_SET );
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: E53SF1_BEEP
|
||||
* 说 明: E53SF1蜂鸣器报警与否
|
||||
* 参 数: status,LED_ENUM枚举的数据
|
||||
* LED_OFF,关灯
|
||||
* LED_ON,开灯
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void E53SF1_Beep(E53SF1_Status_ENUM status)
|
||||
{
|
||||
if(status == ON)
|
||||
HAL_TIM_PWM_Start(&htim16,TIM_CHANNEL_1);
|
||||
if(status == OFF)
|
||||
HAL_TIM_PWM_Stop(&htim16,TIM_CHANNEL_1);
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,49 @@
|
||||
#ifndef __E53_SF1_H__
|
||||
#define __E53_SF1_H__
|
||||
/* 包含头文件 ----------------------------------------------------------------*/
|
||||
#include "stm32l4xx_hal.h"
|
||||
|
||||
extern ADC_HandleTypeDef hadc1;
|
||||
extern TIM_HandleTypeDef htim16;
|
||||
|
||||
/* 控制设备IO口定义 ------------------------------------------------------------*/
|
||||
|
||||
#define SF1_Beep_Pin GPIO_PIN_8
|
||||
#define SF1_Beep_GPIO_Port GPIOB
|
||||
#define SF1_Beep_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
||||
#define SF1_LED_Pin GPIO_PIN_0
|
||||
#define SF1_LED_GPIO_Port GPIOA
|
||||
#define SF1_LED_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
|
||||
|
||||
|
||||
|
||||
/* E53_SF1传感器数据类型定义 ------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
int Smoke_Value;
|
||||
} E53_SF1_Data_TypeDef;
|
||||
|
||||
extern E53_SF1_Data_TypeDef E53_SF1_Data;
|
||||
|
||||
/***************************************************************
|
||||
* 名 称: GasStatus_ENUM
|
||||
* 说 明:枚举状态结构体
|
||||
***************************************************************/
|
||||
typedef enum
|
||||
{
|
||||
OFF = 0,
|
||||
ON
|
||||
} E53SF1_Status_ENUM;
|
||||
|
||||
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
|
||||
void Init_E53_SF1(void);
|
||||
void E53_SF1_Read_Data(void);
|
||||
void E53SF1_LED_StatusSet(E53SF1_Status_ENUM status);
|
||||
void E53SF1_Beep(E53SF1_Status_ENUM status);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
377
board/TencentOS_tiny_EVB_MX_Plus/BSP/Hardware/E53_ST1/E53_ST1.c
Normal file
377
board/TencentOS_tiny_EVB_MX_Plus/BSP/Hardware/E53_ST1/E53_ST1.c
Normal file
@@ -0,0 +1,377 @@
|
||||
#include "E53_ST1.h"
|
||||
#include "stm32l4xx.h"
|
||||
#include "stm32l4xx_it.h"
|
||||
#include "usart.h"
|
||||
#include "main.h"
|
||||
|
||||
gps_msg gpsmsg;
|
||||
static unsigned char gps_uart[1000];
|
||||
|
||||
|
||||
TIM_HandleTypeDef htim16;
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: MX_TIM16_Init
|
||||
* 说 明: 初始化定时器16
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
/* TIM16 init function */
|
||||
void MX_TIM16_Init(void)
|
||||
{
|
||||
TIM_OC_InitTypeDef sConfigOC;
|
||||
TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig;
|
||||
|
||||
htim16.Instance = TIM16;
|
||||
htim16.Init.Prescaler = 79;
|
||||
htim16.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim16.Init.Period = 999;
|
||||
htim16.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
htim16.Init.RepetitionCounter = 0;
|
||||
htim16.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||
if (HAL_TIM_Base_Init(&htim16) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
if (HAL_TIM_PWM_Init(&htim16) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
sConfigOC.OCMode = TIM_OCMODE_PWM1;
|
||||
sConfigOC.Pulse = 499;
|
||||
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
|
||||
sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH;
|
||||
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
||||
sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
|
||||
sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;
|
||||
if (HAL_TIM_PWM_ConfigChannel(&htim16, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE;
|
||||
sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE;
|
||||
sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF;
|
||||
sBreakDeadTimeConfig.DeadTime = 0;
|
||||
sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE;
|
||||
sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH;
|
||||
sBreakDeadTimeConfig.BreakFilter = 0;
|
||||
sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE;
|
||||
if (HAL_TIMEx_ConfigBreakDeadTime(&htim16, &sBreakDeadTimeConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
HAL_TIM_MspPostInit(&htim16);
|
||||
|
||||
}
|
||||
/***************************************************************
|
||||
* 函数名称: HAL_TIM_Base_MspInit
|
||||
* 说 明: 使能定时器16时钟,设置时钟源
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||
{
|
||||
|
||||
if(tim_baseHandle->Instance==TIM16)
|
||||
{
|
||||
/* USER CODE BEGIN TIM16_MspInit 0 */
|
||||
|
||||
/* USER CODE END TIM16_MspInit 0 */
|
||||
/* TIM16 clock enable */
|
||||
__HAL_RCC_TIM16_CLK_ENABLE();
|
||||
/* USER CODE BEGIN TIM16_MspInit 1 */
|
||||
|
||||
/* USER CODE END TIM16_MspInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: HAL_TIM_MspPostInit
|
||||
* 说 明: 使能定时器16硬件初始化
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle)
|
||||
{
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
if(timHandle->Instance==TIM16)
|
||||
{
|
||||
/* USER CODE BEGIN TIM16_MspPostInit 0 */
|
||||
|
||||
/* USER CODE END TIM16_MspPostInit 0 */
|
||||
|
||||
/**TIM16 GPIO Configuration
|
||||
PB8 ------> TIM16_CH1
|
||||
*/
|
||||
GPIO_InitStruct.Pin = ST1_Beep_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF14_TIM16;
|
||||
HAL_GPIO_Init(ST1_Beep_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/* USER CODE BEGIN TIM16_MspPostInit 1 */
|
||||
|
||||
/* USER CODE END TIM16_MspPostInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: Init_Beep
|
||||
* 说 明: 初始化E53_ST1的蜂鸣器
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void Init_Beep(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
|
||||
/* GPIO Ports Clock Enable */
|
||||
ST1_Beep_GPIO_CLK_ENABLE();
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(ST1_Beep_GPIO_Port, ST1_Beep_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin : PtPin */
|
||||
GPIO_InitStruct.Pin = ST1_Beep_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(ST1_Beep_GPIO_Port, &GPIO_InitStruct);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: Init_LED
|
||||
* 说 明: 初始化E53_ST1的LED灯
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void Init_LED(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
|
||||
/* GPIO Ports Clock Enable */
|
||||
ST1_LED_GPIO_CLK_ENABLE();
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(ST1_LED_GPIO_Port, ST1_LED_Pin, GPIO_PIN_SET);
|
||||
|
||||
/*Configure GPIO pin : PtPin */
|
||||
GPIO_InitStruct.Pin = ST1_LED_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(ST1_LED_GPIO_Port, &GPIO_InitStruct);
|
||||
}
|
||||
/***************************************************************
|
||||
* 函数名称: Init_GPS_POW
|
||||
* 说 明: 初始化E53_ST1的GPS使能引脚
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void Init_GPS_POW(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
|
||||
/* GPIO Ports Clock Enable */
|
||||
ST1_GPS_POW_GPIO_CLK_ENABLE();
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(ST1_GPS_POW_GPIO_Port, ST1_GPS_POW_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin : PtPin */
|
||||
GPIO_InitStruct.Pin = ST1_GPS_POW_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(ST1_GPS_POW_GPIO_Port, &GPIO_InitStruct);
|
||||
}
|
||||
/***************************************************************
|
||||
* 函数名称: GPS_Init
|
||||
* 说 明: 初始化GPS模块
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void GPS_Init(void)
|
||||
{
|
||||
MX_USART3_UART_Init(); //初始化串口
|
||||
HAL_UART_Transmit(&huart3, "$CCMSG,GGA,1,0,*19\r\n", 20, 200);
|
||||
HAL_UART_Transmit(&huart3, "$CCMSG,GSA,1,0,*0D\r\n", 20, 200);
|
||||
HAL_UART_Transmit(&huart3, "$CCMSG,GSV,1,0,*1A\r\n", 20, 200);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: Init_E53_ST1
|
||||
* 说 明: 初始化E53_ST1扩展板
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void Init_E53_ST1(void)
|
||||
{
|
||||
GPS_Init();
|
||||
Init_Beep();
|
||||
Init_LED();
|
||||
Init_GPS_POW();
|
||||
MX_TIM16_Init();
|
||||
}
|
||||
|
||||
/***************************************************\
|
||||
* 函数名称: NMEA_Comma_Pos
|
||||
* 函数功能:从buf里面得到第cx个逗号所在的位置
|
||||
* 输入值:
|
||||
* 返回值:0~0xFE,代表逗号所在位置的便宜
|
||||
* 0xFF,代表不存在第cx个逗号
|
||||
\***************************************************/
|
||||
|
||||
uint8_t NMEA_Comma_Pos(uint8_t *buf,uint8_t cx)
|
||||
{
|
||||
uint8_t *p = buf;
|
||||
while(cx)
|
||||
{
|
||||
if(*buf=='*'||*buf<' '||*buf>'z')return 0xFF;
|
||||
if(*buf==',')cx--;
|
||||
buf++;
|
||||
}
|
||||
return buf-p;
|
||||
}
|
||||
/***************************************************\
|
||||
* 函数名称: NMEA_Pow
|
||||
* 函数功能:返回m的n次方值
|
||||
* 输入值:底数m和指数n
|
||||
* 返回值:m^n
|
||||
\***************************************************/
|
||||
uint32_t NMEA_Pow(uint8_t m,uint8_t n)
|
||||
{
|
||||
uint32_t result = 1;
|
||||
while(n--)result *= m;
|
||||
return result;
|
||||
}
|
||||
/***************************************************\
|
||||
* 函数名称: NMEA_Str2num
|
||||
* 函数功能:str数字转换为(int)数字,以','或者'*'结束
|
||||
* 输入值:buf,数字存储区
|
||||
* dx,小数点位数,返回给调用函数
|
||||
* 返回值:转换后的数值
|
||||
\***************************************************/
|
||||
int NMEA_Str2num(uint8_t *buf,uint8_t*dx)
|
||||
{
|
||||
uint8_t *p = buf;
|
||||
uint32_t ires = 0,fres = 0;
|
||||
uint8_t ilen = 0,flen = 0,i;
|
||||
uint8_t mask = 0;
|
||||
int res;
|
||||
while(1)
|
||||
{
|
||||
if(*p=='-'){mask |= 0x02;p++;}//说明有负数
|
||||
if(*p==','||*p=='*')break;//遇到结束符
|
||||
if(*p=='.'){mask |= 0x01;p++;}//遇到小数点
|
||||
else if(*p>'9'||(*p<'0'))//数字不在0和9之内,说明有非法字符
|
||||
{
|
||||
ilen = 0;
|
||||
flen = 0;
|
||||
break;
|
||||
}
|
||||
if(mask&0x01)flen++;//小数点的位数
|
||||
else ilen++;//str长度加一
|
||||
p++;//下一个字符
|
||||
}
|
||||
if(mask&0x02)buf++;//移到下一位,除去负号
|
||||
for(i=0;i<ilen;i++)//得到整数部分数据
|
||||
{
|
||||
ires += NMEA_Pow(10,ilen-1-i)*(buf[i]-'0');
|
||||
}
|
||||
if(flen>5)flen=5;//最多取五位小数
|
||||
*dx = flen;
|
||||
for(i=0;i<flen;i++)//得到小数部分数据
|
||||
{
|
||||
fres +=NMEA_Pow(10,flen-1-i)*(buf[ilen+1+i]-'0');
|
||||
}
|
||||
res = ires*NMEA_Pow(10,flen)+fres;
|
||||
if(mask&0x02)res = -res;
|
||||
return res;
|
||||
}
|
||||
/***************************************************\
|
||||
* 函数名称: NMEA_BDS_GPRMC_Analysis
|
||||
* 函数功能:解析GPRMC信息
|
||||
* 输入值:gpsx,NMEA信息结构体
|
||||
* buf:接收到的GPS数据缓冲区首地址
|
||||
\***************************************************/
|
||||
void NMEA_BDS_GPRMC_Analysis(gps_msg *gpsmsg,uint8_t *buf)
|
||||
{
|
||||
uint8_t *p4,dx;
|
||||
uint8_t posx;
|
||||
uint32_t temp;
|
||||
float rs;
|
||||
p4=(uint8_t*)strstr((const char *)buf,"$GPRMC");//"$GPRMC",经常有&和GPRMC分开的情况,故只判断GPRMC.
|
||||
posx=NMEA_Comma_Pos(p4,3); //得到纬度
|
||||
if(posx!=0XFF)
|
||||
{
|
||||
temp=NMEA_Str2num(p4+posx,&dx);
|
||||
gpsmsg->latitude_bd=temp/NMEA_Pow(10,dx+2); //得到°
|
||||
rs=temp%NMEA_Pow(10,dx+2); //得到'
|
||||
gpsmsg->latitude_bd=gpsmsg->latitude_bd*NMEA_Pow(10,5)+(rs*NMEA_Pow(10,5-dx))/60;//转换为°
|
||||
}
|
||||
posx=NMEA_Comma_Pos(p4,4); //南纬还是北纬
|
||||
if(posx!=0XFF)gpsmsg->nshemi_bd=*(p4+posx);
|
||||
posx=NMEA_Comma_Pos(p4,5); //得到经度
|
||||
if(posx!=0XFF)
|
||||
{
|
||||
temp=NMEA_Str2num(p4+posx,&dx);
|
||||
gpsmsg->longitude_bd=temp/NMEA_Pow(10,dx+2); //得到°
|
||||
rs=temp%NMEA_Pow(10,dx+2); //得到'
|
||||
gpsmsg->longitude_bd=gpsmsg->longitude_bd*NMEA_Pow(10,5)+(rs*NMEA_Pow(10,5-dx))/60;//转换为°
|
||||
}
|
||||
posx=NMEA_Comma_Pos(p4,6); //东经还是西经
|
||||
if(posx!=0XFF)gpsmsg->ewhemi_bd=*(p4+posx);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: E53_ST1_Read_Data
|
||||
* 说 明: 获取GPS经纬度信息
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void E53_ST1_Read_Data(void)
|
||||
{
|
||||
HAL_UART_Receive_IT(&huart3,gps_uart,1000);
|
||||
NMEA_BDS_GPRMC_Analysis(&gpsmsg,(uint8_t*)gps_uart); //分析字符串
|
||||
E53_ST1_Data.Longitude=(float)((float)gpsmsg.longitude_bd/100000);
|
||||
E53_ST1_Data.Latitude=(float)((float)gpsmsg.latitude_bd/100000);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: E53SF1_LED_StatusSet
|
||||
* 说 明: E53SF1开发板上的LED灯的亮灭控制
|
||||
* 参 数: status,LED灯的状态
|
||||
* 非1,关灯
|
||||
* 1,开灯
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void E53_ST1_LED_StatusSet(E53ST1_Status_ENUM status)
|
||||
{
|
||||
HAL_GPIO_WritePin(ST1_LED_GPIO_Port, ST1_LED_Pin, status != ST1_ON ? GPIO_PIN_RESET : GPIO_PIN_SET );
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* 函数名称: E53SF1_BEEP
|
||||
* 说 明: E53SF1蜂鸣器报警与否
|
||||
* 参 数: status,LED_ENUM枚举的数据
|
||||
* LED_OFF,关灯
|
||||
* LED_ON,开灯
|
||||
* 返 回 值: 无
|
||||
***************************************************************/
|
||||
void E53_ST1_Beep(E53ST1_Status_ENUM status)
|
||||
{
|
||||
if(status == ST1_ON)
|
||||
HAL_TIM_PWM_Start(&htim16,TIM_CHANNEL_1);
|
||||
if(status == ST1_OFF)
|
||||
HAL_TIM_PWM_Stop(&htim16,TIM_CHANNEL_1);
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,70 @@
|
||||
#ifndef __E53_ST1_H__
|
||||
#define __E53_ST1_H__
|
||||
/* 包含头文件 ----------------------------------------------------------------*/
|
||||
#include "stm32l4xx_hal.h"
|
||||
|
||||
/* 控制设备IO口定义 ------------------------------------------------------------*/
|
||||
|
||||
#define ST1_Beep_Pin GPIO_PIN_8
|
||||
#define ST1_Beep_GPIO_Port GPIOB
|
||||
#define ST1_Beep_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
||||
#define ST1_LED_Pin GPIO_PIN_0
|
||||
#define ST1_LED_GPIO_Port GPIOA
|
||||
#define ST1_LED_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
|
||||
#define ST1_GPS_POW_Pin GPIO_PIN_9
|
||||
#define ST1_GPS_POW_GPIO_Port GPIOC
|
||||
#define ST1_GPS_POW_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
|
||||
|
||||
/***************************************************************
|
||||
* 名 称: GasStatus_ENUM
|
||||
* 说 明:枚举状态结构体
|
||||
***************************************************************/
|
||||
typedef enum
|
||||
{
|
||||
ST1_OFF = 0,
|
||||
ST1_ON
|
||||
} E53ST1_Status_ENUM;
|
||||
|
||||
/***************************************************\
|
||||
*GPS NMEA-0183协议重要参数结构体定义
|
||||
*卫星信息
|
||||
\***************************************************/
|
||||
__packed typedef struct
|
||||
{
|
||||
uint32_t latitude_bd; //纬度 分扩大100000倍,实际要除以100000
|
||||
uint8_t nshemi_bd; //北纬/南纬,N:北纬;S:南纬
|
||||
uint32_t longitude_bd; //经度 分扩大100000倍,实际要除以100000
|
||||
uint8_t ewhemi_bd; //东经/西经,E:东经;W:西经
|
||||
}gps_msg;
|
||||
|
||||
/* E53_ST1传感器数据类型定义 ------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
float Longitude; //经度
|
||||
float Latitude; //纬度
|
||||
} E53_ST1_Data_TypeDef;
|
||||
|
||||
extern E53_ST1_Data_TypeDef E53_ST1_Data;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char Longitude[9]; //经度
|
||||
char Latitude[8]; //纬度
|
||||
} E53_ST1_Send_TypeDef;
|
||||
|
||||
extern E53_ST1_Send_TypeDef E53_ST1_Send;
|
||||
|
||||
extern TIM_HandleTypeDef htim16;
|
||||
|
||||
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
|
||||
void Init_E53_ST1(void);
|
||||
void E53_ST1_Read_Data(void);
|
||||
void E53_ST1_LED_StatusSet(E53ST1_Status_ENUM status);
|
||||
void E53_ST1_Beep(E53ST1_Status_ENUM status);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
80
board/TencentOS_tiny_EVB_MX_Plus/BSP/Hardware/OLED/bmp.h
Normal file
80
board/TencentOS_tiny_EVB_MX_Plus/BSP/Hardware/OLED/bmp.h
Normal file
@@ -0,0 +1,80 @@
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
//存储图片数据,图片大小为64*32像素
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __BMP_H
|
||||
#define __BMP_H
|
||||
unsigned char BMP1[] =
|
||||
{0x00,0x06,0x0A,0xFE,0x0A,0xC6,0x00,0xE0,0x00,0xF0,0x00,0xF8,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0xFE,0x7D,0xBB,0xC7,0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0xC7,0xBB,0x7D,
|
||||
0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
|
||||
0x0C,0xFE,0xFE,0x0C,0x08,0x20,0x60,0xFE,0xFE,0x60,0x20,0x00,0x00,0x00,0x78,0x48,
|
||||
0xFE,0x82,0xBA,0xBA,0x82,0xBA,0xBA,0x82,0xBA,0xBA,0x82,0xBA,0xBA,0x82,0xFE,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0xFF,
|
||||
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0xFF,0xFF,0x00,0x00,0xFE,0xFF,0x03,
|
||||
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0xFF,0xFE,0x00,0x00,0x00,0x00,0xC0,0xC0,
|
||||
0xC0,0x00,0x00,0x00,0x00,0xFE,0xFF,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
|
||||
0xFF,0xFE,0x00,0x00,0xFE,0xFF,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0xFF,
|
||||
0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x0C,
|
||||
0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0xFF,0xFF,0x00,0x00,0x00,0x00,0xE1,0xE1,
|
||||
0xE1,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0xFF,
|
||||
0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x1F,
|
||||
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1F,0x0F,0x00,0x00,0x0F,0x1F,0x18,
|
||||
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1F,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x0F,0x1F,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
|
||||
0x1F,0x0F,0x00,0x00,0x0F,0x1F,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1F,
|
||||
0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x8C,0x42,0x22,0x12,0x0C,0x00,0xFC,0x02,0x02,0x02,0xFC,0x00,0x00,0x04,
|
||||
0xFE,0x00,0x00,0x00,0x20,0x58,0x44,0xFE,0x40,0x00,0x10,0x10,0x10,0x10,0x10,0x00,
|
||||
0x00,0x04,0xFE,0x00,0x00,0x00,0xFC,0x02,0x02,0x02,0xFC,0x00,0x10,0x10,0x10,0x10,
|
||||
0x10,0x00,0xFC,0x02,0x02,0x02,0xFC,0x00,0x00,0x04,0xFE,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x24,0xA4,0x2E,0x24,0xE4,0x24,0x2E,0xA4,0x24,0x00,0x00,0x00,0xF8,0x4A,0x4C,
|
||||
0x48,0xF8,0x48,0x4C,0x4A,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x01,0x01,0x01,0x00,0x00,0x00,0x01,
|
||||
0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x01,0x01,0x01,0x00,0x00,0x00,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x01,0x01,0x01,0x00,0x00,0x00,0x01,0x01,0x01,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x20,0x10,0x10,
|
||||
0x10,0x10,0x20,0xC0,0x00,0x00,0xC0,0x20,0x10,0x10,0x10,0x10,0x20,0xC0,0x00,0x00,
|
||||
0x00,0x12,0x0A,0x07,0x02,0x7F,0x02,0x07,0x0A,0x12,0x00,0x00,0x00,0x0B,0x0A,0x0A,
|
||||
0x0A,0x7F,0x0A,0x0A,0x0A,0x0B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x40,0x40,
|
||||
0x40,0x50,0x20,0x5F,0x80,0x00,0x1F,0x20,0x40,0x40,0x40,0x50,0x20,0x5F,0x80,0x00,
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
320
board/TencentOS_tiny_EVB_MX_Plus/BSP/Hardware/OLED/oled.c
Normal file
320
board/TencentOS_tiny_EVB_MX_Plus/BSP/Hardware/OLED/oled.c
Normal file
@@ -0,0 +1,320 @@
|
||||
#include "oled.h"
|
||||
#include "stdlib.h"
|
||||
#include "oledfont.h"
|
||||
//OLED的显存
|
||||
//存放格式如下.
|
||||
//-----------------------------------
|
||||
//|x→[0,127] |
|
||||
//| OLED显示坐标 |
|
||||
//|y 范围 |
|
||||
//|↓ |
|
||||
//|[0,31] |
|
||||
//-----------------------------------
|
||||
/**********************************************
|
||||
//IIC Start
|
||||
**********************************************/
|
||||
void IIC_Start(void)
|
||||
{
|
||||
OLED_SCLK_Set();
|
||||
OLED_SDIN_Set();
|
||||
OLED_SDIN_Clr();
|
||||
OLED_SCLK_Clr();
|
||||
}
|
||||
|
||||
/**********************************************
|
||||
//IIC Stop
|
||||
**********************************************/
|
||||
void IIC_Stop(void)
|
||||
{
|
||||
OLED_SCLK_Set();
|
||||
OLED_SDIN_Clr();
|
||||
OLED_SDIN_Set();
|
||||
}
|
||||
|
||||
void IIC_Wait_Ack(void)
|
||||
{
|
||||
OLED_SCLK_Set();
|
||||
OLED_SCLK_Clr();
|
||||
}
|
||||
/**********************************************
|
||||
// IIC Write byte
|
||||
**********************************************/
|
||||
|
||||
void Write_IIC_Byte(unsigned char IIC_Byte)
|
||||
{
|
||||
unsigned char i;
|
||||
unsigned char m,da;
|
||||
da=IIC_Byte;
|
||||
OLED_SCLK_Clr();
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
m=da;
|
||||
m=m&0x80;
|
||||
if(m==0x80)
|
||||
{
|
||||
OLED_SDIN_Set();
|
||||
}
|
||||
else
|
||||
OLED_SDIN_Clr();
|
||||
da=da<<1;
|
||||
OLED_SCLK_Set();
|
||||
OLED_SCLK_Clr();
|
||||
}
|
||||
}
|
||||
/**********************************************
|
||||
// IIC Write Command
|
||||
**********************************************/
|
||||
void Write_IIC_Command(unsigned char IIC_Command)
|
||||
{
|
||||
IIC_Start();
|
||||
Write_IIC_Byte(0x78); //Slave address,SA0=0
|
||||
IIC_Wait_Ack();
|
||||
Write_IIC_Byte(0x00); //write command
|
||||
IIC_Wait_Ack();
|
||||
Write_IIC_Byte(IIC_Command);
|
||||
IIC_Wait_Ack();
|
||||
IIC_Stop();
|
||||
}
|
||||
/**********************************************
|
||||
// IIC Write Data
|
||||
**********************************************/
|
||||
void Write_IIC_Data(unsigned char IIC_Data)
|
||||
{
|
||||
IIC_Start();
|
||||
Write_IIC_Byte(0x78); //D/C#=0; R/W#=0
|
||||
IIC_Wait_Ack();
|
||||
Write_IIC_Byte(0x40); //write data
|
||||
IIC_Wait_Ack();
|
||||
Write_IIC_Byte(IIC_Data);
|
||||
IIC_Wait_Ack();
|
||||
IIC_Stop();
|
||||
}
|
||||
void OLED_WR_Byte(unsigned dat,unsigned cmd)
|
||||
{
|
||||
if(cmd)
|
||||
{
|
||||
Write_IIC_Data(dat);
|
||||
}
|
||||
else
|
||||
{
|
||||
Write_IIC_Command(dat);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/********************************************
|
||||
// fill_Picture
|
||||
********************************************/
|
||||
void fill_picture(unsigned char fill_Data)
|
||||
{
|
||||
unsigned char m,n;
|
||||
for(m=0;m<8;m++)
|
||||
{
|
||||
OLED_WR_Byte(0xb0+m,0); //page0-page1
|
||||
OLED_WR_Byte(0x00,0); //low column start address
|
||||
OLED_WR_Byte(0x10,0); //high column start address
|
||||
for(n=0;n<128;n++)
|
||||
{
|
||||
OLED_WR_Byte(fill_Data,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//坐标设置
|
||||
void OLED_Set_Pos(unsigned char x, unsigned char y)
|
||||
{
|
||||
OLED_WR_Byte(0xb0+y,OLED_CMD);
|
||||
OLED_WR_Byte(((x&0xf0)>>4)|0x10,OLED_CMD);
|
||||
OLED_WR_Byte((x&0x0f),OLED_CMD);
|
||||
}
|
||||
//开启OLED显示
|
||||
void OLED_Display_On(void)
|
||||
{
|
||||
OLED_WR_Byte(0X8D,OLED_CMD); //SET DCDC命令
|
||||
OLED_WR_Byte(0X14,OLED_CMD); //DCDC ON
|
||||
OLED_WR_Byte(0XAF,OLED_CMD); //DISPLAY ON
|
||||
}
|
||||
//关闭OLED显示
|
||||
void OLED_Display_Off(void)
|
||||
{
|
||||
OLED_WR_Byte(0X8D,OLED_CMD); //SET DCDC命令
|
||||
OLED_WR_Byte(0X10,OLED_CMD); //DCDC OFF
|
||||
OLED_WR_Byte(0XAE,OLED_CMD); //DISPLAY OFF
|
||||
}
|
||||
//注意:清屏函数,清完屏,整个屏幕是黑色的!和没点亮一样!!!
|
||||
void OLED_Clear(void)
|
||||
{
|
||||
uint8_t i,n;
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
OLED_WR_Byte (0xb0+i,OLED_CMD); //设置页地址(0~7)
|
||||
OLED_WR_Byte (0x00,OLED_CMD); //设置显示位置—列低地址
|
||||
OLED_WR_Byte (0x10,OLED_CMD); //设置显示位置—列高地址
|
||||
for(n=0;n<128;n++)
|
||||
OLED_WR_Byte(0,OLED_DATA);
|
||||
} //更新显示
|
||||
}
|
||||
void OLED_On(void)
|
||||
{
|
||||
uint8_t i,n;
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
OLED_WR_Byte (0xb0+i,OLED_CMD); //设置页地址(0~7)
|
||||
OLED_WR_Byte (0x00,OLED_CMD); //设置显示位置—列低地址
|
||||
OLED_WR_Byte (0x10,OLED_CMD); //设置显示位置—列高地址
|
||||
for(n=0;n<128;n++)OLED_WR_Byte(1,OLED_DATA);
|
||||
} //更新显示
|
||||
}
|
||||
//在指定位置显示一个字符,包括部分字符
|
||||
//x:0~127
|
||||
//y:0~63
|
||||
//
|
||||
//size:选择字体 16/12
|
||||
void OLED_ShowChar(uint8_t x,uint8_t y,uint8_t chr,uint8_t Char_Size)
|
||||
{
|
||||
unsigned char c=0,i=0;
|
||||
c=chr-' ';//得到偏移后的值
|
||||
if(x>Max_Column-1){x=0;y=y+2;}
|
||||
if(Char_Size ==16)
|
||||
{
|
||||
OLED_Set_Pos(x,y);
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
OLED_WR_Byte(F8X16[c*16+i],OLED_DATA);
|
||||
}
|
||||
OLED_Set_Pos(x,y+1);
|
||||
for(i=0;i<8;i++){
|
||||
OLED_WR_Byte(F8X16[c*16+i+8],OLED_DATA);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OLED_Set_Pos(x,y);
|
||||
for(i=0;i<6;i++)
|
||||
OLED_WR_Byte(F6x8[c][i],OLED_DATA);
|
||||
}
|
||||
}
|
||||
//m^n函数
|
||||
uint32_t oled_pow(uint8_t m,uint8_t n)
|
||||
{
|
||||
uint32_t result=1;
|
||||
while(n--)result*=m;
|
||||
return result;
|
||||
}
|
||||
//显示2个数字
|
||||
//x,y :起点坐标
|
||||
//len :数字的位数
|
||||
//size:字体大小
|
||||
//
|
||||
//num:数值(0~4294967295);
|
||||
void OLED_ShowNum(uint8_t x,uint8_t y,uint32_t num,uint8_t len,uint8_t size2)
|
||||
{
|
||||
uint8_t t,temp;
|
||||
uint8_t enshow=0;
|
||||
for(t=0;t<len;t++)
|
||||
{
|
||||
temp=(num/oled_pow(10,len-t-1))%10;
|
||||
if(enshow==0&&t<(len-1))
|
||||
{
|
||||
if(temp==0)
|
||||
{
|
||||
OLED_ShowChar(x+(size2/2)*t,y,' ',size2);
|
||||
continue;
|
||||
}else
|
||||
enshow=1;
|
||||
}
|
||||
OLED_ShowChar(x+(size2/2)*t,y,temp+'0',size2);
|
||||
}
|
||||
}
|
||||
//显示一个字符号串
|
||||
void OLED_ShowString(uint8_t x,uint8_t y,uint8_t *chr,uint8_t Char_Size)
|
||||
{
|
||||
unsigned char j=0;
|
||||
while (chr[j]!='\0')
|
||||
{
|
||||
OLED_ShowChar(x,y,chr[j],Char_Size);
|
||||
x+=8;
|
||||
if(x>120)
|
||||
{
|
||||
x=0;y+=2;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
}
|
||||
//显示汉字
|
||||
void OLED_ShowChinese(uint8_t x,uint8_t y,uint8_t no)
|
||||
{
|
||||
uint8_t t,adder=0;
|
||||
OLED_Set_Pos(x,y);
|
||||
for(t=0;t<16;t++)
|
||||
{
|
||||
OLED_WR_Byte(Hzk[2*no][t],OLED_DATA);
|
||||
adder+=1;
|
||||
}
|
||||
OLED_Set_Pos(x,y+1);
|
||||
for(t=0;t<16;t++)
|
||||
{
|
||||
OLED_WR_Byte(Hzk[2*no+1][t],OLED_DATA);
|
||||
adder+=1;
|
||||
}
|
||||
}
|
||||
/***********功能描述:显示显示BMP图片128×64起始点坐标(x,y),x的范围0〜127,y为页的范围0〜7*****************/
|
||||
void OLED_DrawBMP(unsigned char x0, unsigned char y0,unsigned char x1, unsigned char y1,unsigned char BMP[])
|
||||
{
|
||||
unsigned int j=0;
|
||||
unsigned char x,y;
|
||||
|
||||
if(y1%8==0) y=y1/8;
|
||||
else y=y1/8+1;
|
||||
for(y=y0;y<y1;y++)
|
||||
{
|
||||
OLED_Set_Pos(x0,y);
|
||||
for(x=x0;x<x1;x++)
|
||||
{
|
||||
OLED_WR_Byte(BMP[j++],OLED_DATA);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//初始化OLED
|
||||
void OLED_Init(void)
|
||||
{
|
||||
HAL_Delay(200);
|
||||
OLED_WR_Byte(0xAE,OLED_CMD);//关闭显示
|
||||
|
||||
OLED_WR_Byte(0x40,OLED_CMD);//---set low column address
|
||||
OLED_WR_Byte(0xB0,OLED_CMD);//---set high column address
|
||||
|
||||
OLED_WR_Byte(0xC8,OLED_CMD);//-not offset
|
||||
|
||||
OLED_WR_Byte(0x81,OLED_CMD);//设置对比度
|
||||
OLED_WR_Byte(0xff,OLED_CMD);
|
||||
|
||||
OLED_WR_Byte(0xa1,OLED_CMD);//段重定向设置
|
||||
|
||||
OLED_WR_Byte(0xa6,OLED_CMD);//
|
||||
|
||||
OLED_WR_Byte(0xa8,OLED_CMD);//设置驱动路数
|
||||
OLED_WR_Byte(0x1f,OLED_CMD);
|
||||
|
||||
OLED_WR_Byte(0xd3,OLED_CMD);
|
||||
OLED_WR_Byte(0x00,OLED_CMD);
|
||||
|
||||
OLED_WR_Byte(0xd5,OLED_CMD);
|
||||
OLED_WR_Byte(0xf0,OLED_CMD);
|
||||
|
||||
OLED_WR_Byte(0xd9,OLED_CMD);
|
||||
OLED_WR_Byte(0x22,OLED_CMD);
|
||||
|
||||
OLED_WR_Byte(0xda,OLED_CMD);
|
||||
OLED_WR_Byte(0x02,OLED_CMD);
|
||||
|
||||
OLED_WR_Byte(0xdb,OLED_CMD);
|
||||
OLED_WR_Byte(0x49,OLED_CMD);
|
||||
|
||||
OLED_WR_Byte(0x8d,OLED_CMD);
|
||||
OLED_WR_Byte(0x14,OLED_CMD);
|
||||
|
||||
OLED_WR_Byte(0xaf,OLED_CMD);
|
||||
OLED_Clear();
|
||||
}
|
41
board/TencentOS_tiny_EVB_MX_Plus/BSP/Hardware/OLED/oled.h
Normal file
41
board/TencentOS_tiny_EVB_MX_Plus/BSP/Hardware/OLED/oled.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef __OLED_H
|
||||
#define __OLED_H
|
||||
#include "stm32l4xx_hal.h"
|
||||
#include "stdlib.h"
|
||||
#define OLED_MODE 0
|
||||
#define OLED_SIZE 8
|
||||
#define XLevelL 0x00
|
||||
#define XLevelH 0x10
|
||||
#define Max_Column 128
|
||||
#define Max_Row 64
|
||||
#define Brightness 0xFF
|
||||
#define X_WIDTH 128
|
||||
#define Y_WIDTH 64
|
||||
//-----------------OLED IIC端口定义----------------
|
||||
//HAL_GPIO_WritePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState);
|
||||
#define OLED_SCLK_Clr() HAL_GPIO_WritePin(GPIOA,GPIO_PIN_7, GPIO_PIN_RESET);//SDA IIC接口的时钟信号
|
||||
#define OLED_SCLK_Set() HAL_GPIO_WritePin(GPIOA,GPIO_PIN_7, GPIO_PIN_SET);
|
||||
|
||||
#define OLED_SDIN_Clr() HAL_GPIO_WritePin(GPIOB,GPIO_PIN_4, GPIO_PIN_RESET);//SCL IIC接口的数据信号
|
||||
#define OLED_SDIN_Set() HAL_GPIO_WritePin(GPIOB,GPIO_PIN_4, GPIO_PIN_SET);
|
||||
|
||||
|
||||
#define OLED_CMD 0 //写命令
|
||||
#define OLED_DATA 1 //写数据
|
||||
|
||||
|
||||
//OLED接口控制用函数
|
||||
void OLED_ShowNum(uint8_t x,uint8_t y,uint32_t num,uint8_t len,uint8_t size);
|
||||
void OLED_ShowString(uint8_t x,uint8_t y, uint8_t *p,uint8_t Char_Size);
|
||||
void OLED_ShowChinese(uint8_t x,uint8_t y,uint8_t no);
|
||||
void OLED_DrawBMP(unsigned char x0, unsigned char y0,unsigned char x1, unsigned char y1,unsigned char BMP[]);
|
||||
|
||||
|
||||
|
||||
//OLED基础函数
|
||||
void OLED_Init(void);
|
||||
void OLED_Clear(void);
|
||||
void OLED_Display_On(void);
|
||||
void OLED_Display_Off(void);
|
||||
void OLED_Set_Pos(unsigned char x, unsigned char y);
|
||||
#endif
|
230
board/TencentOS_tiny_EVB_MX_Plus/BSP/Hardware/OLED/oledfont.h
Normal file
230
board/TencentOS_tiny_EVB_MX_Plus/BSP/Hardware/OLED/oledfont.h
Normal file
@@ -0,0 +1,230 @@
|
||||
#ifndef __OLEDFONT_H
|
||||
#define __OLEDFONT_H
|
||||
//常用ASCII表
|
||||
//偏移量32
|
||||
//ASCII字符集
|
||||
//偏移量32
|
||||
//大小:12*6
|
||||
/************************************6*8的点阵************************************/
|
||||
const unsigned char F6x8[][6] =
|
||||
{
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00},// sp
|
||||
{0x00, 0x00, 0x00, 0x2f, 0x00, 0x00},// !
|
||||
{0x00, 0x00, 0x07, 0x00, 0x07, 0x00},// "
|
||||
{0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14},// #
|
||||
{0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12},// $
|
||||
{0x00, 0x62, 0x64, 0x08, 0x13, 0x23},// %
|
||||
{0x00, 0x36, 0x49, 0x55, 0x22, 0x50},// &
|
||||
{0x00, 0x00, 0x05, 0x03, 0x00, 0x00},// '
|
||||
{0x00, 0x00, 0x1c, 0x22, 0x41, 0x00},// (
|
||||
{0x00, 0x00, 0x41, 0x22, 0x1c, 0x00},// )
|
||||
{0x00, 0x14, 0x08, 0x3E, 0x08, 0x14},// *
|
||||
{0x00, 0x08, 0x08, 0x3E, 0x08, 0x08},// +
|
||||
{0x00, 0x00, 0x00, 0xA0, 0x60, 0x00},// ,
|
||||
{0x00, 0x08, 0x08, 0x08, 0x08, 0x08},// -
|
||||
{0x00, 0x00, 0x60, 0x60, 0x00, 0x00},// .
|
||||
{0x00, 0x20, 0x10, 0x08, 0x04, 0x02},// /
|
||||
{0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E},// 0
|
||||
{0x00, 0x00, 0x42, 0x7F, 0x40, 0x00},// 1
|
||||
{0x00, 0x42, 0x61, 0x51, 0x49, 0x46},// 2
|
||||
{0x00, 0x21, 0x41, 0x45, 0x4B, 0x31},// 3
|
||||
{0x00, 0x18, 0x14, 0x12, 0x7F, 0x10},// 4
|
||||
{0x00, 0x27, 0x45, 0x45, 0x45, 0x39},// 5
|
||||
{0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30},// 6
|
||||
{0x00, 0x01, 0x71, 0x09, 0x05, 0x03},// 7
|
||||
{0x00, 0x36, 0x49, 0x49, 0x49, 0x36},// 8
|
||||
{0x00, 0x06, 0x49, 0x49, 0x29, 0x1E},// 9
|
||||
{0x00, 0x00, 0x36, 0x36, 0x00, 0x00},// :
|
||||
{0x00, 0x00, 0x56, 0x36, 0x00, 0x00},// ;
|
||||
{0x00, 0x08, 0x14, 0x22, 0x41, 0x00},// <
|
||||
{0x00, 0x14, 0x14, 0x14, 0x14, 0x14},// =
|
||||
{0x00, 0x00, 0x41, 0x22, 0x14, 0x08},// >
|
||||
{0x00, 0x02, 0x01, 0x51, 0x09, 0x06},// ?
|
||||
{0x00, 0x32, 0x49, 0x59, 0x51, 0x3E},// @
|
||||
{0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C},// A
|
||||
{0x00, 0x7F, 0x49, 0x49, 0x49, 0x36},// B
|
||||
{0x00, 0x3E, 0x41, 0x41, 0x41, 0x22},// C
|
||||
{0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C},// D
|
||||
{0x00, 0x7F, 0x49, 0x49, 0x49, 0x41},// E
|
||||
{0x00, 0x7F, 0x09, 0x09, 0x09, 0x01},// F
|
||||
{0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A},// G
|
||||
{0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F},// H
|
||||
{0x00, 0x00, 0x41, 0x7F, 0x41, 0x00},// I
|
||||
{0x00, 0x20, 0x40, 0x41, 0x3F, 0x01},// J
|
||||
{0x00, 0x7F, 0x08, 0x14, 0x22, 0x41},// K
|
||||
{0x00, 0x7F, 0x40, 0x40, 0x40, 0x40},// L
|
||||
{0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F},// M
|
||||
{0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F},// N
|
||||
{0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E},// O
|
||||
{0x00, 0x7F, 0x09, 0x09, 0x09, 0x06},// P
|
||||
{0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E},// Q
|
||||
{0x00, 0x7F, 0x09, 0x19, 0x29, 0x46},// R
|
||||
{0x00, 0x46, 0x49, 0x49, 0x49, 0x31},// S
|
||||
{0x00, 0x01, 0x01, 0x7F, 0x01, 0x01},// T
|
||||
{0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F},// U
|
||||
{0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F},// V
|
||||
{0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F},// W
|
||||
{0x00, 0x63, 0x14, 0x08, 0x14, 0x63},// X
|
||||
{0x00, 0x07, 0x08, 0x70, 0x08, 0x07},// Y
|
||||
{0x00, 0x61, 0x51, 0x49, 0x45, 0x43},// Z
|
||||
{0x00, 0x00, 0x7F, 0x41, 0x41, 0x00},// [
|
||||
{0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55},// 55
|
||||
{0x00, 0x00, 0x41, 0x41, 0x7F, 0x00},// ]
|
||||
{0x00, 0x04, 0x02, 0x01, 0x02, 0x04},// ^
|
||||
{0x00, 0x40, 0x40, 0x40, 0x40, 0x40},// _
|
||||
{0x00, 0x00, 0x01, 0x02, 0x04, 0x00},// '
|
||||
{0x00, 0x20, 0x54, 0x54, 0x54, 0x78},// a
|
||||
{0x00, 0x7F, 0x48, 0x44, 0x44, 0x38},// b
|
||||
{0x00, 0x38, 0x44, 0x44, 0x44, 0x20},// c
|
||||
{0x00, 0x38, 0x44, 0x44, 0x48, 0x7F},// d
|
||||
{0x00, 0x38, 0x54, 0x54, 0x54, 0x18},// e
|
||||
{0x00, 0x08, 0x7E, 0x09, 0x01, 0x02},// f
|
||||
{0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C},// g
|
||||
{0x00, 0x7F, 0x08, 0x04, 0x04, 0x78},// h
|
||||
{0x00, 0x00, 0x44, 0x7D, 0x40, 0x00},// i
|
||||
{0x00, 0x40, 0x80, 0x84, 0x7D, 0x00},// j
|
||||
{0x00, 0x7F, 0x10, 0x28, 0x44, 0x00},// k
|
||||
{0x00, 0x00, 0x41, 0x7F, 0x40, 0x00},// l
|
||||
{0x00, 0x7C, 0x04, 0x18, 0x04, 0x78},// m
|
||||
{0x00, 0x7C, 0x08, 0x04, 0x04, 0x78},// n
|
||||
{0x00, 0x38, 0x44, 0x44, 0x44, 0x38},// o
|
||||
{0x00, 0xFC, 0x24, 0x24, 0x24, 0x18},// p
|
||||
{0x00, 0x18, 0x24, 0x24, 0x18, 0xFC},// q
|
||||
{0x00, 0x7C, 0x08, 0x04, 0x04, 0x08},// r
|
||||
{0x00, 0x48, 0x54, 0x54, 0x54, 0x20},// s
|
||||
{0x00, 0x04, 0x3F, 0x44, 0x40, 0x20},// t
|
||||
{0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C},// u
|
||||
{0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C},// v
|
||||
{0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C},// w
|
||||
{0x00, 0x44, 0x28, 0x10, 0x28, 0x44},// x
|
||||
{0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C},// y
|
||||
{0x00, 0x44, 0x64, 0x54, 0x4C, 0x44},// z
|
||||
{0x14, 0x14, 0x14, 0x14, 0x14, 0x14},// horiz lines
|
||||
};
|
||||
/****************************************8*16的点阵************************************/
|
||||
const unsigned char F8X16[]=
|
||||
{
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0
|
||||
0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,//! 1
|
||||
0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//" 2
|
||||
0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,//# 3
|
||||
0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,//$ 4
|
||||
0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,//% 5
|
||||
0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,//& 6
|
||||
0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//' 7
|
||||
0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,//( 8
|
||||
0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,//) 9
|
||||
0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,//* 10
|
||||
0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,//+ 11
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,//, 12
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,//- 13
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,//. 14
|
||||
0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,/// 15
|
||||
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,//0 16
|
||||
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//1 17
|
||||
0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//2 18
|
||||
0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//3 19
|
||||
0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//4 20
|
||||
0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//5 21
|
||||
0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//6 22
|
||||
0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//7 23
|
||||
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//8 24
|
||||
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//9 25
|
||||
0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,//: 26
|
||||
0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,//; 27
|
||||
0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,//< 28
|
||||
0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//= 29
|
||||
0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,//> 30
|
||||
0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,//? 31
|
||||
0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,//@ 32
|
||||
0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,//A 33
|
||||
0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,//B 34
|
||||
0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,//C 35
|
||||
0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,//D 36
|
||||
0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,//E 37
|
||||
0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,//F 38
|
||||
0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,//G 39
|
||||
0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,//H 40
|
||||
0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//I 41
|
||||
0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,//J 42
|
||||
0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,//K 43
|
||||
0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,//L 44
|
||||
0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,//M 45
|
||||
0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,//N 46
|
||||
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,//O 47
|
||||
0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,//P 48
|
||||
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,//Q 49
|
||||
0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,//R 50
|
||||
0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,//S 51
|
||||
0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//T 52
|
||||
0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//U 53
|
||||
0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,//V 54
|
||||
0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,//W 55
|
||||
0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,//X 56
|
||||
0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//Y 57
|
||||
0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,//Z 58
|
||||
0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,//[ 59
|
||||
0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,//\ 60
|
||||
0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,//] 61
|
||||
0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//^ 62
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,//_ 63
|
||||
0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//` 64
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,//a 65
|
||||
0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,//b 66
|
||||
0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,//c 67
|
||||
0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,//d 68
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,//e 69
|
||||
0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//f 70
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,//g 71
|
||||
0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//h 72
|
||||
0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//i 73
|
||||
0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,//j 74
|
||||
0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,//k 75
|
||||
0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//l 76
|
||||
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,//m 77
|
||||
0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//n 78
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//o 79
|
||||
0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,//p 80
|
||||
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,//q 81
|
||||
0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,//r 82
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,//s 83
|
||||
0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,//t 84
|
||||
0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,//u 85
|
||||
0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,//v 86
|
||||
0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,//w 87
|
||||
0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,//x 88
|
||||
0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,//y 89
|
||||
0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,//z 90
|
||||
0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,//{ 91
|
||||
0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,//| 92
|
||||
0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,//} 93
|
||||
0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~ 94
|
||||
};
|
||||
char Hzk[][32]={
|
||||
|
||||
{0x40,0x3C,0x10,0xFF,0x10,0x10,0x20,0x10,0x8F,0x78,0x08,0xF8,0x08,0xF8,0x00,0x00},
|
||||
{0x02,0x06,0x02,0xFF,0x01,0x01,0x04,0x42,0x21,0x18,0x46,0x81,0x40,0x3F,0x00,0x00},/*"物",0*/
|
||||
/* (16 X 16 , 宋体 )*/
|
||||
|
||||
{0x02,0xFE,0x92,0x92,0xFE,0x02,0x00,0x10,0x11,0x16,0xF0,0x14,0x13,0x10,0x00,0x00},
|
||||
{0x10,0x1F,0x08,0x08,0xFF,0x04,0x81,0x41,0x31,0x0D,0x03,0x0D,0x31,0x41,0x81,0x00},/*"联",1*/
|
||||
/* (16 X 16 , 宋体 )*/
|
||||
|
||||
{0x00,0xFE,0x02,0x22,0x42,0x82,0x72,0x02,0x22,0x42,0x82,0x72,0x02,0xFE,0x00,0x00},
|
||||
{0x00,0xFF,0x10,0x08,0x06,0x01,0x0E,0x10,0x08,0x06,0x01,0x4E,0x80,0x7F,0x00,0x00},/*"网",2*/
|
||||
/* (16 X 16 , 宋体 )*/
|
||||
|
||||
{0x00,0x80,0x60,0xF8,0x07,0x00,0xFE,0x52,0x52,0x52,0x52,0x52,0xFE,0x00,0x00,0x00},
|
||||
{0x01,0x00,0x00,0xFF,0x08,0x88,0x4F,0x29,0x09,0x09,0x09,0x29,0x4F,0x88,0x08,0x00},/*"俱",3*/
|
||||
/* (16 X 16 , 宋体 )*/
|
||||
|
||||
{0x00,0x00,0xE0,0x9C,0x84,0x84,0x84,0xF4,0x82,0x82,0x83,0x82,0x80,0x80,0x00,0x00},
|
||||
{0x00,0x20,0x10,0x08,0x06,0x40,0x80,0x7F,0x00,0x00,0x02,0x04,0x08,0x30,0x00,0x00},/*"乐",4*/
|
||||
/* (16 X 16 , 宋体 )*/
|
||||
|
||||
{0x40,0x44,0x54,0x65,0x46,0x44,0x64,0x54,0x44,0x40,0xFE,0x02,0x22,0xDA,0x06,0x00},
|
||||
{0x00,0x00,0x7E,0x22,0x22,0x22,0x22,0x7E,0x00,0x00,0xFF,0x08,0x10,0x08,0x07,0x00},/*"部",5*/
|
||||
/* (16 X 16 , 宋体 )*/
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user