2019-12-13 11:12 AM
I want to use ADS112U04 to read temperature (by enabling temperature sensor mode) and send this result to STM32F777VI via UART interface. How can I achieve this? I'm new to STM32. I have seen an example which does same with MSP430 microcontrollers, but I don't see such example with STM32f7 which reads external ADC. I have generated code from STM32CubeMX . How to initialize this adc, how to put or get any data to/from UART? Is it good to use HAL_UART_Trasnmit/HAL_UART_Receive for communication.?
I have started writing program to read ADC and it looks like:
static void ads112_write_reg(char reg, char data){
uart5_putc(SYNC); // send sync via uart
uart5_putc(CMD_WREG|(reg<<1));
uart5_putc(data);
}
static char ads112_read_reg(char reg){
uart5_putc(SYNC);
uart5_putc(CMD_RREG|(reg<<1));
while(!uart5_data_available());
return uart5_getc();
}
Now, I'm not sure what to write inside APIs name starting with uart5_ . Any suggestion would be great.
Regards,
Heli
2019-12-13 11:52 AM
>>Is it good to use HAL_UART_Transmit/HAL_UART_Receive for communication?
They are good for half-duplex, blocking functionality
ie
uint8_t data[] = { SYNC, CMD_RREG|(reg<<1) };
uint8_t response[1];
HAL_UART_Transmit(&uart5instance, data, sizeof(data), 100);
HAL_UART_Receive(&uart5instance, response, sizeof(response), 500);
return(response[0]);