SWARM-Bot Firmware  v1.0
Mobile robot OS - Embedded C/C++
__adc__.h File Reference

Header file for adc.c. More...

#include <__swarm_wold__.h>
Include dependency graph for __adc__.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void _adc_init (void)
 
int _adc_read (uint8_t channel)
 

Detailed Description

Header file for adc.c.

  • File: adc.h
  • Compiler: GCC-AVR
  • Supported devices: Tested on 328p
  • AppNote: ADC module driver
Author
Swarm robot graduation project workgroub
Mechatronics Program for the Distinguished
$Name$
Revision
1

$RCSfile$

Date
/19/2021 9:30:13 AM

Definition in file __adc__.h.

Function Documentation

◆ _adc_init()

void _adc_init ( void  )

Initialize the ADC module

4 {
5  ADMUX = (1 << REFS0); // AVCC
6  //ADMUX |= (1 << REFS0) | (1 << REFS1); //1v1
7 
8  ADCSRA |= (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0) | (1 << ADEN); // Turn ADC On sample: 16M/128 = 125KHz
9  ADMUX |= (0 << ADLAR);
10  //ADMUX |= (1 << ADLAR); 8 bit
11 }

Referenced by board_init().

Here is the caller graph for this function:

◆ _adc_read()

int _adc_read ( uint8_t  channel)

Reads from

Parameters
channel
Parameters
[in]channeladc channel from PortC.
14 {
15  ADMUX |= channel & 0x0f;
16  ADCSRA |= (1 << ADSC);
17  while(ADCSRA & (1 << ADSC));
18  return ADCW;
19 }