Implement I2C watchdog for the left half. Disable the watchdog because it causes a hard fault. Don't update the test LED inside of SlaveCommand_SetTestLed due to testing purposes until the watchdog issue gets resolved.
This commit is contained in:
@@ -81,6 +81,16 @@
|
|||||||
<type>1</type>
|
<type>1</type>
|
||||||
<locationURI>PARENT-3-PROJECT_LOC/lib/KSDK_2.0_MKL03Z8xxx4/devices/MKL03Z4/drivers/fsl_i2c.h</locationURI>
|
<locationURI>PARENT-3-PROJECT_LOC/lib/KSDK_2.0_MKL03Z8xxx4/devices/MKL03Z4/drivers/fsl_i2c.h</locationURI>
|
||||||
</link>
|
</link>
|
||||||
|
<link>
|
||||||
|
<name>drivers/fsl_lptmr.c</name>
|
||||||
|
<type>1</type>
|
||||||
|
<locationURI>PARENT-3-PROJECT_LOC/lib/KSDK_2.0_MKL03Z8xxx4/devices/MKL03Z4/drivers/fsl_lptmr.c</locationURI>
|
||||||
|
</link>
|
||||||
|
<link>
|
||||||
|
<name>drivers/fsl_lptmr.h</name>
|
||||||
|
<type>1</type>
|
||||||
|
<locationURI>PARENT-3-PROJECT_LOC/lib/KSDK_2.0_MKL03Z8xxx4/devices/MKL03Z4/drivers/fsl_lptmr.h</locationURI>
|
||||||
|
</link>
|
||||||
<link>
|
<link>
|
||||||
<name>drivers/fsl_port.h</name>
|
<name>drivers/fsl_port.h</name>
|
||||||
<type>1</type>
|
<type>1</type>
|
||||||
|
|||||||
@@ -70,13 +70,13 @@
|
|||||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="uhk-left-debug/uhk-left.elf"/>
|
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="uhk-left-debug/uhk-left.elf"/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="uhk-left"/>
|
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="uhk-left"/>
|
||||||
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
|
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value=""/>
|
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1792027861"/>
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||||
<listEntry value="/uhk-left"/>
|
<listEntry value="/uhk-left"/>
|
||||||
</listAttribute>
|
</listAttribute>
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||||
<listEntry value="4"/>
|
<listEntry value="4"/>
|
||||||
</listAttribute>
|
</listAttribute>
|
||||||
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList context="Context string"/> "/>
|
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList context="Context string"/> "/>
|
||||||
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
|
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
|
||||||
</launchConfiguration>
|
</launchConfiguration>
|
||||||
|
|||||||
36
left/src/i2c_watchdog.c
Normal file
36
left/src/i2c_watchdog.c
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#include "fsl_i2c.h"
|
||||||
|
#include "i2c.h"
|
||||||
|
#include "i2c_watchdog.h"
|
||||||
|
#include "test_led.h"
|
||||||
|
#include "init_peripherals.h"
|
||||||
|
|
||||||
|
static uint32_t prevWatchdogCounter = 0;
|
||||||
|
uint32_t I2C_WatchdogInnerCounter;
|
||||||
|
volatile uint32_t I2C_WatchdogOuterCounter;
|
||||||
|
|
||||||
|
void InitI2cWatchdog(void)
|
||||||
|
{
|
||||||
|
lptmr_config_t lptmrConfig;
|
||||||
|
LPTMR_GetDefaultConfig(&lptmrConfig);
|
||||||
|
LPTMR_Init(LPTMR0, &lptmrConfig);
|
||||||
|
LPTMR_SetTimerPeriod(LPTMR0, USEC_TO_COUNT(LPTMR_USEC_COUNT, LPTMR_SOURCE_CLOCK));
|
||||||
|
LPTMR_EnableInterrupts(LPTMR0, kLPTMR_TimerInterruptEnable);
|
||||||
|
EnableIRQ(LPTMR0_IRQn);
|
||||||
|
LPTMR_StartTimer(LPTMR0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void I2C_WATCHDOG_LPTMR_HANDLER(void)
|
||||||
|
{
|
||||||
|
I2C_WatchdogOuterCounter++;
|
||||||
|
TEST_LED_TOGGLE();
|
||||||
|
|
||||||
|
if (I2C_Watchdog == prevWatchdogCounter && I2C_WatchdogOuterCounter>10) { // Restart I2C if there hasn't been any interrupt during 100 ms
|
||||||
|
I2C_WatchdogInnerCounter++;
|
||||||
|
I2C_SlaveDeinit(I2C_BUS_BASEADDR);
|
||||||
|
//InitI2c();
|
||||||
|
}
|
||||||
|
|
||||||
|
prevWatchdogCounter = I2C_Watchdog;
|
||||||
|
|
||||||
|
LPTMR_ClearStatusFlags(LPTMR0, kLPTMR_TimerCompareFlag);
|
||||||
|
}
|
||||||
19
left/src/i2c_watchdog.h
Normal file
19
left/src/i2c_watchdog.h
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#ifndef __I2C_WATCHDOG_H__
|
||||||
|
#define __I2C_WATCHDOG_H__
|
||||||
|
|
||||||
|
// Includes:
|
||||||
|
|
||||||
|
#include "fsl_lptmr.h"
|
||||||
|
|
||||||
|
// Macros:
|
||||||
|
|
||||||
|
#define I2C_WATCHDOG_LPTMR_HANDLER LPTMR0_IRQHandler
|
||||||
|
#define LPTMR_SOURCE_CLOCK CLOCK_GetFreq(kCLOCK_LpoClk)
|
||||||
|
#define LPTMR_USEC_COUNT 100000U
|
||||||
|
|
||||||
|
// Functions:
|
||||||
|
|
||||||
|
extern void InitI2cWatchdog(void);
|
||||||
|
extern void RunWatchdog(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "i2c.h"
|
#include "i2c.h"
|
||||||
#include "led_pwm.h"
|
#include "led_pwm.h"
|
||||||
#include "slave_protocol_handler.h"
|
#include "slave_protocol_handler.h"
|
||||||
|
#include "i2c_watchdog.h"
|
||||||
|
|
||||||
static void i2cSlaveCallback(I2C_Type *base, i2c_slave_transfer_t *xfer, void *userData)
|
static void i2cSlaveCallback(I2C_Type *base, i2c_slave_transfer_t *xfer, void *userData)
|
||||||
{
|
{
|
||||||
@@ -34,6 +35,12 @@ static void i2cSlaveCallback(I2C_Type *base, i2c_slave_transfer_t *xfer, void *u
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InitInterruptPriorities()
|
||||||
|
{
|
||||||
|
NVIC_SetPriority(I2C0_IRQn, 1);
|
||||||
|
NVIC_SetPriority(TPM1_IRQn, 1);
|
||||||
|
}
|
||||||
|
|
||||||
void InitI2c(void) {
|
void InitI2c(void) {
|
||||||
port_pin_config_t pinConfig = {
|
port_pin_config_t pinConfig = {
|
||||||
.pullSelect = kPORT_PullUp,
|
.pullSelect = kPORT_PullUp,
|
||||||
@@ -66,8 +73,10 @@ void InitLedDriver(void) {
|
|||||||
|
|
||||||
void InitPeripherals(void)
|
void InitPeripherals(void)
|
||||||
{
|
{
|
||||||
|
InitInterruptPriorities();
|
||||||
InitLedDriver();
|
InitLedDriver();
|
||||||
InitTestLed();
|
InitTestLed();
|
||||||
LedPwm_Init();
|
LedPwm_Init();
|
||||||
InitI2c();
|
InitI2c();
|
||||||
|
//InitI2cWatchdog();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
// Functions:
|
// Functions:
|
||||||
|
|
||||||
void InitPeripherals(void);
|
extern void InitPeripherals(void);
|
||||||
|
extern void InitI2c(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ void SlaveProtocolHandler(void)
|
|||||||
case SlaveCommand_SetTestLed:
|
case SlaveCommand_SetTestLed:
|
||||||
SlaveTxSize = 0;
|
SlaveTxSize = 0;
|
||||||
bool isLedOn = SlaveRxBuffer[1];
|
bool isLedOn = SlaveRxBuffer[1];
|
||||||
TEST_LED_SET(isLedOn);
|
// TEST_LED_SET(isLedOn);
|
||||||
break;
|
break;
|
||||||
case SlaveCommand_SetLedPwmBrightness:
|
case SlaveCommand_SetLedPwmBrightness:
|
||||||
SlaveTxSize = 0;
|
SlaveTxSize = 0;
|
||||||
|
|||||||
Submodule lib/KSDK_2.0_MKL03Z8xxx4 updated: c02d0df05b...ac55fc28ee
@@ -77,6 +77,6 @@
|
|||||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||||
</listAttribute>
|
</listAttribute>
|
||||||
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList context="Context string"/> "/>
|
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList context="Context string"/> "/>
|
||||||
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
|
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
|
||||||
</launchConfiguration>
|
</launchConfiguration>
|
||||||
|
|||||||
Reference in New Issue
Block a user