Name a couple of I2C related variables more intuitively.

This commit is contained in:
László Monda
2016-09-26 20:33:03 +02:00
parent b280fde8a5
commit 2dd9aa87b0
4 changed files with 9 additions and 9 deletions

View File

@@ -1,9 +1,10 @@
#ifndef __MAIN_H__ #ifndef __MAIN_H__
#define __MAIN_H__ #define __MAIN_H__
#define EXAMPLE_I2C_MASTER_BASEADDR I2C0 #define I2C_BASEADDR_MAIN_BUS I2C0
#define I2C_BASEADDR_EEPROM_BUS I2C1
#define I2C_BAUD_RATE 100000 #define I2C_BAUD_RATE 100000
#define I2C_MASTER_CLK_SRC I2C0_CLK_SRC #define I2C_MASTER_CLK_SRC I2C0_CLK_SRC
#define I2C_DATA_LENGTH 2
#endif #endif

View File

@@ -10,9 +10,9 @@ void LedDriver_WriteBuffer(uint8_t txBuffer[], uint8_t size)
masterXfer.data = txBuffer; masterXfer.data = txBuffer;
masterXfer.dataSize = size; masterXfer.dataSize = size;
masterXfer.flags = kI2C_TransferDefaultFlag; masterXfer.flags = kI2C_TransferDefaultFlag;
I2C_MasterTransferBlocking(EXAMPLE_I2C_MASTER_BASEADDR, &masterXfer); I2C_MasterTransferBlocking(I2C_BASEADDR_MAIN_BUS, &masterXfer);
masterXfer.slaveAddress = RIGHT_LED_DRIVER_ADDRESS_7BIT; masterXfer.slaveAddress = RIGHT_LED_DRIVER_ADDRESS_7BIT;
I2C_MasterTransferBlocking(EXAMPLE_I2C_MASTER_BASEADDR, &masterXfer); I2C_MasterTransferBlocking(I2C_BASEADDR_MAIN_BUS, &masterXfer);
} }
void LedDriver_WriteRegister(uint8_t reg, uint8_t val) void LedDriver_WriteRegister(uint8_t reg, uint8_t val)

View File

@@ -3,14 +3,13 @@
// Includes: // Includes:
#include "fsl_gpio.h" #include "fsl_gpio.h"
#include "fsl_port.h" #include "fsl_port.h"
#include "fsl_i2c.h" #include "fsl_i2c.h"
#include "i2c.h" #include "i2c.h"
#include "i2c_addresses.h" #include "i2c_addresses.h"
// Macros: // Functions:
extern void LedDriver_WriteBuffer(uint8_t txBuffer[], uint8_t size); extern void LedDriver_WriteBuffer(uint8_t txBuffer[], uint8_t size);
extern void LedDriver_WriteRegister(uint8_t reg, uint8_t val); extern void LedDriver_WriteRegister(uint8_t reg, uint8_t val);

View File

@@ -16,7 +16,7 @@ void main() {
I2C_MasterGetDefaultConfig(&masterConfig); I2C_MasterGetDefaultConfig(&masterConfig);
masterConfig.baudRate_Bps = I2C_BAUD_RATE; masterConfig.baudRate_Bps = I2C_BAUD_RATE;
sourceClock = CLOCK_GetFreq(I2C_MASTER_CLK_SRC); sourceClock = CLOCK_GetFreq(I2C_MASTER_CLK_SRC);
I2C_MasterInit(EXAMPLE_I2C_MASTER_BASEADDR, &masterConfig, sourceClock); I2C_MasterInit(I2C_BASEADDR_MAIN_BUS, &masterConfig, sourceClock);
LedDriver_EnableAllLeds(); LedDriver_EnableAllLeds();
InitUsb(); InitUsb();