Разработка, производство и продажа радиоэлектронной аппаратуры
|
Требуется программист в Зеленограде - обработка данных с датчиков; ColdFire; 40 тыс.
e-mail: jobsmp@pochta.ru
|
void readi2c(u8 slave,u8 reg)
{
int i;
u8 f,d;
GPIO_ResetBits(GPIOB, GPIO_Pin_6);
Delay(100);
GPIO_ResetBits(GPIOB, GPIO_Pin_7);
Delay(100);
d=slave;
f=0x80;
for(i=0;i<8;i++)
{
if (d&f) GPIO_SetBits(GPIOB, GPIO_Pin_6);
Delay(100);
GPIO_SetBits(GPIOB, GPIO_Pin_7);
Delay(100);
GPIO_ResetBits(GPIOB, GPIO_Pin_7);
Delay(100);
GPIO_ResetBits(GPIOB, GPIO_Pin_6);
f=f>>1;
}
//GPIO_SetBits(GPIOB, GPIO_Pin_6);
//if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_6))USART_SendData(USART1,0x30);
//else USART_SendData(USART1,0x31);
//GPIO_ResetBits(GPIOB, GPIO_Pin_6);
Delay(100);
GPIO_SetBits(GPIOB, GPIO_Pin_7);
Delay(100);
GPIO_ResetBits(GPIOB, GPIO_Pin_7);
Delay(100); //ack
d=reg;
f=0x80;
for(i=0;i<8;i++)
{
if (d&f) GPIO_SetBits(GPIOB, GPIO_Pin_6);
Delay(100);
GPIO_SetBits(GPIOB, GPIO_Pin_7);
Delay(100);
GPIO_ResetBits(GPIOB, GPIO_Pin_7);
Delay(100);
GPIO_ResetBits(GPIOB, GPIO_Pin_6);
f=f>>1;
}
//GPIO_SetBits(GPIOB, GPIO_Pin_6);
//if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_6))USART_SendData(USART1,0x30);
//else USART_SendData(USART1,0x31);
//GPIO_ResetBits(GPIOB, GPIO_Pin_6);
Delay(100);
GPIO_SetBits(GPIOB, GPIO_Pin_7);
Delay(100);
GPIO_ResetBits(GPIOB, GPIO_Pin_7);
Delay(100); //ack
GPIO_SetBits(GPIOB, GPIO_Pin_6);
Delay(100);
GPIO_SetBits(GPIOB, GPIO_Pin_7);
Delay(100);
GPIO_ResetBits(GPIOB, GPIO_Pin_6);
Delay(100);
GPIO_ResetBits(GPIOB, GPIO_Pin_7);
Delay(100);
d=slave+1;
f=0x80;
for(i=0;i<8;i++)
{
if (d&f) GPIO_SetBits(GPIOB, GPIO_Pin_6);
Delay(100);
GPIO_SetBits(GPIOB, GPIO_Pin_7);
Delay(100);
GPIO_ResetBits(GPIOB, GPIO_Pin_7);
Delay(100);
GPIO_ResetBits(GPIOB, GPIO_Pin_6);
f=f>>1;
}
//GPIO_SetBits(GPIOB, GPIO_Pin_6);
//if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_6))USART_SendData(USART1,0x30);
//else USART_SendData(USART1,0x31);
//GPIO_ResetBits(GPIOB, GPIO_Pin_6);
Delay(100);
GPIO_SetBits(GPIOB, GPIO_Pin_7);
Delay(100);
GPIO_ResetBits(GPIOB, GPIO_Pin_7);
Delay(100); //ack
GPIO_SetBits(GPIOB, GPIO_Pin_6);
f=0x80;
for(i=0;i<8;i++)
{
if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_6))USART_SendData(USART1,0x31);
else USART_SendData(USART1,0x30);
Delay(1000);
GPIO_SetBits(GPIOB, GPIO_Pin_7);
Delay(100);
GPIO_ResetBits(GPIOB, GPIO_Pin_7);
Delay(100);
f=f>>1;
}
Delay(100);
GPIO_SetBits(GPIOB, GPIO_Pin_7);
Delay(100);
GPIO_ResetBits(GPIOB, GPIO_Pin_7);
Delay(100);
GPIO_SetBits(GPIOB, GPIO_Pin_7);
Delay(100);
GPIO_SetBits(GPIOB, GPIO_Pin_6);
Delay(100);
}
Составить ответ | Вернуться на конференцию
Ответы