More comments to LM35 part in cli.c and general comments to uart.c

master
_N0x 2 years ago
parent 6310b91164
commit da447a2efa

@ -353,14 +353,15 @@ static void cmd_adc(const char* _data){
if(Timer_getTick() - g_startMS >= loopInterval){
g_startMS=Timer_getTick();
// Print Potentiometer info
/* Print Potentiometer info */
sprintf(potiData, "Poti: %d", adc_get_poti());
//sprintf(potiData, "Poti: %f", (adc_get_poti() / 1023.0)); // uses floats - disabled for performance reasons.
print_string(potiData);
print_string(NEXT_LINE);
// Print LM35 temperature
lm35 = (int)(adc_get_LM35() * 5000.0 / 1024 / 10);
/* Print LM35 temperature */
/* calculate the temperature from the ADC reading */
lm35 = (int)(adc_get_LM35() * 5000.0 / 1024 / 10);
sprintf(lm35Data, "LM35: %d\xC2\xB0 C", lm35);
//sprintf(lm35Data, "LM35: %f\xC2\xB0 C", (adc_get_LM35() * (5000 / 1024.0) / 10)); // uses floats - disabled for performance reasons.
print_string(lm35Data);

@ -30,7 +30,7 @@ uart_init(void) {
(1<<RXCIE0); /* enable Receive interrupts */
/* Initiate read- and write-pointers */
/* Initiate read- and write-pointers with 0 */
pTxBuffer->Readpointer = 0;
pTxBuffer->Writepointer = 0;
pRxBuffer->Readpointer = 0;
@ -71,7 +71,7 @@ uart_send_byte(char c) {
UCSR0B |= (1<<TXCIE0);
}
/* when data (a data frame) is to be send */
/* when data (a data frame) is to be send (written to UDR0) */
ISR(USART0_TX_vect) {
/* check if the read and write pointer of the send buffer are not aligned
if not aligned -> read the next byte and write it to UDR0 register
@ -117,7 +117,7 @@ uart_get_data(void) {
if yes -> data is available and can be read */
if(pRxBuffer->Readpointer != pRxBuffer->Writepointer)
{
/* read a char from the buffer and increment the readpointer */
/* read a char from the buffer and increment the read pointer */
data = pRxBuffer->data[pRxBuffer->Readpointer++];
if(pRxBuffer->Readpointer >= SIZE_BUFFER){
pRxBuffer->Readpointer = 0;

Loading…
Cancel
Save