# MIOS32_IIC_BS

## Functions
s32 | MIOS32_IIC_BS_Init (u32 mode)
s32 | MIOS32_IIC_BS_ScanBankSticks (void)
s32 | MIOS32_IIC_BS_CheckAvailable (u8 bs)
s32 | MIOS32_IIC_BS_Read (u8 bs, u16 address, u8 *buffer, u8 len)
s32 | MIOS32_IIC_BS_Write (u8 bs, u16 address, u8 *buffer, u8 len)
s32 | MIOS32_IIC_BS_CheckWriteFinished (u8 bs)

## Detailed Description

IIC BankStick layer for MIOS32

## Function Documentation

s32 MIOS32_IIC_BS_CheckAvailable | ( | u8 | bs | ) |

This function checks the availability of a BankStick taken from the last results of MIOS32_IIC_BS_ScanBankSticks

Parameters:

  `[in]` | bs | BankStick number (0-7)

Returns:
  >0: BankStick available, returns the size in bytes (e.g. 32768)
  0: BankStick not available

s32 MIOS32_IIC_BS_CheckWriteFinished | ( | u8 | bs | ) |

Has to be used after MIOS32_IIC_BS_Write (during write operation) to poll the device state

Parameters:

  `[in]` | bs | BankStick number (0-7)

Returns:
  1 if BankStick was available before, and now doesn't respond: write operation is in progress
  0 if BankStick available, write operation finished
  -1 if error during IIC transfer
  -2 if BankStick blocked by another task (retry it!)
  -3 if BankStick wasn't available at last scan

Here is the call graph for this function:

s32 MIOS32_IIC_BS_Init | ( | u32 | mode | ) |

Initializes BankSticks

Parameters:

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

Returns:
  < 0 if initialisation failed

Here is the call graph for this function:

s32 MIOS32_IIC_BS_Read | ( | u8 | bs,
|  | u16 | address,
|  | u8 * | buffer,
|  | u8 | len |
| ) |  |  |

Reads one or more bytes into a buffer

Parameters:

  `[in]` | bs | BankStick number (0-7)
  `[in]` | address | BankStick address (depends on size)
  `[out]` | buffer | destination buffer
  `[in]` | len | number of bytes which should be read (1..64)

Returns:
  0 if operation was successful
  -1 if error during IIC transfer
  -2 if BankStick blocked by another task (retry it!)
  -3 if BankStick wasn't available at last scan
  -4 if invalid length

Here is the call graph for this function:

s32 MIOS32_IIC_BS_ScanBankSticks | ( | void |  | ) |

Scans all BankSticks to check the availablility by sending dummy requests and checking the ACK response.

Per module, this procedure takes at least ca. 25 uS, if no module is connected ca. 75 uS (3 retries), or even more if we have to wait for completion of the previous IIC transfer. Therefore this function should only be rarely used (e.g. once per second), and the state should be saved somewhere in the application

Returns:
  0 if all BankSticks scanned
  -2 if BankStick blocked by another task (retry the scan!)

Here is the call graph for this function:

s32 MIOS32_IIC_BS_Write | ( | u8 | bs,
|  | u16 | address,
|  | u8 * | buffer,
|  | u8 | len |
| ) |  |  |

Writes one or more bytes into the BankStick

Parameters:

  `[in]` | bs | BankStick number (0-7)
  `[in]` | address | BankStick address (depends on size)
  `[in]` | buffer | source buffer
  `[in]` | len | number of bytes which should be written (1..64)

Returns:
  0 if operation was successful
  -1 if error during IIC transfer
  -2 if BankStick blocked by another task (retry it!)
  -3 if BankStick wasn't available at last scan
  -4 if invalid length

Note:
  Use MIOS32_IIC_BS_CheckWriteFinished to check when the write operation has been finished - this can take up to 5 mS!

Here is the call graph for this function: