#include "sceptre.h"#include "device.h"#include "ds18b20.h"Go to the source code of this file.
Functions | |
| int | thermo_open (struct _reent *p_reent, const char *p_name, int flags, int mode) |
| _ssize_t | thermo_read (struct _reent *p_reent, int file, void *p_dst, size_t dst_size) |
| _ssize_t | thermo_write (struct _reent *p_reent, int file, const void *p_src, size_t src_size) |
Variables | |
| device_table_entry_t | thermo_device |
Thermometer device driver.
Definition in file thermo_device.c.
| int thermo_open | ( | struct _reent * | p_reent, | |
| const char * | p_name, | |||
| int | flags, | |||
| int | mode | |||
| ) |
Open function for the thermometer device driver.
This function gets called when you do something like this:
FILE *p_thermometer = fopen("/thermo/","rw");
Note the forward slashes surrounding the "file" name. Everything that follows the string "/thermo/" is passed to this function in p_name, i.e.
FILE *p_thermometer = fopen("/thermo/alarm","rw");
will pass "alarm" 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 71 of file thermo_device.c.
| _ssize_t thermo_read | ( | struct _reent * | p_reent, | |
| int | file, | |||
| void * | p_dst, | |||
| size_t | dst_size | |||
| ) |
Read function for the thermometer device driver.
This function gets called when you do something like this after obtaining a valid FILE handle with fopen():
uint8_t data[9]; fread(data,sizeof(uint8_t),9,p_thermometer);
| 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 105 of file thermo_device.c.
| _ssize_t thermo_write | ( | struct _reent * | p_reent, | |
| int | file, | |||
| const void * | p_src, | |||
| size_t | src_size | |||
| ) |
Write function for the thermometer device driver.
This function gets called when you do something like this after obtaining a valid FILE handle with fopen():
uint32_t data = 0x12345678; fwrite(&data,sizeof(uint32_t),1,p_thermometer);
| p_reent | Pointer to a structure that will receive the return value. | |
| file | Handle of the file to write to. | |
| p_dst | Pointer to the data to write. | |
| dst_size | Number of bytes to write. |
Definition at line 131 of file thermo_device.c.
{
"thermo",
SCEPTRE_THERMOMETER,
thermo_open,
NULL,
thermo_read,
thermo_write,
NULL,
NULL
}
A pointer to this structure has to be registered in the device_table_list.
Definition at line 38 of file thermo_device.c.
1.6.2