core/thermometer/thermo_device.c File Reference

#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

Detailed Description

Thermometer device driver.

Definition in file thermo_device.c.


Function Documentation

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.

Parameters:
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.
Returns:
A valid handle on success, -1 otherwise.

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);

Parameters:
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.
Returns:
The number of bytes read on success, -1 otherwise.

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);

Parameters:
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.
Returns:
The number of bytes written on success, -1 otherwise.

Definition at line 131 of file thermo_device.c.


Variable Documentation

Initial value:
{
  "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.

 All Data Structures Files Functions Variables Typedefs Enumerations Defines

Generated by  doxygen 1.6.2