遥控驱动软件

stm8单片机HXD019驱动

2017-02-18 14:21:18  点击次数:5730

                                    STM8单片机和HXD019驱动程序范例

#include "stm8l15x.h"
#include "Spi_flash_hw.h"
#include "mcu_init.h"
 
#define  I2CERR_NO_ERROR 0
#define  Delay_Time  21 //28.5us 已校准//550 //H: 25uS-35uS
#define  DELAY_ST  20//20.07ms 已校准//19 //18mS-25mS
 
 
//extern unsigned char irda_data[232];
/*********************** SDA_PIN ************************/
void SetSDAInput(void) //数据信号端口:输入
{
//  GPIO_Init(GPIOC, GPIO_Pin_0, GPIO_Mode_In_PU_No_IT); //设置端口上拉输入无中断
  GPIOC->DDR &= (uint8_t)(~GPIO_Pin_0);
 
//  GPIOC->CR1 |= GPIO_Pin_0;
  GPIOC->CR1 &= (uint8_t)(~GPIO_Pin_0);
 
  GPIOC->CR2 &= (uint8_t)(~GPIO_Pin_0);
  GPIOC->ODR |= GPIO_Pin_0;
 
 
/*********************** 开启 IIC ************************/
u16 I2COpen(void)
{
  SetSDAOutput(); 
//  SetSCLOutput();
 
  SetSCLHigh();
  SetSDAHigh();
  
  return I2CERR_NO_ERROR; 
}
 
 
/*********************** 关闭 IIC ************************/
u16 I2CClose(void)   
{
  SetSDAOutput(); 
//  SetSCLOutput(); 
  
  SetSCLHigh();
  SetSDAHigh();
  
  return I2CERR_NO_ERROR; 
}