# MIOS32_SRIO

## Functions
s32 | MIOS32_SRIO_Init (u32 mode)
u8 | MIOS32_SRIO_ScanNumGet (void)
s32 | MIOS32_SRIO_ScanNumSet (u8 new_num_sr)
s32 | MIOS32_SRIO_DoutPageGet (void)
u32 | MIOS32_SRIO_DebounceGet (void)
s32 | MIOS32_SRIO_DebounceSet (u8 _debounce_time)
s32 | MIOS32_SRIO_DebounceStart (void)
s32 | MIOS32_SRIO_ScanStart (void *_notify_hook)
## Variables
volatile u8 | mios32_srio_dout [MIOS32_SRIO_NUM_DOUT_PAGES][MIOS32_SRIO_NUM_SR]
volatile u8 | mios32_srio_din [MIOS32_SRIO_NUM_SR]
volatile u8 | mios32_srio_din_buffer [MIOS32_SRIO_NUM_SR]
volatile u8 | mios32_srio_din_changed [MIOS32_SRIO_NUM_SR]

## Detailed Description

SRIO Driver for MIOS32

## Function Documentation

u32 MIOS32_SRIO_DebounceGet | ( | void |  | ) |

Returns the debounce counter reload value of the DIN SR registers

Returns:
  debounce counter reload value (0 if disabled, otherwise 1..255)

s32 MIOS32_SRIO_DebounceSet | ( | u8 | _debounce_time | ) |

Sets the debounce counter reload value for the DIN SR registers which are not assigned to rotary encoders (or other drivers which get use of MIOS32_DIN_SRChangedGetAndClear()) to debounce low-quality buttons.

Debouncing is realized in the following way: on every button movement the debounce preload value will be loaded into the debounce counter register. The counter will be decremented on every SRIO update cycle (usually 1 mS) As long as this counter isn't zero, button changes will still be recorded, but they won't trigger the APP_DIN_NotifyToggle hook.

No (intended) button movement will get lost, but the latency will be increased. Example: if the update frequency is set to 1 mS, and the debounce value to 32, the first button movement will be regognized with a worst-case latency of 1 mS. Every additional button movement which happens within 32 mS will be regognized within a worst-case latency of 32 mS. After the debounce time has passed, the worst-case latency is 1 mS again.

This function affects all DIN registers. If the application should record pin changes from digital sensors which are switching very fast, then debouncing should be ommited.

Parameters:

  `[in]` | debounce_time | delay in mS (1..255) 0 disables debouncing (default)

Returns:
  < 0 on errors

s32 MIOS32_SRIO_DebounceStart | ( | void |  | ) |

Internally used function to start the debounce delay after a button has been moved.
This function is used by MIOS32_DIN_Handler(), there is no need to use it in a common application.

Returns:
  < 0 on errors

s32 MIOS32_SRIO_DoutPageGet | ( | void |  | ) |

Returns:
  the DOUT page which is currently active (counted from 0)
  (changes with each SRIO update cycle)

s32 MIOS32_SRIO_Init | ( | u32 | mode | ) |

Initializes SPI pins and peripheral

Parameters:

  `[in]` | mode | currently only mode 0 supported

Returns:
  < 0 if initialisation failed

Here is the call graph for this function:

u8 MIOS32_SRIO_ScanNumGet | ( | void |  | ) |

Returns the number of SRs which will be scanned by the SRIO driver

Returns:
  number of SRs

s32 MIOS32_SRIO_ScanNumSet | ( | u8 | new_num_sr | ) |

Allows to change the number of SRs which will be scanned by the SRIO driver during runtime.

Parameters:

  `[in]` | new_num_sr | must be lower or equal MIOS32_SRIO_NUM_SR

Returns:
  != 0 on errors

s32 MIOS32_SRIO_ScanStart | ( | void * | _notify_hook | ) |

(Re-)Starts the SPI IRQ Handler which scans the SRIO chain

Parameters:

  `[in]` | _notify_hook | notification function which will be called after the scan has been finished (all DOUT registers written, all DIN registers read) use NULL if no function should be called

Returns:
  < 0 if operation failed

Here is the call graph for this function:

## Variable Documentation

volatile u8 mios32_srio_din[MIOS32_SRIO_NUM_SR]

volatile u8 mios32_srio_din_buffer[MIOS32_SRIO_NUM_SR]

volatile u8 mios32_srio_din_changed[MIOS32_SRIO_NUM_SR]

volatile u8 mios32_srio_dout[MIOS32_SRIO_NUM_DOUT_PAGES][MIOS32_SRIO_NUM_SR]