Robobo
|
#include "chip.h"
#include <stdlib.h>
#include <assert.h>
Functions | |
void | TWI_ConfigureMaster (Twi *pTwi, uint32_t dwTwCk, uint32_t dwMCk) |
Configures a TWI peripheral to operate in master mode, at the given frequency (in Hz). The duty cycle of the TWI clock is set to 50%. More... | |
void | TWI_SetClock (Twi *pTwi, uint32_t dwTwCk, uint32_t dwMCk) |
void | TWI_ConfigureSlave (Twi *pTwi, uint8_t slaveAddress) |
Configures a TWI peripheral to operate in slave mode. More... | |
void | TWI_Disable (Twi *pTwi) |
Disables the TWI. More... | |
void | TWI_Stop (Twi *pTwi) |
Sends a STOP condition on the TWI. More... | |
void | TWI_StartRead (Twi *pTwi, uint8_t address, uint32_t iaddress, uint8_t isize) |
Starts a read operation on the TWI bus with the specified slave, it returns immediately. Data must then be read using TWI_ReadByte() whenever a byte is available (poll using TWI_ByteReceived()). More... | |
uint8_t | TWI_ReadByte (Twi *pTwi) |
Reads a byte from the TWI bus. The read operation must have been started using TWI_StartRead() and a byte must be available (check with TWI_ByteReceived()). More... | |
void | TWI_WriteByte (Twi *pTwi, uint8_t byte) |
Sends a byte of data to one of the TWI slaves on the bus. More... | |
void | TWI_StartWrite (Twi *pTwi, uint8_t address, uint32_t iaddress, uint8_t isize, uint8_t byte) |
Starts a write operation on the TWI to access the selected slave, then returns immediately. A byte of data must be provided to start the write; other bytes are written next. after that to send the remaining bytes. More... | |
uint8_t | TWI_ByteReceived (Twi *pTwi) |
Check if a byte have been receiced from TWI. More... | |
uint8_t | TWI_ByteSent (Twi *pTwi) |
Check if a byte have been sent to TWI. More... | |
uint8_t | TWI_TransferComplete (Twi *pTwi) |
Check if current transmission is complet. More... | |
void | TWI_EnableIt (Twi *pTwi, uint32_t sources) |
Enables the selected interrupts sources on a TWI peripheral. More... | |
void | TWI_DisableIt (Twi *pTwi, uint32_t sources) |
Disables the selected interrupts sources on a TWI peripheral. More... | |
uint32_t | TWI_GetStatus (Twi *pTwi) |
Get the current status register of the given TWI peripheral. More... | |
uint32_t | TWI_GetMaskedStatus (Twi *pTwi) |
Returns the current status register of the given TWI peripheral, but masking interrupt sources which are not currently enabled. More... | |
void | TWI_SendSTOPCondition (Twi *pTwi) |
Sends a STOP condition. STOP Condition is sent just after completing the current byte transmission in master read mode. More... | |
Implementation of Two Wire Interface (TWI).
uint8_t TWI_ByteReceived | ( | Twi * | pTwi | ) |
Check if a byte have been receiced from TWI.
pTwi | Pointer to an Twi instance. |
uint8_t TWI_ByteSent | ( | Twi * | pTwi | ) |
Check if a byte have been sent to TWI.
pTwi | Pointer to an Twi instance. |
void TWI_ConfigureMaster | ( | Twi * | pTwi, |
uint32_t | dwTwCk, | ||
uint32_t | dwMCk | ||
) |
Configures a TWI peripheral to operate in master mode, at the given frequency (in Hz). The duty cycle of the TWI clock is set to 50%.
pTwi | Pointer to an Twi instance. |
twck | Desired TWI clock frequency. |
mck | Master clock frequency. |
void TWI_ConfigureSlave | ( | Twi * | pTwi, |
uint8_t | slaveAddress | ||
) |
Configures a TWI peripheral to operate in slave mode.
pTwi | Pointer to an Twi instance. |
slaveAddress | Slave address. |
void TWI_DisableIt | ( | Twi * | pTwi, |
uint32_t | sources | ||
) |
Disables the selected interrupts sources on a TWI peripheral.
pTwi | Pointer to an Twi instance. |
sources | Bitwise OR of selected interrupt sources. |
void TWI_EnableIt | ( | Twi * | pTwi, |
uint32_t | sources | ||
) |
Enables the selected interrupts sources on a TWI peripheral.
pTwi | Pointer to an Twi instance. |
sources | Bitwise OR of selected interrupt sources. |
uint32_t TWI_GetMaskedStatus | ( | Twi * | pTwi | ) |
Returns the current status register of the given TWI peripheral, but masking interrupt sources which are not currently enabled.
pTwi | Pointer to an Twi instance. |
uint32_t TWI_GetStatus | ( | Twi * | pTwi | ) |
Get the current status register of the given TWI peripheral.
pTwi | Pointer to an Twi instance. |
uint8_t TWI_ReadByte | ( | Twi * | pTwi | ) |
Reads a byte from the TWI bus. The read operation must have been started using TWI_StartRead() and a byte must be available (check with TWI_ByteReceived()).
pTwi | Pointer to an Twi instance. |
void TWI_SendSTOPCondition | ( | Twi * | pTwi | ) |
Sends a STOP condition. STOP Condition is sent just after completing the current byte transmission in master read mode.
pTwi | Pointer to an Twi instance. |
void TWI_StartRead | ( | Twi * | pTwi, |
uint8_t | address, | ||
uint32_t | iaddress, | ||
uint8_t | isize | ||
) |
Starts a read operation on the TWI bus with the specified slave, it returns immediately. Data must then be read using TWI_ReadByte() whenever a byte is available (poll using TWI_ByteReceived()).
pTwi | Pointer to an Twi instance. |
address | Slave address on the bus. |
iaddress | Optional internal address bytes. |
isize | Number of internal address bytes. |
void TWI_StartWrite | ( | Twi * | pTwi, |
uint8_t | address, | ||
uint32_t | iaddress, | ||
uint8_t | isize, | ||
uint8_t | byte | ||
) |
Starts a write operation on the TWI to access the selected slave, then returns immediately. A byte of data must be provided to start the write; other bytes are written next. after that to send the remaining bytes.
pTwi | Pointer to an Twi instance. |
address | Address of slave to acccess on the bus. |
iaddress | Optional slave internal address. |
isize | Number of internal address bytes. |
byte | First byte to send. |
void TWI_Stop | ( | Twi * | pTwi | ) |
Sends a STOP condition on the TWI.
pTwi | Pointer to an Twi instance. |
uint8_t TWI_TransferComplete | ( | Twi * | pTwi | ) |
Check if current transmission is complet.
pTwi | Pointer to an Twi instance. |
void TWI_WriteByte | ( | Twi * | pTwi, |
uint8_t | byte | ||
) |
Sends a byte of data to one of the TWI slaves on the bus.
pTwi | Pointer to an Twi instance. |
byte | Byte to send. |