#include "sceptre.h"#include "device.h"#include "accelero.h"#include <stdlib.h>Go to the source code of this file.
Functions | |
| int | accelero_dev_open (struct _reent *p_reent, const char *p_name, int flags, int mode) |
| _ssize_t | accelero_dev_read (struct _reent *p_reent, int file, void *p_dst, size_t dst_size) |
| _ssize_t | accelero_dev_close (struct _reent *p_reent, int file) |
Variables | |
| device_table_entry_t | accelero_device |
Accelerometer device driver implementation.
Definition in file accelero_device.c.
| _ssize_t accelero_dev_close | ( | struct _reent * | p_reent, | |
| int | file | |||
| ) |
Close function for the accelerometer device driver.
This function gets called when you do something like this after obtaining a valid FILE handle with fopen():
fclose(p_accelerometer);
Definition at line 125 of file accelero_device.c.
| int accelero_dev_open | ( | struct _reent * | p_reent, | |
| const char * | p_name, | |||
| int | flags, | |||
| int | mode | |||
| ) |
Open function for the accelerometer device driver.
This function gets called when you do something like this:
FILE *p_accelerometer = fopen("/accelero/","rw");
Note the forward slashes surrounding the "file" name. Everything that follows the string "/accelero/" is passed to this function in p_name, i.e.
FILE *p_accelerometer = fopen("/accelero/1000000","rw");
will pass "1000000" (adc clock frequency) in p_name to this function.
| p_reent | Pointer to a structure that will receive the return value. | |
| p_name | Pointer to the name of the file to open. | |
| flags | Flags. | |
| mode | Mode. |
Definition at line 72 of file accelero_device.c.
| _ssize_t accelero_dev_read | ( | struct _reent * | p_reent, | |
| int | file, | |||
| void * | p_dst, | |||
| size_t | dst_size | |||
| ) |
Read function for the accelerometer device driver.
This function gets called when you do something like this after obtaining a valid FILE handle with fopen():
float data[3]; fread(data,sizeof(float),3,p_accelerometer);
| p_reent | Pointer to a structure that will receive the return value. | |
| file | Handle of the file to read from. | |
| p_dst | Address to write the data to. | |
| dst_size | Number of bytes to read. |
Definition at line 98 of file accelero_device.c.
{
"accelero",
SCEPTRE_ACCELEROMETER,
accelero_dev_open,
accelero_dev_close,
accelero_dev_read,
NULL,
NULL,
NULL
}
A pointer to this structure has to be registered in the device_table_list.
Definition at line 39 of file accelero_device.c.
1.6.2