Implement DevicePropertyId_I2cMainBusBaudRate
This commit is contained in:
Submodule lib/KSDK_2.0_MK22FN512xxx12 updated: 7142722eed...9fbf2bbf08
@@ -16,7 +16,8 @@
|
|||||||
#include "usb_api.h"
|
#include "usb_api.h"
|
||||||
#include "slave_scheduler.h"
|
#include "slave_scheduler.h"
|
||||||
|
|
||||||
uint32_t I2cMainBusBaudRateBps = I2C_MAIN_BUS_BAUD_RATE;
|
uint32_t I2cMainBusRequestedBaudRateBps = I2C_MAIN_BUS_BAUD_RATE;
|
||||||
|
uint32_t I2cMainBusActualBaudRateBps;
|
||||||
|
|
||||||
void InitInterruptPriorities(void)
|
void InitInterruptPriorities(void)
|
||||||
{
|
{
|
||||||
@@ -81,9 +82,10 @@ void initI2cMainBus(void)
|
|||||||
|
|
||||||
i2c_master_config_t masterConfig;
|
i2c_master_config_t masterConfig;
|
||||||
I2C_MasterGetDefaultConfig(&masterConfig);
|
I2C_MasterGetDefaultConfig(&masterConfig);
|
||||||
masterConfig.baudRate_Bps = I2cMainBusBaudRateBps;
|
masterConfig.baudRate_Bps = I2cMainBusRequestedBaudRateBps;
|
||||||
uint32_t sourceClock = CLOCK_GetFreq(I2C_MAIN_BUS_CLK_SRC);
|
uint32_t sourceClock = CLOCK_GetFreq(I2C_MAIN_BUS_CLK_SRC);
|
||||||
I2C_MasterInit(I2C_MAIN_BUS_BASEADDR, &masterConfig, sourceClock);
|
I2C_MasterInit(I2C_MAIN_BUS_BASEADDR, &masterConfig, sourceClock);
|
||||||
|
I2cMainBusActualBaudRateBps = I2C_ActualBaudRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReinitI2cMainBus(void)
|
void ReinitI2cMainBus(void)
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
|
|
||||||
// Variables:
|
// Variables:
|
||||||
|
|
||||||
extern uint32_t I2cMainBusBaudRateBps;
|
extern uint32_t I2cMainBusRequestedBaudRateBps;
|
||||||
|
extern uint32_t I2cMainBusActualBaudRateBps;
|
||||||
|
|
||||||
// Functions:
|
// Functions:
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,9 @@
|
|||||||
#include "eeprom.h"
|
#include "eeprom.h"
|
||||||
#include "versions.h"
|
#include "versions.h"
|
||||||
#include "slave_drivers/kboot_driver.h"
|
#include "slave_drivers/kboot_driver.h"
|
||||||
|
#include "i2c.h"
|
||||||
|
#include "init_peripherals.h"
|
||||||
|
#include "fsl_i2c.h"
|
||||||
|
|
||||||
version_t deviceProtocolVersion = {
|
version_t deviceProtocolVersion = {
|
||||||
DEVICE_PROTOCOL_MAJOR_VERSION,
|
DEVICE_PROTOCOL_MAJOR_VERSION,
|
||||||
@@ -59,6 +62,11 @@ void UsbCommand_GetDeviceProperty(void)
|
|||||||
case DevicePropertyId_CurrentKbootCommand:
|
case DevicePropertyId_CurrentKbootCommand:
|
||||||
GenericHidOutBuffer[1] = KbootDriverState.command;
|
GenericHidOutBuffer[1] = KbootDriverState.command;
|
||||||
break;
|
break;
|
||||||
|
case DevicePropertyId_I2cMainBusBaudRate:
|
||||||
|
GenericHidOutBuffer[1] = I2C_MAIN_BUS_BASEADDR->F;
|
||||||
|
SetUsbTxBufferUint32(2, I2cMainBusRequestedBaudRateBps);
|
||||||
|
SetUsbTxBufferUint32(6, I2cMainBusActualBaudRateBps);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
SetUsbTxBufferUint8(0, UsbStatusCode_GetDeviceProperty_InvalidProperty);
|
SetUsbTxBufferUint8(0, UsbStatusCode_GetDeviceProperty_InvalidProperty);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -8,7 +8,8 @@
|
|||||||
DevicePropertyId_ProtocolVersions = 1,
|
DevicePropertyId_ProtocolVersions = 1,
|
||||||
DevicePropertyId_ConfigSizes = 2,
|
DevicePropertyId_ConfigSizes = 2,
|
||||||
DevicePropertyId_CurrentKbootCommand = 3,
|
DevicePropertyId_CurrentKbootCommand = 3,
|
||||||
} system_property_t;
|
DevicePropertyId_I2cMainBusBaudRate = 4,
|
||||||
|
} device_property_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
UsbStatusCode_GetDeviceProperty_InvalidProperty = 2,
|
UsbStatusCode_GetDeviceProperty_InvalidProperty = 2,
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
#include "usb_protocol_handler.h"
|
#include "usb_protocol_handler.h"
|
||||||
#include "usb_commands/usb_command_set_i2c_baud_rate.h"
|
#include "usb_commands/usb_command_set_i2c_baud_rate.h"
|
||||||
#include "init_peripherals.h"
|
#include "init_peripherals.h"
|
||||||
|
#include "fsl_i2c.h"
|
||||||
|
|
||||||
void UsbCommand_SetI2cBaudRate(void)
|
void UsbCommand_SetI2cBaudRate(void)
|
||||||
{
|
{
|
||||||
uint32_t i2cBaudRate = GetUsbRxBufferUint32(1);
|
uint32_t i2cBaudRate = GetUsbRxBufferUint32(1);
|
||||||
I2cMainBusBaudRateBps = i2cBaudRate;
|
I2cMainBusRequestedBaudRateBps = i2cBaudRate;
|
||||||
ReinitI2cMainBus();
|
ReinitI2cMainBus();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user