generated from hulk/gd32e23x_template
recevice function
This commit is contained in:
67
src/main.c
67
src/main.c
@@ -40,6 +40,23 @@ void led_config(void)
|
||||
nvic_irq_enable(LED_IRQ, 2);
|
||||
}
|
||||
|
||||
void iicSendData(void)
|
||||
{
|
||||
while (i2c_flag_get(I2C0, I2C_FLAG_I2CBSY));
|
||||
i2c_start_on_bus(I2C0);
|
||||
printf("1\r\n");
|
||||
while (!i2c_flag_get(I2C0, I2C_FLAG_SBSEND));
|
||||
i2c_master_addressing(I2C0, LDC1612_ADDR, I2C_TRANSMITTER);
|
||||
printf("2\r\n");
|
||||
while (!i2c_flag_get(I2C0, I2C_FLAG_ADDSEND));
|
||||
i2c_flag_clear(I2C0, I2C_FLAG_ADDSEND);
|
||||
printf("3\r\n");
|
||||
while (!i2c_flag_get(I2C0, I2C_FLAG_TBE));
|
||||
i2c_data_transmit(I2C0, 0x7E);
|
||||
printf("4\r\n");
|
||||
i2c_start_on_bus(I2C0);
|
||||
}
|
||||
|
||||
void iicReceiveData(void)
|
||||
{
|
||||
uint16_t data[3] = {0};
|
||||
@@ -87,11 +104,11 @@ int main(void)
|
||||
printf("XLSW-3DP-LDC1612! V0.0.1\r\n");
|
||||
printf("\r\n");
|
||||
|
||||
uint16_t data[3] = {0};
|
||||
// uint16_t data[3] = {0};
|
||||
|
||||
// I2C _scan();
|
||||
|
||||
delay_ms(1000);
|
||||
delay_ms(200);
|
||||
|
||||
// while (i2c_flag_get(I2C0, I2C_FLAG_I2CBSY));
|
||||
// i2c_start_on_bus(I2C0);
|
||||
@@ -105,51 +122,35 @@ int main(void)
|
||||
// while (!i2c_flag_get(I2C0, I2C_FLAG_TBE));
|
||||
// i2c_data_transmit(I2C0, 0x7E);
|
||||
// printf("4\r\n");
|
||||
//
|
||||
// // delay_us(2);
|
||||
// while (!i2c_flag_get(I2C0, I2C_FLAG_TBE));
|
||||
//
|
||||
// // i2c_start_on_bus(I2C0);
|
||||
// i2c_start_on_bus(I2C0);
|
||||
// // i2c_stop_on_bus(I2C0);
|
||||
|
||||
|
||||
// delay_ms(100);
|
||||
// i2c_start_on_bus(I2C0);
|
||||
// delay_ms(100);
|
||||
// i2c_stop_on_bus(I2C0);
|
||||
|
||||
|
||||
// printf("5\r\n");
|
||||
// while (!i2c_flag_get(I2C0, I2C_FLAG_SBSEND));
|
||||
// i2c_master_addressing(I2C0, LDC1612_ADDR, I2C_RECEIVER);
|
||||
// printf("6\r\n");
|
||||
// while (!i2c_flag_get(I2C0, I2C_FLAG_ADDSEND));
|
||||
// i2c_flag_clear(I2C0, I2C_FLAG_ADDSEND);
|
||||
// printf("7\r\n");
|
||||
// i2c_ack_config(I2C0, I2C_ACK_DISABLE);
|
||||
// while (!i2c_flag_get(I2C0, I2C_FLAG_RBNE));
|
||||
// data[0] = i2c_data_receive(I2C0);
|
||||
// while (!i2c_flag_get(I2C0, I2C_FLAG_RBNE));
|
||||
// data[1] = i2c_data_receive(I2C0);
|
||||
// while (!i2c_flag_get(I2C0, I2C_FLAG_RBNE));
|
||||
// data[2] = i2c_data_receive(I2C0);
|
||||
|
||||
//
|
||||
// i2c_stop_on_bus(I2C0);
|
||||
//
|
||||
// i2c_ack_config(I2C0, I2C_ACK_ENABLE);
|
||||
//
|
||||
// printf("data[0] = %x\r\n", data[0]);
|
||||
// printf("data[1] = %x\r\n", data[1]);
|
||||
// printf("data[2] = %x\r\n", data[2]);
|
||||
|
||||
|
||||
|
||||
|
||||
iicSendData();
|
||||
iicReceiveData();
|
||||
|
||||
// int result = 0;
|
||||
// result = LDC1612_IIC_read_16bits();
|
||||
// printf("result = %d\r\n", result);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
while(1){
|
||||
printf("OK!!!\r\n");
|
||||
|
||||
delay_ms(1000);
|
||||
// printf("OK!!!\r\n");
|
||||
//
|
||||
// delay_ms(1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user