Switches SPI and I2C to use enums in the HAL for ports (#531)

Closes #397
This commit is contained in:
Thad House
2017-05-09 12:12:46 -07:00
committed by Peter Johnson
parent 67d62ba164
commit b2f3479692
14 changed files with 198 additions and 183 deletions

View File

@@ -31,7 +31,7 @@ extern "C" {
* If opening the MXP port, also sets up the channel functions appropriately
* @param port The port to open, 0 for the on-board, 1 for the MXP.
*/
void HAL_InitializeI2C(int32_t port, int32_t* status) {
void HAL_InitializeI2C(HAL_I2CPort port, int32_t* status) {
initializeDigital(status);
if (*status != 0) return;
@@ -80,7 +80,7 @@ void HAL_InitializeI2C(int32_t port, int32_t* status) {
* @param receiveSize Number of bytes to read from the device.
* @return >= 0 on success or -1 on transfer abort.
*/
int32_t HAL_TransactionI2C(int32_t port, int32_t deviceAddress,
int32_t HAL_TransactionI2C(HAL_I2CPort port, int32_t deviceAddress,
uint8_t* dataToSend, int32_t sendSize,
uint8_t* dataReceived, int32_t receiveSize) {
if (port > 1) {
@@ -112,8 +112,8 @@ int32_t HAL_TransactionI2C(int32_t port, int32_t deviceAddress,
* @param data The byte to write to the register on the device.
* @return >= 0 on success or -1 on transfer abort.
*/
int32_t HAL_WriteI2C(int32_t port, int32_t deviceAddress, uint8_t* dataToSend,
int32_t sendSize) {
int32_t HAL_WriteI2C(HAL_I2CPort port, int32_t deviceAddress,
uint8_t* dataToSend, int32_t sendSize) {
if (port > 1) {
// Set port out of range error here
return -1;
@@ -142,7 +142,7 @@ int32_t HAL_WriteI2C(int32_t port, int32_t deviceAddress, uint8_t* dataToSend,
* device.
* @return >= 0 on success or -1 on transfer abort.
*/
int32_t HAL_ReadI2C(int32_t port, int32_t deviceAddress, uint8_t* buffer,
int32_t HAL_ReadI2C(HAL_I2CPort port, int32_t deviceAddress, uint8_t* buffer,
int32_t count) {
if (port > 1) {
// Set port out of range error here
@@ -159,7 +159,7 @@ int32_t HAL_ReadI2C(int32_t port, int32_t deviceAddress, uint8_t* buffer,
}
}
void HAL_CloseI2C(int32_t port) {
void HAL_CloseI2C(HAL_I2CPort port) {
if (port > 1) {
// Set port out of range error here
return;