Sonochan II 0.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
generic_driver.h File Reference

Generic driver. More...

`#include <inttypes.h>`
`#include <stdio.h>`

Go to the source code of this file.

## Data Structures
union | GD_DATA_VALUE
| For different data types is used union. More...
struct | gd_config_struct
| Structure for configuration table. More...
struct | gd_metadata
| Structure for metadata of specific hardware. More...

## Macros
#define | GD_MAX_STRING_SIZE 80
| Maximal size of text array for descriptors. More...
#define | GD_RES_CODE_DEFINED
#define | uint unsigned int
#define | gd_read_byte_ro_mem(p_address) *(p_address)
#define | gd_read_word_ro_mem(p_address) *(p_address)
#define | gd_read_dword_ro_mem(p_address) *(p_address)
#define | GD_POINTER_TO_FUNCTION

## Enumerations
enum | GD_RES_CODE { GD_SUCCESS = 0, GD_FAIL = 1, GD_INCORRECT_PARAMETER = 2, GD_INCORRECT_CMD_ID = 3, GD_CMD_ID_NOT_EQUAL_IN_FLASH = 4, GD_INCORRECT_DEVICE_ID = 5 }
| Error codes returned by functions. More...
enum | GD_DATA_TYPE { void_type = 0, char_type = 1, int_type = 2, int8_type = 3, int16_type = 4, int32_type = 5, uint_type = 6, uint8_type = 7, uint16_type = 8, uint32_type = 9, float_type = 10, group_type = 11 }
| Enum of supported data types as values. More...

## Functions
GD_RES_CODE | gd_get_setting (const gd_metadata *p_metadata, uint16_t i_cmd_ID, gd_config_struct *p_config_table)
| Get settings data from driver. More...
GD_RES_CODE | gd_set_setting (const gd_metadata *p_metadata, uint16_t i_cmd_ID, GD_DATA_VALUE i_data)
| Set settings data to driver. More...
GD_RES_CODE | gd_void_function (void)
| Void function. Do nothing. More...

## Variables
volatile GD_DATA_VALUE | gd_void_value
| Empty value. More...

## Detailed Description

Generic driver.

Important note for AVR8 architecture: functions, that read from
flash memory presume that constants are stored in low 64 kB of flash
memory. If not, please take a look at
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=93874

Created 26.08.2013
Modified 12.05.2014

Version
  1.3.1

Author
  Martin Stejskal

## Macro Definition Documentation

#define GD_MAX_STRING_SIZE 80

Maximal size of text array for descriptors.

Due to SRAM limitations it is recommended set this value to 80. However on
more powerful AVR it could be more.

#define GD_POINTER_TO_FUNCTION

Value:
switch(sizeof(p_size)) \
{ \
case 1: \
p_func = (void*) gd_read_byte_ro_mem(&p_flash->p_funtion); \
break; \
case 2: \
p_func = (void*) gd_read_word_ro_mem(&p_flash->p_funtion); \
break; \
case 4: \
p_func = (void*) gd_read_dword_ro_mem(&p_flash->p_funtion); \
break; \
default: \
while(1); \
}

#define gd_read_byte_ro_mem | ( |  | p_address) |  | *(p_address)

#define gd_read_dword_ro_mem | ( |  | p_address) |  | *(p_address)

#define gd_read_word_ro_mem | ( |  | p_address) |  | *(p_address)

#define GD_RES_CODE_DEFINED

#define uint unsigned int

## Enumeration Type Documentation

enum GD_DATA_TYPE

Enum of supported data types as values.

Note
  Every type should have defined number. It is not allowed to use
  number 255 or higher. Higher layers use number 255 (0xFF) as special
  signal that some exception was detected

Enumerator
void_type | void_type No data
char_type | char_type One character
int_type | int_type Signed integer
int8_type | int8_type 8 bit signed integer
int16_type | int16_type 16 bit signed integer
int32_type | int32_type 32 bit signed integer
uint_type | uint_type Unsigned integer
uint8_type | uint8_type 8 bit unsigned integer
uint16_type | uint16_type 16 bit unsigned integer
uint32_type | uint32_type 32 bit unsigned integer
float_type | float_type Float
group_type | group_type Dummy command. Just metadata for group

enum GD_RES_CODE

Error codes returned by functions.

Enumerator
GD_SUCCESS | GD_SUCCESS.
GD_FAIL | GD_FAIL.
GD_INCORRECT_PARAMETER | GD_INCORRECT_PARAMETER.
GD_INCORRECT_CMD_ID | GD_INCORRECT_CMD_ID.
GD_CMD_ID_NOT_EQUAL_IN_FLASH | GD_CMD_ID_NOT_EQUAL_IN_FLASH.
GD_INCORRECT_DEVICE_ID | GD_INCORRECT_DEVICE_ID.

## Function Documentation

GD_RES_CODE gd_get_setting | ( | const gd_metadata * | p_metadata,
|  | uint16_t | i_cmd_ID,
|  | gd_config_struct * | p_config_table
| ) |  |

Get settings data from driver.

Parameters

  p_metadata | Pointer to metadata of driver (max CMD ID and so on)
  i_cmd_ID | Command ID. Thru commands user can control target device
  p_config_table | Pointer to image of configure table - 1 structure. Settings will be saved to this structure

Returns
  GD_SUCCESS if all OK. Else please refer GD_RES_CODE

GD_RES_CODE gd_set_setting | ( | const gd_metadata * | p_metadata,
|  | uint16_t | i_cmd_ID,
|  | GD_DATA_VALUE | i_data
| ) |  |

Set settings data to driver.

Parameters

  p_metadata | Pointer to metadata of driver (max CMD ID and so on)
  i_cmd_ID | Command ID. Thru commands user can control target device.
  i_data | Data in union structure GD_DATA_VALUE

Returns
  GD_SUCCESS if all OK. Else please refer GD_RES_CODE

GD_RES_CODE gd_void_function | ( | void | ) |  |

Void function. Do nothing.

Sometimes is need to point to function, that does not do anything, so
there is

Returns
  Always GD_SUCCESS

## Variable Documentation

volatile GD_DATA_VALUE gd_void_value

Empty value.

Useful when called function has no parameter -> link to this "empty value"
-> no compilation problems, no reading problems