Fixed I2C clocks.
This commit is contained in:
parent
13985fff92
commit
ddb367b97a
|
@ -54,6 +54,7 @@ set(TARGET_SOURCES
|
|||
"src/main.c"
|
||||
"src/pah8001_impl.c"
|
||||
"src/sensors_impl.c"
|
||||
"src/util_systick.c"
|
||||
)
|
||||
|
||||
set(TARGET_C_DEFINES
|
||||
|
@ -62,6 +63,8 @@ set(TARGET_C_DEFINES
|
|||
"MCUXPRESSO_SDK"
|
||||
"SERIAL_PORT_TYPE_UART=1"
|
||||
"__STARTUP_CLEAR_BSS"
|
||||
"PRINTF_FLOAT_ENABLE=1"
|
||||
"PRINTF_ADVANCED_ENABLE=1"
|
||||
)
|
||||
|
||||
set(TARGET_C_INCLUDES
|
||||
|
@ -78,9 +81,10 @@ set(TARGET_C_INCLUDES
|
|||
|
||||
# Shared libraries linked with application
|
||||
set(TARGET_LIBS
|
||||
"imsensors"
|
||||
"m"
|
||||
"power_cm4_hardabi"
|
||||
"pah8001"
|
||||
"imsensors"
|
||||
)
|
||||
|
||||
# Shared library and linker script search paths
|
||||
|
@ -93,9 +97,9 @@ set(TARGET_CFLAGS_HARDWARE "-mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-
|
|||
|
||||
# Conditional flags
|
||||
# DEBUG
|
||||
set(CMAKE_C_FLAGS_DEBUG "-DDEBUG -Og -g")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -Og -g")
|
||||
set(CMAKE_ASM_FLAGS_DEBUG "-DDEBUG -Og -g")
|
||||
set(CMAKE_C_FLAGS_DEBUG "-DDEBUG -O0 -g")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -O0 -g")
|
||||
set(CMAKE_ASM_FLAGS_DEBUG "-DDEBUG -O0 -g")
|
||||
|
||||
# RELEASE
|
||||
set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2 -flto")
|
||||
|
@ -107,7 +111,7 @@ set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-flto")
|
|||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TARGET_CFLAGS_HARDWARE} -Wall -fno-common -fno-builtin -ffreestanding -fdata-sections -ffunction-sections")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TARGET_CFLAGS_HARDWARE} -Wall -fno-common -fno-builtin -ffreestanding -fdata-sections -ffunction-sections")
|
||||
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${CMAKE_C_FLAGS} -x assembler-with-cpp")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-specs=nano.specs -specs=nosys.specs -Wl,--gc-sections -Wl,--print-memory-usage -lc -lm -lnosys ")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-specs=nano.specs -specs=nosys.specs -lnosys -Wl,--gc-sections -Wl,--print-memory-usage -Wl,--no-warn-rwx-segments")
|
||||
|
||||
add_subdirectory(lib/pixart_pah8001ei)
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding= "UTF-8" ?>
|
||||
<configuration name="LPC54102J512" xsi:schemaLocation="http://mcuxpresso.nxp.com/XSD/mex_configuration_11 http://mcuxpresso.nxp.com/XSD/mex_configuration_11.xsd" uuid="1ea9ba79-e007-415b-b3ad-7f5dc302a761" version="11" xmlns="http://mcuxpresso.nxp.com/XSD/mex_configuration_11" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<configuration name="LPC54102J512" xsi:schemaLocation="http://mcuxpresso.nxp.com/XSD/mex_configuration_12 http://mcuxpresso.nxp.com/XSD/mex_configuration_12.xsd" uuid="1ea9ba79-e007-415b-b3ad-7f5dc302a761" version="12" xmlns="http://mcuxpresso.nxp.com/XSD/mex_configuration_12" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<common>
|
||||
<processor>LPC54102J512</processor>
|
||||
<package>LPC54102J512BD64</package>
|
||||
|
@ -18,13 +18,17 @@
|
|||
<generate_registers_defines>false</generate_registers_defines>
|
||||
</preferences>
|
||||
<tools>
|
||||
<pins name="Pins" version="11.0" enabled="true" update_project_code="true">
|
||||
<pins name="Pins" version="12.0" enabled="true" update_project_code="true">
|
||||
<generated_project_files>
|
||||
<file path="board/pin_mux.c" update_enabled="true"/>
|
||||
<file path="board/pin_mux.h" update_enabled="true"/>
|
||||
</generated_project_files>
|
||||
<pins_profile>
|
||||
<processor_version>11.0.1</processor_version>
|
||||
<processor_version>12.0.0</processor_version>
|
||||
<pin_labels>
|
||||
<pin_label pin_num="28" pin_signal="PIO1_8/ADC_11/SPI1_MISO/CT32B1_MAT3/CT32B1_CAP3" label="LED_R" identifier="LED_R"/>
|
||||
<pin_label pin_num="41" pin_signal="PIO0_7/U1_SCLK/SCT0_OUT0/CT32B0_MAT2/CT32B0_CAP2" label="BMM_DRDY" identifier="BMM_DRDY"/>
|
||||
</pin_labels>
|
||||
</pins_profile>
|
||||
<functions_list>
|
||||
<function name="BOARD_InitPins">
|
||||
|
@ -45,60 +49,82 @@
|
|||
<data>true</data>
|
||||
</feature>
|
||||
</dependency>
|
||||
<dependency resourceType="Peripheral" resourceId="PINT" description="Peripheral PINT is not initialized" problem_level="1" source="Pins:BOARD_InitPins">
|
||||
<feature name="initialized" evaluation="equal" configuration="cm4">
|
||||
<data>true</data>
|
||||
</feature>
|
||||
</dependency>
|
||||
<dependency resourceType="SWComponent" resourceId="platform.drivers.common" description="Pins initialization requires the COMMON Driver in the project." problem_level="2" source="Pins:BOARD_InitPins">
|
||||
<feature name="enabled" evaluation="equal" configuration="cm4">
|
||||
<data>true</data>
|
||||
</feature>
|
||||
</dependency>
|
||||
<dependency resourceType="SWComponent" resourceId="platform.drivers.lpc_gpio" description="Pins initialization requires the LPC_GPIO Driver in the project." problem_level="2" source="Pins:BOARD_InitPins">
|
||||
<feature name="enabled" evaluation="equal" configuration="cm4">
|
||||
<data>true</data>
|
||||
</feature>
|
||||
</dependency>
|
||||
<dependency resourceType="SWComponent" resourceId="platform.drivers.inputmux" description="Pins initialization requires the INPUTMUX Driver in the project." problem_level="2" source="Pins:BOARD_InitPins">
|
||||
<feature name="enabled" evaluation="equal" configuration="cm4">
|
||||
<data>true</data>
|
||||
</feature>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<pins>
|
||||
<pin peripheral="USART0" signal="RXD" pin_num="31" pin_signal="PIO0_0/U0_RXD/SPI0_SSEL0/CT32B0_CAP0/SCT0_OUT3"/>
|
||||
<pin peripheral="USART0" signal="TXD" pin_num="32" pin_signal="PIO0_1/U0_TXD/SPI0_SSEL1/CT32B0_CAP1/SCT0_OUT1"/>
|
||||
<pin peripheral="I2C0" signal="SCL" pin_num="1" pin_signal="PIO0_23/I2C0_SCL/CT32B0_CAP0"/>
|
||||
<pin peripheral="I2C0" signal="SDA" pin_num="2" pin_signal="PIO0_24/I2C0_SDA/CT32B0_CAP1/CT32B0_MAT0"/>
|
||||
<pin peripheral="GPIO" signal="PIO1, 8" pin_num="28" pin_signal="PIO1_8/ADC_11/SPI1_MISO/CT32B1_MAT3/CT32B1_CAP3">
|
||||
<pin_features>
|
||||
<pin_feature name="direction" value="OUTPUT"/>
|
||||
<pin_feature name="gpio_init_state" value="true"/>
|
||||
</pin_features>
|
||||
</pin>
|
||||
<pin peripheral="PINT" signal="PINT, 0" pin_num="41" pin_signal="PIO0_7/U1_SCLK/SCT0_OUT0/CT32B0_MAT2/CT32B0_CAP2"/>
|
||||
</pins>
|
||||
</function>
|
||||
</functions_list>
|
||||
</pins>
|
||||
<clocks name="Clocks" version="9.0" enabled="true" update_project_code="true">
|
||||
<clocks name="Clocks" version="10.0" enabled="true" update_project_code="true">
|
||||
<generated_project_files>
|
||||
<file path="board/clock_config.c" update_enabled="true"/>
|
||||
<file path="board/clock_config.h" update_enabled="true"/>
|
||||
</generated_project_files>
|
||||
<clocks_profile>
|
||||
<processor_version>11.0.1</processor_version>
|
||||
<processor_version>12.0.0</processor_version>
|
||||
</clocks_profile>
|
||||
<clock_configurations>
|
||||
<clock_configuration name="BOARD_BootClockRUN" id_prefix="" prefix_user_defined="false">
|
||||
<clock_configuration name="BOARD_BootClockIRC12M" id_prefix="" prefix_user_defined="false">
|
||||
<description></description>
|
||||
<options/>
|
||||
<dependencies>
|
||||
<dependency resourceType="SWComponent" resourceId="platform.drivers.common" description="Clocks initialization requires the COMMON Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockRUN">
|
||||
<dependency resourceType="SWComponent" resourceId="platform.drivers.common" description="Clocks initialization requires the COMMON Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockIRC12M">
|
||||
<feature name="enabled" evaluation="equal" configuration="cm0plus">
|
||||
<data>true</data>
|
||||
</feature>
|
||||
</dependency>
|
||||
<dependency resourceType="SWComponent" resourceId="platform.drivers.common" description="Clocks initialization requires the COMMON Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockRUN">
|
||||
<dependency resourceType="SWComponent" resourceId="platform.drivers.common" description="Clocks initialization requires the COMMON Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockIRC12M">
|
||||
<feature name="enabled" evaluation="equal" configuration="cm4">
|
||||
<data>true</data>
|
||||
</feature>
|
||||
</dependency>
|
||||
<dependency resourceType="SWComponent" resourceId="platform.drivers.power" description="Clocks initialization requires the POWER Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockRUN">
|
||||
<dependency resourceType="SWComponent" resourceId="platform.drivers.power" description="Clocks initialization requires the POWER Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockIRC12M">
|
||||
<feature name="enabled" evaluation="equal" configuration="cm0plus">
|
||||
<data>true</data>
|
||||
</feature>
|
||||
</dependency>
|
||||
<dependency resourceType="SWComponent" resourceId="platform.drivers.power" description="Clocks initialization requires the POWER Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockRUN">
|
||||
<dependency resourceType="SWComponent" resourceId="platform.drivers.power" description="Clocks initialization requires the POWER Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockIRC12M">
|
||||
<feature name="enabled" evaluation="equal" configuration="cm4">
|
||||
<data>true</data>
|
||||
</feature>
|
||||
</dependency>
|
||||
<dependency resourceType="SWComponent" resourceId="platform.drivers.clock" description="Clocks initialization requires the CLOCK Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockRUN">
|
||||
<dependency resourceType="SWComponent" resourceId="platform.drivers.clock" description="Clocks initialization requires the CLOCK Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockIRC12M">
|
||||
<feature name="enabled" evaluation="equal" configuration="cm0plus">
|
||||
<data>true</data>
|
||||
</feature>
|
||||
</dependency>
|
||||
<dependency resourceType="SWComponent" resourceId="platform.drivers.clock" description="Clocks initialization requires the CLOCK Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockRUN">
|
||||
<dependency resourceType="SWComponent" resourceId="platform.drivers.clock" description="Clocks initialization requires the CLOCK Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockIRC12M">
|
||||
<feature name="enabled" evaluation="equal" configuration="cm4">
|
||||
<data>true</data>
|
||||
</feature>
|
||||
|
@ -112,6 +138,63 @@
|
|||
<clock_output id="System_clock.outFreq" value="12 MHz" locked="false" accuracy=""/>
|
||||
</clock_outputs>
|
||||
<clock_settings/>
|
||||
<called_from_default_init>false</called_from_default_init>
|
||||
</clock_configuration>
|
||||
<clock_configuration name="BOARD_BootClockPLL150M" id_prefix="" prefix_user_defined="false">
|
||||
<description></description>
|
||||
<options/>
|
||||
<dependencies>
|
||||
<dependency resourceType="SWComponent" resourceId="platform.drivers.common" description="Clocks initialization requires the COMMON Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockPLL150M">
|
||||
<feature name="enabled" evaluation="equal" configuration="cm0plus">
|
||||
<data>true</data>
|
||||
</feature>
|
||||
</dependency>
|
||||
<dependency resourceType="SWComponent" resourceId="platform.drivers.common" description="Clocks initialization requires the COMMON Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockPLL150M">
|
||||
<feature name="enabled" evaluation="equal" configuration="cm4">
|
||||
<data>true</data>
|
||||
</feature>
|
||||
</dependency>
|
||||
<dependency resourceType="SWComponent" resourceId="platform.drivers.power" description="Clocks initialization requires the POWER Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockPLL150M">
|
||||
<feature name="enabled" evaluation="equal" configuration="cm0plus">
|
||||
<data>true</data>
|
||||
</feature>
|
||||
</dependency>
|
||||
<dependency resourceType="SWComponent" resourceId="platform.drivers.power" description="Clocks initialization requires the POWER Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockPLL150M">
|
||||
<feature name="enabled" evaluation="equal" configuration="cm4">
|
||||
<data>true</data>
|
||||
</feature>
|
||||
</dependency>
|
||||
<dependency resourceType="SWComponent" resourceId="platform.drivers.clock" description="Clocks initialization requires the CLOCK Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockPLL150M">
|
||||
<feature name="enabled" evaluation="equal" configuration="cm0plus">
|
||||
<data>true</data>
|
||||
</feature>
|
||||
</dependency>
|
||||
<dependency resourceType="SWComponent" resourceId="platform.drivers.clock" description="Clocks initialization requires the CLOCK Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockPLL150M">
|
||||
<feature name="enabled" evaluation="equal" configuration="cm4">
|
||||
<data>true</data>
|
||||
</feature>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<clock_sources/>
|
||||
<clock_outputs>
|
||||
<clock_output id="ASYNCAPB_clock.outFreq" value="50 MHz" locked="false" accuracy=""/>
|
||||
<clock_output id="FRG_clock.outFreq" value="50 MHz" locked="false" accuracy=""/>
|
||||
<clock_output id="MAIN_clock.outFreq" value="150 MHz" locked="false" accuracy=""/>
|
||||
<clock_output id="SYSTICK_clock.outFreq" value="10 MHz" locked="false" accuracy=""/>
|
||||
<clock_output id="System_clock.outFreq" value="150 MHz" locked="false" accuracy=""/>
|
||||
</clock_outputs>
|
||||
<clock_settings>
|
||||
<setting id="PLL_Mode" value="Normal" locked="false"/>
|
||||
<setting id="ASYNC_SYSCON.ASYNCAPBCLKSELB.sel" value="SYSCON.pll_clk" locked="false"/>
|
||||
<setting id="ASYNC_SYSCON.ASYNCCLKDIV.scale" value="3" locked="false"/>
|
||||
<setting id="SYSCON.CLKOUTDIV.scale" value="0" locked="true"/>
|
||||
<setting id="SYSCON.DIRECTO.sel" value="SYSCON.PLL" locked="false"/>
|
||||
<setting id="SYSCON.MAINCLKSELB.sel" value="SYSCON.PLL_BYPASS" locked="false"/>
|
||||
<setting id="SYSCON.M_MULT.scale" value="50" locked="true"/>
|
||||
<setting id="SYSCON.N_DIV.scale" value="4" locked="true"/>
|
||||
<setting id="SYSCON.PLL_BYPASS.sel" value="SYSCON.DIRECTO" locked="false"/>
|
||||
<setting id="SYSCON.SYSTICKCLKDIV.scale" value="15" locked="true"/>
|
||||
</clock_settings>
|
||||
<called_from_default_init>true</called_from_default_init>
|
||||
</clock_configuration>
|
||||
</clock_configurations>
|
||||
|
@ -135,25 +218,35 @@
|
|||
<data type="Version">2.0.2</data>
|
||||
</feature>
|
||||
</dependency>
|
||||
<dependency resourceType="SWComponent" resourceId="platform.drivers.pint" description="PINT Driver not found in the toolchain/IDE project. Project will not compile!" problem_level="2" source="Peripherals">
|
||||
<feature name="enabled" evaluation="equal">
|
||||
<data type="Boolean">true</data>
|
||||
</feature>
|
||||
</dependency>
|
||||
<dependency resourceType="SWComponent" resourceId="platform.drivers.pint" description="Unsupported version of the PINT Driver in the toolchain/IDE project. Required: ${required_value}, actual: ${actual_value}. Project might not compile correctly." problem_level="1" source="Peripherals">
|
||||
<feature name="version" evaluation="equivalent">
|
||||
<data type="Version">2.1.3</data>
|
||||
</feature>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<generated_project_files>
|
||||
<file path="board/peripherals.c" update_enabled="true"/>
|
||||
<file path="board/peripherals.h" update_enabled="true"/>
|
||||
</generated_project_files>
|
||||
<peripherals_profile>
|
||||
<processor_version>11.0.1</processor_version>
|
||||
<processor_version>12.0.0</processor_version>
|
||||
</peripherals_profile>
|
||||
<functional_groups>
|
||||
<functional_group name="BOARD_InitPeripherals" uuid="bf976c30-387a-4c02-956c-44a37954526e" called_from_default_init="true" id_prefix="" core="cm4">
|
||||
<description></description>
|
||||
<options/>
|
||||
<dependencies>
|
||||
<dependency resourceType="PeripheralUnifiedSignal" resourceId="I2C0.i2c_scl" description="Signal I2C serial clock of the peripheral I2C0 is not routed." problem_level="1" source="Peripherals:BOARD_InitPeripherals">
|
||||
<dependency resourceType="PeripheralUnifiedSignal" resourceId="I2C0.i2c_scl" description="Signal I2C serial clock is not routed." problem_level="1" source="Peripherals:BOARD_InitPeripherals">
|
||||
<feature name="routed" evaluation="">
|
||||
<data type="Boolean">true</data>
|
||||
</feature>
|
||||
</dependency>
|
||||
<dependency resourceType="PeripheralUnifiedSignal" resourceId="I2C0.i2c_sda" description="Signal I2C serial data of the peripheral I2C0 is not routed." problem_level="1" source="Peripherals:BOARD_InitPeripherals">
|
||||
<dependency resourceType="PeripheralUnifiedSignal" resourceId="I2C0.i2c_sda" description="Signal I2C serial data is not routed." problem_level="1" source="Peripherals:BOARD_InitPeripherals">
|
||||
<feature name="routed" evaluation="">
|
||||
<data type="Boolean">true</data>
|
||||
</feature>
|
||||
|
@ -163,11 +256,18 @@
|
|||
<data type="Frequency" unit="Hz">0</data>
|
||||
</feature>
|
||||
</dependency>
|
||||
<dependency resourceType="PeripheralUnifiedSignal" resourceId="PINT.pint.0" description="Signal PINT, 0 is not routed." problem_level="1" source="Peripherals:BOARD_InitPeripherals">
|
||||
<feature name="routed" evaluation="">
|
||||
<data type="Boolean">true</data>
|
||||
</feature>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<instances>
|
||||
<instance name="NVIC" uuid="95540aad-a83e-4f89-94d4-464eb84246d4" type="nvic" type_id="nvic_57b5eef3774cc60acaede6f5b8bddc67" mode="general" peripheral="NVIC" enabled="true" comment="" custom_name_enabled="false" editing_lock="false">
|
||||
<config_set name="nvic">
|
||||
<array name="interrupt_table"/>
|
||||
<array name="interrupt_table">
|
||||
<struct name="0"/>
|
||||
</array>
|
||||
<array name="interrupts"/>
|
||||
</config_set>
|
||||
</instance>
|
||||
|
@ -175,7 +275,7 @@
|
|||
<config_set name="fsl_i2c">
|
||||
<setting name="i2c_mode" value="kI2C_Master"/>
|
||||
<setting name="clockSource" value="FunctionClock"/>
|
||||
<setting name="clockSourceFreq" value="BOARD_BootClockRUN"/>
|
||||
<setting name="clockSourceFreq" value="BOARD_BootClockPLL150M"/>
|
||||
<struct name="i2c_master_config">
|
||||
<setting name="enableMaster" value="true"/>
|
||||
<setting name="baudRate_Bps" value="100000"/>
|
||||
|
@ -183,6 +283,24 @@
|
|||
</struct>
|
||||
</config_set>
|
||||
</instance>
|
||||
<instance name="PINT" uuid="b8df67aa-993d-44ea-bd26-65aad827c55d" type="pint" type_id="pint_cf4a806bb2a6c1ffced58ae2ed7b43af" mode="interrupt_mode" peripheral="PINT" enabled="true" comment="" custom_name_enabled="false" editing_lock="false">
|
||||
<config_set name="general">
|
||||
<array name="interrupt_array">
|
||||
<struct name="0">
|
||||
<setting name="interrupt_id" value="INT_0"/>
|
||||
<setting name="interrupt_selection" value="PINT.0"/>
|
||||
<setting name="interrupt_type" value="kPINT_PinIntEnableFallEdge"/>
|
||||
<setting name="callback_function" value="bmm_drdy_callback"/>
|
||||
<setting name="enable_callback" value="true"/>
|
||||
<struct name="interrupt">
|
||||
<setting name="IRQn" value="PIN_INT0_IRQn"/>
|
||||
<setting name="enable_priority" value="true"/>
|
||||
<setting name="priority" value="4"/>
|
||||
</struct>
|
||||
</struct>
|
||||
</array>
|
||||
</config_set>
|
||||
</instance>
|
||||
</instances>
|
||||
</functional_group>
|
||||
</functional_groups>
|
||||
|
|
|
@ -25,8 +25,8 @@ const uint32_t ExtClockIn = BOARD_EXTCLKINRATE;
|
|||
status_t BOARD_InitDebugConsole(void)
|
||||
{
|
||||
status_t result;
|
||||
/* attach 12 MHz clock to USART0 (debug console) */
|
||||
CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);
|
||||
/* Do not attach clock here, since the clocks are already configured by tools */
|
||||
// CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);
|
||||
RESET_PeripheralReset(BOARD_DEBUG_UART_RST);
|
||||
result = DbgConsole_Init(BOARD_DEBUG_UART_INSTANCE, BOARD_DEBUG_UART_BAUDRATE, BOARD_DEBUG_UART_TYPE,
|
||||
BOARD_DEBUG_UART_CLK_FREQ);
|
||||
|
@ -36,8 +36,8 @@ status_t BOARD_InitDebugConsole(void)
|
|||
status_t BOARD_InitDebugConsole_Core1(void)
|
||||
{
|
||||
status_t result;
|
||||
/* attach 12 MHz clock to USART2 (debug console) */
|
||||
CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH_CORE1);
|
||||
/* Do not attach clock here, since the clocks are already configured by tools */
|
||||
// CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH_CORE1);
|
||||
RESET_PeripheralReset(BOARD_DEBUG_UART_RST_CORE1);
|
||||
result = DbgConsole_Init(BOARD_DEBUG_UART_INSTANCE_CORE1, BOARD_DEBUG_UART_BAUDRATE_CORE1,
|
||||
BOARD_DEBUG_UART_TYPE_CORE1, BOARD_DEBUG_UART_CLK_FREQ_CORE1);
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
/* clang-format off */
|
||||
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
|
||||
!!GlobalInfo
|
||||
product: Clocks v9.0
|
||||
product: Clocks v10.0
|
||||
processor: LPC54102J512
|
||||
package_id: LPC54102J512BD64
|
||||
mcu_data: ksdk2_0
|
||||
processor_version: 11.0.1
|
||||
processor_version: 12.0.0
|
||||
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
|
||||
/* clang-format on */
|
||||
|
||||
|
@ -38,25 +38,22 @@ processor_version: 11.0.1
|
|||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
/* System clock frequency. */
|
||||
extern uint32_t SystemCoreClock;
|
||||
|
||||
/*******************************************************************************
|
||||
************************ BOARD_InitBootClocks function ************************
|
||||
******************************************************************************/
|
||||
void BOARD_InitBootClocks(void)
|
||||
{
|
||||
BOARD_BootClockRUN();
|
||||
BOARD_BootClockPLL150M();
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
********************** Configuration BOARD_BootClockRUN ***********************
|
||||
******************** Configuration BOARD_BootClockIRC12M **********************
|
||||
******************************************************************************/
|
||||
/* clang-format off */
|
||||
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
|
||||
!!Configuration
|
||||
name: BOARD_BootClockRUN
|
||||
called_from_default_init: true
|
||||
name: BOARD_BootClockIRC12M
|
||||
outputs:
|
||||
- {id: ASYNCAPB_clock.outFreq, value: 12 MHz}
|
||||
- {id: FRG_clock.outFreq, value: 12 MHz}
|
||||
|
@ -66,12 +63,12 @@ outputs:
|
|||
/* clang-format on */
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables for BOARD_BootClockRUN configuration
|
||||
* Variables for BOARD_BootClockIRC12M configuration
|
||||
******************************************************************************/
|
||||
/*******************************************************************************
|
||||
* Code for BOARD_BootClockRUN configuration
|
||||
* Code for BOARD_BootClockIRC12M configuration
|
||||
******************************************************************************/
|
||||
void BOARD_BootClockRUN(void)
|
||||
void BOARD_BootClockIRC12M(void)
|
||||
{
|
||||
/*!< Set up the clock sources */
|
||||
/*!< Set up IRC */
|
||||
|
@ -96,6 +93,82 @@ void BOARD_BootClockRUN(void)
|
|||
CLOCK_AttachClk(kIRC12M_to_MAIN_CLK); /*!< Switch MAIN_CLK to IRC12M */
|
||||
|
||||
/*!< Set SystemCoreClock variable. */
|
||||
SystemCoreClock = BOARD_BOOTCLOCKRUN_CORE_CLOCK;
|
||||
SystemCoreClock = BOARD_BOOTCLOCKIRC12M_CORE_CLOCK;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
******************** Configuration BOARD_BootClockPLL150M *********************
|
||||
******************************************************************************/
|
||||
/* clang-format off */
|
||||
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
|
||||
!!Configuration
|
||||
name: BOARD_BootClockPLL150M
|
||||
called_from_default_init: true
|
||||
outputs:
|
||||
- {id: ASYNCAPB_clock.outFreq, value: 50 MHz}
|
||||
- {id: FRG_clock.outFreq, value: 50 MHz}
|
||||
- {id: MAIN_clock.outFreq, value: 150 MHz}
|
||||
- {id: SYSTICK_clock.outFreq, value: 10 MHz}
|
||||
- {id: System_clock.outFreq, value: 150 MHz}
|
||||
settings:
|
||||
- {id: PLL_Mode, value: Normal}
|
||||
- {id: ASYNC_SYSCON.ASYNCAPBCLKSELB.sel, value: SYSCON.pll_clk}
|
||||
- {id: ASYNC_SYSCON.ASYNCCLKDIV.scale, value: '3'}
|
||||
- {id: SYSCON.CLKOUTDIV.scale, value: '0', locked: true}
|
||||
- {id: SYSCON.DIRECTO.sel, value: SYSCON.PLL}
|
||||
- {id: SYSCON.MAINCLKSELB.sel, value: SYSCON.PLL_BYPASS}
|
||||
- {id: SYSCON.M_MULT.scale, value: '50', locked: true}
|
||||
- {id: SYSCON.N_DIV.scale, value: '4', locked: true}
|
||||
- {id: SYSCON.PLL_BYPASS.sel, value: SYSCON.DIRECTO}
|
||||
- {id: SYSCON.SYSTICKCLKDIV.scale, value: '15', locked: true}
|
||||
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
|
||||
/* clang-format on */
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables for BOARD_BootClockPLL150M configuration
|
||||
******************************************************************************/
|
||||
/*******************************************************************************
|
||||
* Code for BOARD_BootClockPLL150M configuration
|
||||
******************************************************************************/
|
||||
void BOARD_BootClockPLL150M(void)
|
||||
{
|
||||
/*!< Set up the clock sources */
|
||||
/*!< Set up IRC */
|
||||
POWER_DisablePD(kPDRUNCFG_PD_IRC_OSC); /*!< Ensure IRC OSC is on */
|
||||
POWER_DisablePD(kPDRUNCFG_PD_IRC); /*!< Ensure IRC is on */
|
||||
CLOCK_AttachClk(kIRC12M_to_MAIN_CLK); /*!< Switch to IRC 12MHz first to ensure we can change voltage without accidentally
|
||||
being below the voltage for current speed */
|
||||
|
||||
/*!< Set up PLL */
|
||||
CLOCK_AttachClk(kIRC12M_to_SYS_PLL); /*!< Switch SYSPLLCLKSEL to IRC12M */
|
||||
POWER_DisablePD(kPDRUNCFG_PD_SYS_PLL); /*!< Ensure PLL is on */
|
||||
const pll_setup_t pllSetup = {
|
||||
.syspllctrl = SYSCON_SYSPLLCTRL_BANDSEL_MASK | SYSCON_SYSPLLCTRL_SELI(52U) | SYSCON_SYSPLLCTRL_SELP(26U) | SYSCON_SYSPLLCTRL_DIRECTO_MASK,
|
||||
.syspllndec = SYSCON_SYSPLLNDEC_NDEC(2U),
|
||||
.syspllpdec = SYSCON_SYSPLLPDEC_PDEC(2U),
|
||||
.syspllssctrl = {(SYSCON_SYSPLLSSCTRL0_MDEC(32597U) | SYSCON_SYSPLLSSCTRL0_SEL_EXT_MASK),0x0U},
|
||||
.pllRate = 150000000U,
|
||||
.flags = PLL_SETUPFLAG_WAITLOCK
|
||||
};
|
||||
CLOCK_SetPLLFreq(&pllSetup); /*!< Configure PLL to the desired values */
|
||||
|
||||
|
||||
POWER_SetVoltageForFreq(150000000U); /*!< Set voltage for the one of the fastest clock outputs: System clock output */
|
||||
CLOCK_SetFLASHAccessCyclesForFreq(150000000U); /*!< Set FLASH wait states for core */
|
||||
|
||||
/*!< Set up dividers */
|
||||
CLOCK_SetClkDiv(kCLOCK_DivSystickClk, 15U, false); /*!< Set SYSTICKCLKDIV divider to value 15 */
|
||||
CLOCK_SetClkDiv(kCLOCK_DivAhbClk, 1U, false); /*!< Set AHBCLKDIV divider to value 1 */
|
||||
SYSCON->ASYNCAPBCTRL = SYSCON_ASYNCAPBCTRL_ENABLE_MASK; /*!< Enable ASYNC APB subsystem */
|
||||
Clock_SetAsyncClkDiv(3U); /*!< Set ASYNCCLKDIV divider to value 3 */
|
||||
ASYNC_SYSCON->FRGCTRL = ((ASYNC_SYSCON->FRGCTRL & ~ASYNC_SYSCON_FRGCTRL_MULT_MASK) | ASYNC_SYSCON_FRGCTRL_MULT(0U)); /*!< Set FRG MULT to value 0 */
|
||||
ASYNC_SYSCON->ASYNCAPBCLKCTRL |= ASYNC_SYSCON_ASYNCAPBCLKCTRL_FRG0_MASK; /*!< Enable FRG clock */
|
||||
|
||||
/*!< Set up clock selectors - Attach clocks to the peripheries */
|
||||
CLOCK_AttachClk(kSYS_PLL_OUT_to_MAIN_CLK); /*!< Switch MAIN_CLK to SYS_PLL_OUT */
|
||||
CLOCK_AttachClk(kSYS_PLL_OUT_to_ASYNC_APB); /*!< Switch ASYNC_APB to SYS_PLL_OUT */
|
||||
|
||||
/*!< Set SystemCoreClock variable. */
|
||||
SystemCoreClock = BOARD_BOOTCLOCKPLL150M_CORE_CLOCK;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,16 +33,16 @@ void BOARD_InitBootClocks(void);
|
|||
#endif /* __cplusplus*/
|
||||
|
||||
/*******************************************************************************
|
||||
********************** Configuration BOARD_BootClockRUN ***********************
|
||||
******************** Configuration BOARD_BootClockIRC12M **********************
|
||||
******************************************************************************/
|
||||
/*******************************************************************************
|
||||
* Definitions for BOARD_BootClockRUN configuration
|
||||
* Definitions for BOARD_BootClockIRC12M configuration
|
||||
******************************************************************************/
|
||||
#define BOARD_BOOTCLOCKRUN_CORE_CLOCK 12000000U /*!< Core clock frequency: 12000000Hz */
|
||||
#define BOARD_BOOTCLOCKIRC12M_CORE_CLOCK 12000000U /*!< Core clock frequency: 12000000Hz */
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* API for BOARD_BootClockRUN configuration
|
||||
* API for BOARD_BootClockIRC12M configuration
|
||||
******************************************************************************/
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
|
@ -52,7 +52,33 @@ extern "C" {
|
|||
* @brief This function executes configuration of clocks.
|
||||
*
|
||||
*/
|
||||
void BOARD_BootClockRUN(void);
|
||||
void BOARD_BootClockIRC12M(void);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus*/
|
||||
|
||||
/*******************************************************************************
|
||||
******************** Configuration BOARD_BootClockPLL150M *********************
|
||||
******************************************************************************/
|
||||
/*******************************************************************************
|
||||
* Definitions for BOARD_BootClockPLL150M configuration
|
||||
******************************************************************************/
|
||||
#define BOARD_BOOTCLOCKPLL150M_CORE_CLOCK 150000000U /*!< Core clock frequency: 150000000Hz */
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* API for BOARD_BootClockPLL150M configuration
|
||||
******************************************************************************/
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* __cplusplus*/
|
||||
|
||||
/*!
|
||||
* @brief This function executes configuration of clocks.
|
||||
*
|
||||
*/
|
||||
void BOARD_BootClockPLL150M(void);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ product: Peripherals v11.0
|
|||
processor: LPC54102J512
|
||||
package_id: LPC54102J512BD64
|
||||
mcu_data: ksdk2_0
|
||||
processor_version: 11.0.1
|
||||
processor_version: 12.0.0
|
||||
functionalGroups:
|
||||
- name: BOARD_InitPeripherals
|
||||
UUID: bf976c30-387a-4c02-956c-44a37954526e
|
||||
|
@ -67,7 +67,8 @@ instance:
|
|||
- peripheral: 'NVIC'
|
||||
- config_sets:
|
||||
- nvic:
|
||||
- interrupt_table: []
|
||||
- interrupt_table:
|
||||
- 0: []
|
||||
- interrupts: []
|
||||
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
|
||||
/* clang-format on */
|
||||
|
@ -93,7 +94,7 @@ instance:
|
|||
- fsl_i2c:
|
||||
- i2c_mode: 'kI2C_Master'
|
||||
- clockSource: 'FunctionClock'
|
||||
- clockSourceFreq: 'BOARD_BootClockRUN'
|
||||
- clockSourceFreq: 'BOARD_BootClockPLL150M'
|
||||
- i2c_master_config:
|
||||
- enableMaster: 'true'
|
||||
- baudRate_Bps: '100000'
|
||||
|
@ -111,6 +112,46 @@ static void I2C0_init(void) {
|
|||
I2C_MasterInit(I2C0_PERIPHERAL, &I2C0_config, I2C0_CLOCK_SOURCE);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* PINT initialization code
|
||||
**********************************************************************************************************************/
|
||||
/* clang-format off */
|
||||
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
|
||||
instance:
|
||||
- name: 'PINT'
|
||||
- type: 'pint'
|
||||
- mode: 'interrupt_mode'
|
||||
- custom_name_enabled: 'false'
|
||||
- type_id: 'pint_cf4a806bb2a6c1ffced58ae2ed7b43af'
|
||||
- functional_group: 'BOARD_InitPeripherals'
|
||||
- peripheral: 'PINT'
|
||||
- config_sets:
|
||||
- general:
|
||||
- interrupt_array:
|
||||
- 0:
|
||||
- interrupt_id: 'INT_0'
|
||||
- interrupt_selection: 'PINT.0'
|
||||
- interrupt_type: 'kPINT_PinIntEnableFallEdge'
|
||||
- callback_function: 'bmm_drdy_callback'
|
||||
- enable_callback: 'true'
|
||||
- interrupt:
|
||||
- IRQn: 'PIN_INT0_IRQn'
|
||||
- enable_priority: 'true'
|
||||
- priority: '4'
|
||||
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
|
||||
/* clang-format on */
|
||||
|
||||
static void PINT_init(void) {
|
||||
/* PINT initiation */
|
||||
PINT_Init(PINT_PERIPHERAL);
|
||||
/* Interrupt vector PIN_INT0_IRQn priority settings in the NVIC. */
|
||||
NVIC_SetPriority(PINT_PINT_0_IRQN, PINT_PINT_0_IRQ_PRIORITY);
|
||||
/* PINT PINT.0 configuration */
|
||||
PINT_PinInterruptConfig(PINT_PERIPHERAL, PINT_INT_0, kPINT_PinIntEnableFallEdge, bmm_drdy_callback);
|
||||
/* Enable PINT PINT.0 callback */
|
||||
PINT_EnableCallbackByIndex(PINT_PERIPHERAL, kPINT_PinInt0);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* Initialization functions
|
||||
**********************************************************************************************************************/
|
||||
|
@ -118,6 +159,7 @@ void BOARD_InitPeripherals(void)
|
|||
{
|
||||
/* Initialize components */
|
||||
I2C0_init();
|
||||
PINT_init();
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
**********************************************************************************************************************/
|
||||
#include "fsl_common.h"
|
||||
#include "fsl_i2c.h"
|
||||
#include "fsl_pint.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
|
@ -24,13 +25,28 @@ extern "C" {
|
|||
/* Definition of peripheral ID */
|
||||
#define I2C0_PERIPHERAL ((I2C_Type *)I2C0)
|
||||
/* Definition of the clock source frequency */
|
||||
#define I2C0_CLOCK_SOURCE 12000000UL
|
||||
#define I2C0_CLOCK_SOURCE 50000000UL
|
||||
/* BOARD_InitPeripherals defines for PINT */
|
||||
/* Definition of peripheral ID */
|
||||
#define PINT_PERIPHERAL ((PINT_Type *) PINT_BASE)
|
||||
/* PINT interrupt vector ID (number). */
|
||||
#define PINT_PINT_0_IRQN PIN_INT0_IRQn
|
||||
/* PINT interrupt vector priority. */
|
||||
#define PINT_PINT_0_IRQ_PRIORITY 4
|
||||
/* Definition of PINT interrupt ID for interrupt 0 */
|
||||
#define PINT_INT_0 kPINT_PinInt0
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* Global variables
|
||||
**********************************************************************************************************************/
|
||||
extern const i2c_master_config_t I2C0_config;
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* Callback functions
|
||||
**********************************************************************************************************************/
|
||||
/* INT_0 callback function for the PINT component */
|
||||
extern void bmm_drdy_callback(pint_pin_int_t pintr, uint32_t pmatch_status);
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* Initialization functions
|
||||
**********************************************************************************************************************/
|
||||
|
|
|
@ -7,16 +7,21 @@
|
|||
/*
|
||||
* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
|
||||
!!GlobalInfo
|
||||
product: Pins v11.0
|
||||
product: Pins v12.0
|
||||
processor: LPC54102J512
|
||||
package_id: LPC54102J512BD64
|
||||
mcu_data: ksdk2_0
|
||||
processor_version: 11.0.1
|
||||
processor_version: 12.0.0
|
||||
pin_labels:
|
||||
- {pin_num: '28', pin_signal: PIO1_8/ADC_11/SPI1_MISO/CT32B1_MAT3/CT32B1_CAP3, label: LED_R, identifier: LED_R}
|
||||
- {pin_num: '41', pin_signal: PIO0_7/U1_SCLK/SCT0_OUT0/CT32B0_MAT2/CT32B0_CAP2, label: BMM_DRDY, identifier: BMM_DRDY}
|
||||
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS ***********
|
||||
*/
|
||||
/* clang-format on */
|
||||
|
||||
#include "fsl_common.h"
|
||||
#include "fsl_gpio.h"
|
||||
#include "fsl_inputmux.h"
|
||||
#include "pin_mux.h"
|
||||
|
||||
/* FUNCTION ************************************************************************************************************
|
||||
|
@ -40,6 +45,8 @@ BOARD_InitPins:
|
|||
- {pin_num: '32', peripheral: USART0, signal: TXD, pin_signal: PIO0_1/U0_TXD/SPI0_SSEL1/CT32B0_CAP1/SCT0_OUT1}
|
||||
- {pin_num: '1', peripheral: I2C0, signal: SCL, pin_signal: PIO0_23/I2C0_SCL/CT32B0_CAP0}
|
||||
- {pin_num: '2', peripheral: I2C0, signal: SDA, pin_signal: PIO0_24/I2C0_SDA/CT32B0_CAP1/CT32B0_MAT0}
|
||||
- {pin_num: '28', peripheral: GPIO, signal: 'PIO1, 8', pin_signal: PIO1_8/ADC_11/SPI1_MISO/CT32B1_MAT3/CT32B1_CAP3, direction: OUTPUT, gpio_init_state: 'true'}
|
||||
- {pin_num: '41', peripheral: PINT, signal: 'PINT, 0', pin_signal: PIO0_7/U1_SCLK/SCT0_OUT0/CT32B0_MAT2/CT32B0_CAP2}
|
||||
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS ***********
|
||||
*/
|
||||
/* clang-format on */
|
||||
|
@ -53,8 +60,21 @@ BOARD_InitPins:
|
|||
/* Function assigned for the Cortex-M4F */
|
||||
void BOARD_InitPins(void)
|
||||
{
|
||||
/* Enables the clock for the input muxes. 0 = Disable; 1 = Enable.: 0x01u */
|
||||
CLOCK_EnableClock(kCLOCK_InputMux);
|
||||
/* Enables the clock for the IOCON block. 0 = Disable; 1 = Enable.: 0x01u */
|
||||
CLOCK_EnableClock(kCLOCK_Iocon);
|
||||
/* Enables the clock for the GPIO1 module */
|
||||
CLOCK_EnableClock(kCLOCK_Gpio1);
|
||||
|
||||
gpio_pin_config_t LED_R_config = {
|
||||
.pinDirection = kGPIO_DigitalOutput,
|
||||
.outputLogic = 1U
|
||||
};
|
||||
/* Initialize GPIO functionality on pin PIO1_8 (pin 28) */
|
||||
GPIO_PinInit(BOARD_INITPINS_LED_R_GPIO, BOARD_INITPINS_LED_R_PORT, BOARD_INITPINS_LED_R_PIN, &LED_R_config);
|
||||
/* PIO0_7 is selected for PINT input 0 */
|
||||
INPUTMUX_AttachSignal(INPUTMUX, 0U, kINPUTMUX_GpioPort0Pin7ToPintsel);
|
||||
|
||||
IOCON->PIO[0][0] = ((IOCON->PIO[0][0] &
|
||||
/* Mask bits to zero which are setting */
|
||||
|
@ -103,6 +123,30 @@ void BOARD_InitPins(void)
|
|||
/* Select Analog/Digital mode.
|
||||
* : Digital mode. */
|
||||
| IOCON_PIO_DIGIMODE(PIO024_DIGIMODE_DIGITAL));
|
||||
|
||||
IOCON->PIO[0][7] = ((IOCON->PIO[0][7] &
|
||||
/* Mask bits to zero which are setting */
|
||||
(~(IOCON_PIO_FUNC_MASK | IOCON_PIO_DIGIMODE_MASK)))
|
||||
|
||||
/* Selects pin function.
|
||||
* : PORT07 (pin 41) is configured as PIO0_7. */
|
||||
| IOCON_PIO_FUNC(PIO07_FUNC_ALT0)
|
||||
|
||||
/* Select Analog/Digital mode.
|
||||
* : Digital mode. */
|
||||
| IOCON_PIO_DIGIMODE(PIO07_DIGIMODE_DIGITAL));
|
||||
|
||||
IOCON->PIO[1][8] = ((IOCON->PIO[1][8] &
|
||||
/* Mask bits to zero which are setting */
|
||||
(~(IOCON_PIO_FUNC_MASK | IOCON_PIO_DIGIMODE_MASK)))
|
||||
|
||||
/* Selects pin function.
|
||||
* : PORT18 (pin 28) is configured as PIO1_8. */
|
||||
| IOCON_PIO_FUNC(PIO18_FUNC_ALT0)
|
||||
|
||||
/* Select Analog/Digital mode.
|
||||
* : Digital mode. */
|
||||
| IOCON_PIO_DIGIMODE(PIO18_DIGIMODE_DIGITAL));
|
||||
}
|
||||
/***********************************************************************************************************************
|
||||
* EOF
|
||||
|
|
|
@ -33,6 +33,28 @@ void BOARD_InitBootPins(void);
|
|||
#define PIO023_FUNC_ALT1 0x01u /*!<@brief Selects pin function.: Alternative connection 1. */
|
||||
#define PIO024_DIGIMODE_DIGITAL 0x01u /*!<@brief Select Analog/Digital mode.: Digital mode. */
|
||||
#define PIO024_FUNC_ALT1 0x01u /*!<@brief Selects pin function.: Alternative connection 1. */
|
||||
#define PIO07_DIGIMODE_DIGITAL 0x01u /*!<@brief Select Analog/Digital mode.: Digital mode. */
|
||||
#define PIO07_FUNC_ALT0 0x00u /*!<@brief Selects pin function.: Alternative connection 0. */
|
||||
#define PIO18_DIGIMODE_DIGITAL 0x01u /*!<@brief Select Analog/Digital mode.: Digital mode. */
|
||||
#define PIO18_FUNC_ALT0 0x00u /*!<@brief Selects pin function.: Alternative connection 0. */
|
||||
|
||||
/*! @name PIO1_8 (number 28), LED_R
|
||||
@{ */
|
||||
|
||||
/* Symbols to be used with GPIO driver */
|
||||
#define BOARD_INITPINS_LED_R_GPIO GPIO /*!<@brief GPIO peripheral base pointer */
|
||||
#define BOARD_INITPINS_LED_R_GPIO_PIN_MASK (1U << 8U) /*!<@brief GPIO pin mask */
|
||||
#define BOARD_INITPINS_LED_R_PORT 1U /*!<@brief PORT peripheral base pointer */
|
||||
#define BOARD_INITPINS_LED_R_PIN 8U /*!<@brief PORT pin number */
|
||||
#define BOARD_INITPINS_LED_R_PIN_MASK (1U << 8U) /*!<@brief PORT pin mask */
|
||||
/* @} */
|
||||
|
||||
/*! @name PIO0_7 (number 41), BMM_DRDY
|
||||
@{ */
|
||||
#define BOARD_INITPINS_BMM_DRDY_PORT 0U /*!<@brief PORT peripheral base pointer */
|
||||
#define BOARD_INITPINS_BMM_DRDY_PIN 7U /*!<@brief PORT pin number */
|
||||
#define BOARD_INITPINS_BMM_DRDY_PIN_MASK (1U << 7U) /*!<@brief PORT pin mask */
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @brief Configures pin routing and optionally pin electrical features.
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
#ifndef UTIL_SYSTICK_H
|
||||
#define UTIL_SYSTICK_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void util_systick_init(void);
|
||||
void util_systick_delay(uint64_t msec);
|
||||
uint64_t util_systick_get(void);
|
||||
|
||||
|
||||
#endif
|
13
src/main.c
13
src/main.c
|
@ -9,6 +9,9 @@
|
|||
/* PPG */
|
||||
#include "pixart_pah8001ei.h"
|
||||
|
||||
/* Utils */
|
||||
#include "util_systick.h"
|
||||
|
||||
/* Sensors */
|
||||
#include "imsensors/dht/dht_bme280.h"
|
||||
|
||||
|
@ -50,11 +53,13 @@ ims_bme280_t s_bmp = {
|
|||
|
||||
int main(void) {
|
||||
BOARD_InitBootPins();
|
||||
BOARD_BootClockRUN();
|
||||
BOARD_InitBootClocks();
|
||||
BOARD_InitBootPeripherals();
|
||||
|
||||
BOARD_InitDebugConsole();
|
||||
|
||||
util_systick_init();
|
||||
|
||||
PRINTF("Hello world!!\r\n");
|
||||
|
||||
pah8001_init(&s_pah);
|
||||
|
@ -73,5 +78,11 @@ int main(void) {
|
|||
for (;;) {
|
||||
ims_bme280_measure_float(&s_bme, &r_bme_float);
|
||||
ims_bme280_measure_float(&s_bmp, &r_bmp_float);
|
||||
|
||||
PRINTF("BME T: %3.2f, H:%3.02f, P: %5.02f\r\n", r_bme_float.temperature, r_bme_float.humidity, r_bme_float.pressure);
|
||||
PRINTF("BMP T: %3.2f, H:%3.02f, P: %5.02f\r\n", r_bmp_float.temperature, r_bmp_float.humidity, r_bmp_float.pressure);
|
||||
|
||||
util_systick_delay(500);
|
||||
GPIO_PortToggle(BOARD_INITPINS_LED_R_GPIO, BOARD_INITPINS_LED_R_PORT, BOARD_INITPINS_LED_R_GPIO_PIN_MASK);
|
||||
}
|
||||
}
|
|
@ -2,43 +2,54 @@
|
|||
|
||||
/* SDK drivers */
|
||||
#include "fsl_i2c.h"
|
||||
#include "fsl_pint.h"
|
||||
|
||||
/* Utils */
|
||||
#include "util_systick.h"
|
||||
|
||||
ims_ret_t sensors_impl_i2c_xfer(void *pdev, uint16_t addr, ims_i2c_xfer_desc_t *xfer) {
|
||||
if (xfer->tx_size > 0) {
|
||||
if (I2C_MasterStart(I2C0, addr, kI2C_Write) != kStatus_Success) {
|
||||
return IMS_FAIL;
|
||||
goto xfer_fail;
|
||||
}
|
||||
|
||||
if (I2C_MasterWriteBlocking(I2C0, xfer->tx_data, xfer->tx_size, kI2C_TransferNoStopFlag) != kStatus_Success) {
|
||||
return IMS_FAIL;
|
||||
goto xfer_fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (xfer->rx_size > 0) {
|
||||
if (xfer->tx_size > 0) {
|
||||
if (I2C_MasterRepeatedStart(I2C0, addr, kI2C_Read) != kStatus_Success) {
|
||||
return IMS_FAIL;
|
||||
goto xfer_fail;
|
||||
}
|
||||
} else {
|
||||
if (I2C_MasterStart(I2C0, addr, kI2C_Read) != kStatus_Success) {
|
||||
return IMS_FAIL;
|
||||
goto xfer_fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (I2C_MasterReadBlocking(I2C0, xfer->rx_data, xfer->rx_size, kI2C_TransferNoStopFlag) != kStatus_Success) {
|
||||
return IMS_FAIL;
|
||||
goto xfer_fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (I2C_MasterStop(I2C0) != kStatus_Success) {
|
||||
return IMS_FAIL;
|
||||
goto xfer_fail;
|
||||
}
|
||||
|
||||
return IMS_SUCCESS;
|
||||
|
||||
xfer_fail:
|
||||
/* Clean-up */
|
||||
I2C_MasterReset(I2C0);
|
||||
return IMS_FAIL;
|
||||
}
|
||||
|
||||
ims_ret_t sensors_impl_delay(void *pdev, uint32_t msec) {
|
||||
util_systick_delay(msec);
|
||||
|
||||
return IMS_SUCCESS;
|
||||
}
|
||||
|
||||
ims_ret_t sensors_impl_delay(void *pdev, uint32_t msec) {
|
||||
SDK_DelayAtLeastUs(msec * 20);
|
||||
|
||||
return IMS_SUCCESS;
|
||||
}
|
||||
void bmm_drdy_callback(pint_pin_int_t pintr, uint32_t pmatch_status) {}
|
|
@ -0,0 +1,33 @@
|
|||
/* SDK drivers */
|
||||
#include "fsl_common.h"
|
||||
|
||||
#include "util_systick.h"
|
||||
|
||||
static volatile uint64_t s_tickcount;
|
||||
|
||||
void util_systick_init(void) {
|
||||
uint32_t tick_freq = CLOCK_GetFreq(kCLOCK_MainClk) / SYSCON->SYSTICKCLKDIV;
|
||||
|
||||
SysTick->LOAD = (tick_freq / 1000) - 1U;
|
||||
SysTick->VAL = 0U;
|
||||
|
||||
NVIC_SetPriority(SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL);
|
||||
|
||||
SysTick->CTRL = SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk;
|
||||
}
|
||||
|
||||
uint64_t util_systick_get(void) {
|
||||
return s_tickcount;
|
||||
}
|
||||
|
||||
void util_systick_delay(uint64_t msec) {
|
||||
uint64_t tick_end = s_tickcount + msec;
|
||||
|
||||
while(tick_end > s_tickcount) {
|
||||
__WFI();
|
||||
}
|
||||
}
|
||||
|
||||
void SysTick_Handler(void) {
|
||||
s_tickcount++;
|
||||
}
|
Loading…
Reference in New Issue