91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 8KB
    文件類型: .c
    金幣: 1
    下載: 0 次
    發布日期: 2021-06-10
  • 語言: 其他
  • 標簽: cypress??cy8cmbr3106s??

資源簡介

cypress觸摸芯片cy8cmbr3106s驅動程序,項目中正常使用。

資源截圖

代碼片段和文件信息


#include?“CY8CMBR3106S.h“
#define?I2C_ADDR?0x37
void?delay_us(uint32_t?nus)
{

??????uint32_t?ij;
??????for(i=nus;?i?!=?0;?i--)
??{
for(j=2;?j?!=?0;?j--);?
??}
}

static?void?SDA_IN()?
{
GPIO_InitTypeDef?GPIO_InitStruct;

??GPIO_InitStruct.Pin?=?GPIO_PIN_10;
??GPIO_InitStruct.Mode?=?GPIO_MODE_INPUT;
??GPIO_InitStruct.Pull?=?GPIO_PULLDOWN;//?GPIO_NOPULL;
??HAL_GPIO_Init(GPIOA?&GPIO_InitStruct);

}
static?void?SDA_OUT()
{
??
GPIO_InitTypeDef?GPIO_InitStruct;

GPIO_InitStruct.Pin?=?GPIO_PIN_10;
GPIO_InitStruct.Mode?=?GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull?=?GPIO_NOPULL;
GPIO_InitStruct.Speed?=?GPIO_SPEED_HIGH;
HAL_GPIO_Init(GPIOA?&GPIO_InitStruct);
//HAL_GPIO_WritePin(GPIOA?GPIO_PIN_10?GPIO_PIN_RESET);
}

static?void?SCL_IN()
{
GPIO_InitTypeDef?GPIO_InitStruct;

/*?GPIO?Ports?Clock?Enable?*/
// __GPIOC_CLK_ENABLE();
// __GPIOA_CLK_ENABLE();
// __GPIOB_CLK_ENABLE();

GPIO_InitStruct.Pin?=?GPIO_PIN_9;
GPIO_InitStruct.Mode?=?GPIO_MODE_INPUT;
GPIO_InitStruct.Pull?=?GPIO_PULLDOWN;//?GPIO_NOPULL;
HAL_GPIO_Init(GPIOA?&GPIO_InitStruct);
}
static?void?SCL_OUT()
{
GPIO_InitTypeDef?GPIO_InitStruct;

GPIO_InitStruct.Pin?=?GPIO_PIN_9;
GPIO_InitStruct.Mode?=?GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull?=?GPIO_NOPULL;
GPIO_InitStruct.Speed?=?GPIO_SPEED_HIGH;
HAL_GPIO_Init(GPIOA?&GPIO_InitStruct);
}

static?void?SDA_1()
{
HAL_GPIO_WritePin(GPIOA?GPIO_PIN_10?GPIO_PIN_SET);
}
static?void?SDA_0()
{
HAL_GPIO_WritePin(GPIOA?GPIO_PIN_10?GPIO_PIN_RESET);
}
static?void?SCL_1()
{
HAL_GPIO_WritePin(GPIOA?GPIO_PIN_9?GPIO_PIN_SET);
}
static?void?SCL_0()
{
HAL_GPIO_WritePin(GPIOA?GPIO_PIN_9?GPIO_PIN_RESET);
}

static?uint8_t?READ_SDA()
{

return?HAL_GPIO_ReadPin(GPIOAGPIO_PIN_10);
}
static?uint8_t?READ_SCL()
{

return?HAL_GPIO_ReadPin(GPIOAGPIO_PIN_9);
}
static?void?IIC_Init(void)
{ ?????
GPIO_InitTypeDef?GPIO_InitStruct;

/*?GPIO?Ports?Clock?Enable?*/
__GPIOC_CLK_ENABLE();
__GPIOA_CLK_ENABLE();
__GPIOB_CLK_ENABLE();

/*Configure?GPIO?pin?Output?Level?*/
//HAL_GPIO_WritePin(GPIOA?GPIO_PIN_12?GPIO_PIN_SET);

GPIO_InitStruct.Pin?=?GPIO_PIN_9|GPIO_PIN_10;
GPIO_InitStruct.Mode?=?GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull?=?GPIO_NOPULL;
GPIO_InitStruct.Speed?=?GPIO_SPEED_HIGH;
HAL_GPIO_Init(GPIOA?&GPIO_InitStruct);
}

static?void?IIC_Start(void)
{
SDA_OUT();?
//start//
SDA_0();
delay_us(10);
SCL_0();
delay_us(10);
} ??


static?void?IIC_Stop(void)
{
//stop
?? SDA_0();
delay_us(10);
SCL_1();
delay_us(10);
SDA_1();

delay_us(20); ???
}

static?uint8_t?IIC_Wait_Ack(void)
{
uint8_t?ucErrTime=0;
SDA_IN();??????
//SDA_1();
delay_us(10); ???
SCL_1();
delay_us(10); ?
//uint8_t?cur?=?READ_SDA();
while(READ_SDA())
{
ucErrTime++;
if(ucErrTime>250)
{
IIC_Stop();
return?1;
}
}
SCL_0();?
delay_us(20);
SDA_OUT();
return?0;??
}?


評論

共有 條評論