Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
adc_arch.c File Reference
#include "mcu_periph/adc.h"
#include <BOARD_CONFIG>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <poll.h>
+ Include dependency graph for adc_arch.c:

Go to the source code of this file.

Functions

static void adc_dev_init (struct adc_t *adc)
 Initialize an ADC device. More...
 
static void write_sysfs_int (uint8_t dev_id, char *filename, int val)
 Write an int to a sysfs file. More...
 
void adc_init (void)
 Initialize the ADC. More...
 
void adc_buf_channel (uint8_t adc_channel, struct adc_buf *s, uint8_t av_nb_sample)
 Link between ChibiOS ADC drivers and Paparazzi adc_buffers. More...
 
void adc_enable (struct adc_t *adc, uint8_t value)
 Start or stop the ADC readings. More...
 
int adc_read (struct adc_t *adc, uint16_t *buf, uint16_t size)
 Read the ADC buffer from the driver. More...
 

Detailed Description

Driver for the analog to digital converters in Linux based systems.

Definition in file adc_arch.c.

Function Documentation

◆ adc_buf_channel()

void adc_buf_channel ( uint8_t  adc_channel,
struct adc_buf s,
uint8_t  av_nb_sample 
)

Link between ChibiOS ADC drivers and Paparazzi adc_buffers.

Todo:
: fx a more general ADC

Definition at line 91 of file adc_arch.c.

◆ adc_dev_init()

static void adc_dev_init ( struct adc_t adc)
inlinestatic

Initialize an ADC device.

Parameters
[in]*adcThe ADC device to initialize

Definition at line 148 of file adc_arch.c.

References adc_t::buf_length, adc_t::channels, adc_t::channels_cnt, adc_t::dev_id, and write_sysfs_int().

Referenced by adc_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ adc_enable()

void adc_enable ( struct adc_t adc,
uint8_t  value 
)

Start or stop the ADC readings.

Parameters
[in]*adcThe ADC to start the readings for
[in]value1 to enable and 0 to disable

Definition at line 101 of file adc_arch.c.

References adc_t::dev_id, and write_sysfs_int().

Referenced by sonar_bebop_read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ adc_init()

void adc_init ( void  )

Initialize the ADC.

Starts conversions.

Definition at line 78 of file adc_arch.c.

References adc_dev_init().

+ Here is the call graph for this function:

◆ adc_read()

int adc_read ( struct adc_t adc,
uint16_t buf,
uint16_t  size 
)

Read the ADC buffer from the driver.

Parameters
[in]*adcThe adc you want to read from
[out]*bufOutput values
[in]sizeThe amount of bytes you want to read

Definition at line 113 of file adc_arch.c.

References adc_t::dev_id, and fd.

Referenced by sonar_bebop_read().

+ Here is the caller graph for this function:

◆ write_sysfs_int()

static void write_sysfs_int ( uint8_t  dev_id,
char *  filename,
int  val 
)
static

Write an int to a sysfs file.

Parameters
[in]dev_idThe device id
[in]*filenameThe file to write to
[in]valThe value to write

Definition at line 169 of file adc_arch.c.

References fd, and val.

Referenced by adc_dev_init(), and adc_enable().

+ Here is the caller graph for this function: