├── .gitignore ├── libs ├── libpower_hardabi.a └── libpower_softabi.a ├── .settings ├── org.eclipse.cdt.ui.prefs ├── language.settings.xml └── org.eclipse.cdt.codan.core.prefs ├── sources ├── gpio.h ├── can.h ├── gpio.c ├── main.h ├── semihost_hardfault.c ├── usb_device_descriptor.h ├── usb_device_config.h └── can.c ├── .project ├── LICENSE.txt ├── README.md ├── CMSIS ├── cmsis_version.h ├── fsl_device_registers.h ├── arm_const_structs.h ├── arm_common_tables.h ├── system_LPC54618.h ├── system_LPC54616.h ├── mpu_armv7.h └── cmsis_compiler.h ├── usb ├── device │ ├── class │ │ └── gs_usb │ │ │ ├── gs_usb_class.h │ │ │ └── gs_usb.h │ └── source │ │ ├── usb_device_ch9.h │ │ └── usb_device_dci.h └── include │ └── usb.h ├── board ├── peripherals.h ├── peripherals.c └── src │ ├── pin_mux.h │ ├── clock_config.h │ └── board.c ├── drivers ├── fsl_power.c ├── fsl_flexcomm.h ├── fsl_gpio.c ├── fsl_reset.c ├── fsl_common.c ├── fsl_power.h └── fsl_iocon.h ├── utilities ├── fsl_assert.c ├── fsl_str.h ├── fsl_io.h ├── fsl_log.h ├── fsl_debug_console_conf.h └── fsl_debug_console.h └── osa └── usb_osa_bm.h /.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | *.launch 3 | /Release/ 4 | -------------------------------------------------------------------------------- /libs/libpower_hardabi.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linklayer/cantact-pro-fw/HEAD/libs/libpower_hardabi.a -------------------------------------------------------------------------------- /libs/libpower_softabi.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linklayer/cantact-pro-fw/HEAD/libs/libpower_softabi.a -------------------------------------------------------------------------------- /.settings/org.eclipse.cdt.ui.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | formatter_profile=org.eclipse.cdt.ui.default.kandr_profile 3 | formatter_settings_version=1 4 | -------------------------------------------------------------------------------- /sources/gpio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * gpio.h 3 | * 4 | */ 5 | 6 | #ifndef GPIO_H_ 7 | #define GPIO_H_ 8 | 9 | #include 10 | 11 | #define GPIO_LED_1_PORT 0 12 | #define GPIO_LED_1_PIN 23 13 | #define GPIO_LED_2_PORT 1 14 | #define GPIO_LED_2_PIN 8 15 | #define GPIO_LED_3_PORT 1 16 | #define GPIO_LED_3_PIN 21 17 | #define GPIO_LED_4_PORT 0 18 | #define GPIO_LED_4_PIN 24 19 | 20 | #define GPIO_SWCAN_MODE0_PORT 0 21 | #define GPIO_SWCAN_MODE0_PIN 2 22 | #define GPIO_SWCAN_MODE1_PORT 1 23 | #define GPIO_SWCAN_MODE1_PIN 14 24 | #define GPIO_SWCAN_ENABLE_PORT 0 25 | #define GPIO_SWCAN_ENABLE_PIN 21 26 | 27 | enum { 28 | GPIO_LED_1 = 1, 29 | GPIO_LED_2, 30 | GPIO_LED_3, 31 | GPIO_LED_4 32 | }; 33 | 34 | void gpio_set_swcan_mode(uint8_t mode); 35 | void gpio_set_swcan_enable(uint8_t enable); 36 | void gpio_set_led(uint8_t led, uint8_t state); 37 | void gpio_toggle_led(uint8_t led); 38 | 39 | 40 | #endif /* GPIO_H_ */ 41 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | cantact-pro 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | com.nxp.mcuxpresso.core.datamodels.sdkNature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /sources/can.h: -------------------------------------------------------------------------------- 1 | /* 2 | * can.h 3 | * 4 | */ 5 | 6 | #ifndef CAN_H_ 7 | #define CAN_H_ 8 | 9 | #include "fsl_mcan.h" 10 | 11 | #define CAN_NUM_CHANNELS 2 12 | #define STDID_OFFSET 18U 13 | 14 | uint64_t can_get_rx_count(uint8_t channel); 15 | uint64_t can_get_tx_count(uint8_t channel); 16 | uint8_t can_get_enabled(uint8_t channel); 17 | void can_set_identify(uint8_t channel, uint8_t enable); 18 | uint8_t can_get_identify(uint8_t channel); 19 | uint8_t can_get_monitor_mode(uint8_t channel); 20 | int can_set_timing(uint8_t index, mcan_timing_config_t *timing_config); 21 | int can_set_data_timing(uint8_t index, mcan_timing_config_t *timing_config); 22 | int can_len2dlc(uint8_t len); 23 | int can_dlc2len(uint8_t dlc); 24 | int can_start(uint8_t index, uint32_t flags); 25 | int can_stop(uint8_t index); 26 | int can_send(uint8_t channel, uint8_t buf, uint32_t can_id, uint8_t flags, uint8_t can_dlc, 27 | uint8_t *can_data); 28 | 29 | #endif /* CAN_H_ */ 30 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2020 Linklayer Labs 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CANtact FD Firmware 2 | 3 | This repository contains firmware for the CANtact FD device. This firmware is 4 | provided as a project for the NXP MCUXpresso IDE, which is available for free 5 | from NXP. 6 | 7 | ## IDE and SDK 8 | 9 | This IDE can be downloaded from NXP [here](https://www.nxp.com/support/developer-resources/software-development-tools/mcuxpresso-software-and-tools/mcuxpresso-integrated-development-environment-ide:MCUXpresso-IDE). 10 | 11 | The project has been tested using MCUXpresso IDE v10.2.1 [Build 795] [2018-07-25] 12 | and SDK version 2.4.1. Since SDK file are bundled with the project, you should 13 | not need to install the SDK. 14 | 15 | ## Importing Project 16 | 17 | 1. To import the project to MCUXpresso, first clone it using git: `git clone ssh://git@gitlab.com:linklayer/cantact-pro.git` 18 | 2. Open MCUXpresso 19 | 3. Select File -> Import... and choose "Existing Projects into Workspace" 20 | 4. Click "Browse" beside "Select root directory" and select the location of the cloned firmware 21 | 5. Check the box beside the projects in the "Projects:" list 22 | 6. Click Finish 23 | -------------------------------------------------------------------------------- /sources/gpio.c: -------------------------------------------------------------------------------- 1 | /* 2 | * gpio.c 3 | * 4 | */ 5 | 6 | #include "fsl_gpio.h" 7 | 8 | #include "gpio.h" 9 | 10 | void gpio_set_swcan_mode(uint8_t mode) { 11 | // invert the mode bits since inverted logic is used 12 | 13 | // set SWCAN_MODE0 14 | GPIO_WritePinOutput(GPIO, GPIO_SWCAN_MODE0_PORT, GPIO_SWCAN_MODE0_PIN, ~(mode & 0x01)); 15 | 16 | // set SWCAN_MODE1 17 | GPIO_WritePinOutput(GPIO, GPIO_SWCAN_MODE1_PORT, GPIO_SWCAN_MODE1_PIN, ~((mode & 0x01) >> 1)); 18 | } 19 | 20 | void gpio_set_swcan_enable(uint8_t enable) { 21 | if (enable) { 22 | // set SWCAN_ENABLE low to enable 23 | GPIO_WritePinOutput(GPIO, GPIO_SWCAN_ENABLE_PORT, GPIO_SWCAN_ENABLE_PIN, 0); 24 | } else { 25 | // set SWCAN_ENABLE high to disable 26 | GPIO_WritePinOutput(GPIO, GPIO_SWCAN_ENABLE_PORT, GPIO_SWCAN_ENABLE_PIN, 1); 27 | } 28 | } 29 | 30 | void gpio_set_led(uint8_t led, uint8_t state) { 31 | switch (led) { 32 | case GPIO_LED_1: 33 | GPIO_WritePinOutput(GPIO, GPIO_LED_1_PORT, GPIO_LED_1_PIN, state); 34 | break; 35 | case GPIO_LED_2: 36 | GPIO_WritePinOutput(GPIO, GPIO_LED_2_PORT, GPIO_LED_2_PIN, state); 37 | break; 38 | case GPIO_LED_3: 39 | GPIO_WritePinOutput(GPIO, GPIO_LED_3_PORT, GPIO_LED_3_PIN, state); 40 | break; 41 | case GPIO_LED_4: 42 | GPIO_WritePinOutput(GPIO, GPIO_LED_4_PORT, GPIO_LED_4_PIN, state); 43 | break; 44 | } 45 | } 46 | 47 | void gpio_toggle_led(uint8_t led) { 48 | switch (led) { 49 | case GPIO_LED_1: 50 | GPIO_PortToggle(GPIO, GPIO_LED_1_PORT, 1< 0) 15 | #define CONTROLLER_ID kUSB_ControllerEhci0 16 | #define DATA_BUFF_SIZE HS_GS_USB_BULK_OUT_PACKET_SIZE 17 | 18 | #endif 19 | #if defined(USB_DEVICE_CONFIG_KHCI) && (USB_DEVICE_CONFIG_KHCI > 0) 20 | #define CONTROLLER_ID kUSB_ControllerKhci0 21 | #define DATA_BUFF_SIZE FS_GS_USB_BULK_OUT_PACKET_SIZE 22 | 23 | #endif 24 | #if defined(USB_DEVICE_CONFIG_LPCIP3511FS) && (USB_DEVICE_CONFIG_LPCIP3511FS > 0U) 25 | #define CONTROLLER_ID kUSB_ControllerLpcIp3511Fs0 26 | #define DATA_BUFF_SIZE FS_GS_USB_BULK_OUT_PACKET_SIZE 27 | 28 | #endif 29 | 30 | #if defined(USB_DEVICE_CONFIG_LPCIP3511HS) && (USB_DEVICE_CONFIG_LPCIP3511HS > 0U) 31 | #define CONTROLLER_ID kUSB_ControllerLpcIp3511Hs0 32 | #define DATA_BUFF_SIZE HS_GS_USB_BULK_OUT_PACKET_SIZE 33 | #endif 34 | 35 | #define USB_DEVICE_INTERRUPT_PRIORITY (3U) 36 | 37 | /* Define the types for application */ 38 | typedef struct _usb_can_struct { 39 | usb_device_handle deviceHandle; /* USB device handle. */ 40 | volatile uint8_t attach; /* A flag to indicate whether a usb device is attached. 1: attached, 0: not attached */ 41 | uint8_t speed; /* Speed of USB device. USB_SPEED_FULL/USB_SPEED_LOW/USB_SPEED_HIGH. */ 42 | uint8_t currentConfiguration; /* Current configuration value. */ 43 | uint8_t hasSentState; /*!< 1: The device has primed the state in interrupt pipe, 0: Not primed the state. */ 44 | } usb_can_t; 45 | 46 | usb_status_t USB_DeviceCallback(usb_device_handle handle, uint32_t event, 47 | void *param); 48 | usb_status_t USB_ClassCallback(class_handle_t handle, uint32_t event, 49 | void *param); 50 | void usb_send(uint8_t *buf, uint32_t len); 51 | void gs_usb_init(); 52 | 53 | #endif /* DEVICE_CLASS_GS_USB_CLASS_H_ */ 54 | -------------------------------------------------------------------------------- /.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /board/peripherals.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2018 NXP 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * o Redistributions of source code must retain the above copyright notice, this list 9 | * of conditions and the following disclaimer. 10 | * 11 | * o Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * o Neither the name of NXP Semiconductor, Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from this 17 | * software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | /** 32 | * @file peripherals.h 33 | * @brief Peripherals initialization header file. 34 | */ 35 | 36 | /* This is a template for board specific configuration created by MCUXpresso IDE Project Wizard.*/ 37 | 38 | #ifndef _PERIPHERALS_H_ 39 | #define _PERIPHERALS_H_ 40 | 41 | #if defined(__cplusplus) 42 | extern "C" { 43 | #endif /* __cplusplus */ 44 | 45 | /** 46 | * @brief Initialize peripherals specific settings. 47 | */ 48 | void BOARD_InitBootPeripherals(void); 49 | 50 | #if defined(__cplusplus) 51 | } 52 | #endif /* __cplusplus */ 53 | 54 | #endif /* _PERIPHERALS_H_ */ 55 | 56 | 57 | -------------------------------------------------------------------------------- /sources/main.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The Clear BSD License 3 | * Copyright (c) 2015, Freescale Semiconductor, Inc. 4 | * Copyright 2016 NXP 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted (subject to the limitations in the disclaimer below) provided 9 | * that the following conditions are met: 10 | * 11 | * o Redistributions of source code must retain the above copyright notice, this list 12 | * of conditions and the following disclaimer. 13 | * 14 | * o Redistributions in binary form must reproduce the above copyright notice, this 15 | * list of conditions and the following disclaimer in the documentation and/or 16 | * other materials provided with the distribution. 17 | * 18 | * o Neither the name of the copyright holder nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | #ifndef _MAIN_H_ 35 | #define _MAIN_H_ 1 36 | 37 | #include "gs_usb.h" 38 | 39 | /******************************************************************************* 40 | * Definitions 41 | ******************************************************************************/ 42 | #define RX_FRAME_BUF_SIZE 1000 43 | 44 | int rx_enqueue(uint8_t channel, mcan_rx_buffer_frame_t *frame); 45 | int rx_enqueue_echo(struct gs_host_frame *frame); 46 | 47 | #endif /* _MAIN_H_ */ 48 | -------------------------------------------------------------------------------- /board/peripherals.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2018 NXP 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * o Redistributions of source code must retain the above copyright notice, this list 9 | * of conditions and the following disclaimer. 10 | * 11 | * o Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * o Neither the name of NXP Semiconductor, Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from this 17 | * software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | /* TEXT BELOW IS USED AS SETTING FOR TOOLS ************************************* 32 | !!GlobalInfo 33 | product: Peripherals v1.0 34 | * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/ 35 | 36 | /** 37 | * @file peripherals.c 38 | * @brief Peripherals initialization file. 39 | */ 40 | 41 | /* This is a template for board specific configuration created by MCUXpresso IDE Project Wizard.*/ 42 | 43 | #include "peripherals.h" 44 | 45 | /** 46 | * @brief Set up and initialize all required blocks and functions related to the peripherals hardware. 47 | */ 48 | void BOARD_InitBootPeripherals(void) { 49 | /* The user initialization should be placed here */ 50 | } 51 | -------------------------------------------------------------------------------- /drivers/fsl_power.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The Clear BSD License 3 | * Copyright (c) 2016, Freescale Semiconductor, Inc. 4 | * Copyright (c) 2016, NXP 5 | * All rights reserved. 6 | * 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted (subject to the limitations in the disclaimer below) provided 10 | * that the following conditions are met: 11 | * 12 | * o Redistributions of source code must retain the above copyright notice, this list 13 | * of conditions and the following disclaimer. 14 | * 15 | * o Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * o Neither the name of copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived from this 21 | * software without specific prior written permission. 22 | * 23 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 28 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 31 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | #include "fsl_common.h" 36 | #include "fsl_power.h" 37 | /* Component ID definition, used by tools. */ 38 | #ifndef FSL_COMPONENT_ID 39 | #define FSL_COMPONENT_ID "platform.drivers.power" 40 | #endif 41 | 42 | /******************************************************************************* 43 | * Code 44 | ******************************************************************************/ 45 | 46 | /* Empty file since implementation is in header file and power library */ 47 | -------------------------------------------------------------------------------- /utilities/fsl_assert.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The Clear BSD License 3 | * Copyright (c) 2015-2016, Freescale Semiconductor, Inc. 4 | * Copyright 2016-2017 NXP 5 | * All rights reserved. 6 | * 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted (subject to the limitations in the disclaimer below) provided 10 | * that the following conditions are met: 11 | * 12 | * o Redistributions of source code must retain the above copyright notice, this list 13 | * of conditions and the following disclaimer. 14 | * 15 | * o Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * o Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived from this 21 | * software without specific prior written permission. 22 | * 23 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 28 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 31 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include "fsl_common.h" 37 | #include "fsl_debug_console.h" 38 | 39 | #ifndef NDEBUG 40 | #if (defined(__CC_ARM)) || (defined(__ICCARM__)) 41 | void __aeabi_assert(const char *failedExpr, const char *file, int line) 42 | { 43 | PRINTF("ASSERT ERROR \" %s \": file \"%s\" Line \"%d\" \n", failedExpr, file, line); 44 | for (;;) 45 | { 46 | __BKPT(0); 47 | } 48 | } 49 | #elif(defined(__GNUC__)) 50 | void __assert_func(const char *file, int line, const char *func, const char *failedExpr) 51 | { 52 | PRINTF("ASSERT ERROR \" %s \": file \"%s\" Line \"%d\" function name \"%s\" \n", failedExpr, file, line, func); 53 | for (;;) 54 | { 55 | __BKPT(0); 56 | } 57 | } 58 | #endif /* (defined(__CC_ARM)) || (defined (__ICCARM__)) */ 59 | #endif /* NDEBUG */ 60 | -------------------------------------------------------------------------------- /CMSIS/fsl_device_registers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The Clear BSD License 3 | * Copyright (c) 2014 - 2016, Freescale Semiconductor, Inc. 4 | * Copyright 2016 - 2017 NXP 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted (subject to the limitations in the disclaimer below) provided 9 | * that the following conditions are met: 10 | * 11 | * o Redistributions of source code must retain the above copyright notice, this list 12 | * of conditions and the following disclaimer. 13 | * 14 | * o Redistributions in binary form must reproduce the above copyright notice, this 15 | * list of conditions and the following disclaimer in the documentation and/or 16 | * other materials provided with the distribution. 17 | * 18 | * o Neither the name of the copyright holder nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | */ 35 | 36 | #ifndef __FSL_DEVICE_REGISTERS_H__ 37 | #define __FSL_DEVICE_REGISTERS_H__ 38 | 39 | /* 40 | * Include the cpu specific register header files. 41 | * 42 | * The CPU macro should be declared in the project or makefile. 43 | */ 44 | #if (defined(CPU_LPC54616J256ET180) || defined(CPU_LPC54616J512BD100) || defined(CPU_LPC54616J512BD208) || \ 45 | defined(CPU_LPC54616J512ET100)) 46 | 47 | #define LPC54616_SERIES 48 | 49 | /* CMSIS-style register definitions */ 50 | #include "LPC54616.h" 51 | /* CPU specific feature definitions */ 52 | #include "LPC54616_features.h" 53 | 54 | #else 55 | #error "No valid CPU defined!" 56 | #endif 57 | 58 | #endif /* __FSL_DEVICE_REGISTERS_H__ */ 59 | 60 | /******************************************************************************* 61 | * EOF 62 | ******************************************************************************/ 63 | -------------------------------------------------------------------------------- /osa/usb_osa_bm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The Clear BSD License 3 | * Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc. 4 | * Copyright 2016 NXP 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted (subject to the limitations in the disclaimer below) provided 9 | * that the following conditions are met: 10 | * 11 | * o Redistributions of source code must retain the above copyright notice, this list 12 | * of conditions and the following disclaimer. 13 | * 14 | * o Redistributions in binary form must reproduce the above copyright notice, this 15 | * list of conditions and the following disclaimer in the documentation and/or 16 | * other materials provided with the distribution. 17 | * 18 | * o Neither the name of the copyright holder nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef __USB_OSA_BM_H__ 36 | #define __USB_OSA_BM_H__ 37 | 38 | /******************************************************************************* 39 | * Definitions 40 | ******************************************************************************/ 41 | 42 | #define USB_OSA_SR_ALLOC() uint32_t usbOsaCurrentSr; 43 | #define USB_OSA_ENTER_CRITICAL() USB_OsaEnterCritical(&usbOsaCurrentSr) 44 | #define USB_OSA_EXIT_CRITICAL() USB_OsaExitCritical(usbOsaCurrentSr) 45 | 46 | /******************************************************************************* 47 | * API 48 | ******************************************************************************/ 49 | 50 | #if defined(__cplusplus) 51 | extern "C" { 52 | #endif 53 | 54 | extern void USB_OsaEnterCritical(uint32_t *sr); 55 | extern void USB_OsaExitCritical(uint32_t sr); 56 | 57 | #if defined(__cplusplus) 58 | } 59 | #endif 60 | 61 | #endif /* __USB_OSA_BM_H__ */ 62 | -------------------------------------------------------------------------------- /CMSIS/arm_const_structs.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Project: CMSIS DSP Library 3 | * Title: arm_const_structs.h 4 | * Description: Constant structs that are initialized for user convenience. 5 | * For example, some can be given as arguments to the arm_cfft_f32() function. 6 | * 7 | * $Date: 27. January 2017 8 | * $Revision: V.1.5.1 9 | * 10 | * Target Processor: Cortex-M cores 11 | * -------------------------------------------------------------------- */ 12 | /* 13 | * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved. 14 | * 15 | * SPDX-License-Identifier: Apache-2.0 16 | * 17 | * Licensed under the Apache License, Version 2.0 (the License); you may 18 | * not use this file except in compliance with the License. 19 | * You may obtain a copy of the License at 20 | * 21 | * www.apache.org/licenses/LICENSE-2.0 22 | * 23 | * Unless required by applicable law or agreed to in writing, software 24 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 25 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | * See the License for the specific language governing permissions and 27 | * limitations under the License. 28 | */ 29 | 30 | #ifndef _ARM_CONST_STRUCTS_H 31 | #define _ARM_CONST_STRUCTS_H 32 | 33 | #include "arm_math.h" 34 | #include "arm_common_tables.h" 35 | 36 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len16; 37 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len32; 38 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len64; 39 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len128; 40 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len256; 41 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len512; 42 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024; 43 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048; 44 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096; 45 | 46 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len16; 47 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len32; 48 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len64; 49 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len128; 50 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len256; 51 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len512; 52 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024; 53 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048; 54 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096; 55 | 56 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len16; 57 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len32; 58 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len64; 59 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len128; 60 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len256; 61 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len512; 62 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024; 63 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048; 64 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096; 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /drivers/fsl_flexcomm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The Clear BSD License 3 | * Copyright (c) 2016, Freescale Semiconductor, Inc. 4 | * Copyright 2016-2017 NXP 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted (subject to the limitations in the disclaimer below) provided 9 | * that the following conditions are met: 10 | * 11 | * o Redistributions of source code must retain the above copyright notice, this list 12 | * of conditions and the following disclaimer. 13 | * 14 | * o Redistributions in binary form must reproduce the above copyright notice, this 15 | * list of conditions and the following disclaimer in the documentation and/or 16 | * other materials provided with the distribution. 17 | * 18 | * o Neither the name of the copyright holder nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | #ifndef _FSL_FLEXCOMM_H_ 35 | #define _FSL_FLEXCOMM_H_ 36 | 37 | #include "fsl_common.h" 38 | 39 | /*! 40 | * @addtogroup flexcomm_driver 41 | * @{ 42 | */ 43 | 44 | /*! @name Driver version */ 45 | /*@{*/ 46 | /*! @brief FlexCOMM driver version 2.0.0. */ 47 | #define FSL_FLEXCOMM_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) 48 | /*@}*/ 49 | 50 | /*! @brief FLEXCOMM peripheral modes. */ 51 | typedef enum 52 | { 53 | FLEXCOMM_PERIPH_NONE, /*!< No peripheral */ 54 | FLEXCOMM_PERIPH_USART, /*!< USART peripheral */ 55 | FLEXCOMM_PERIPH_SPI, /*!< SPI Peripheral */ 56 | FLEXCOMM_PERIPH_I2C, /*!< I2C Peripheral */ 57 | FLEXCOMM_PERIPH_I2S_TX, /*!< I2S TX Peripheral */ 58 | FLEXCOMM_PERIPH_I2S_RX, /*!< I2S RX Peripheral */ 59 | } FLEXCOMM_PERIPH_T; 60 | 61 | /*! @brief Typedef for interrupt handler. */ 62 | typedef void (*flexcomm_irq_handler_t)(void *base, void *handle); 63 | 64 | /*! @brief Array with IRQ number for each FLEXCOMM module. */ 65 | extern IRQn_Type const kFlexcommIrqs[]; 66 | 67 | /*! @brief Returns instance number for FLEXCOMM module with given base address. */ 68 | uint32_t FLEXCOMM_GetInstance(void *base); 69 | 70 | /*! @brief Initializes FLEXCOMM and selects peripheral mode according to the second parameter. */ 71 | status_t FLEXCOMM_Init(void *base, FLEXCOMM_PERIPH_T periph); 72 | 73 | /*! @brief Sets IRQ handler for given FLEXCOMM module. It is used by drivers register IRQ handler according to FLEXCOMM 74 | * mode */ 75 | void FLEXCOMM_SetIRQHandler(void *base, flexcomm_irq_handler_t handler, void *handle); 76 | 77 | /*@}*/ 78 | 79 | #endif /* _FSL_FLEXCOMM_H_*/ 80 | -------------------------------------------------------------------------------- /utilities/fsl_str.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The Clear BSD License 3 | * Copyright 2017 NXP 4 | * All rights reserved. 5 | * 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted (subject to the limitations in the disclaimer below) provided 9 | * that the following conditions are met: 10 | * 11 | * o Redistributions of source code must retain the above copyright notice, this list 12 | * of conditions and the following disclaimer. 13 | * 14 | * o Redistributions in binary form must reproduce the above copyright notice, this 15 | * list of conditions and the following disclaimer in the documentation and/or 16 | * other materials provided with the distribution. 17 | * 18 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | */ 35 | 36 | #ifndef _FSL_STR_H 37 | #define _FSL_STR_H 38 | 39 | #include "fsl_common.h" 40 | 41 | /*! 42 | * @addtogroup debugconsole 43 | * @{ 44 | */ 45 | 46 | /******************************************************************************* 47 | * Prototypes 48 | ******************************************************************************/ 49 | #if defined(__cplusplus) 50 | extern "C" { 51 | #endif /* __cplusplus */ 52 | 53 | /*! 54 | * @brief A function pointer which is used when format printf log. 55 | */ 56 | typedef void (*printfCb)(char *buf, int32_t *indicator, char val, int len); 57 | 58 | /*! 59 | * @brief This function outputs its parameters according to a formatted string. 60 | * 61 | * @note I/O is performed by calling given function pointer using following 62 | * (*func_ptr)(c); 63 | * 64 | * @param[in] fmt_ptr Format string for printf. 65 | * @param[in] args_ptr Arguments to printf. 66 | * @param[in] buf pointer to the buffer 67 | * @param cb print callbck function pointer 68 | * 69 | * @return Number of characters to be print 70 | */ 71 | int StrFormatPrintf(const char *fmt, va_list ap, char *buf, printfCb cb); 72 | 73 | /*! 74 | * @brief Converts an input line of ASCII characters based upon a provided 75 | * string format. 76 | * 77 | * @param[in] line_ptr The input line of ASCII data. 78 | * @param[in] format Format first points to the format string. 79 | * @param[in] args_ptr The list of parameters. 80 | * 81 | * @return Number of input items converted and assigned. 82 | * @retval IO_EOF When line_ptr is empty string "". 83 | */ 84 | int StrFormatScanf(const char *line_ptr, char *format, va_list args_ptr); 85 | 86 | #if defined(__cplusplus) 87 | } 88 | #endif /* __cplusplus */ 89 | 90 | /*! @} */ 91 | 92 | #endif /* _FSL_STR_H */ 93 | -------------------------------------------------------------------------------- /drivers/fsl_gpio.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The Clear BSD License 3 | * Copyright (c) 2016, Freescale Semiconductor, Inc. 4 | * Copyright 2016-2017 NXP 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted (subject to the limitations in the disclaimer below) provided 9 | * that the following conditions are met: 10 | * 11 | * o Redistributions of source code must retain the above copyright notice, this list 12 | * of conditions and the following disclaimer. 13 | * 14 | * o Redistributions in binary form must reproduce the above copyright notice, this 15 | * list of conditions and the following disclaimer in the documentation and/or 16 | * other materials provided with the distribution. 17 | * 18 | * o Neither the name of the copyright holder nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #include "fsl_gpio.h" 36 | 37 | /* Component ID definition, used by tools. */ 38 | #ifndef FSL_COMPONENT_ID 39 | #define FSL_COMPONENT_ID "platform.drivers.lpc_gpio" 40 | #endif 41 | 42 | 43 | /******************************************************************************* 44 | * Variables 45 | ******************************************************************************/ 46 | #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) 47 | /*! @brief Array to map FGPIO instance number to clock name. */ 48 | static const clock_ip_name_t s_gpioClockName[] = GPIO_CLOCKS; 49 | #endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */ 50 | /******************************************************************************* 51 | * Prototypes 52 | ************ ******************************************************************/ 53 | 54 | /******************************************************************************* 55 | * Code 56 | ******************************************************************************/ 57 | void GPIO_PortInit(GPIO_Type *base, uint32_t port) 58 | { 59 | #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) 60 | assert(port < ARRAY_SIZE(s_gpioClockName)); 61 | 62 | /* Upgate the GPIO clock */ 63 | CLOCK_EnableClock(s_gpioClockName[port]); 64 | #endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */ 65 | } 66 | 67 | void GPIO_PinInit(GPIO_Type *base, uint32_t port, uint32_t pin, const gpio_pin_config_t *config) 68 | { 69 | if (config->pinDirection == kGPIO_DigitalInput) 70 | { 71 | base->DIR[port] &= ~(1U << pin); 72 | } 73 | else 74 | { 75 | /* Set default output value */ 76 | if (config->outputLogic == 0U) 77 | { 78 | base->CLR[port] = (1U << pin); 79 | } 80 | else 81 | { 82 | base->SET[port] = (1U << pin); 83 | } 84 | /* Set pin direction */ 85 | base->DIR[port] |= 1U << pin; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /usb/device/class/gs_usb/gs_usb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * gs_usb.h 3 | */ 4 | 5 | #ifndef GS_USB_H_ 6 | #define GS_USB_H_ 7 | 8 | #include "stdint.h" 9 | 10 | /* Device specific constants */ 11 | enum gs_usb_breq { 12 | GS_USB_BREQ_HOST_FORMAT = 0, 13 | GS_USB_BREQ_BITTIMING, 14 | GS_USB_BREQ_MODE, 15 | GS_USB_BREQ_BERR, 16 | GS_USB_BREQ_BT_CONST, 17 | GS_USB_BREQ_DEVICE_CONFIG, 18 | GS_USB_BREQ_TIMESTAMP, 19 | GS_USB_BREQ_IDENTIFY, 20 | GS_USB_BREQ_DATA_BITTIMING, 21 | }; 22 | 23 | enum gs_can_mode { 24 | /* reset a channel. turns it off */ 25 | GS_CAN_MODE_RESET = 0, 26 | /* starts a channel */ 27 | GS_CAN_MODE_START 28 | }; 29 | 30 | enum gs_can_state { 31 | GS_CAN_STATE_ERROR_ACTIVE = 0, 32 | GS_CAN_STATE_ERROR_WARNING, 33 | GS_CAN_STATE_ERROR_PASSIVE, 34 | GS_CAN_STATE_BUS_OFF, 35 | GS_CAN_STATE_STOPPED, 36 | GS_CAN_STATE_SLEEPING 37 | }; 38 | 39 | enum gs_can_identify_mode { 40 | GS_CAN_IDENTIFY_OFF = 0, GS_CAN_IDENTIFY_ON 41 | }; 42 | 43 | /* data types passed between host and device */ 44 | struct gs_host_config { 45 | uint32_t byte_order; 46 | }; 47 | /* All data exchanged between host and device is exchanged in host byte order, 48 | * thanks to the struct gs_host_config byte_order member, which is sent first 49 | * to indicate the desired byte order. 50 | */ 51 | 52 | struct gs_device_config { 53 | uint8_t reserved1; 54 | uint8_t reserved2; 55 | uint8_t reserved3; 56 | uint8_t icount; 57 | uint32_t sw_version; 58 | uint32_t hw_version; 59 | }; 60 | 61 | #define GS_CAN_MODE_NORMAL 0 62 | #define GS_CAN_MODE_LISTEN_ONLY BIT(0) 63 | #define GS_CAN_MODE_LOOP_BACK BIT(1) 64 | #define GS_CAN_MODE_TRIPLE_SAMPLE BIT(2) 65 | #define GS_CAN_MODE_ONE_SHOT BIT(3) 66 | #define GS_CAN_MODE_HW_TIMESTAMP BIT(4) 67 | #define GS_CAN_MODE_PAD_PKTS_TO_MAX_PKT_SIZE BIT(7) 68 | #define GS_CAN_MODE_FD BIT(8) 69 | 70 | struct gs_device_mode { 71 | uint32_t mode; 72 | uint32_t flags; 73 | }; 74 | 75 | struct gs_device_state { 76 | uint32_t state; 77 | uint32_t rxerr; 78 | uint32_t txerr; 79 | }; 80 | 81 | struct gs_device_bittiming { 82 | uint32_t prop_seg; 83 | uint32_t phase_seg1; 84 | uint32_t phase_seg2; 85 | uint32_t sjw; 86 | uint32_t brp; 87 | }; 88 | 89 | struct gs_identify_mode { 90 | uint32_t mode; 91 | }; 92 | 93 | #define BIT(X) (1< 0)) || \ 60 | (defined(FSL_FEATURE_SOC_ASYNC_SYSCON_COUNT) && (FSL_FEATURE_SOC_ASYNC_SYSCON_COUNT > 0))) 61 | 62 | void RESET_SetPeripheralReset(reset_ip_name_t peripheral) 63 | { 64 | const uint32_t regIndex = ((uint32_t)peripheral & 0xFFFF0000u) >> 16; 65 | const uint32_t bitPos = ((uint32_t)peripheral & 0x0000FFFFu); 66 | const uint32_t bitMask = 1u << bitPos; 67 | 68 | assert(bitPos < 32u); 69 | 70 | /* ASYNC_SYSCON registers have offset 1024 */ 71 | if (regIndex >= SYSCON_PRESETCTRL_COUNT) 72 | { 73 | /* reset register is in ASYNC_SYSCON */ 74 | 75 | /* set bit */ 76 | ASYNC_SYSCON->ASYNCPRESETCTRLSET = bitMask; 77 | /* wait until it reads 0b1 */ 78 | while (0u == (ASYNC_SYSCON->ASYNCPRESETCTRL & bitMask)) 79 | { 80 | } 81 | } 82 | else 83 | { 84 | /* reset register is in SYSCON */ 85 | 86 | /* set bit */ 87 | SYSCON->PRESETCTRLSET[regIndex] = bitMask; 88 | /* wait until it reads 0b1 */ 89 | while (0u == (SYSCON->PRESETCTRL[regIndex] & bitMask)) 90 | { 91 | } 92 | } 93 | } 94 | 95 | void RESET_ClearPeripheralReset(reset_ip_name_t peripheral) 96 | { 97 | const uint32_t regIndex = ((uint32_t)peripheral & 0xFFFF0000u) >> 16; 98 | const uint32_t bitPos = ((uint32_t)peripheral & 0x0000FFFFu); 99 | const uint32_t bitMask = 1u << bitPos; 100 | 101 | assert(bitPos < 32u); 102 | 103 | /* ASYNC_SYSCON registers have offset 1024 */ 104 | if (regIndex >= SYSCON_PRESETCTRL_COUNT) 105 | { 106 | /* reset register is in ASYNC_SYSCON */ 107 | 108 | /* clear bit */ 109 | ASYNC_SYSCON->ASYNCPRESETCTRLCLR = bitMask; 110 | /* wait until it reads 0b0 */ 111 | while (bitMask == (ASYNC_SYSCON->ASYNCPRESETCTRL & bitMask)) 112 | { 113 | } 114 | } 115 | else 116 | { 117 | /* reset register is in SYSCON */ 118 | 119 | /* clear bit */ 120 | SYSCON->PRESETCTRLCLR[regIndex] = bitMask; 121 | /* wait until it reads 0b0 */ 122 | while (bitMask == (SYSCON->PRESETCTRL[regIndex] & bitMask)) 123 | { 124 | } 125 | } 126 | } 127 | 128 | void RESET_PeripheralReset(reset_ip_name_t peripheral) 129 | { 130 | RESET_SetPeripheralReset(peripheral); 131 | RESET_ClearPeripheralReset(peripheral); 132 | } 133 | 134 | #endif /* FSL_FEATURE_SOC_SYSCON_COUNT || FSL_FEATURE_SOC_ASYNC_SYSCON_COUNT */ 135 | -------------------------------------------------------------------------------- /sources/semihost_hardfault.c: -------------------------------------------------------------------------------- 1 | // **************************************************************************** 2 | // semihost_hardfault.c 3 | // - Provides hard fault handler to allow semihosting code not 4 | // to hang application when debugger not connected. 5 | // 6 | // **************************************************************************** 7 | // Copyright(C) NXP Semiconductors, 2017-2018 8 | // All rights reserved. 9 | // 10 | // Software that is described herein is for illustrative purposes only 11 | // which provides customers with programming information regarding the 12 | // NXP Cortex-M based MCUs. This software is supplied "AS IS" without any 13 | // warranties of any kind, and NXP Semiconductors and its licensor disclaim any 14 | // and all warranties, express or implied, including all implied warranties of 15 | // merchantability, fitness for a particular purpose and non-infringement of 16 | // intellectual property rights. NXP Semiconductors assumes no responsibility 17 | // or liability for the use of the software, conveys no license or rights under 18 | // any patent, copyright, mask work right, or any other intellectual property 19 | // rights in or to any products. NXP Semiconductors reserves the right to make 20 | // changes in the software without notification. NXP Semiconductors also makes 21 | // no representation or warranty that such application will be suitable for the 22 | // specified use without further testing or modification. 23 | // 24 | // Permission to use, copy, modify, and distribute this software and its 25 | // documentation is hereby granted, under NXP Semiconductors' and its 26 | // licensor's relevant copyrights in the software, without fee, provided that it 27 | // is used in conjunction with NXP Semiconductors microcontrollers. This 28 | // copyright, permission, and disclaimer notice must appear in all copies of 29 | // this code. 30 | // **************************************************************************** 31 | // 32 | // ===== DESCRIPTION ===== 33 | // 34 | // One of the issues with applications that make use of semihosting operations 35 | // (such as printf calls) is that the code will not execute correctly when the 36 | // debugger is not connected. Generally this will show up with the application 37 | // appearing to just hang. This may include the application running from reset 38 | // or powering up the board (with the application already in FLASH), and also 39 | // as the application failing to continue to execute after a debug session is 40 | // terminated. 41 | // 42 | // The problem here is that the "bottom layer" of the semihosted variants of 43 | // the C library, semihosting is implemented by a "BKPT 0xAB" instruction. 44 | // When the debug tools are not connected, this instruction triggers a hard 45 | // fault - and the default hard fault handler within an application will 46 | // typically just contains an infinite loop - causing the application to 47 | // appear to have hang when no debugger is connected. 48 | // 49 | // The below code provides an example hard fault handler which instead looks 50 | // to see what the instruction that caused the hard fault was - and if it 51 | // was a "BKPT 0xAB", then it instead returns back to the user application. 52 | // 53 | // In most cases this will allow applications containing semihosting 54 | // operations to execute (to some degree) when the debugger is not connected. 55 | // 56 | // == NOTE == 57 | // 58 | // Correct execution of the application containing semihosted operations 59 | // which are vectored onto this hard fault handler cannot be guaranteed. This 60 | // is because the handler may not return data or return codes that the higher 61 | // level C library code or application code expects. This hard fault handler 62 | // is meant as a development aid, and it is not recommended to leave 63 | // semihosted code in a production build of your application! 64 | // 65 | // **************************************************************************** 66 | 67 | // Allow handler to be removed by setting a define (via command line) 68 | #if !defined (__SEMIHOST_HARDFAULT_DISABLE) 69 | 70 | __attribute__((naked)) 71 | void HardFault_Handler(void) { 72 | __asm( ".syntax unified\n" 73 | // Check which stack is in use 74 | "MOVS R0, #4 \n" 75 | "MOV R1, LR \n" 76 | "TST R0, R1 \n" 77 | "BEQ _MSP \n" 78 | "MRS R0, PSP \n" 79 | "B _process \n" 80 | "_MSP: \n" 81 | "MRS R0, MSP \n" 82 | // Load the instruction that triggered hard fault 83 | "_process: \n" 84 | "LDR R1,[R0,#24] \n" 85 | "LDRH R2,[r1] \n" 86 | // Semihosting instruction is "BKPT 0xAB" (0xBEAB) 87 | "LDR R3,=0xBEAB \n" 88 | "CMP R2,R3 \n" 89 | "BEQ _semihost_return \n" 90 | // Wasn't semihosting instruction so enter infinite loop 91 | "B . \n" 92 | // Was semihosting instruction, so adjust location to 93 | // return to by 1 instruction (2 bytes), then exit function 94 | "_semihost_return: \n" 95 | "ADDS R1,#2 \n" 96 | "STR R1,[R0,#24] \n" 97 | // Set a return value from semihosting operation. 98 | // 32 is slightly arbitrary, but appears to allow most 99 | // C Library IO functions sitting on top of semihosting to 100 | // continue to operate to some degree 101 | "MOVS R1,#32 \n" 102 | "STR R1,[ R0,#0 ] \n"// R0 is at location 0 on stack 103 | // Return from hard fault handler to application 104 | "BX LR \n" 105 | ".syntax divided\n"); 106 | } 107 | 108 | #endif 109 | 110 | -------------------------------------------------------------------------------- /CMSIS/arm_common_tables.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Project: CMSIS DSP Library 3 | * Title: arm_common_tables.h 4 | * Description: Extern declaration for common tables 5 | * 6 | * $Date: 27. January 2017 7 | * $Revision: V.1.5.1 8 | * 9 | * Target Processor: Cortex-M cores 10 | * -------------------------------------------------------------------- */ 11 | /* 12 | * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | * 16 | * Licensed under the Apache License, Version 2.0 (the License); you may 17 | * not use this file except in compliance with the License. 18 | * You may obtain a copy of the License at 19 | * 20 | * www.apache.org/licenses/LICENSE-2.0 21 | * 22 | * Unless required by applicable law or agreed to in writing, software 23 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 24 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | * See the License for the specific language governing permissions and 26 | * limitations under the License. 27 | */ 28 | 29 | #ifndef _ARM_COMMON_TABLES_H 30 | #define _ARM_COMMON_TABLES_H 31 | 32 | #include "arm_math.h" 33 | 34 | extern const uint16_t armBitRevTable[1024]; 35 | extern const q15_t armRecipTableQ15[64]; 36 | extern const q31_t armRecipTableQ31[64]; 37 | extern const float32_t twiddleCoef_16[32]; 38 | extern const float32_t twiddleCoef_32[64]; 39 | extern const float32_t twiddleCoef_64[128]; 40 | extern const float32_t twiddleCoef_128[256]; 41 | extern const float32_t twiddleCoef_256[512]; 42 | extern const float32_t twiddleCoef_512[1024]; 43 | extern const float32_t twiddleCoef_1024[2048]; 44 | extern const float32_t twiddleCoef_2048[4096]; 45 | extern const float32_t twiddleCoef_4096[8192]; 46 | #define twiddleCoef twiddleCoef_4096 47 | extern const q31_t twiddleCoef_16_q31[24]; 48 | extern const q31_t twiddleCoef_32_q31[48]; 49 | extern const q31_t twiddleCoef_64_q31[96]; 50 | extern const q31_t twiddleCoef_128_q31[192]; 51 | extern const q31_t twiddleCoef_256_q31[384]; 52 | extern const q31_t twiddleCoef_512_q31[768]; 53 | extern const q31_t twiddleCoef_1024_q31[1536]; 54 | extern const q31_t twiddleCoef_2048_q31[3072]; 55 | extern const q31_t twiddleCoef_4096_q31[6144]; 56 | extern const q15_t twiddleCoef_16_q15[24]; 57 | extern const q15_t twiddleCoef_32_q15[48]; 58 | extern const q15_t twiddleCoef_64_q15[96]; 59 | extern const q15_t twiddleCoef_128_q15[192]; 60 | extern const q15_t twiddleCoef_256_q15[384]; 61 | extern const q15_t twiddleCoef_512_q15[768]; 62 | extern const q15_t twiddleCoef_1024_q15[1536]; 63 | extern const q15_t twiddleCoef_2048_q15[3072]; 64 | extern const q15_t twiddleCoef_4096_q15[6144]; 65 | extern const float32_t twiddleCoef_rfft_32[32]; 66 | extern const float32_t twiddleCoef_rfft_64[64]; 67 | extern const float32_t twiddleCoef_rfft_128[128]; 68 | extern const float32_t twiddleCoef_rfft_256[256]; 69 | extern const float32_t twiddleCoef_rfft_512[512]; 70 | extern const float32_t twiddleCoef_rfft_1024[1024]; 71 | extern const float32_t twiddleCoef_rfft_2048[2048]; 72 | extern const float32_t twiddleCoef_rfft_4096[4096]; 73 | 74 | /* floating-point bit reversal tables */ 75 | #define ARMBITREVINDEXTABLE_16_TABLE_LENGTH ((uint16_t)20) 76 | #define ARMBITREVINDEXTABLE_32_TABLE_LENGTH ((uint16_t)48) 77 | #define ARMBITREVINDEXTABLE_64_TABLE_LENGTH ((uint16_t)56) 78 | #define ARMBITREVINDEXTABLE_128_TABLE_LENGTH ((uint16_t)208) 79 | #define ARMBITREVINDEXTABLE_256_TABLE_LENGTH ((uint16_t)440) 80 | #define ARMBITREVINDEXTABLE_512_TABLE_LENGTH ((uint16_t)448) 81 | #define ARMBITREVINDEXTABLE_1024_TABLE_LENGTH ((uint16_t)1800) 82 | #define ARMBITREVINDEXTABLE_2048_TABLE_LENGTH ((uint16_t)3808) 83 | #define ARMBITREVINDEXTABLE_4096_TABLE_LENGTH ((uint16_t)4032) 84 | 85 | extern const uint16_t armBitRevIndexTable16[ARMBITREVINDEXTABLE_16_TABLE_LENGTH]; 86 | extern const uint16_t armBitRevIndexTable32[ARMBITREVINDEXTABLE_32_TABLE_LENGTH]; 87 | extern const uint16_t armBitRevIndexTable64[ARMBITREVINDEXTABLE_64_TABLE_LENGTH]; 88 | extern const uint16_t armBitRevIndexTable128[ARMBITREVINDEXTABLE_128_TABLE_LENGTH]; 89 | extern const uint16_t armBitRevIndexTable256[ARMBITREVINDEXTABLE_256_TABLE_LENGTH]; 90 | extern const uint16_t armBitRevIndexTable512[ARMBITREVINDEXTABLE_512_TABLE_LENGTH]; 91 | extern const uint16_t armBitRevIndexTable1024[ARMBITREVINDEXTABLE_1024_TABLE_LENGTH]; 92 | extern const uint16_t armBitRevIndexTable2048[ARMBITREVINDEXTABLE_2048_TABLE_LENGTH]; 93 | extern const uint16_t armBitRevIndexTable4096[ARMBITREVINDEXTABLE_4096_TABLE_LENGTH]; 94 | 95 | /* fixed-point bit reversal tables */ 96 | #define ARMBITREVINDEXTABLE_FIXED_16_TABLE_LENGTH ((uint16_t)12) 97 | #define ARMBITREVINDEXTABLE_FIXED_32_TABLE_LENGTH ((uint16_t)24) 98 | #define ARMBITREVINDEXTABLE_FIXED_64_TABLE_LENGTH ((uint16_t)56) 99 | #define ARMBITREVINDEXTABLE_FIXED_128_TABLE_LENGTH ((uint16_t)112) 100 | #define ARMBITREVINDEXTABLE_FIXED_256_TABLE_LENGTH ((uint16_t)240) 101 | #define ARMBITREVINDEXTABLE_FIXED_512_TABLE_LENGTH ((uint16_t)480) 102 | #define ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH ((uint16_t)992) 103 | #define ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH ((uint16_t)1984) 104 | #define ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH ((uint16_t)4032) 105 | 106 | extern const uint16_t armBitRevIndexTable_fixed_16[ARMBITREVINDEXTABLE_FIXED_16_TABLE_LENGTH]; 107 | extern const uint16_t armBitRevIndexTable_fixed_32[ARMBITREVINDEXTABLE_FIXED_32_TABLE_LENGTH]; 108 | extern const uint16_t armBitRevIndexTable_fixed_64[ARMBITREVINDEXTABLE_FIXED_64_TABLE_LENGTH]; 109 | extern const uint16_t armBitRevIndexTable_fixed_128[ARMBITREVINDEXTABLE_FIXED_128_TABLE_LENGTH]; 110 | extern const uint16_t armBitRevIndexTable_fixed_256[ARMBITREVINDEXTABLE_FIXED_256_TABLE_LENGTH]; 111 | extern const uint16_t armBitRevIndexTable_fixed_512[ARMBITREVINDEXTABLE_FIXED_512_TABLE_LENGTH]; 112 | extern const uint16_t armBitRevIndexTable_fixed_1024[ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH]; 113 | extern const uint16_t armBitRevIndexTable_fixed_2048[ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH]; 114 | extern const uint16_t armBitRevIndexTable_fixed_4096[ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH]; 115 | 116 | /* Tables for Fast Math Sine and Cosine */ 117 | extern const float32_t sinTable_f32[FAST_MATH_TABLE_SIZE + 1]; 118 | extern const q31_t sinTable_q31[FAST_MATH_TABLE_SIZE + 1]; 119 | extern const q15_t sinTable_q15[FAST_MATH_TABLE_SIZE + 1]; 120 | 121 | #endif /* ARM_COMMON_TABLES_H */ 122 | -------------------------------------------------------------------------------- /CMSIS/system_LPC54618.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** ################################################################### 3 | ** Processors: LPC54618J512BD208 4 | ** LPC54618J512ET180 5 | ** 6 | ** Compilers: Keil ARM C/C++ Compiler 7 | ** GNU C Compiler 8 | ** IAR ANSI C/C++ Compiler for ARM 9 | ** MCUXpresso Compiler 10 | ** 11 | ** Reference manual: LPC546xx User manual Rev.1.9 5 June 2017 12 | ** Version: rev. 1.2, 2017-06-08 13 | ** Build: b180115 14 | ** 15 | ** Abstract: 16 | ** Provides a system configuration function and a global variable that 17 | ** contains the system frequency. It configures the device and initializes 18 | ** the oscillator (PLL) that is part of the microcontroller device. 19 | ** 20 | ** The Clear BSD License 21 | ** Copyright 2016 Freescale Semiconductor, Inc. 22 | ** Copyright 2016-2018 NXP 23 | ** All rights reserved. 24 | ** 25 | ** Redistribution and use in source and binary forms, with or without 26 | ** modification, are permitted (subject to the limitations in the 27 | ** disclaimer below) provided that the following conditions are met: 28 | ** 29 | ** * Redistributions of source code must retain the above copyright 30 | ** notice, this list of conditions and the following disclaimer. 31 | ** 32 | ** * Redistributions in binary form must reproduce the above copyright 33 | ** notice, this list of conditions and the following disclaimer in the 34 | ** documentation and/or other materials provided with the distribution. 35 | ** 36 | ** * Neither the name of the copyright holder nor the names of its 37 | ** contributors may be used to endorse or promote products derived from 38 | ** this software without specific prior written permission. 39 | ** 40 | ** NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE 41 | ** GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT 42 | ** HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 43 | ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 44 | ** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 45 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 46 | ** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 47 | ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 48 | ** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 49 | ** BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 50 | ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 51 | ** OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 52 | ** IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 53 | ** 54 | ** http: www.nxp.com 55 | ** mail: support@nxp.com 56 | ** 57 | ** Revisions: 58 | ** - rev. 1.0 (2016-08-12) 59 | ** Initial version. 60 | ** - rev. 1.1 (2016-11-25) 61 | ** Update CANFD and Classic CAN register. 62 | ** Add MAC TIMERSTAMP registers. 63 | ** - rev. 1.2 (2017-06-08) 64 | ** Remove RTC_CTRL_RTC_OSC_BYPASS. 65 | ** SYSCON_ARMTRCLKDIV rename to SYSCON_ARMTRACECLKDIV. 66 | ** Remove RESET and HALT from SYSCON_AHBCLKDIV. 67 | ** 68 | ** ################################################################### 69 | */ 70 | 71 | /*! 72 | * @file LPC54618 73 | * @version 1.2 74 | * @date 2017-06-08 75 | * @brief Device specific configuration file for LPC54618 (header file) 76 | * 77 | * Provides a system configuration function and a global variable that contains 78 | * the system frequency. It configures the device and initializes the oscillator 79 | * (PLL) that is part of the microcontroller device. 80 | */ 81 | 82 | #ifndef _SYSTEM_LPC54618_H_ 83 | #define _SYSTEM_LPC54618_H_ /**< Symbol preventing repeated inclusion */ 84 | 85 | #ifdef __cplusplus 86 | extern "C" { 87 | #endif 88 | 89 | #include 90 | 91 | #define DEFAULT_SYSTEM_CLOCK 12000000u /* Default System clock value */ 92 | #define CLK_RTC_32K_CLK 32768u /* RTC oscillator 32 kHz output (32k_clk */ 93 | #define CLK_FRO_12MHZ 12000000u /* FRO 12 MHz (fro_12m) */ 94 | #define CLK_FRO_48MHZ 48000000u /* FRO 48 MHz (fro_48m) */ 95 | #define CLK_FRO_96MHZ 96000000u /* FRO 96 MHz (fro_96m) */ 96 | #define CLK_CLK_IN 0u /* Default CLK_IN pin clock */ 97 | 98 | 99 | /** 100 | * @brief System clock frequency (core clock) 101 | * 102 | * The system clock frequency supplied to the SysTick timer and the processor 103 | * core clock. This variable can be used by the user application to setup the 104 | * SysTick timer or configure other parameters. It may also be used by debugger to 105 | * query the frequency of the debug timer or configure the trace clock speed 106 | * SystemCoreClock is initialized with a correct predefined value. 107 | */ 108 | extern uint32_t SystemCoreClock; 109 | 110 | /** 111 | * @brief Setup the microcontroller system. 112 | * 113 | * Typically this function configures the oscillator (PLL) that is part of the 114 | * microcontroller device. For systems with variable clock speed it also updates 115 | * the variable SystemCoreClock. SystemInit is called from startup_device file. 116 | */ 117 | void SystemInit (void); 118 | 119 | /** 120 | * @brief Updates the SystemCoreClock variable. 121 | * 122 | * It must be called whenever the core clock is changed during program 123 | * execution. SystemCoreClockUpdate() evaluates the clock register settings and calculates 124 | * the current core clock. 125 | */ 126 | void SystemCoreClockUpdate (void); 127 | 128 | /** 129 | * @brief SystemInit function hook. 130 | * 131 | * This weak function allows to call specific initialization code during the 132 | * SystemInit() execution.This can be used when an application specific code needs 133 | * to be called as close to the reset entry as possible (for example the Multicore 134 | * Manager MCMGR_EarlyInit() function call). 135 | * NOTE: No global r/w variables can be used in this hook function because the 136 | * initialization of these variables happens after this function. 137 | */ 138 | void SystemInitHook (void); 139 | 140 | #ifdef __cplusplus 141 | } 142 | #endif 143 | 144 | #endif /* _SYSTEM_LPC54618_H_ */ 145 | -------------------------------------------------------------------------------- /CMSIS/system_LPC54616.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** ################################################################### 3 | ** Processors: LPC54616J256ET180 4 | ** LPC54616J512BD100 5 | ** LPC54616J512BD208 6 | ** LPC54616J512ET100 7 | ** 8 | ** Compilers: Keil ARM C/C++ Compiler 9 | ** GNU C Compiler 10 | ** IAR ANSI C/C++ Compiler for ARM 11 | ** MCUXpresso Compiler 12 | ** 13 | ** Reference manual: LPC546xx User manual Rev.1.9 5 June 2017 14 | ** Version: rev. 1.2, 2017-06-08 15 | ** Build: b180115 16 | ** 17 | ** Abstract: 18 | ** Provides a system configuration function and a global variable that 19 | ** contains the system frequency. It configures the device and initializes 20 | ** the oscillator (PLL) that is part of the microcontroller device. 21 | ** 22 | ** The Clear BSD License 23 | ** Copyright 2016 Freescale Semiconductor, Inc. 24 | ** Copyright 2016-2018 NXP 25 | ** All rights reserved. 26 | ** 27 | ** Redistribution and use in source and binary forms, with or without 28 | ** modification, are permitted (subject to the limitations in the 29 | ** disclaimer below) provided that the following conditions are met: 30 | ** 31 | ** * Redistributions of source code must retain the above copyright 32 | ** notice, this list of conditions and the following disclaimer. 33 | ** 34 | ** * Redistributions in binary form must reproduce the above copyright 35 | ** notice, this list of conditions and the following disclaimer in the 36 | ** documentation and/or other materials provided with the distribution. 37 | ** 38 | ** * Neither the name of the copyright holder nor the names of its 39 | ** contributors may be used to endorse or promote products derived from 40 | ** this software without specific prior written permission. 41 | ** 42 | ** NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE 43 | ** GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT 44 | ** HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 45 | ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 46 | ** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 47 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 48 | ** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 49 | ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 50 | ** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 51 | ** BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 52 | ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 53 | ** OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 54 | ** IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 55 | ** 56 | ** http: www.nxp.com 57 | ** mail: support@nxp.com 58 | ** 59 | ** Revisions: 60 | ** - rev. 1.0 (2016-08-12) 61 | ** Initial version. 62 | ** - rev. 1.1 (2016-11-25) 63 | ** Update CANFD and Classic CAN register. 64 | ** Add MAC TIMERSTAMP registers. 65 | ** - rev. 1.2 (2017-06-08) 66 | ** Remove RTC_CTRL_RTC_OSC_BYPASS. 67 | ** SYSCON_ARMTRCLKDIV rename to SYSCON_ARMTRACECLKDIV. 68 | ** Remove RESET and HALT from SYSCON_AHBCLKDIV. 69 | ** 70 | ** ################################################################### 71 | */ 72 | 73 | /*! 74 | * @file LPC54616 75 | * @version 1.2 76 | * @date 2017-06-08 77 | * @brief Device specific configuration file for LPC54616 (header file) 78 | * 79 | * Provides a system configuration function and a global variable that contains 80 | * the system frequency. It configures the device and initializes the oscillator 81 | * (PLL) that is part of the microcontroller device. 82 | */ 83 | 84 | #ifndef _SYSTEM_LPC54616_H_ 85 | #define _SYSTEM_LPC54616_H_ /**< Symbol preventing repeated inclusion */ 86 | 87 | #ifdef __cplusplus 88 | extern "C" { 89 | #endif 90 | 91 | #include 92 | 93 | #define DEFAULT_SYSTEM_CLOCK 12000000u /* Default System clock value */ 94 | #define CLK_RTC_32K_CLK 32768u /* RTC oscillator 32 kHz output (32k_clk */ 95 | #define CLK_FRO_12MHZ 12000000u /* FRO 12 MHz (fro_12m) */ 96 | #define CLK_FRO_48MHZ 48000000u /* FRO 48 MHz (fro_48m) */ 97 | #define CLK_FRO_96MHZ 96000000u /* FRO 96 MHz (fro_96m) */ 98 | #define CLK_CLK_IN 0u /* Default CLK_IN pin clock */ 99 | 100 | 101 | /** 102 | * @brief System clock frequency (core clock) 103 | * 104 | * The system clock frequency supplied to the SysTick timer and the processor 105 | * core clock. This variable can be used by the user application to setup the 106 | * SysTick timer or configure other parameters. It may also be used by debugger to 107 | * query the frequency of the debug timer or configure the trace clock speed 108 | * SystemCoreClock is initialized with a correct predefined value. 109 | */ 110 | extern uint32_t SystemCoreClock; 111 | 112 | /** 113 | * @brief Setup the microcontroller system. 114 | * 115 | * Typically this function configures the oscillator (PLL) that is part of the 116 | * microcontroller device. For systems with variable clock speed it also updates 117 | * the variable SystemCoreClock. SystemInit is called from startup_device file. 118 | */ 119 | void SystemInit (void); 120 | 121 | /** 122 | * @brief Updates the SystemCoreClock variable. 123 | * 124 | * It must be called whenever the core clock is changed during program 125 | * execution. SystemCoreClockUpdate() evaluates the clock register settings and calculates 126 | * the current core clock. 127 | */ 128 | void SystemCoreClockUpdate (void); 129 | 130 | /** 131 | * @brief SystemInit function hook. 132 | * 133 | * This weak function allows to call specific initialization code during the 134 | * SystemInit() execution.This can be used when an application specific code needs 135 | * to be called as close to the reset entry as possible (for example the Multicore 136 | * Manager MCMGR_EarlyInit() function call). 137 | * NOTE: No global r/w variables can be used in this hook function because the 138 | * initialization of these variables happens after this function. 139 | */ 140 | void SystemInitHook (void); 141 | 142 | #ifdef __cplusplus 143 | } 144 | #endif 145 | 146 | #endif /* _SYSTEM_LPC54616_H_ */ 147 | -------------------------------------------------------------------------------- /usb/include/usb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The Clear BSD License 3 | * Copyright (c) 2015, Freescale Semiconductor, Inc. 4 | * Copyright 2016 NXP 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted (subject to the limitations in the disclaimer below) provided 9 | * that the following conditions are met: 10 | * 11 | * o Redistributions of source code must retain the above copyright notice, this list 12 | * of conditions and the following disclaimer. 13 | * 14 | * o Redistributions in binary form must reproduce the above copyright notice, this 15 | * list of conditions and the following disclaimer in the documentation and/or 16 | * other materials provided with the distribution. 17 | * 18 | * o Neither the name of the copyright holder nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef __USB_H__ 36 | #define __USB_H__ 37 | 38 | #include 39 | #include 40 | #include "fsl_common.h" 41 | #include "usb_osa.h" 42 | #include "usb_misc.h" 43 | #include "usb_spec.h" 44 | 45 | /*! 46 | * @addtogroup usb_drv 47 | * @{ 48 | */ 49 | 50 | /******************************************************************************* 51 | * Definitions 52 | ******************************************************************************/ 53 | /*! @brief Defines USB stack major version */ 54 | #define USB_STACK_VERSION_MAJOR (2U) 55 | /*! @brief Defines USB stack minor version */ 56 | #define USB_STACK_VERSION_MINOR (0U) 57 | /*! @brief Defines USB stack bugfix version */ 58 | #define USB_STACK_VERSION_BUGFIX (1U) 59 | 60 | /*! @brief USB stack version definition */ 61 | #define USB_MAKE_VERSION(major, minor, bugfix) (((major) << 16) | ((minor) << 8) | (bugfix)) 62 | 63 | /*! @brief USB error code */ 64 | typedef enum _usb_status 65 | { 66 | kStatus_USB_Success = 0x00U, /*!< Success */ 67 | kStatus_USB_Error, /*!< Failed */ 68 | 69 | kStatus_USB_Busy, /*!< Busy */ 70 | kStatus_USB_InvalidHandle, /*!< Invalid handle */ 71 | kStatus_USB_InvalidParameter, /*!< Invalid parameter */ 72 | kStatus_USB_InvalidRequest, /*!< Invalid request */ 73 | kStatus_USB_ControllerNotFound, /*!< Controller cannot be found */ 74 | kStatus_USB_InvalidControllerInterface, /*!< Invalid controller interface */ 75 | 76 | kStatus_USB_NotSupported, /*!< Configuration is not supported */ 77 | kStatus_USB_Retry, /*!< Enumeration get configuration retry */ 78 | kStatus_USB_TransferStall, /*!< Transfer stalled */ 79 | kStatus_USB_TransferFailed, /*!< Transfer failed */ 80 | kStatus_USB_AllocFail, /*!< Allocation failed */ 81 | kStatus_USB_LackSwapBuffer, /*!< Insufficient swap buffer for KHCI */ 82 | kStatus_USB_TransferCancel, /*!< The transfer cancelled */ 83 | kStatus_USB_BandwidthFail, /*!< Allocate bandwidth failed */ 84 | kStatus_USB_MSDStatusFail, /*!< For MSD, the CSW status means fail */ 85 | kStatus_USB_EHCIAttached, 86 | kStatus_USB_EHCIDetached, 87 | } usb_status_t; 88 | 89 | /*! @brief USB host handle type define */ 90 | typedef void *usb_host_handle; 91 | 92 | /*! @brief USB device handle type define. For device stack it is the whole device handle; for host stack it is the 93 | * attached device instance handle*/ 94 | typedef void *usb_device_handle; 95 | 96 | /*! @brief USB OTG handle type define */ 97 | typedef void *usb_otg_handle; 98 | 99 | /*! @brief USB controller ID */ 100 | typedef enum _usb_controller_index 101 | { 102 | kUSB_ControllerKhci0 = 0U, /*!< KHCI 0U */ 103 | kUSB_ControllerKhci1 = 1U, /*!< KHCI 1U, Currently, there are no platforms which have two KHCI IPs, this is reserved 104 | to be used in the future. */ 105 | kUSB_ControllerEhci0 = 2U, /*!< EHCI 0U */ 106 | kUSB_ControllerEhci1 = 3U, /*!< EHCI 1U, Currently, there are no platforms which have two EHCI IPs, this is reserved 107 | to be used in the future. */ 108 | 109 | kUSB_ControllerLpcIp3511Fs0 = 4U, /*!< LPC USB IP3511 FS controller 0 */ 110 | kUSB_ControllerLpcIp3511Fs1 = 111 | 5U, /*!< LPC USB IP3511 FS controller 1, there are no platforms which have two IP3511 IPs, this is reserved 112 | to be used in the future. */ 113 | 114 | kUSB_ControllerLpcIp3511Hs0 = 6U, /*!< LPC USB IP3511 HS controller 0 */ 115 | kUSB_ControllerLpcIp3511Hs1 = 116 | 7U, /*!< LPC USB IP3511 HS controller 1, there are no platforms which have two IP3511 IPs, this is reserved 117 | to be used in the future. */ 118 | 119 | kUSB_ControllerOhci0 = 8U, /*!< OHCI 0U */ 120 | kUSB_ControllerOhci1 = 9U, /*!< OHCI 1U, Currently, there are no platforms which have two OHCI IPs, this is reserved 121 | to be used in the future. */ 122 | 123 | kUSB_ControllerIp3516Hs0 = 10U, /*!< IP3516HS 0U */ 124 | kUSB_ControllerIp3516Hs1 = 125 | 11U, /*!< IP3516HS 1U, Currently, there are no platforms which have two IP3516HS IPs, this is reserved 126 | to be used in the future. */ 127 | } usb_controller_index_t; 128 | 129 | /** 130 | * @brief USB stack version fields 131 | */ 132 | typedef struct _usb_version 133 | { 134 | uint8_t major; /*!< Major */ 135 | uint8_t minor; /*!< Minor */ 136 | uint8_t bugfix; /*!< Bug fix */ 137 | } usb_version_t; 138 | 139 | /******************************************************************************* 140 | * API 141 | ******************************************************************************/ 142 | 143 | /*! @} */ 144 | 145 | #endif /* __USB_H__ */ 146 | -------------------------------------------------------------------------------- /sources/usb_device_descriptor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The Clear BSD License 3 | * Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc. 4 | * Copyright 2016 NXP 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted (subject to the limitations in the disclaimer below) provided 9 | * that the following conditions are met: 10 | * 11 | * o Redistributions of source code must retain the above copyright notice, this list 12 | * of conditions and the following disclaimer. 13 | * 14 | * o Redistributions in binary form must reproduce the above copyright notice, this 15 | * list of conditions and the following disclaimer in the documentation and/or 16 | * other materials provided with the distribution. 17 | * 18 | * o Neither the name of the copyright holder nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | #ifndef _USB_DEVICE_DESCRIPTOR_H_ 35 | #define _USB_DEVICE_DESCRIPTOR_H_ 1 36 | 37 | #include "usb_device_class.h" 38 | 39 | /******************************************************************************* 40 | * Definitions 41 | ******************************************************************************/ 42 | #define USB_DEVICE_SPECIFIC_BCD_VERSION (0x0200) 43 | #define USB_DEVICE_DEMO_BCD_VERSION (0x0101U) 44 | 45 | // gs_usb defines 46 | #define CAN_DATA_MAX_PACKET_SIZE 512 /* Endpoint IN & OUT Packet size */ 47 | #define CAN_CMD_PACKET_SIZE 64 /* Control Endpoint Packet size */ 48 | 49 | #define USB_CAN_VID 0x1d50 50 | #define USB_CAN_PID 0x606f 51 | #define USB_CAN_INTERFACE_COUNT 0x02 52 | 53 | #define GSUSB_ENDPOINT_IN 0x81 54 | #define GSUSB_ENDPOINT_OUT 0x02 55 | 56 | #define USB_GS_USB_INTERFACE_COUNT 0x01 57 | #define USB_GS_USB_CONFIGURE_INDEX 0x01 58 | #define USB_GS_USB_INTERFACE_INDEX 0x00 59 | #define USB_GS_USB_ENDPOINT_COUNT 0x02 60 | #define USB_DESCRIPTOR_LENGTH_GS_USB_EP 0x07 61 | #define USB_GS_USB_BULK_ENDPOINT_COUNT 0x02 62 | 63 | /* usb descritpor length */ 64 | #define USB_DESCRIPTOR_LENGTH_CONFIGURATION_ALL (sizeof(g_UsbDeviceConfigurationDescriptor)) 65 | 66 | /* Configuration, interface and endpoint. */ 67 | #define USB_DEVICE_CONFIGURATION_COUNT 0x01 68 | #define USB_DEVICE_STRING_COUNT 0x03 69 | #define USB_DEVICE_LANGUAGE_COUNT 0x01 70 | 71 | /* Packet size. */ 72 | #define HS_GS_USB_INTERRUPT_IN_INTERVAL 0x00 73 | #define FS_GS_USB_INTERRUPT_IN_INTERVAL 0x00 74 | #define HS_GS_USB_BULK_IN_PACKET_SIZE 512 75 | #define FS_GS_USB_BULK_IN_PACKET_SIZE 64 76 | #define HS_GS_USB_BULK_OUT_PACKET_SIZE 512 77 | #define FS_GS_USB_BULK_OUT_PACKET_SIZE 64 78 | 79 | /* String descriptor length. */ 80 | #define USB_DESCRIPTOR_LENGTH_STRING0 (sizeof(g_UsbDeviceString0)) 81 | #define USB_DESCRIPTOR_LENGTH_STRING1 (sizeof(g_UsbDeviceString1)) 82 | #define USB_DESCRIPTOR_LENGTH_STRING2 (sizeof(g_UsbDeviceString2)) 83 | 84 | /* Class code. */ 85 | #define USB_DEVICE_CLASS 0xFF 86 | #define USB_DEVICE_SUBCLASS 0xFF 87 | #define USB_DEVICE_PROTOCOL 0xFF 88 | 89 | #define USB_DEVICE_MAX_POWER 0x32 90 | 91 | // WinUSB Vendor Code 92 | #define WINUSB_VENDOR_CODE 0x20 93 | 94 | /******************************************************************************* 95 | * API 96 | ******************************************************************************/ 97 | /*! 98 | * @brief USB device set speed function. 99 | * 100 | * This function sets the speed of the USB device. 101 | * 102 | * Due to the difference of HS and FS descriptors, the device descriptors and configurations need to be updated to match 103 | * current speed. 104 | * As the default, the device descriptors and configurations are configured by using FS parameters for both EHCI and 105 | * KHCI. 106 | * When the EHCI is enabled, the application needs to call this fucntion to update device by using current speed. 107 | * The updated information includes endpoint max packet size, endpoint interval, etc. 108 | * 109 | * @param handle The USB device handle. 110 | * @param speed Speed type. USB_SPEED_HIGH/USB_SPEED_FULL/USB_SPEED_LOW. 111 | * 112 | * @return A USB error code or kStatus_USB_Success. 113 | */ 114 | extern usb_status_t USB_DeviceSetSpeed(usb_device_handle handle, uint8_t speed); 115 | /*! 116 | * @brief USB device get device descriptor function. 117 | * 118 | * This function gets the device descriptor of the USB device. 119 | * 120 | * @param handle The USB device handle. 121 | * @param deviceDescriptor The pointer to the device descriptor structure. 122 | * 123 | * @return A USB error code or kStatus_USB_Success. 124 | */ 125 | extern usb_status_t USB_DeviceGetDeviceDescriptor(usb_device_handle handle, 126 | usb_device_get_device_descriptor_struct_t *deviceDescriptor); 127 | /*! 128 | * @brief USB device get string descriptor function. 129 | * 130 | * This function gets the string descriptor of the USB device. 131 | * 132 | * @param handle The USB device handle. 133 | * @param stringDescriptor Pointer to the string descriptor structure. 134 | * 135 | * @return A USB error code or kStatus_USB_Success. 136 | */ 137 | usb_status_t USB_DeviceGetStringDescriptor(usb_device_handle handle, 138 | usb_device_get_string_descriptor_struct_t *stringDescriptor); 139 | /*! 140 | * @brief USB device get configuration descriptor function. 141 | * 142 | * This function gets the configuration descriptor of the USB device. 143 | * 144 | * @param handle The USB device handle. 145 | * @param configurationDescriptor The pointer to the configuration descriptor structure. 146 | * 147 | * @return A USB error code or kStatus_USB_Success. 148 | */ 149 | extern usb_status_t USB_DeviceGetConfigurationDescriptor( 150 | usb_device_handle handle, 151 | usb_device_get_configuration_descriptor_struct_t *configurationDescriptor); 152 | #endif /* _USB_DEVICE_DESCRIPTOR_H_ */ 153 | -------------------------------------------------------------------------------- /board/src/clock_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The Clear BSD License 3 | * Copyright (c) 2015, Freescale Semiconductor, Inc. 4 | * Copyright 2016-2017 NXP 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted (subject to the limitations in the disclaimer below) provided 9 | * that the following conditions are met: 10 | * 11 | * o Redistributions of source code must retain the above copyright notice, this list 12 | * of conditions and the following disclaimer. 13 | * 14 | * o Redistributions in binary form must reproduce the above copyright notice, this 15 | * list of conditions and the following disclaimer in the documentation and/or 16 | * other materials provided with the distribution. 17 | * 18 | * o Neither the name of the copyright holder nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef _CLOCK_CONFIG_H_ 36 | #define _CLOCK_CONFIG_H_ 37 | 38 | #include "fsl_common.h" 39 | 40 | /******************************************************************************* 41 | * Definitions 42 | ******************************************************************************/ 43 | #define BOARD_XTAL0_CLK_HZ 12000000U /*!< Board xtal0 frequency in Hz */ 44 | #define BOARD_XTAL32K_CLK_HZ 32768U /*!< Board xtal32K frequency in Hz */ 45 | #define BOARD_BootClockRUN BOARD_BootClockFROHF48M 46 | 47 | 48 | /******************************************************************************* 49 | ********************* Configuration BOARD_BootClockFRO12M *********************** 50 | ******************************************************************************/ 51 | /******************************************************************************* 52 | * Definitions for BOARD_BootClockFRO12M configuration 53 | ******************************************************************************/ 54 | #define BOARD_BOOTCLOCKFRO12M_CORE_CLOCK 12000000U /*!< Core clock frequency:12000000Hz */ 55 | 56 | /******************************************************************************* 57 | * API for BOARD_BootClockFRO12M configuration 58 | ******************************************************************************/ 59 | #if defined(__cplusplus) 60 | extern "C" { 61 | #endif /* __cplusplus*/ 62 | 63 | /*! 64 | * @brief This function executes configuration of clocks. 65 | * 66 | */ 67 | void BOARD_BootClockFRO12M(void); 68 | 69 | #if defined(__cplusplus) 70 | } 71 | #endif /* __cplusplus*/ 72 | 73 | /******************************************************************************* 74 | ********************** Configuration BOARD_BootClockFROHF48M *********************** 75 | ******************************************************************************/ 76 | /******************************************************************************* 77 | * Definitions for BOARD_BootClockFROHF48M configuration 78 | ******************************************************************************/ 79 | #define BOARD_BOOTCLOCKFROHF48M_CORE_CLOCK 48000000U /*!< Core clock frequency:48000000Hz */ 80 | 81 | /******************************************************************************* 82 | * API for BOARD_BootClockFROHF48M configuration 83 | ******************************************************************************/ 84 | #if defined(__cplusplus) 85 | extern "C" { 86 | #endif /* __cplusplus*/ 87 | 88 | /*! 89 | * @brief This function executes configuration of clocks. 90 | * 91 | */ 92 | void BOARD_BootClockFROHF48M(void); 93 | 94 | #if defined(__cplusplus) 95 | } 96 | #endif /* __cplusplus*/ 97 | 98 | /******************************************************************************* 99 | ********************* Configuration BOARD_BootClockFROHF96M ********************** 100 | ******************************************************************************/ 101 | /******************************************************************************* 102 | * Definitions for BOARD_BootClockFROHF96M configuration 103 | ******************************************************************************/ 104 | #define BOARD_BOOTCLOCKFROHF96M_CORE_CLOCK 96000000U /*!< Core clock frequency:96000000Hz */ 105 | 106 | /******************************************************************************* 107 | * API for BOARD_BootClockFROHF96M configuration 108 | ******************************************************************************/ 109 | #if defined(__cplusplus) 110 | extern "C" { 111 | #endif /* __cplusplus*/ 112 | 113 | /*! 114 | * @brief This function executes configuration of clocks. 115 | * 116 | */ 117 | void BOARD_BootClockFROHF96M(void); 118 | 119 | #if defined(__cplusplus) 120 | } 121 | #endif /* __cplusplus*/ 122 | 123 | /******************************************************************************* 124 | ********************* Configuration BOARD_BootClockPLL180M ********************** 125 | ******************************************************************************/ 126 | /******************************************************************************* 127 | * Definitions for BOARD_BootClockPLL180M configuration 128 | ******************************************************************************/ 129 | #define BOARD_BOOTCLOCKPLL180M_CORE_CLOCK 180000000U /*!< Core clock frequency:180000000Hz */ 130 | 131 | /******************************************************************************* 132 | * API for BOARD_BootClockPLL180M configuration 133 | ******************************************************************************/ 134 | #if defined(__cplusplus) 135 | extern "C" { 136 | #endif /* __cplusplus*/ 137 | 138 | /*! 139 | * @brief This function executes configuration of clocks. 140 | * 141 | */ 142 | void BOARD_BootClockPLL180M(void); 143 | 144 | #if defined(__cplusplus) 145 | } 146 | #endif /* __cplusplus*/ 147 | #endif /* _CLOCK_CONFIG_H_ */ 148 | 149 | -------------------------------------------------------------------------------- /sources/usb_device_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The Clear BSD License 3 | * Copyright (c) 2015, Freescale Semiconductor, Inc. 4 | * Copyright 2016 - 2017 NXP 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted (subject to the limitations in the disclaimer below) provided 9 | * that the following conditions are met: 10 | * 11 | * o Redistributions of source code must retain the above copyright notice, this list 12 | * of conditions and the following disclaimer. 13 | * 14 | * o Redistributions in binary form must reproduce the above copyright notice, this 15 | * list of conditions and the following disclaimer in the documentation and/or 16 | * other materials provided with the distribution. 17 | * 18 | * o Neither the name of the copyright holder nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef _USB_DEVICE_CONFIG_H_ 36 | #define _USB_DEVICE_CONFIG_H_ 37 | 38 | /******************************************************************************* 39 | * Definitions 40 | ******************************************************************************/ 41 | /*! 42 | * @addtogroup usb_device_configuration 43 | * @{ 44 | */ 45 | 46 | /*! 47 | * @name Hardware instance define 48 | * @{ 49 | */ 50 | 51 | /*! @brief KHCI instance count */ 52 | #define USB_DEVICE_CONFIG_KHCI (0U) 53 | 54 | /*! @brief EHCI instance count */ 55 | #define USB_DEVICE_CONFIG_EHCI (0U) 56 | 57 | /*! @brief LPC USB IP3511 FS instance count */ 58 | #define USB_DEVICE_CONFIG_LPCIP3511FS (0U) 59 | 60 | /*! @brief LPC USB IP3511 HS instance count */ 61 | #define USB_DEVICE_CONFIG_LPCIP3511HS (1U) 62 | 63 | /*! @brief Device instance count, the sum of KHCI and EHCI instance counts*/ 64 | #define USB_DEVICE_CONFIG_NUM \ 65 | (USB_DEVICE_CONFIG_KHCI + USB_DEVICE_CONFIG_EHCI + USB_DEVICE_CONFIG_LPCIP3511FS + USB_DEVICE_CONFIG_LPCIP3511HS) 66 | 67 | /* @} */ 68 | 69 | /*! 70 | * @name class instance define 71 | * @{ 72 | */ 73 | 74 | /*! @brief HID instance count */ 75 | #define USB_DEVICE_CONFIG_HID (0U) 76 | 77 | /*! @brief CDC ACM instance count */ 78 | #define USB_DEVICE_CONFIG_CDC_ACM (0U) 79 | 80 | /*! @brief MSC instance count */ 81 | #define USB_DEVICE_CONFIG_MSC (0U) 82 | 83 | /*! @brief Audio instance count */ 84 | #define USB_DEVICE_CONFIG_AUDIO (0U) 85 | 86 | /*! @brief PHDC instance count */ 87 | #define USB_DEVICE_CONFIG_PHDC (0U) 88 | 89 | /*! @brief Video instance count */ 90 | #define USB_DEVICE_CONFIG_VIDEO (0U) 91 | 92 | /*! @brief CCID instance count */ 93 | #define USB_DEVICE_CONFIG_CCID (0U) 94 | 95 | /*! @brief Printer instance count */ 96 | #define USB_DEVICE_CONFIG_PRINTER (0U) 97 | 98 | /*! @brief DFU instance count */ 99 | #define USB_DEVICE_CONFIG_DFU (0U) 100 | 101 | /* @} */ 102 | 103 | /*! @brief Whether device is self power. 1U supported, 0U not supported */ 104 | #define USB_DEVICE_CONFIG_SELF_POWER (0U) 105 | 106 | /*! @brief How many endpoints are supported in the stack. */ 107 | #define USB_DEVICE_CONFIG_ENDPOINTS (3U) 108 | 109 | /*! @brief Whether the device task is enabled. */ 110 | #define USB_DEVICE_CONFIG_USE_TASK (0U) 111 | 112 | /*! @brief How many the notification message are supported when the device task is enabled. */ 113 | #define USB_DEVICE_CONFIG_MAX_MESSAGES (8U) 114 | 115 | /*! @brief Whether test mode enabled. */ 116 | #define USB_DEVICE_CONFIG_USB20_TEST_MODE (0U) 117 | 118 | /*! @brief Whether device CV test is enabled. */ 119 | #define USB_DEVICE_CONFIG_CV_TEST (0U) 120 | 121 | /*! @brief Whether device compliance test is enabled. If the macro is enabled, 122 | the test mode and CV test macroes will be set.*/ 123 | #define USB_DEVICE_CONFIG_COMPLIANCE_TEST (0U) 124 | 125 | #if ((defined(USB_DEVICE_CONFIG_COMPLIANCE_TEST)) && (USB_DEVICE_CONFIG_COMPLIANCE_TEST > 0U)) 126 | 127 | /*! @brief Undefine the marco USB_DEVICE_CONFIG_USB20_TEST_MODE. */ 128 | #undef USB_DEVICE_CONFIG_USB20_TEST_MODE 129 | /*! @brief Undefine the marco USB_DEVICE_CONFIG_CV_TEST. */ 130 | #undef USB_DEVICE_CONFIG_CV_TEST 131 | 132 | /*! @brief enable the test mode. */ 133 | #define USB_DEVICE_CONFIG_USB20_TEST_MODE (1U) 134 | 135 | /*! @brief enable the CV test */ 136 | #define USB_DEVICE_CONFIG_CV_TEST (1U) 137 | 138 | #endif 139 | 140 | #if ((defined(USB_DEVICE_CONFIG_KHCI)) && (USB_DEVICE_CONFIG_KHCI > 0U)) 141 | 142 | /*! @brief The MAX buffer length for the KHCI DMA workaround.*/ 143 | #define USB_DEVICE_CONFIG_KHCI_DMA_ALIGN_BUFFER_LENGTH (64U) 144 | #endif 145 | 146 | #if ((defined(USB_DEVICE_CONFIG_EHCI)) && (USB_DEVICE_CONFIG_EHCI > 0U)) 147 | /*! @brief How many the DTD are supported. */ 148 | #define USB_DEVICE_CONFIG_EHCI_MAX_DTD (16U) 149 | 150 | /*! @brief Whether the EHCI ID pin detect feature enabled. */ 151 | #define USB_DEVICE_CONFIG_EHCI_ID_PIN_DETECT (0U) 152 | #endif 153 | 154 | /*! @brief Whether the keep alive feature enabled. */ 155 | #define USB_DEVICE_CONFIG_KEEP_ALIVE_MODE (0U) 156 | 157 | /*! @brief Whether the transfer buffer is cache-enabled or not. */ 158 | #ifndef USB_DEVICE_CONFIG_BUFFER_PROPERTY_CACHEABLE 159 | #define USB_DEVICE_CONFIG_BUFFER_PROPERTY_CACHEABLE (0U) 160 | #endif 161 | /*! @brief Whether the low power mode is enabled or not. */ 162 | #define USB_DEVICE_CONFIG_LOW_POWER_MODE (0U) 163 | 164 | #if ((defined(USB_DEVICE_CONFIG_LOW_POWER_MODE)) && (USB_DEVICE_CONFIG_LOW_POWER_MODE > 0U)) 165 | /*! @brief Whether device remote wakeup supported. 1U supported, 0U not supported */ 166 | #define USB_DEVICE_CONFIG_REMOTE_WAKEUP (0U) 167 | 168 | /*! @brief Whether LPM is supported. 1U supported, 0U not supported */ 169 | #define USB_DEVICE_CONFIG_LPM_L1 (0U) 170 | #else 171 | /*! @brief The device remote wakeup is unsupported. */ 172 | #define USB_DEVICE_CONFIG_REMOTE_WAKEUP (0U) 173 | #endif 174 | 175 | /*! @brief Whether the device detached feature is enabled or not. */ 176 | #define USB_DEVICE_CONFIG_DETACH_ENABLE (0U) 177 | 178 | /*! @brief Whether handle the USB bus error. */ 179 | #define USB_DEVICE_CONFIG_ERROR_HANDLING (0U) 180 | 181 | /* @} */ 182 | 183 | #endif /* _USB_DEVICE_CONFIG_H_ */ 184 | -------------------------------------------------------------------------------- /drivers/fsl_common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The Clear BSD License 3 | * Copyright (c) 2015-2016, Freescale Semiconductor, Inc. 4 | * Copyright 2016 NXP 5 | * All rights reserved. 6 | * 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted (subject to the limitations in the disclaimer below) provided 10 | * that the following conditions are met: 11 | * 12 | * o Redistributions of source code must retain the above copyright notice, this list 13 | * of conditions and the following disclaimer. 14 | * 15 | * o Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * o Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived from this 21 | * software without specific prior written permission. 22 | * 23 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 28 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 31 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include "fsl_common.h" 37 | #define SDK_MEM_MAGIC_NUMBER 12345U 38 | 39 | typedef struct _mem_align_control_block 40 | { 41 | uint16_t identifier; /*!< Identifier for the memory control block. */ 42 | uint16_t offset; /*!< offset from aligned adress to real address */ 43 | } mem_align_cb_t; 44 | 45 | /* Component ID definition, used by tools. */ 46 | #ifndef FSL_COMPONENT_ID 47 | #define FSL_COMPONENT_ID "platform.drivers.common" 48 | #endif 49 | 50 | 51 | #ifndef __GIC_PRIO_BITS 52 | #if defined(ENABLE_RAM_VECTOR_TABLE) 53 | uint32_t InstallIRQHandler(IRQn_Type irq, uint32_t irqHandler) 54 | { 55 | /* Addresses for VECTOR_TABLE and VECTOR_RAM come from the linker file */ 56 | #if defined(__CC_ARM) 57 | extern uint32_t Image$$VECTOR_ROM$$Base[]; 58 | extern uint32_t Image$$VECTOR_RAM$$Base[]; 59 | extern uint32_t Image$$RW_m_data$$Base[]; 60 | 61 | #define __VECTOR_TABLE Image$$VECTOR_ROM$$Base 62 | #define __VECTOR_RAM Image$$VECTOR_RAM$$Base 63 | #define __RAM_VECTOR_TABLE_SIZE (((uint32_t)Image$$RW_m_data$$Base - (uint32_t)Image$$VECTOR_RAM$$Base)) 64 | #elif defined(__ICCARM__) 65 | extern uint32_t __RAM_VECTOR_TABLE_SIZE[]; 66 | extern uint32_t __VECTOR_TABLE[]; 67 | extern uint32_t __VECTOR_RAM[]; 68 | #elif defined(__GNUC__) 69 | extern uint32_t __VECTOR_TABLE[]; 70 | extern uint32_t __VECTOR_RAM[]; 71 | extern uint32_t __RAM_VECTOR_TABLE_SIZE_BYTES[]; 72 | uint32_t __RAM_VECTOR_TABLE_SIZE = (uint32_t)(__RAM_VECTOR_TABLE_SIZE_BYTES); 73 | #endif /* defined(__CC_ARM) */ 74 | uint32_t n; 75 | uint32_t ret; 76 | uint32_t irqMaskValue; 77 | 78 | irqMaskValue = DisableGlobalIRQ(); 79 | if (SCB->VTOR != (uint32_t)__VECTOR_RAM) 80 | { 81 | /* Copy the vector table from ROM to RAM */ 82 | for (n = 0; n < ((uint32_t)__RAM_VECTOR_TABLE_SIZE) / sizeof(uint32_t); n++) 83 | { 84 | __VECTOR_RAM[n] = __VECTOR_TABLE[n]; 85 | } 86 | /* Point the VTOR to the position of vector table */ 87 | SCB->VTOR = (uint32_t)__VECTOR_RAM; 88 | } 89 | 90 | ret = __VECTOR_RAM[irq + 16]; 91 | /* make sure the __VECTOR_RAM is noncachable */ 92 | __VECTOR_RAM[irq + 16] = irqHandler; 93 | 94 | EnableGlobalIRQ(irqMaskValue); 95 | 96 | /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping 97 | exception return operation might vector to incorrect interrupt */ 98 | #if defined __CORTEX_M && (__CORTEX_M == 4U) 99 | __DSB(); 100 | #endif 101 | 102 | return ret; 103 | } 104 | #endif /* ENABLE_RAM_VECTOR_TABLE. */ 105 | #endif /* __GIC_PRIO_BITS. */ 106 | 107 | #ifndef QN908XC_SERIES 108 | #if (defined(FSL_FEATURE_SOC_SYSCON_COUNT) && (FSL_FEATURE_SOC_SYSCON_COUNT > 0)) 109 | 110 | void EnableDeepSleepIRQ(IRQn_Type interrupt) 111 | { 112 | uint32_t intNumber = (uint32_t)interrupt; 113 | 114 | #if (defined(FSL_FEATURE_SYSCON_STARTER_DISCONTINUOUS) && (FSL_FEATURE_SYSCON_STARTER_DISCONTINUOUS == 1)) 115 | { 116 | SYSCON->STARTERP1 = 1u << intNumber; 117 | } 118 | #else 119 | { 120 | uint32_t index = 0; 121 | 122 | while (intNumber >= 32u) 123 | { 124 | index++; 125 | intNumber -= 32u; 126 | } 127 | 128 | SYSCON->STARTERSET[index] = 1u << intNumber; 129 | } 130 | #endif /* FSL_FEATURE_STARTER_DISCONTINUOUS */ 131 | EnableIRQ(interrupt); /* also enable interrupt at NVIC */ 132 | } 133 | 134 | void DisableDeepSleepIRQ(IRQn_Type interrupt) 135 | { 136 | uint32_t intNumber = (uint32_t)interrupt; 137 | 138 | DisableIRQ(interrupt); /* also disable interrupt at NVIC */ 139 | #if (defined(FSL_FEATURE_SYSCON_STARTER_DISCONTINUOUS) && (FSL_FEATURE_SYSCON_STARTER_DISCONTINUOUS == 1)) 140 | { 141 | SYSCON->STARTERP1 &= ~(1u << intNumber); 142 | } 143 | #else 144 | { 145 | uint32_t index = 0; 146 | 147 | while (intNumber >= 32u) 148 | { 149 | index++; 150 | intNumber -= 32u; 151 | } 152 | 153 | SYSCON->STARTERCLR[index] = 1u << intNumber; 154 | } 155 | #endif /* FSL_FEATURE_STARTER_DISCONTINUOUS */ 156 | } 157 | #endif /* FSL_FEATURE_SOC_SYSCON_COUNT */ 158 | 159 | #endif /* QN908XC_SERIES */ 160 | 161 | void *SDK_Malloc(size_t size, size_t alignbytes) 162 | { 163 | mem_align_cb_t *p_cb = NULL; 164 | uint32_t alignedsize = SDK_SIZEALIGN(size, alignbytes) + alignbytes + sizeof(mem_align_cb_t); 165 | void *p_align_addr, *p_addr = malloc(alignedsize); 166 | 167 | if (!p_addr) 168 | { 169 | return NULL; 170 | } 171 | 172 | p_align_addr = (void *)SDK_SIZEALIGN((uint32_t)p_addr + sizeof(mem_align_cb_t), alignbytes); 173 | 174 | p_cb = (mem_align_cb_t *)((uint32_t)p_align_addr - 4); 175 | p_cb->identifier = SDK_MEM_MAGIC_NUMBER; 176 | p_cb->offset = (uint32_t)p_align_addr - (uint32_t)p_addr; 177 | 178 | return (void *)p_align_addr; 179 | } 180 | 181 | void SDK_Free(void *ptr) 182 | { 183 | mem_align_cb_t *p_cb = (mem_align_cb_t *)((uint32_t)ptr - 4); 184 | 185 | if (p_cb->identifier != SDK_MEM_MAGIC_NUMBER) 186 | { 187 | return; 188 | } 189 | 190 | free((void *)((uint32_t)ptr - p_cb->offset)); 191 | } 192 | 193 | -------------------------------------------------------------------------------- /utilities/fsl_debug_console_conf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The Clear BSD License 3 | * Copyright 2017 NXP 4 | * All rights reserved. 5 | * 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted (subject to the limitations in the disclaimer below) provided 9 | * that the following conditions are met: 10 | * 11 | * o Redistributions of source code must retain the above copyright notice, this list 12 | * of conditions and the following disclaimer. 13 | * 14 | * o Redistributions in binary form must reproduce the above copyright notice, this 15 | * list of conditions and the following disclaimer in the documentation and/or 16 | * other materials provided with the distribution. 17 | * 18 | * o Neither the name of the copyright holder nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | #ifndef _FSL_DEBUG_CONSOLE_CONF_H_ 35 | #define _FSL_DEBUG_CONSOLE_CONF_H_ 36 | 37 | /****************Debug console configuration********************/ 38 | 39 | /*! @brief If Non-blocking mode is needed, please define it at project setting, 40 | * otherwise blocking mode is the default transfer mode. 41 | * Warning: If you want to use non-blocking transfer,please make sure the corresponding 42 | * IO interrupt is enable, otherwise there is no output. 43 | * And non-blocking is combine with buffer, no matter bare-metal or rtos. 44 | */ 45 | #ifdef DEBUG_CONSOLE_TRANSFER_NON_BLOCKING 46 | /*! @brief define the transmit buffer length which is used to store the multi task log, buffer is enabled automatically 47 | * when 48 | * non-blocking transfer is using, 49 | * This value will affect the RAM's ultilization, should be set per paltform's capability and software requirement. 50 | * If it is configured too small, log maybe missed , because the log will not be 51 | * buffered if the buffer is full, and the print will return immediately with -1. 52 | * And this value should be multiple of 4 to meet memory alignment. 53 | * 54 | */ 55 | #ifndef DEBUG_CONSOLE_TRANSMIT_BUFFER_LEN 56 | #define DEBUG_CONSOLE_TRANSMIT_BUFFER_LEN (512U) 57 | #endif /* DEBUG_CONSOLE_TRANSMIT_BUFFER_LEN */ 58 | 59 | /*! @brief define the receive buffer length which is used to store the user input, buffer is enabled automatically when 60 | * non-blocking transfer is using, 61 | * This value will affect the RAM's ultilization, should be set per paltform's capability and software requirement. 62 | * If it is configured too small, log maybe missed, because buffer will be overwrited if buffer is too small. 63 | * And this value should be multiple of 4 to meet memory alignment. 64 | * 65 | */ 66 | #ifndef DEBUG_CONSOLE_RECEIVE_BUFFER_LEN 67 | #define DEBUG_CONSOLE_RECEIVE_BUFFER_LEN (512U) 68 | #endif /* DEBUG_CONSOLE_RECEIVE_BUFFER_LEN */ 69 | 70 | #else 71 | #define DEBUG_CONSOLE_TRANSFER_BLOCKING 72 | #endif /* DEBUG_CONSOLE_TRANSFER_NON_BLOCKING */ 73 | 74 | /*!@ brief define the MAX log length debug console support , that is when you call printf("log", x);, the log 75 | * length can not bigger than this value. 76 | * This macro decide the local log buffer length, the buffer locate at stack, the stack maybe overflow if 77 | * the buffer is too big and current task stack size not big enough. 78 | */ 79 | #ifndef DEBUG_CONSOLE_PRINTF_MAX_LOG_LEN 80 | #define DEBUG_CONSOLE_PRINTF_MAX_LOG_LEN (128U) 81 | #endif /* DEBUG_CONSOLE_PRINTF_MAX_LOG_LEN */ 82 | 83 | /*!@ brief define the buffer support buffer scanf log length, that is when you call scanf("log", &x);, the log 84 | * length can not bigger than this value. 85 | * As same as the DEBUG_CONSOLE_BUFFER_PRINTF_MAX_LOG_LEN. 86 | */ 87 | #ifndef DEBUG_CONSOLE_SCANF_MAX_LOG_LEN 88 | #define DEBUG_CONSOLE_SCANF_MAX_LOG_LEN (20U) 89 | #endif /* DEBUG_CONSOLE_SCANF_MAX_LOG_LEN */ 90 | 91 | /*! @brief Debug console synchronization 92 | * User should not change these macro for synchronization mode, but add the 93 | * corresponding synchronization mechanism per different software environment. 94 | * Such as, if another RTOS is used, 95 | * add: 96 | * #define DEBUG_CONSOLE_SYNCHRONIZATION_XXXX 3 97 | * in this configuration file and implement the synchronization in fsl.log.c. 98 | */ 99 | /*! @brief synchronization for baremetal software */ 100 | #define DEBUG_CONSOLE_SYNCHRONIZATION_BM 0 101 | /*! @brief synchronization for freertos software */ 102 | #define DEBUG_CONSOLE_SYNCHRONIZATION_FREERTOS 1 103 | 104 | /*! @brief RTOS synchronization mechanism disable 105 | * If not defined, default is enable, to avoid multitask log print mess. 106 | * If other RTOS is used, you can implement the RTOS's specific synchronization mechanism in fsl.log.c 107 | * If synchronization is disabled, log maybe messed on terminal. 108 | */ 109 | #ifndef DEBUG_CONSOLE_DISABLE_RTOS_SYNCHRONIZATION 110 | #ifdef DEBUG_CONSOLE_TRANSFER_NON_BLOCKING 111 | #ifdef FSL_RTOS_FREE_RTOS 112 | #define DEBUG_CONSOLE_SYNCHRONIZATION_MODE DEBUG_CONSOLE_SYNCHRONIZATION_FREERTOS 113 | #else 114 | #define DEBUG_CONSOLE_SYNCHRONIZATION_MODE DEBUG_CONSOLE_SYNCHRONIZATION_BM 115 | #endif /* FSL_RTOS_FREE_RTOS */ 116 | #else 117 | #define DEBUG_CONSOLE_SYNCHRONIZATION_MODE DEBUG_CONSOLE_SYNCHRONIZATION_BM 118 | #endif /* DEBUG_CONSOLE_TRANSFER_NON_BLOCKING */ 119 | #endif /* DEBUG_CONSOLE_DISABLE_RTOS_SYNCHRONIZATION */ 120 | 121 | /*! @brief echo function support 122 | * If you want to use the echo function,please define DEBUG_CONSOLE_ENABLE_ECHO 123 | * at your project setting. 124 | */ 125 | #ifndef DEBUG_CONSOLE_ENABLE_ECHO 126 | #define DEBUG_CONSOLE_ENABLE_ECHO_FUNCTION 0 127 | #else 128 | #define DEBUG_CONSOLE_ENABLE_ECHO_FUNCTION 1 129 | #endif /* DEBUG_CONSOLE_ENABLE_ECHO */ 130 | 131 | /*********************************************************************/ 132 | 133 | /***************Debug console other configuration*********************/ 134 | /*! @brief Definition to printf the float number. */ 135 | #ifndef PRINTF_FLOAT_ENABLE 136 | #define PRINTF_FLOAT_ENABLE 0U 137 | #endif /* PRINTF_FLOAT_ENABLE */ 138 | 139 | /*! @brief Definition to scanf the float number. */ 140 | #ifndef SCANF_FLOAT_ENABLE 141 | #define SCANF_FLOAT_ENABLE 0U 142 | #endif /* SCANF_FLOAT_ENABLE */ 143 | 144 | /*! @brief Definition to support advanced format specifier for printf. */ 145 | #ifndef PRINTF_ADVANCED_ENABLE 146 | #define PRINTF_ADVANCED_ENABLE 0U 147 | #endif /* PRINTF_ADVANCED_ENABLE */ 148 | 149 | /*! @brief Definition to support advanced format specifier for scanf. */ 150 | #ifndef SCANF_ADVANCED_ENABLE 151 | #define SCANF_ADVANCED_ENABLE 0U 152 | #endif /* SCANF_ADVANCED_ENABLE */ 153 | 154 | /*! @brief Definition to select virtual com(USB CDC) as the debug console. */ 155 | #ifndef BOARD_USE_VIRTUALCOM 156 | #define BOARD_USE_VIRTUALCOM 0U 157 | #endif 158 | /*******************************************************************/ 159 | 160 | #endif /* _FSL_DEBUG_CONSOLE_CONF_H_ */ 161 | -------------------------------------------------------------------------------- /CMSIS/mpu_armv7.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @file mpu_armv7.h 3 | * @brief CMSIS MPU API for Armv7-M MPU 4 | * @version V5.0.4 5 | * @date 10. January 2018 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2017-2018 Arm Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef ARM_MPU_ARMV7_H 32 | #define ARM_MPU_ARMV7_H 33 | 34 | #define ARM_MPU_REGION_SIZE_32B ((uint8_t)0x04U) 35 | #define ARM_MPU_REGION_SIZE_64B ((uint8_t)0x05U) 36 | #define ARM_MPU_REGION_SIZE_128B ((uint8_t)0x06U) 37 | #define ARM_MPU_REGION_SIZE_256B ((uint8_t)0x07U) 38 | #define ARM_MPU_REGION_SIZE_512B ((uint8_t)0x08U) 39 | #define ARM_MPU_REGION_SIZE_1KB ((uint8_t)0x09U) 40 | #define ARM_MPU_REGION_SIZE_2KB ((uint8_t)0x0AU) 41 | #define ARM_MPU_REGION_SIZE_4KB ((uint8_t)0x0BU) 42 | #define ARM_MPU_REGION_SIZE_8KB ((uint8_t)0x0CU) 43 | #define ARM_MPU_REGION_SIZE_16KB ((uint8_t)0x0DU) 44 | #define ARM_MPU_REGION_SIZE_32KB ((uint8_t)0x0EU) 45 | #define ARM_MPU_REGION_SIZE_64KB ((uint8_t)0x0FU) 46 | #define ARM_MPU_REGION_SIZE_128KB ((uint8_t)0x10U) 47 | #define ARM_MPU_REGION_SIZE_256KB ((uint8_t)0x11U) 48 | #define ARM_MPU_REGION_SIZE_512KB ((uint8_t)0x12U) 49 | #define ARM_MPU_REGION_SIZE_1MB ((uint8_t)0x13U) 50 | #define ARM_MPU_REGION_SIZE_2MB ((uint8_t)0x14U) 51 | #define ARM_MPU_REGION_SIZE_4MB ((uint8_t)0x15U) 52 | #define ARM_MPU_REGION_SIZE_8MB ((uint8_t)0x16U) 53 | #define ARM_MPU_REGION_SIZE_16MB ((uint8_t)0x17U) 54 | #define ARM_MPU_REGION_SIZE_32MB ((uint8_t)0x18U) 55 | #define ARM_MPU_REGION_SIZE_64MB ((uint8_t)0x19U) 56 | #define ARM_MPU_REGION_SIZE_128MB ((uint8_t)0x1AU) 57 | #define ARM_MPU_REGION_SIZE_256MB ((uint8_t)0x1BU) 58 | #define ARM_MPU_REGION_SIZE_512MB ((uint8_t)0x1CU) 59 | #define ARM_MPU_REGION_SIZE_1GB ((uint8_t)0x1DU) 60 | #define ARM_MPU_REGION_SIZE_2GB ((uint8_t)0x1EU) 61 | #define ARM_MPU_REGION_SIZE_4GB ((uint8_t)0x1FU) 62 | 63 | #define ARM_MPU_AP_NONE 0U 64 | #define ARM_MPU_AP_PRIV 1U 65 | #define ARM_MPU_AP_URO 2U 66 | #define ARM_MPU_AP_FULL 3U 67 | #define ARM_MPU_AP_PRO 5U 68 | #define ARM_MPU_AP_RO 6U 69 | 70 | /** MPU Region Base Address Register Value 71 | * 72 | * \param Region The region to be configured, number 0 to 15. 73 | * \param BaseAddress The base address for the region. 74 | */ 75 | #define ARM_MPU_RBAR(Region, BaseAddress) \ 76 | (((BaseAddress) & MPU_RBAR_ADDR_Msk) | \ 77 | ((Region) & MPU_RBAR_REGION_Msk) | \ 78 | (MPU_RBAR_VALID_Msk)) 79 | 80 | /** 81 | * MPU Region Attribute and Size Register Value 82 | * 83 | * \param DisableExec Instruction access disable bit, 1= disable instruction fetches. 84 | * \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode. 85 | * \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral. 86 | * \param IsShareable Region is shareable between multiple bus masters. 87 | * \param IsCacheable Region is cacheable, i.e. its value may be kept in cache. 88 | * \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy. 89 | * \param SubRegionDisable Sub-region disable field. 90 | * \param Size Region size of the region to be configured, for example 4K, 8K. 91 | */ 92 | #define ARM_MPU_RASR(DisableExec, AccessPermission, TypeExtField, IsShareable, IsCacheable, IsBufferable, SubRegionDisable, Size) \ 93 | ((((DisableExec ) << MPU_RASR_XN_Pos) & MPU_RASR_XN_Msk) | \ 94 | (((AccessPermission) << MPU_RASR_AP_Pos) & MPU_RASR_AP_Msk) | \ 95 | (((TypeExtField ) << MPU_RASR_TEX_Pos) & MPU_RASR_TEX_Msk) | \ 96 | (((IsShareable ) << MPU_RASR_S_Pos) & MPU_RASR_S_Msk) | \ 97 | (((IsCacheable ) << MPU_RASR_C_Pos) & MPU_RASR_C_Msk) | \ 98 | (((IsBufferable ) << MPU_RASR_B_Pos) & MPU_RASR_B_Msk) | \ 99 | (((SubRegionDisable) << MPU_RASR_SRD_Pos) & MPU_RASR_SRD_Msk) | \ 100 | (((Size ) << MPU_RASR_SIZE_Pos) & MPU_RASR_SIZE_Msk) | \ 101 | (MPU_RASR_ENABLE_Msk)) 102 | 103 | 104 | /** 105 | * Struct for a single MPU Region 106 | */ 107 | typedef struct { 108 | uint32_t RBAR; //!< The region base address register value (RBAR) 109 | uint32_t RASR; //!< The region attribute and size register value (RASR) \ref MPU_RASR 110 | } ARM_MPU_Region_t; 111 | 112 | /** Enable the MPU. 113 | * \param MPU_Control Default access permissions for unconfigured regions. 114 | */ 115 | __STATIC_INLINE void ARM_MPU_Enable(uint32_t MPU_Control) 116 | { 117 | __DSB(); 118 | __ISB(); 119 | MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk; 120 | #ifdef SCB_SHCSR_MEMFAULTENA_Msk 121 | SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk; 122 | #endif 123 | } 124 | 125 | /** Disable the MPU. 126 | */ 127 | __STATIC_INLINE void ARM_MPU_Disable(void) 128 | { 129 | __DSB(); 130 | __ISB(); 131 | #ifdef SCB_SHCSR_MEMFAULTENA_Msk 132 | SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk; 133 | #endif 134 | MPU->CTRL &= ~MPU_CTRL_ENABLE_Msk; 135 | } 136 | 137 | /** Clear and disable the given MPU region. 138 | * \param rnr Region number to be cleared. 139 | */ 140 | __STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr) 141 | { 142 | MPU->RNR = rnr; 143 | MPU->RASR = 0U; 144 | } 145 | 146 | /** Configure an MPU region. 147 | * \param rbar Value for RBAR register. 148 | * \param rsar Value for RSAR register. 149 | */ 150 | __STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rbar, uint32_t rasr) 151 | { 152 | MPU->RBAR = rbar; 153 | MPU->RASR = rasr; 154 | } 155 | 156 | /** Configure the given MPU region. 157 | * \param rnr Region number to be configured. 158 | * \param rbar Value for RBAR register. 159 | * \param rsar Value for RSAR register. 160 | */ 161 | __STATIC_INLINE void ARM_MPU_SetRegionEx(uint32_t rnr, uint32_t rbar, uint32_t rasr) 162 | { 163 | MPU->RNR = rnr; 164 | MPU->RBAR = rbar; 165 | MPU->RASR = rasr; 166 | } 167 | 168 | /** Memcopy with strictly ordered memory access, e.g. for register targets. 169 | * \param dst Destination data is copied to. 170 | * \param src Source data is copied from. 171 | * \param len Amount of data words to be copied. 172 | */ 173 | __STATIC_INLINE void orderedCpy(volatile uint32_t* dst, const uint32_t* __RESTRICT src, uint32_t len) 174 | { 175 | uint32_t i; 176 | for (i = 0U; i < len; ++i) 177 | { 178 | dst[i] = src[i]; 179 | } 180 | } 181 | 182 | /** Load the given number of MPU regions from a table. 183 | * \param table Pointer to the MPU configuration table. 184 | * \param cnt Amount of regions to be configured. 185 | */ 186 | __STATIC_INLINE void ARM_MPU_Load(ARM_MPU_Region_t const* table, uint32_t cnt) 187 | { 188 | const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U; 189 | while (cnt > MPU_TYPE_RALIASES) { 190 | orderedCpy(&(MPU->RBAR), &(table->RBAR), MPU_TYPE_RALIASES*rowWordSize); 191 | table += MPU_TYPE_RALIASES; 192 | cnt -= MPU_TYPE_RALIASES; 193 | } 194 | orderedCpy(&(MPU->RBAR), &(table->RBAR), cnt*rowWordSize); 195 | } 196 | 197 | #endif 198 | -------------------------------------------------------------------------------- /utilities/fsl_debug_console.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The Clear BSD License 3 | * Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc. 4 | * Copyright 2016-2017 NXP 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted (subject to the limitations in the disclaimer below) provided 9 | * that the following conditions are met: 10 | * 11 | * o Redistributions of source code must retain the above copyright notice, this list 12 | * of conditions and the following disclaimer. 13 | * 14 | * o Redistributions in binary form must reproduce the above copyright notice, this 15 | * list of conditions and the following disclaimer in the documentation and/or 16 | * other materials provided with the distribution. 17 | * 18 | * o Neither the name of the copyright holder nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * Debug console shall provide input and output functions to scan and print formatted data. 35 | * o Support a format specifier for PRINTF follows this prototype "%[flags][width][.precision][length]specifier" 36 | * - [flags] :'-', '+', '#', ' ', '0' 37 | * - [width]: number (0,1...) 38 | * - [.precision]: number (0,1...) 39 | * - [length]: do not support 40 | * - [specifier]: 'd', 'i', 'f', 'F', 'x', 'X', 'o', 'p', 'u', 'c', 's', 'n' 41 | * o Support a format specifier for SCANF follows this prototype " %[*][width][length]specifier" 42 | * - [*]: is supported. 43 | * - [width]: number (0,1...) 44 | * - [length]: 'h', 'hh', 'l','ll','L'. ignore ('j','z','t') 45 | * - [specifier]: 'd', 'i', 'u', 'f', 'F', 'e', 'E', 'g', 'G', 'a', 'A', 'o', 'c', 's' 46 | */ 47 | 48 | #ifndef _FSL_DEBUGCONSOLE_H_ 49 | #define _FSL_DEBUGCONSOLE_H_ 50 | 51 | #include "fsl_common.h" 52 | /*! 53 | * @addtogroup debugconsole 54 | * @{ 55 | */ 56 | 57 | /******************************************************************************* 58 | * Definitions 59 | ******************************************************************************/ 60 | 61 | /*! @brief Definition to select sdk or toolchain printf, scanf. */ 62 | #ifndef SDK_DEBUGCONSOLE 63 | #define SDK_DEBUGCONSOLE 1U 64 | #endif 65 | 66 | /*! @brief Definition to select redirect toolchain printf, scanf to uart or not. */ 67 | #ifndef SDK_DEBUGCONSOLE_UART 68 | /* mcux will handle this macro, not define it here */ 69 | #if (!defined(__MCUXPRESSO)) 70 | #define SDK_DEBUGCONSOLE_UART 71 | #endif 72 | #endif 73 | 74 | #if defined(SDK_DEBUGCONSOLE) && !(SDK_DEBUGCONSOLE) 75 | #include 76 | #endif 77 | 78 | #if SDK_DEBUGCONSOLE /* Select printf, scanf, putchar, getchar of SDK version. */ 79 | #define PRINTF DbgConsole_Printf 80 | #define SCANF DbgConsole_Scanf 81 | #define PUTCHAR DbgConsole_Putchar 82 | #define GETCHAR DbgConsole_Getchar 83 | #else /* Select printf, scanf, putchar, getchar of toolchain. */ 84 | #define PRINTF printf 85 | #define SCANF scanf 86 | #define PUTCHAR putchar 87 | #define GETCHAR getchar 88 | #endif /* SDK_DEBUGCONSOLE */ 89 | 90 | /******************************************************************************* 91 | * Prototypes 92 | ******************************************************************************/ 93 | 94 | #if defined(__cplusplus) 95 | extern "C" { 96 | #endif /* __cplusplus */ 97 | 98 | /*! @name Initialization*/ 99 | /* @{ */ 100 | 101 | /*! 102 | * @brief Initializes the peripheral used for debug messages. 103 | * 104 | * Call this function to enable debug log messages to be output via the specified peripheral, 105 | * frequency of peripheral source clock, and base address at the specified baud rate. 106 | * After this function has returned, stdout and stdin are connected to the selected peripheral. 107 | * 108 | * @param baseAddr Indicates the address of the peripheral used to send debug messages. 109 | * @param baudRate The desired baud rate in bits per second. 110 | * @param device Low level device type for the debug console, can be one of the following. 111 | * @arg DEBUG_CONSOLE_DEVICE_TYPE_UART, 112 | * @arg DEBUG_CONSOLE_DEVICE_TYPE_LPUART, 113 | * @arg DEBUG_CONSOLE_DEVICE_TYPE_LPSCI, 114 | * @arg DEBUG_CONSOLE_DEVICE_TYPE_USBCDC. 115 | * @param clkSrcFreq Frequency of peripheral source clock. 116 | * 117 | * @return Indicates whether initialization was successful or not. 118 | * @retval kStatus_Success Execution successfully 119 | * @retval kStatus_Fail Execution failure 120 | * @retval kStatus_InvalidArgument Invalid argument existed 121 | */ 122 | status_t DbgConsole_Init(uint32_t baseAddr, uint32_t baudRate, uint8_t device, uint32_t clkSrcFreq); 123 | 124 | /*! 125 | * @brief De-initializes the peripheral used for debug messages. 126 | * 127 | * Call this function to disable debug log messages to be output via the specified peripheral 128 | * base address and at the specified baud rate. 129 | * 130 | * @return Indicates whether de-initialization was successful or not. 131 | */ 132 | status_t DbgConsole_Deinit(void); 133 | 134 | #if SDK_DEBUGCONSOLE 135 | /*! 136 | * @brief Writes formatted output to the standard output stream. 137 | * 138 | * Call this function to write a formatted output to the standard output stream. 139 | * 140 | * @param fmt_s Format control string. 141 | * @return Returns the number of characters printed or a negative value if an error occurs. 142 | */ 143 | int DbgConsole_Printf(const char *fmt_s, ...); 144 | 145 | /*! 146 | * @brief Writes a character to stdout. 147 | * 148 | * Call this function to write a character to stdout. 149 | * 150 | * @param ch Character to be written. 151 | * @return Returns the character written. 152 | */ 153 | int DbgConsole_Putchar(int ch); 154 | 155 | /*! 156 | * @brief Reads formatted data from the standard input stream. 157 | * 158 | * Call this function to read formatted data from the standard input stream. 159 | * 160 | * @param fmt_ptr Format control string. 161 | * @return Returns the number of fields successfully converted and assigned. 162 | */ 163 | int DbgConsole_Scanf(char *fmt_ptr, ...); 164 | 165 | /*! 166 | * @brief Reads a character from standard input. 167 | * 168 | * Call this function to read a character from standard input. 169 | * 170 | * @return Returns the character read. 171 | */ 172 | int DbgConsole_Getchar(void); 173 | 174 | /*! 175 | * @brief Debug console flush log. 176 | * 177 | * Call this function to wait the buffer empty and io idle before. 178 | * If interrupt transfer is using, make sure the global IRQ is enable before call this function 179 | * This function should be called when 180 | * 1, before enter power down mode 181 | * 2, log is required to print to terminal immediately 182 | * @return Indicates whether wait idle was successful or not. 183 | */ 184 | status_t DbgConsole_Flush(void); 185 | 186 | #ifdef DEBUG_CONSOLE_TRANSFER_NON_BLOCKING 187 | /*! 188 | * @brief Debug console try to get char 189 | * This function provide a api which will not block current task, if character is 190 | * avaliable return it , otherwise return fail. 191 | * @param ch the address of char to receive 192 | * @return Indicates get char was successful or not. 193 | */ 194 | status_t DbgConsole_TryGetchar(char *ch); 195 | #endif 196 | 197 | #endif /* SDK_DEBUGCONSOLE */ 198 | 199 | /*! @} */ 200 | 201 | #if defined(__cplusplus) 202 | } 203 | #endif /* __cplusplus */ 204 | 205 | /*! @} */ 206 | 207 | #endif /* _FSL_DEBUGCONSOLE_H_ */ 208 | -------------------------------------------------------------------------------- /drivers/fsl_power.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The Clear BSD License 3 | * Copyright (c) 2016, Freescale Semiconductor, Inc. 4 | * Copyright (c) 2016, NXP 5 | * All rights reserved. 6 | * 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted (subject to the limitations in the disclaimer below) provided 10 | * that the following conditions are met: 11 | * 12 | * o Redistributions of source code must retain the above copyright notice, this list 13 | * of conditions and the following disclaimer. 14 | * 15 | * o Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * o Neither the name of copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived from this 21 | * software without specific prior written permission. 22 | * 23 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 28 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 31 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | #ifndef _FSL_POWER_H_ 36 | #define _FSL_POWER_H_ 37 | 38 | #include "fsl_common.h" 39 | 40 | /******************************************************************************* 41 | * Definitions 42 | ******************************************************************************/ 43 | 44 | /*! @name Driver version */ 45 | /*@{*/ 46 | /*! @brief power driver version 2.0.0. */ 47 | #define FSL_POWER_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) 48 | /*@}*/ 49 | 50 | #define MAKE_PD_BITS(reg, slot) (((reg) << 8) | (slot)) 51 | #define PDRCFG0 0x0U 52 | #define PDRCFG1 0x1U 53 | 54 | typedef enum pd_bits 55 | { 56 | kPDRUNCFG_LP_REG = MAKE_PD_BITS(PDRCFG0, 2U), 57 | kPDRUNCFG_PD_FRO_EN = MAKE_PD_BITS(PDRCFG0, 4U), 58 | kPDRUNCFG_PD_TS = MAKE_PD_BITS(PDRCFG0, 6U), 59 | kPDRUNCFG_PD_BOD_RESET = MAKE_PD_BITS(PDRCFG0, 7U), 60 | kPDRUNCFG_PD_BOD_INTR = MAKE_PD_BITS(PDRCFG0, 8U), 61 | kPDRUNCFG_PD_VD2_ANA = MAKE_PD_BITS(PDRCFG0, 9U), 62 | kPDRUNCFG_PD_ADC0 = MAKE_PD_BITS(PDRCFG0, 10U), 63 | kPDRUNCFG_PD_RAM0 = MAKE_PD_BITS(PDRCFG0, 13U), 64 | kPDRUNCFG_PD_RAM1 = MAKE_PD_BITS(PDRCFG0, 14U), 65 | kPDRUNCFG_PD_RAM2 = MAKE_PD_BITS(PDRCFG0, 15U), 66 | kPDRUNCFG_PD_RAM3 = MAKE_PD_BITS(PDRCFG0, 16U), 67 | kPDRUNCFG_PD_ROM = MAKE_PD_BITS(PDRCFG0, 17U), 68 | kPDRUNCFG_PD_VDDA = MAKE_PD_BITS(PDRCFG0, 19U), 69 | kPDRUNCFG_PD_WDT_OSC = MAKE_PD_BITS(PDRCFG0, 20U), 70 | kPDRUNCFG_PD_USB0_PHY = MAKE_PD_BITS(PDRCFG0, 21U), 71 | kPDRUNCFG_PD_SYS_PLL0 = MAKE_PD_BITS(PDRCFG0, 22U), 72 | kPDRUNCFG_PD_VREFP = MAKE_PD_BITS(PDRCFG0, 23U), 73 | kPDRUNCFG_PD_FLASH_BG = MAKE_PD_BITS(PDRCFG0, 25U), 74 | kPDRUNCFG_PD_VD3 = MAKE_PD_BITS(PDRCFG0, 26U), 75 | kPDRUNCFG_PD_VD4 = MAKE_PD_BITS(PDRCFG0, 27U), 76 | kPDRUNCFG_PD_VD5 = MAKE_PD_BITS(PDRCFG0, 28U), 77 | kPDRUNCFG_PD_VD6 = MAKE_PD_BITS(PDRCFG0, 29U), 78 | kPDRUNCFG_REQ_DELAY = MAKE_PD_BITS(PDRCFG0, 30U), 79 | kPDRUNCFG_FORCE_RBB = MAKE_PD_BITS(PDRCFG0, 31U), 80 | 81 | kPDRUNCFG_PD_USB1_PHY = MAKE_PD_BITS(PDRCFG1, 0U), 82 | kPDRUNCFG_PD_USB_PLL = MAKE_PD_BITS(PDRCFG1, 1U), 83 | kPDRUNCFG_PD_AUDIO_PLL = MAKE_PD_BITS(PDRCFG1, 2U), 84 | kPDRUNCFG_PD_SYS_OSC = MAKE_PD_BITS(PDRCFG1, 3U), 85 | kPDRUNCFG_PD_EEPROM = MAKE_PD_BITS(PDRCFG1, 5U), 86 | kPDRUNCFG_PD_rng = MAKE_PD_BITS(PDRCFG1, 6U), 87 | 88 | /* 89 | This enum member has no practical meaning,it is used to avoid MISRA issue, 90 | user should not trying to use it. 91 | */ 92 | kPDRUNCFG_ForceUnsigned = 0x80000000U, 93 | } pd_bit_t; 94 | 95 | /* Power mode configuration API parameter */ 96 | typedef enum _power_mode_config 97 | { 98 | kPmu_Sleep = 0U, 99 | kPmu_Deep_Sleep = 1U, 100 | kPmu_Deep_PowerDown = 2U, 101 | } power_mode_cfg_t; 102 | 103 | /******************************************************************************* 104 | * API 105 | ******************************************************************************/ 106 | 107 | #ifdef __cplusplus 108 | extern "C" { 109 | #endif 110 | 111 | /*! 112 | * @name Power Configuration 113 | * @{ 114 | */ 115 | 116 | /*! 117 | * @brief API to enable PDRUNCFG bit in the Syscon. Note that enabling the bit powers down the peripheral 118 | * 119 | * @param en peripheral for which to enable the PDRUNCFG bit 120 | * @return none 121 | */ 122 | static inline void POWER_EnablePD(pd_bit_t en) 123 | { 124 | /* PDRUNCFGSET */ 125 | SYSCON->PDRUNCFGSET[(en >> 8UL)] = (1UL << (en & 0xffU)); 126 | } 127 | 128 | /*! 129 | * @brief API to disable PDRUNCFG bit in the Syscon. Note that disabling the bit powers up the peripheral 130 | * 131 | * @param en peripheral for which to disable the PDRUNCFG bit 132 | * @return none 133 | */ 134 | static inline void POWER_DisablePD(pd_bit_t en) 135 | { 136 | /* PDRUNCFGCLR */ 137 | SYSCON->PDRUNCFGCLR[(en >> 8UL)] = (1UL << (en & 0xffU)); 138 | } 139 | 140 | /*! 141 | * @brief API to enable deep sleep bit in the ARM Core. 142 | * 143 | * @param none 144 | * @return none 145 | */ 146 | static inline void POWER_EnableDeepSleep(void) 147 | { 148 | SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; 149 | } 150 | 151 | /*! 152 | * @brief API to disable deep sleep bit in the ARM Core. 153 | * 154 | * @param none 155 | * @return none 156 | */ 157 | static inline void POWER_DisableDeepSleep(void) 158 | { 159 | SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk; 160 | } 161 | 162 | /*! 163 | * @brief API to power down flash controller. 164 | * 165 | * @param none 166 | * @return none 167 | */ 168 | static inline void POWER_PowerDownFlash(void) 169 | { 170 | /* TURN OFF clock ip_2113 (only needed for FLASH programming, will be turned on by ROM API) */ 171 | CLOCK_DisableClock(kCLOCK_Flash); 172 | 173 | /* TURN OFF clock ip_2113 (only needed for FLASH programming, will be turned on by ROM API) */ 174 | CLOCK_DisableClock(kCLOCK_Fmc); 175 | } 176 | 177 | /*! 178 | * @brief API to power up flash controller. 179 | * 180 | * @param none 181 | * @return none 182 | */ 183 | static inline void POWER_PowerUpFlash(void) 184 | { 185 | /* TURN OFF clock ip_2113 (only needed for FLASH programming, will be turned on by ROM API) */ 186 | CLOCK_EnableClock(kCLOCK_Fmc); 187 | } 188 | 189 | /*! 190 | * @brief Power Library API to power the PLLs. 191 | * 192 | * @param none 193 | * @return none 194 | */ 195 | void POWER_SetPLL(void); 196 | 197 | /*! 198 | * @brief Power Library API to power the USB PHY. 199 | * 200 | * @param none 201 | * @return none 202 | */ 203 | void POWER_SetUsbPhy(void); 204 | 205 | /*! 206 | * @brief Power Library API to enter different power mode. 207 | * 208 | * @param exclude_from_pd Bit mask of the PDRUNCFG0(low 32bits) and PDRUNCFG1(high 32bits) that needs to be powered on 209 | * during power mode selected. 210 | * @return none 211 | */ 212 | void POWER_EnterPowerMode(power_mode_cfg_t mode, uint64_t exclude_from_pd); 213 | 214 | /*! 215 | * @brief Power Library API to enter sleep mode. 216 | * 217 | * @return none 218 | */ 219 | void POWER_EnterSleep(void); 220 | 221 | /*! 222 | * @brief Power Library API to enter deep sleep mode. 223 | * 224 | * @param exclude_from_pd Bit mask of the PDRUNCFG0(low 32bits) and PDRUNCFG1(high 32bits) bits that needs to be 225 | * powered on during deep sleep 226 | * @return none 227 | */ 228 | void POWER_EnterDeepSleep(uint64_t exclude_from_pd); 229 | 230 | /*! 231 | * @brief Power Library API to enter deep power down mode. 232 | * 233 | * @param exclude_from_pd Bit mask of the PDRUNCFG0(low 32bits) and PDRUNCFG1(high 32bits) that needs to be powered on 234 | during deep power 235 | * down mode, but this is has no effect as the voltages are cut off. 236 | 237 | * @return none 238 | */ 239 | void POWER_EnterDeepPowerDown(uint64_t exclude_from_pd); 240 | 241 | /*! 242 | * @brief Power Library API to choose normal regulation and set the voltage for the desired operating frequency. 243 | * 244 | * @param freq - The desired frequency at which the part would like to operate, 245 | * note that the voltage and flash wait states should be set before changing frequency 246 | * @return none 247 | */ 248 | void POWER_SetVoltageForFreq(uint32_t freq); 249 | 250 | /*! 251 | * @brief Power Library API to return the library version. 252 | * 253 | * @param none 254 | * @return version number of the power library 255 | */ 256 | uint32_t POWER_GetLibVersion(void); 257 | 258 | #ifdef __cplusplus 259 | } 260 | #endif 261 | 262 | #endif /* _FSL_POWER_H_ */ 263 | -------------------------------------------------------------------------------- /sources/can.c: -------------------------------------------------------------------------------- 1 | /* 2 | * can.c 3 | * 4 | */ 5 | 6 | #include "can.h" 7 | #include "gpio.h" 8 | #include "main.h" 9 | 10 | #define MCAN0_CLK_FREQ CLOCK_GetFreq(kCLOCK_MCAN0) 11 | #define MCAN1_CLK_FREQ CLOCK_GetFreq(kCLOCK_MCAN1) 12 | 13 | #define CAN_RAM_BASE 0x20010000U 14 | #define CAN0_STD_FILTER_OFS 0x00 15 | #define CAN0_RX_FIFO0_OFS 0x10 16 | #define CAN0_TX_BUFFER_OFS 0x20 17 | #define CAN1_STD_FILTER_OFS 0x100 18 | #define CAN1_RX_FIFO0_OFS 0x110 19 | #define CAN1_TX_BUFFER_OFS 0x120 20 | 21 | static CAN_Type* can_devs[CAN_NUM_CHANNELS] = { 22 | CAN0, 23 | CAN1 }; 24 | static mcan_timing_config_t timing_configs[CAN_NUM_CHANNELS]; 25 | static mcan_timing_config_t data_timing_configs[CAN_NUM_CHANNELS]; 26 | static uint8_t channel_enabled[CAN_NUM_CHANNELS]; 27 | static uint8_t monitor_mode[CAN_NUM_CHANNELS]; 28 | static uint8_t identify[CAN_NUM_CHANNELS]; 29 | static uint64_t rx_count[CAN_NUM_CHANNELS]; 30 | static uint64_t tx_count[CAN_NUM_CHANNELS]; 31 | 32 | void CAN0_IRQ0_IRQHandler(void) { 33 | mcan_rx_buffer_frame_t rx_frame; 34 | 35 | if (MCAN_GetStatusFlag(CAN0, CAN_IR_RF0N_MASK)) { 36 | MCAN_ClearStatusFlag(CAN0, CAN_IR_RF0N_MASK); 37 | MCAN_ReadRxFifo(CAN0, 0, &rx_frame); 38 | rx_enqueue(0, &rx_frame); 39 | rx_count[0]++; 40 | } else if (MCAN_GetStatusFlag(CAN0, CAN_IR_TC_MASK)) { 41 | MCAN_ClearStatusFlag(CAN0, CAN_IR_TC_MASK); 42 | } 43 | } 44 | 45 | void CAN1_IRQ0_IRQHandler(void) { 46 | mcan_rx_buffer_frame_t rx_frame; 47 | 48 | if (MCAN_GetStatusFlag(CAN1, CAN_IR_RF0N_MASK)) { 49 | MCAN_ClearStatusFlag(CAN1, CAN_IR_RF0N_MASK); 50 | MCAN_ReadRxFifo(CAN1, 0, &rx_frame); 51 | rx_enqueue(1, &rx_frame); 52 | rx_count[1]++; 53 | } else if (MCAN_GetStatusFlag(CAN1, CAN_IR_TC_MASK)) { 54 | MCAN_ClearStatusFlag(CAN1, CAN_IR_TC_MASK); 55 | } 56 | } 57 | 58 | uint64_t can_get_rx_count(uint8_t channel) { 59 | if (channel >= CAN_NUM_CHANNELS) { 60 | return 0; 61 | } 62 | return rx_count[channel]; 63 | } 64 | 65 | uint64_t can_get_tx_count(uint8_t channel) { 66 | if (channel >= CAN_NUM_CHANNELS) { 67 | return 0; 68 | } 69 | return tx_count[channel]; 70 | } 71 | 72 | uint8_t can_get_enabled(uint8_t channel) { 73 | if (channel >= CAN_NUM_CHANNELS) { 74 | return 0; 75 | } 76 | return channel_enabled[channel]; 77 | } 78 | 79 | void can_set_identify(uint8_t channel, uint8_t enable) { 80 | if (channel >= CAN_NUM_CHANNELS) { 81 | return; 82 | } 83 | identify[channel] = enable; 84 | } 85 | uint8_t can_get_identify(uint8_t channel) { 86 | if (channel >= CAN_NUM_CHANNELS) { 87 | return 0; 88 | } 89 | return identify[channel]; 90 | } 91 | 92 | uint8_t can_get_monitor_mode(uint8_t channel) { 93 | if (channel >= CAN_NUM_CHANNELS) { 94 | return 0; 95 | } 96 | return monitor_mode[channel]; 97 | } 98 | 99 | int can_set_timing(uint8_t channel, mcan_timing_config_t *timing_config) { 100 | if (channel >= CAN_NUM_CHANNELS) { 101 | return -1; 102 | } 103 | memcpy(&timing_configs[channel], timing_config, sizeof(mcan_timing_config_t)); 104 | 105 | // hardware expects these to be one less than value 106 | timing_configs[channel].preDivider -= 1; 107 | timing_configs[channel].seg1 -= 1; 108 | timing_configs[channel].seg2 -= 1; 109 | timing_configs[channel].rJumpwidth -= 1; 110 | 111 | return 0; 112 | } 113 | 114 | int can_set_data_timing(uint8_t channel, mcan_timing_config_t *timing_config) { 115 | if (channel >= CAN_NUM_CHANNELS) { 116 | return -1; 117 | } 118 | memcpy(&data_timing_configs[channel], timing_config, sizeof(mcan_timing_config_t)); 119 | 120 | // hardware expects these to be one less than value 121 | data_timing_configs[channel].preDivider -= 1; 122 | data_timing_configs[channel].seg1 -= 1; 123 | data_timing_configs[channel].seg2 -= 1; 124 | data_timing_configs[channel].rJumpwidth -= 1; 125 | 126 | return 0; 127 | } 128 | 129 | /* Data Length Code 9 10 11 12 13 14 15 130 | Number of data bytes 12 16 20 24 32 48 64 */ 131 | int can_len2dlc(uint8_t len) { 132 | if (len <= 8) { 133 | return len; 134 | } else if (len <= 12) { 135 | return 9; 136 | } else if (len <= 16) { 137 | return 10; 138 | } else if (len <= 20) { 139 | return 11; 140 | } else if (len <= 24) { 141 | return 12; 142 | } else if (len <= 32) { 143 | return 13; 144 | } else if (len <= 48) { 145 | return 14; 146 | } else if (len <= 64) { 147 | return 15; 148 | } 149 | return 0; 150 | } 151 | int can_dlc2len(uint8_t dlc) { 152 | if (dlc <= 8) { 153 | return dlc; 154 | } else if (dlc == 9) { 155 | return 12; 156 | } else if (dlc == 10) { 157 | return 16; 158 | } else if (dlc == 11) { 159 | return 20; 160 | } else if (dlc == 12) { 161 | return 24; 162 | } else if (dlc == 13) { 163 | return 32; 164 | } else if (dlc == 14) { 165 | return 48; 166 | } else if (dlc == 15) { 167 | return 64; 168 | } 169 | return 0; 170 | } 171 | 172 | int can_start(uint8_t channel, uint32_t flags) { 173 | mcan_config_t config; 174 | mcan_rx_fifo_config_t rxFifo0; 175 | mcan_tx_buffer_config_t txBuffer; 176 | CAN_Type *can_dev; 177 | 178 | if (channel >= CAN_NUM_CHANNELS) { 179 | return -1; 180 | } 181 | can_dev = can_devs[channel]; 182 | 183 | MCAN_GetDefaultConfig(&config); 184 | monitor_mode[channel] = 0; 185 | if (flags & GS_CAN_MODE_LISTEN_ONLY) { 186 | config.enableBusMon = true; 187 | monitor_mode[channel] = 1; 188 | } 189 | if (flags & GS_CAN_MODE_LOOP_BACK) { 190 | config.enableLoopBackExt = true; 191 | } 192 | if (flags & GS_CAN_MODE_FD) { 193 | config.enableCanfdSwitch = true; 194 | } 195 | 196 | if (can_dev == CAN0) { 197 | MCAN_Init(can_dev, &config, MCAN0_CLK_FREQ); 198 | } else if (can_dev == CAN1) { 199 | MCAN_Init(can_dev, &config, MCAN1_CLK_FREQ); 200 | } 201 | 202 | channel_enabled[channel] = 1; 203 | 204 | // set timing configuration 205 | // this must happen after MCAN_Init or it will be overridden 206 | MCAN_SetArbitrationTimingConfig(can_dev, &timing_configs[channel]); 207 | MCAN_SetDataTimingConfig(can_dev, &data_timing_configs[channel]); 208 | 209 | /* Set Message RAM base address and clear to avoid BEU/BEC error. */ 210 | MCAN_SetMsgRAMBase(can_dev, CAN_RAM_BASE); 211 | if (can_dev == CAN0) { 212 | uint32_t *p = (uint32_t *) (CAN_RAM_BASE); 213 | memset(p, 0, 0x100U); 214 | } else if (can_dev == CAN1) { 215 | uint32_t *p = (uint32_t *) (CAN_RAM_BASE + CAN1_STD_FILTER_OFS); 216 | memset(p, 0, 0x100); 217 | } 218 | 219 | /* RX fifo0 config. */ 220 | if (can_dev == CAN0) { 221 | rxFifo0.address = CAN0_RX_FIFO0_OFS; 222 | } else { 223 | rxFifo0.address = CAN1_RX_FIFO0_OFS; 224 | } 225 | rxFifo0.elementSize = 1U; 226 | rxFifo0.watermark = 0; 227 | rxFifo0.opmode = kMCAN_FifoBlocking; 228 | rxFifo0.datafieldSize = kMCAN_64ByteDatafield; 229 | MCAN_SetRxFifo0Config(can_dev, &rxFifo0); 230 | 231 | /* TX buffer config */ 232 | if (can_dev == CAN0) { 233 | txBuffer.address = CAN0_TX_BUFFER_OFS; 234 | } else { 235 | txBuffer.address = CAN1_TX_BUFFER_OFS; 236 | } 237 | txBuffer.dedicatedSize = 16U; 238 | txBuffer.fqSize = 16U; 239 | txBuffer.datafieldSize = kMCAN_64ByteDatafield; 240 | MCAN_SetTxBufferConfig(can_dev, &txBuffer); 241 | 242 | /* Enable RX fifo0 new message interrupt using interrupt line 0. */ 243 | MCAN_EnableInterrupts(can_dev, 0, CAN_IE_RF0NE_MASK); 244 | if (can_dev == CAN0) { 245 | EnableIRQ(CAN0_IRQ0_IRQn); 246 | } else if (can_dev == CAN1) { 247 | EnableIRQ(CAN1_IRQ0_IRQn); 248 | } 249 | 250 | /* Enter normal mode. */ 251 | MCAN_EnterNormalMode(can_dev); 252 | 253 | return 0; 254 | } 255 | 256 | int can_stop(uint8_t channel) { 257 | CAN_Type* can_dev; 258 | 259 | if (channel >= CAN_NUM_CHANNELS) { 260 | return -1; 261 | } 262 | can_dev = can_devs[channel]; 263 | channel_enabled[channel] = 0; 264 | 265 | MCAN_Deinit(can_dev); 266 | 267 | return 0; 268 | } 269 | 270 | int can_send(uint8_t channel, uint8_t buf, uint32_t can_id, uint8_t flags, uint8_t can_dlc, 271 | uint8_t *can_data) { 272 | CAN_Type* can_dev; 273 | mcan_handle_t handle; 274 | mcan_buffer_transfer_t xfer; 275 | mcan_tx_buffer_frame_t frame; 276 | 277 | if (channel >= CAN_NUM_CHANNELS) { 278 | return -1; 279 | } 280 | if (!channel_enabled[channel]) { 281 | return -1; 282 | } 283 | can_dev = can_devs[channel]; 284 | 285 | MCAN_TransferCreateHandle(can_dev, &handle, NULL, NULL); 286 | 287 | // check extended bit 288 | if (can_id & 0x80000000) { 289 | // extended frame, remove extended bit 290 | frame.id = can_id & 0x7FFFFFFF; 291 | frame.xtd = kMCAN_FrameIDExtend; 292 | } else { 293 | // standard ID, bit shift for MCAN FIFO 294 | frame.id = can_id << STDID_OFFSET; 295 | frame.xtd = kMCAN_FrameIDStandard; 296 | } 297 | // check RTR bit 298 | if (can_id & 0x40000000) { 299 | // RTR frame, remove RTR bit 300 | frame.rtr = kMCAN_FrameTypeRemote; 301 | frame.id = frame.id & 0x3FFFFFFF; 302 | } else { 303 | frame.rtr = kMCAN_FrameTypeData; 304 | } 305 | 306 | frame.dlc = can_dlc; 307 | frame.size = can_dlc2len(can_dlc); 308 | frame.data = can_data; 309 | 310 | if (flags & GS_CAN_FLAG_FD) { 311 | frame.fdf = 1; 312 | } else { 313 | frame.fdf = 0; 314 | 315 | } 316 | if (flags & GS_CAN_FLAG_BRS) { 317 | frame.brs = 1; 318 | } else { 319 | frame.brs = 0; 320 | } 321 | if (flags & GS_CAN_FLAG_ESI) { 322 | frame.esi = 1; 323 | } else { 324 | frame.esi = 0; 325 | } 326 | 327 | xfer.frame = &frame; 328 | xfer.bufferIdx = buf; 329 | 330 | MCAN_TransferSendNonBlocking(can_dev, &handle, &xfer); 331 | 332 | tx_count[channel]++; 333 | 334 | return 0; 335 | } 336 | -------------------------------------------------------------------------------- /board/src/board.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The Clear BSD License 3 | * Copyright (c) 2016, Freescale Semiconductor, Inc. 4 | * Copyright 2016-2017 NXP 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted (subject to the limitations in the disclaimer below) provided 9 | * that the following conditions are met: 10 | * 11 | * o Redistributions of source code must retain the above copyright notice, this list 12 | * of conditions and the following disclaimer. 13 | * 14 | * o Redistributions in binary form must reproduce the above copyright notice, this 15 | * list of conditions and the following disclaimer in the documentation and/or 16 | * other materials provided with the distribution. 17 | * 18 | * o Neither the name of the copyright holder nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #include "board.h" 36 | #include 37 | #include "clock_config.h" 38 | #include "fsl_common.h" 39 | #include "fsl_debug_console.h" 40 | #include "fsl_emc.h" 41 | #if defined(SDK_I2C_BASED_COMPONENT_USED) && SDK_I2C_BASED_COMPONENT_USED 42 | #include "fsl_i2c.h" 43 | #endif /* SDK_I2C_BASED_COMPONENT_USED */ 44 | #if defined BOARD_USE_CODEC 45 | #include "fsl_wm8904.h" 46 | #endif 47 | /******************************************************************************* 48 | * Definitions 49 | ******************************************************************************/ 50 | /* The SDRAM timing. */ 51 | #define SDRAM_REFRESHPERIOD_NS (64 * 1000000 / 4096) /* 4096 rows/ 64ms */ 52 | #define SDRAM_TRP_NS (18u) 53 | #define SDRAM_TRAS_NS (42u) 54 | #define SDRAM_TSREX_NS (67u) 55 | #define SDRAM_TAPR_NS (18u) 56 | #define SDRAM_TWRDELT_NS (6u) 57 | #define SDRAM_TRC_NS (60u) 58 | #define SDRAM_RFC_NS (60u) 59 | #define SDRAM_XSR_NS (67u) 60 | #define SDRAM_RRD_NS (12u) 61 | #define SDRAM_MRD_NCLK (2u) 62 | #define SDRAM_RAS_NCLK (2u) 63 | #define SDRAM_MODEREG_VALUE (0x23u) 64 | #define SDRAM_DEV_MEMORYMAP (0x09u) /* 128Mbits (8M*16, 4banks, 12 rows, 9 columns)*/ 65 | 66 | /******************************************************************************* 67 | * Variables 68 | ******************************************************************************/ 69 | 70 | /* Clock rate on the CLKIN pin */ 71 | const uint32_t ExtClockIn = BOARD_EXTCLKINRATE; 72 | 73 | #if defined BOARD_USE_CODEC 74 | codec_config_t boardCodecConfig = { 75 | .I2C_SendFunc = BOARD_Codec_I2C_Send, 76 | .I2C_ReceiveFunc = BOARD_Codec_I2C_Receive, 77 | .op.Init = WM8904_Init, 78 | .op.Deinit = WM8904_Deinit, 79 | .op.SetFormat = WM8904_SetAudioFormat 80 | }; 81 | #endif 82 | /******************************************************************************* 83 | * Code 84 | ******************************************************************************/ 85 | /* Initialize debug console. */ 86 | status_t BOARD_InitDebugConsole(void) 87 | { 88 | status_t result; 89 | /* attach 12 MHz clock to FLEXCOMM0 (debug console) */ 90 | CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH); 91 | RESET_PeripheralReset(BOARD_DEBUG_UART_RST); 92 | result = DbgConsole_Init(BOARD_DEBUG_UART_BASEADDR, BOARD_DEBUG_UART_BAUDRATE, DEBUG_CONSOLE_DEVICE_TYPE_FLEXCOMM, 93 | BOARD_DEBUG_UART_CLK_FREQ); 94 | assert(kStatus_Success == result); 95 | return result; 96 | } 97 | 98 | /* Initialize the external memory. */ 99 | void BOARD_InitSDRAM(void) 100 | { 101 | emc_basic_config_t basicConfig; 102 | emc_dynamic_timing_config_t dynTiming; 103 | emc_dynamic_chip_config_t dynChipConfig; 104 | 105 | /* Basic configuration. */ 106 | basicConfig.endian = kEMC_LittleEndian; 107 | basicConfig.fbClkSrc = kEMC_IntloopbackEmcclk; 108 | /* EMC Clock = CPU FREQ/2 here can fit CPU freq from 12M ~ 180M. 109 | * If you change the divide to 0 and EMC clock is larger than 100M 110 | * please take refer to emc.dox to adjust EMC clock delay. 111 | */ 112 | basicConfig.emcClkDiv = 1; 113 | /* Dynamic memory timing configuration. */ 114 | dynTiming.readConfig = kEMC_Cmddelay; 115 | dynTiming.refreshPeriod_Nanosec = SDRAM_REFRESHPERIOD_NS; 116 | dynTiming.tRp_Ns = SDRAM_TRP_NS; 117 | dynTiming.tRas_Ns = SDRAM_TRAS_NS; 118 | dynTiming.tSrex_Ns = SDRAM_TSREX_NS; 119 | dynTiming.tApr_Ns = SDRAM_TAPR_NS; 120 | dynTiming.tWr_Ns = (1000000000 / CLOCK_GetFreq(kCLOCK_EMC) + SDRAM_TWRDELT_NS); /* one clk + 6ns */ 121 | dynTiming.tDal_Ns = dynTiming.tWr_Ns + dynTiming.tRp_Ns; 122 | dynTiming.tRc_Ns = SDRAM_TRC_NS; 123 | dynTiming.tRfc_Ns = SDRAM_RFC_NS; 124 | dynTiming.tXsr_Ns = SDRAM_XSR_NS; 125 | dynTiming.tRrd_Ns = SDRAM_RRD_NS; 126 | dynTiming.tMrd_Nclk = SDRAM_MRD_NCLK; 127 | /* Dynamic memory chip specific configuration: Chip 0 - MTL48LC8M16A2B4-6A */ 128 | dynChipConfig.chipIndex = 0; 129 | dynChipConfig.dynamicDevice = kEMC_Sdram; 130 | dynChipConfig.rAS_Nclk = SDRAM_RAS_NCLK; 131 | dynChipConfig.sdramModeReg = SDRAM_MODEREG_VALUE; 132 | dynChipConfig.sdramExtModeReg = 0; /* it has no use for normal sdram */ 133 | dynChipConfig.devAddrMap = SDRAM_DEV_MEMORYMAP; 134 | /* EMC Basic configuration. */ 135 | EMC_Init(EMC, &basicConfig); 136 | /* EMC Dynamc memory configuration. */ 137 | EMC_DynamicMemInit(EMC, &dynTiming, &dynChipConfig, 1); 138 | } 139 | 140 | #if defined(SDK_I2C_BASED_COMPONENT_USED) && SDK_I2C_BASED_COMPONENT_USED 141 | void BOARD_I2C_Init(I2C_Type *base, uint32_t clkSrc_Hz) 142 | { 143 | i2c_master_config_t i2cConfig = {0}; 144 | 145 | I2C_MasterGetDefaultConfig(&i2cConfig); 146 | I2C_MasterInit(base, &i2cConfig, clkSrc_Hz); 147 | } 148 | 149 | status_t BOARD_I2C_Send(I2C_Type *base, 150 | uint8_t deviceAddress, 151 | uint32_t subAddress, 152 | uint8_t subaddressSize, 153 | uint8_t *txBuff, 154 | uint8_t txBuffSize) 155 | { 156 | i2c_master_transfer_t masterXfer; 157 | 158 | /* Prepare transfer structure. */ 159 | masterXfer.slaveAddress = deviceAddress; 160 | masterXfer.direction = kI2C_Write; 161 | masterXfer.subaddress = subAddress; 162 | masterXfer.subaddressSize = subaddressSize; 163 | masterXfer.data = txBuff; 164 | masterXfer.dataSize = txBuffSize; 165 | masterXfer.flags = kI2C_TransferDefaultFlag; 166 | 167 | return I2C_MasterTransferBlocking(base, &masterXfer); 168 | } 169 | 170 | status_t BOARD_I2C_Receive(I2C_Type *base, 171 | uint8_t deviceAddress, 172 | uint32_t subAddress, 173 | uint8_t subaddressSize, 174 | uint8_t *rxBuff, 175 | uint8_t rxBuffSize) 176 | { 177 | i2c_master_transfer_t masterXfer; 178 | 179 | /* Prepare transfer structure. */ 180 | masterXfer.slaveAddress = deviceAddress; 181 | masterXfer.subaddress = subAddress; 182 | masterXfer.subaddressSize = subaddressSize; 183 | masterXfer.data = rxBuff; 184 | masterXfer.dataSize = rxBuffSize; 185 | masterXfer.direction = kI2C_Read; 186 | masterXfer.flags = kI2C_TransferDefaultFlag; 187 | 188 | return I2C_MasterTransferBlocking(base, &masterXfer); 189 | } 190 | 191 | void BOARD_Accel_I2C_Init(void) 192 | { 193 | BOARD_I2C_Init(BOARD_ACCEL_I2C_BASEADDR, BOARD_ACCEL_I2C_CLOCK_FREQ); 194 | } 195 | 196 | status_t BOARD_Accel_I2C_Send(uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint32_t txBuff) 197 | { 198 | uint8_t data = (uint8_t)txBuff; 199 | 200 | return BOARD_I2C_Send(BOARD_ACCEL_I2C_BASEADDR, deviceAddress, subAddress, subaddressSize, &data, 1); 201 | } 202 | 203 | status_t BOARD_Accel_I2C_Receive(uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint8_t *rxBuff, uint8_t rxBuffSize) 204 | { 205 | return BOARD_I2C_Receive(BOARD_ACCEL_I2C_BASEADDR, deviceAddress, subAddress, subaddressSize, rxBuff, rxBuffSize); 206 | } 207 | 208 | void BOARD_Codec_I2C_Init(void) 209 | { 210 | BOARD_I2C_Init(BOARD_CODEC_I2C_BASEADDR, BOARD_CODEC_I2C_CLOCK_FREQ); 211 | } 212 | 213 | status_t BOARD_Codec_I2C_Send( 214 | uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize) 215 | { 216 | return BOARD_I2C_Send(BOARD_CODEC_I2C_BASEADDR, deviceAddress, subAddress, subAddressSize, (uint8_t *)txBuff, 217 | txBuffSize); 218 | } 219 | 220 | status_t BOARD_Codec_I2C_Receive( 221 | uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize) 222 | { 223 | return BOARD_I2C_Receive(BOARD_CODEC_I2C_BASEADDR, deviceAddress, subAddress, subAddressSize, rxBuff, 224 | rxBuffSize); 225 | } 226 | #endif /* SDK_I2C_BASED_COMPONENT_USED */ 227 | -------------------------------------------------------------------------------- /CMSIS/cmsis_compiler.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_compiler.h 3 | * @brief CMSIS compiler generic header file 4 | * @version V5.0.4 5 | * @date 10. January 2018 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2018 Arm Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #ifndef __CMSIS_COMPILER_H 26 | #define __CMSIS_COMPILER_H 27 | 28 | #include 29 | 30 | /* 31 | * Arm Compiler 4/5 32 | */ 33 | #if defined ( __CC_ARM ) 34 | #include "cmsis_armcc.h" 35 | 36 | 37 | /* 38 | * Arm Compiler 6 (armclang) 39 | */ 40 | #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 41 | #include "cmsis_armclang.h" 42 | 43 | 44 | /* 45 | * GNU Compiler 46 | */ 47 | #elif defined ( __GNUC__ ) 48 | #include "cmsis_gcc.h" 49 | 50 | 51 | /* 52 | * IAR Compiler 53 | */ 54 | #elif defined ( __ICCARM__ ) 55 | #include 56 | 57 | 58 | /* 59 | * TI Arm Compiler 60 | */ 61 | #elif defined ( __TI_ARM__ ) 62 | #include 63 | 64 | #ifndef __ASM 65 | #define __ASM __asm 66 | #endif 67 | #ifndef __INLINE 68 | #define __INLINE inline 69 | #endif 70 | #ifndef __STATIC_INLINE 71 | #define __STATIC_INLINE static inline 72 | #endif 73 | #ifndef __STATIC_FORCEINLINE 74 | #define __STATIC_FORCEINLINE __STATIC_INLINE 75 | #endif 76 | #ifndef __NO_RETURN 77 | #define __NO_RETURN __attribute__((noreturn)) 78 | #endif 79 | #ifndef __USED 80 | #define __USED __attribute__((used)) 81 | #endif 82 | #ifndef __WEAK 83 | #define __WEAK __attribute__((weak)) 84 | #endif 85 | #ifndef __PACKED 86 | #define __PACKED __attribute__((packed)) 87 | #endif 88 | #ifndef __PACKED_STRUCT 89 | #define __PACKED_STRUCT struct __attribute__((packed)) 90 | #endif 91 | #ifndef __PACKED_UNION 92 | #define __PACKED_UNION union __attribute__((packed)) 93 | #endif 94 | #ifndef __UNALIGNED_UINT32 /* deprecated */ 95 | struct __attribute__((packed)) T_UINT32 { uint32_t v; }; 96 | #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 97 | #endif 98 | #ifndef __UNALIGNED_UINT16_WRITE 99 | __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 100 | #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val)) 101 | #endif 102 | #ifndef __UNALIGNED_UINT16_READ 103 | __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 104 | #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 105 | #endif 106 | #ifndef __UNALIGNED_UINT32_WRITE 107 | __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 108 | #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 109 | #endif 110 | #ifndef __UNALIGNED_UINT32_READ 111 | __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 112 | #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 113 | #endif 114 | #ifndef __ALIGNED 115 | #define __ALIGNED(x) __attribute__((aligned(x))) 116 | #endif 117 | #ifndef __RESTRICT 118 | #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. 119 | #define __RESTRICT 120 | #endif 121 | 122 | 123 | /* 124 | * TASKING Compiler 125 | */ 126 | #elif defined ( __TASKING__ ) 127 | /* 128 | * The CMSIS functions have been implemented as intrinsics in the compiler. 129 | * Please use "carm -?i" to get an up to date list of all intrinsics, 130 | * Including the CMSIS ones. 131 | */ 132 | 133 | #ifndef __ASM 134 | #define __ASM __asm 135 | #endif 136 | #ifndef __INLINE 137 | #define __INLINE inline 138 | #endif 139 | #ifndef __STATIC_INLINE 140 | #define __STATIC_INLINE static inline 141 | #endif 142 | #ifndef __STATIC_FORCEINLINE 143 | #define __STATIC_FORCEINLINE __STATIC_INLINE 144 | #endif 145 | #ifndef __NO_RETURN 146 | #define __NO_RETURN __attribute__((noreturn)) 147 | #endif 148 | #ifndef __USED 149 | #define __USED __attribute__((used)) 150 | #endif 151 | #ifndef __WEAK 152 | #define __WEAK __attribute__((weak)) 153 | #endif 154 | #ifndef __PACKED 155 | #define __PACKED __packed__ 156 | #endif 157 | #ifndef __PACKED_STRUCT 158 | #define __PACKED_STRUCT struct __packed__ 159 | #endif 160 | #ifndef __PACKED_UNION 161 | #define __PACKED_UNION union __packed__ 162 | #endif 163 | #ifndef __UNALIGNED_UINT32 /* deprecated */ 164 | struct __packed__ T_UINT32 { uint32_t v; }; 165 | #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 166 | #endif 167 | #ifndef __UNALIGNED_UINT16_WRITE 168 | __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 169 | #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) 170 | #endif 171 | #ifndef __UNALIGNED_UINT16_READ 172 | __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 173 | #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 174 | #endif 175 | #ifndef __UNALIGNED_UINT32_WRITE 176 | __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 177 | #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 178 | #endif 179 | #ifndef __UNALIGNED_UINT32_READ 180 | __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 181 | #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 182 | #endif 183 | #ifndef __ALIGNED 184 | #define __ALIGNED(x) __align(x) 185 | #endif 186 | #ifndef __RESTRICT 187 | #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. 188 | #define __RESTRICT 189 | #endif 190 | 191 | 192 | /* 193 | * COSMIC Compiler 194 | */ 195 | #elif defined ( __CSMC__ ) 196 | #include 197 | 198 | #ifndef __ASM 199 | #define __ASM _asm 200 | #endif 201 | #ifndef __INLINE 202 | #define __INLINE inline 203 | #endif 204 | #ifndef __STATIC_INLINE 205 | #define __STATIC_INLINE static inline 206 | #endif 207 | #ifndef __STATIC_FORCEINLINE 208 | #define __STATIC_FORCEINLINE __STATIC_INLINE 209 | #endif 210 | #ifndef __NO_RETURN 211 | // NO RETURN is automatically detected hence no warning here 212 | #define __NO_RETURN 213 | #endif 214 | #ifndef __USED 215 | #warning No compiler specific solution for __USED. __USED is ignored. 216 | #define __USED 217 | #endif 218 | #ifndef __WEAK 219 | #define __WEAK __weak 220 | #endif 221 | #ifndef __PACKED 222 | #define __PACKED @packed 223 | #endif 224 | #ifndef __PACKED_STRUCT 225 | #define __PACKED_STRUCT @packed struct 226 | #endif 227 | #ifndef __PACKED_UNION 228 | #define __PACKED_UNION @packed union 229 | #endif 230 | #ifndef __UNALIGNED_UINT32 /* deprecated */ 231 | @packed struct T_UINT32 { uint32_t v; }; 232 | #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 233 | #endif 234 | #ifndef __UNALIGNED_UINT16_WRITE 235 | __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 236 | #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) 237 | #endif 238 | #ifndef __UNALIGNED_UINT16_READ 239 | __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 240 | #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 241 | #endif 242 | #ifndef __UNALIGNED_UINT32_WRITE 243 | __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 244 | #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 245 | #endif 246 | #ifndef __UNALIGNED_UINT32_READ 247 | __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 248 | #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 249 | #endif 250 | #ifndef __ALIGNED 251 | #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored. 252 | #define __ALIGNED(x) 253 | #endif 254 | #ifndef __RESTRICT 255 | #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. 256 | #define __RESTRICT 257 | #endif 258 | 259 | 260 | #else 261 | #error Unknown compiler. 262 | #endif 263 | 264 | 265 | #endif /* __CMSIS_COMPILER_H */ 266 | 267 | -------------------------------------------------------------------------------- /usb/device/source/usb_device_dci.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The Clear BSD License 3 | * Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc. 4 | * Copyright 2016 NXP 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted (subject to the limitations in the disclaimer below) provided 9 | * that the following conditions are met: 10 | * 11 | * o Redistributions of source code must retain the above copyright notice, this list 12 | * of conditions and the following disclaimer. 13 | * 14 | * o Redistributions in binary form must reproduce the above copyright notice, this 15 | * list of conditions and the following disclaimer in the documentation and/or 16 | * other materials provided with the distribution. 17 | * 18 | * o Neither the name of the copyright holder nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef __USB_DEVICE_DCI_H__ 36 | #define __USB_DEVICE_DCI_H__ 37 | 38 | /*! 39 | * @addtogroup usb_device_controller_driver 40 | * @{ 41 | */ 42 | 43 | /******************************************************************************* 44 | * Definitions 45 | ******************************************************************************/ 46 | 47 | /*! @brief Macro to define controller handle */ 48 | #define usb_device_controller_handle usb_device_handle 49 | 50 | /*! @brief Available notify types for device notification */ 51 | typedef enum _usb_device_notification 52 | { 53 | kUSB_DeviceNotifyBusReset = 0x10U, /*!< Reset signal detected */ 54 | kUSB_DeviceNotifySuspend, /*!< Suspend signal detected */ 55 | kUSB_DeviceNotifyResume, /*!< Resume signal detected */ 56 | kUSB_DeviceNotifyLPMSleep, /*!< LPM signal detected */ 57 | kUSB_DeviceNotifyLPMResume, /*!< Resume signal detected */ 58 | kUSB_DeviceNotifyError, /*!< Errors happened in bus */ 59 | kUSB_DeviceNotifyDetach, /*!< Device disconnected from a host */ 60 | kUSB_DeviceNotifyAttach, /*!< Device connected to a host */ 61 | #if (defined(USB_DEVICE_CHARGER_DETECT_ENABLE) && (USB_DEVICE_CHARGER_DETECT_ENABLE > 0U)) 62 | kUSB_DeviceNotifyDcdTimeOut, /*!< Device charger detection timeout */ 63 | kUSB_DeviceNotifyDcdUnknownPortType, /*!< Device charger detection unknown port type */ 64 | kUSB_DeviceNotifySDPDetected, /*!< The SDP facility is detected */ 65 | kUSB_DeviceNotifyChargingPortDetected, /*!< The charging port is detected */ 66 | kUSB_DeviceNotifyChargingHostDetected, /*!< The CDP facility is detected */ 67 | kUSB_DeviceNotifyDedicatedChargerDetected, /*!< The DCP facility is detected */ 68 | #endif 69 | } usb_device_notification_t; 70 | 71 | /*! @brief Device notification message structure */ 72 | typedef struct _usb_device_callback_message_struct 73 | { 74 | uint8_t *buffer; /*!< Transferred buffer */ 75 | uint32_t length; /*!< Transferred data length */ 76 | uint8_t code; /*!< Notification code */ 77 | uint8_t isSetup; /*!< Is in a setup phase */ 78 | } usb_device_callback_message_struct_t; 79 | 80 | /*! @brief Control type for controller */ 81 | typedef enum _usb_device_control_type 82 | { 83 | kUSB_DeviceControlRun = 0U, /*!< Enable the device functionality */ 84 | kUSB_DeviceControlStop, /*!< Disable the device functionality */ 85 | kUSB_DeviceControlEndpointInit, /*!< Initialize a specified endpoint */ 86 | kUSB_DeviceControlEndpointDeinit, /*!< De-initialize a specified endpoint */ 87 | kUSB_DeviceControlEndpointStall, /*!< Stall a specified endpoint */ 88 | kUSB_DeviceControlEndpointUnstall, /*!< Unstall a specified endpoint */ 89 | kUSB_DeviceControlGetDeviceStatus, /*!< Get device status */ 90 | kUSB_DeviceControlGetEndpointStatus, /*!< Get endpoint status */ 91 | kUSB_DeviceControlSetDeviceAddress, /*!< Set device address */ 92 | kUSB_DeviceControlGetSynchFrame, /*!< Get current frame */ 93 | kUSB_DeviceControlResume, /*!< Drive controller to generate a resume signal in USB bus */ 94 | kUSB_DeviceControlSleepResume, /*!< Drive controller to generate a LPM resume signal in USB bus */ 95 | kUSB_DeviceControlSuspend, /*!< Drive controller to enetr into suspend mode */ 96 | kUSB_DeviceControlSleep, /*!< Drive controller to enetr into sleep mode */ 97 | kUSB_DeviceControlSetDefaultStatus, /*!< Set controller to default status */ 98 | kUSB_DeviceControlGetSpeed, /*!< Get current speed */ 99 | kUSB_DeviceControlGetOtgStatus, /*!< Get OTG status */ 100 | kUSB_DeviceControlSetOtgStatus, /*!< Set OTG status */ 101 | kUSB_DeviceControlSetTestMode, /*!< Drive xCHI into test mode */ 102 | kUSB_DeviceControlGetRemoteWakeUp, /*!< Get flag of LPM Remote Wake-up Enabled by USB host. */ 103 | #if (defined(USB_DEVICE_CHARGER_DETECT_ENABLE) && (USB_DEVICE_CHARGER_DETECT_ENABLE > 0U)) 104 | kUSB_DeviceControlDcdInitModule, 105 | kUSB_DeviceControlDcdDeinitModule, 106 | #endif 107 | } usb_device_control_type_t; 108 | 109 | /*! @brief USB device controller initialization function typedef */ 110 | typedef usb_status_t (*usb_device_controller_init_t)(uint8_t controllerId, 111 | usb_device_handle handle, 112 | usb_device_controller_handle *controllerHandle); 113 | 114 | /*! @brief USB device controller de-initialization function typedef */ 115 | typedef usb_status_t (*usb_device_controller_deinit_t)(usb_device_controller_handle controllerHandle); 116 | 117 | /*! @brief USB device controller send data function typedef */ 118 | typedef usb_status_t (*usb_device_controller_send_t)(usb_device_controller_handle controllerHandle, 119 | uint8_t endpointAddress, 120 | uint8_t *buffer, 121 | uint32_t length); 122 | 123 | /*! @brief USB device controller receive data function typedef */ 124 | typedef usb_status_t (*usb_device_controller_recv_t)(usb_device_controller_handle controllerHandle, 125 | uint8_t endpointAddress, 126 | uint8_t *buffer, 127 | uint32_t length); 128 | 129 | /*! @brief USB device controller cancel transfer function in a specified endpoint typedef */ 130 | typedef usb_status_t (*usb_device_controller_cancel_t)(usb_device_controller_handle controllerHandle, 131 | uint8_t endpointAddress); 132 | 133 | /*! @brief USB device controller control function typedef */ 134 | typedef usb_status_t (*usb_device_controller_control_t)(usb_device_controller_handle controllerHandle, 135 | usb_device_control_type_t command, 136 | void *param); 137 | 138 | /*! @brief USB device controller interface structure */ 139 | typedef struct _usb_device_controller_interface_struct 140 | { 141 | usb_device_controller_init_t deviceInit; /*!< Controller initialization */ 142 | usb_device_controller_deinit_t deviceDeinit; /*!< Controller de-initialization */ 143 | usb_device_controller_send_t deviceSend; /*!< Controller send data */ 144 | usb_device_controller_recv_t deviceRecv; /*!< Controller receive data */ 145 | usb_device_controller_cancel_t deviceCancel; /*!< Controller cancel transfer */ 146 | usb_device_controller_control_t deviceControl; /*!< Controller control */ 147 | } usb_device_controller_interface_struct_t; 148 | 149 | /*! @brief USB device status structure */ 150 | typedef struct _usb_device_struct 151 | { 152 | #if ((defined(USB_DEVICE_CONFIG_REMOTE_WAKEUP)) && (USB_DEVICE_CONFIG_REMOTE_WAKEUP > 0U)) 153 | volatile uint64_t hwTick; /*!< Current hw tick(ms)*/ 154 | #endif 155 | usb_device_controller_handle controllerHandle; /*!< Controller handle */ 156 | const usb_device_controller_interface_struct_t *controllerInterface; /*!< Controller interface handle */ 157 | #if USB_DEVICE_CONFIG_USE_TASK 158 | usb_osa_msgq_handle notificationQueue; /*!< Message queue */ 159 | #endif 160 | usb_device_callback_t deviceCallback; /*!< Device callback function pointer */ 161 | usb_device_endpoint_callback_struct_t 162 | epCallback[USB_DEVICE_CONFIG_ENDPOINTS << 1U]; /*!< Endpoint callback function structure */ 163 | uint8_t deviceAddress; /*!< Current device address */ 164 | uint8_t controllerId; /*!< Controller ID */ 165 | uint8_t state; /*!< Current device state */ 166 | #if ((defined(USB_DEVICE_CONFIG_REMOTE_WAKEUP)) && (USB_DEVICE_CONFIG_REMOTE_WAKEUP > 0U)) 167 | uint8_t remotewakeup; /*!< Remote wakeup is enabled or not */ 168 | #endif 169 | uint8_t isResetting; /*!< Is doing device reset or not */ 170 | #if (defined(USB_DEVICE_CONFIG_USE_TASK) && (USB_DEVICE_CONFIG_USE_TASK > 0U)) 171 | uint8_t epCallbackDirectly; /*!< Whether call ep callback directly when the task is enabled */ 172 | #endif 173 | } usb_device_struct_t; 174 | 175 | /******************************************************************************* 176 | * API 177 | ******************************************************************************/ 178 | 179 | /*! @}*/ 180 | 181 | #endif /* __USB_DEVICE_DCI_H__ */ 182 | -------------------------------------------------------------------------------- /drivers/fsl_iocon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The Clear BSD License 3 | * Copyright (c) 2016, Freescale Semiconductor, Inc. 4 | * Copyright 2016-2017 NXP 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted (subject to the limitations in the disclaimer below) provided 9 | * that the following conditions are met: 10 | * 11 | * o Redistributions of source code must retain the above copyright notice, this list 12 | * of conditions and the following disclaimer. 13 | * 14 | * o Redistributions in binary form must reproduce the above copyright notice, this 15 | * list of conditions and the following disclaimer in the documentation and/or 16 | * other materials provided with the distribution. 17 | * 18 | * o Neither the name of the copyright holder nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef _FSL_IOCON_H_ 36 | #define _FSL_IOCON_H_ 37 | 38 | #include "fsl_common.h" 39 | 40 | /*! 41 | * @addtogroup lpc_iocon 42 | * @{ 43 | */ 44 | 45 | /*! @file */ 46 | 47 | /******************************************************************************* 48 | * Definitions 49 | ******************************************************************************/ 50 | 51 | /* Component ID definition, used by tools. */ 52 | #ifndef FSL_COMPONENT_ID 53 | #define FSL_COMPONENT_ID "platform.drivers.lpc_iocon" 54 | #endif 55 | 56 | 57 | /*! @name Driver version */ 58 | /*@{*/ 59 | /*! @brief IOCON driver version 2.0.0. */ 60 | #define FSL_IOCON_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) 61 | /*@}*/ 62 | 63 | /** 64 | * @brief Array of IOCON pin definitions passed to IOCON_SetPinMuxing() must be in this format 65 | */ 66 | typedef struct _iocon_group 67 | { 68 | uint32_t port : 8; /* Pin port */ 69 | uint32_t pin : 8; /* Pin number */ 70 | uint32_t ionumber : 8; /* IO number */ 71 | uint32_t modefunc : 16; /* Function and mode */ 72 | } iocon_group_t; 73 | 74 | /** 75 | * @brief IOCON function and mode selection definitions 76 | * @note See the User Manual for specific modes and functions supported by the various pins. 77 | */ 78 | #if defined(FSL_FEATURE_IOCON_FUNC_FIELD_WIDTH) && (FSL_FEATURE_IOCON_FUNC_FIELD_WIDTH == 4) 79 | #define IOCON_FUNC0 0x0 /*!< Selects pin function 0 */ 80 | #define IOCON_FUNC1 0x1 /*!< Selects pin function 1 */ 81 | #define IOCON_FUNC2 0x2 /*!< Selects pin function 2 */ 82 | #define IOCON_FUNC3 0x3 /*!< Selects pin function 3 */ 83 | #define IOCON_FUNC4 0x4 /*!< Selects pin function 4 */ 84 | #define IOCON_FUNC5 0x5 /*!< Selects pin function 5 */ 85 | #define IOCON_FUNC6 0x6 /*!< Selects pin function 6 */ 86 | #define IOCON_FUNC7 0x7 /*!< Selects pin function 7 */ 87 | #define IOCON_FUNC8 0x8 /*!< Selects pin function 8 */ 88 | #define IOCON_FUNC9 0x9 /*!< Selects pin function 9 */ 89 | #define IOCON_FUNC10 0xA /*!< Selects pin function 10 */ 90 | #define IOCON_FUNC11 0xB /*!< Selects pin function 11 */ 91 | #define IOCON_FUNC12 0xC /*!< Selects pin function 12 */ 92 | #define IOCON_FUNC13 0xD /*!< Selects pin function 13 */ 93 | #define IOCON_FUNC14 0xE /*!< Selects pin function 14 */ 94 | #define IOCON_FUNC15 0xF /*!< Selects pin function 15 */ 95 | #define IOCON_MODE_INACT (0x0 << 4) /*!< No addition pin function */ 96 | #define IOCON_MODE_PULLDOWN (0x1 << 4) /*!< Selects pull-down function */ 97 | #define IOCON_MODE_PULLUP (0x2 << 4) /*!< Selects pull-up function */ 98 | #define IOCON_MODE_REPEATER (0x3 << 4) /*!< Selects pin repeater function */ 99 | #define IOCON_HYS_EN (0x1 << 6) /*!< Enables hysteresis */ 100 | #define IOCON_GPIO_MODE (0x1 << 6) /*!< GPIO Mode */ 101 | #define IOCON_I2C_SLEW (0x0 << 6) /*!< I2C Slew Rate Control */ 102 | #define IOCON_INV_EN (0x1 << 7) /*!< Enables invert function on input */ 103 | #define IOCON_ANALOG_EN (0x0 << 8) /*!< Enables analog function by setting 0 to bit 7 */ 104 | #define IOCON_DIGITAL_EN (0x1 << 8) /*!< Enables digital function by setting 1 to bit 7(default) */ 105 | #define IOCON_STDI2C_EN (0x1 << 9) /*!< I2C standard mode/fast-mode */ 106 | #define IOCON_FASTI2C_EN (0x3 << 9) /*!< I2C Fast-mode Plus and high-speed slave */ 107 | #define IOCON_INPFILT_OFF (0x1 << 9) /*!< Input filter Off for GPIO pins */ 108 | #define IOCON_INPFILT_ON (0x0 << 9) /*!< Input filter On for GPIO pins */ 109 | #define IOCON_OPENDRAIN_EN (0x1 << 11) /*!< Enables open-drain function */ 110 | #define IOCON_S_MODE_0CLK (0x0 << 12) /*!< Bypass input filter */ 111 | #define IOCON_S_MODE_1CLK (0x1 << 12) /*!< Input pulses shorter than 1 filter clock are rejected */ 112 | #define IOCON_S_MODE_2CLK (0x2 << 12) /*!< Input pulses shorter than 2 filter clock2 are rejected */ 113 | #define IOCON_S_MODE_3CLK (0x3 << 12) /*!< Input pulses shorter than 3 filter clock2 are rejected */ 114 | #define IOCON_S_MODE(clks) ((clks) << 12) /*!< Select clocks for digital input filter mode */ 115 | #define IOCON_CLKDIV(div) \ 116 | ((div) << 14) /*!< Select peripheral clock divider for input filter sampling clock, 2^n, n=0-6 */ 117 | #else 118 | #define IOCON_FUNC0 0x0 /*!< Selects pin function 0 */ 119 | #define IOCON_FUNC1 0x1 /*!< Selects pin function 1 */ 120 | #define IOCON_FUNC2 0x2 /*!< Selects pin function 2 */ 121 | #define IOCON_FUNC3 0x3 /*!< Selects pin function 3 */ 122 | #define IOCON_FUNC4 0x4 /*!< Selects pin function 4 */ 123 | #define IOCON_FUNC5 0x5 /*!< Selects pin function 5 */ 124 | #define IOCON_FUNC6 0x6 /*!< Selects pin function 6 */ 125 | #define IOCON_FUNC7 0x7 /*!< Selects pin function 7 */ 126 | #define IOCON_MODE_INACT (0x0 << 3) /*!< No addition pin function */ 127 | #define IOCON_MODE_PULLDOWN (0x1 << 3) /*!< Selects pull-down function */ 128 | #define IOCON_MODE_PULLUP (0x2 << 3) /*!< Selects pull-up function */ 129 | #define IOCON_MODE_REPEATER (0x3 << 3) /*!< Selects pin repeater function */ 130 | #define IOCON_HYS_EN (0x1 << 5) /*!< Enables hysteresis */ 131 | #define IOCON_GPIO_MODE (0x1 << 5) /*!< GPIO Mode */ 132 | #define IOCON_I2C_SLEW (0x0 << 5) /*!< I2C Slew Rate Control */ 133 | #define IOCON_INV_EN (0x1 << 6) /*!< Enables invert function on input */ 134 | #define IOCON_ANALOG_EN (0x0 << 7) /*!< Enables analog function by setting 0 to bit 7 */ 135 | #define IOCON_DIGITAL_EN (0x1 << 7) /*!< Enables digital function by setting 1 to bit 7(default) */ 136 | #define IOCON_STDI2C_EN (0x1 << 8) /*!< I2C standard mode/fast-mode */ 137 | #define IOCON_FASTI2C_EN (0x3 << 8) /*!< I2C Fast-mode Plus and high-speed slave */ 138 | #define IOCON_INPFILT_OFF (0x1 << 8) /*!< Input filter Off for GPIO pins */ 139 | #define IOCON_INPFILT_ON (0x0 << 8) /*!< Input filter On for GPIO pins */ 140 | #define IOCON_OPENDRAIN_EN (0x1 << 10) /*!< Enables open-drain function */ 141 | #define IOCON_S_MODE_0CLK (0x0 << 11) /*!< Bypass input filter */ 142 | #define IOCON_S_MODE_1CLK (0x1 << 11) /*!< Input pulses shorter than 1 filter clock are rejected */ 143 | #define IOCON_S_MODE_2CLK (0x2 << 11) /*!< Input pulses shorter than 2 filter clock2 are rejected */ 144 | #define IOCON_S_MODE_3CLK (0x3 << 11) /*!< Input pulses shorter than 3 filter clock2 are rejected */ 145 | #define IOCON_S_MODE(clks) ((clks) << 11) /*!< Select clocks for digital input filter mode */ 146 | #define IOCON_CLKDIV(div) \ 147 | ((div) << 13) /*!< Select peripheral clock divider for input filter sampling clock, 2^n, n=0-6 */ 148 | #endif 149 | #if defined(__cplusplus) 150 | extern "C" { 151 | #endif 152 | 153 | #if (defined(FSL_FEATURE_IOCON_ONE_DIMENSION) && (FSL_FEATURE_IOCON_ONE_DIMENSION == 1)) 154 | /** 155 | * @brief Sets I/O Control pin mux 156 | * @param base : The base of IOCON peripheral on the chip 157 | * @param ionumber : GPIO number to mux 158 | * @param modefunc : OR'ed values of type IOCON_* 159 | * @return Nothing 160 | */ 161 | __STATIC_INLINE void IOCON_PinMuxSet(IOCON_Type *base, uint8_t ionumber, uint32_t modefunc) 162 | { 163 | base->PIO[ionumber] = modefunc; 164 | } 165 | #else 166 | /** 167 | * @brief Sets I/O Control pin mux 168 | * @param base : The base of IOCON peripheral on the chip 169 | * @param port : GPIO port to mux 170 | * @param pin : GPIO pin to mux 171 | * @param modefunc : OR'ed values of type IOCON_* 172 | * @return Nothing 173 | */ 174 | __STATIC_INLINE void IOCON_PinMuxSet(IOCON_Type *base, uint8_t port, uint8_t pin, uint32_t modefunc) 175 | { 176 | base->PIO[port][pin] = modefunc; 177 | } 178 | #endif 179 | 180 | /** 181 | * @brief Set all I/O Control pin muxing 182 | * @param base : The base of IOCON peripheral on the chip 183 | * @param pinArray : Pointer to array of pin mux selections 184 | * @param arrayLength : Number of entries in pinArray 185 | * @return Nothing 186 | */ 187 | __STATIC_INLINE void IOCON_SetPinMuxing(IOCON_Type *base, const iocon_group_t *pinArray, uint32_t arrayLength) 188 | { 189 | uint32_t i; 190 | 191 | for (i = 0; i < arrayLength; i++) 192 | { 193 | #if (defined(FSL_FEATURE_IOCON_ONE_DIMENSION) && (FSL_FEATURE_IOCON_ONE_DIMENSION == 1)) 194 | IOCON_PinMuxSet(base, pinArray[i].ionumber, pinArray[i].modefunc); 195 | #else 196 | IOCON_PinMuxSet(base, pinArray[i].port, pinArray[i].pin, pinArray[i].modefunc); 197 | #endif /* FSL_FEATURE_IOCON_ONE_DIMENSION */ 198 | } 199 | } 200 | 201 | /* @} */ 202 | 203 | #if defined(__cplusplus) 204 | } 205 | #endif 206 | 207 | #endif /* _FSL_IOCON_H_ */ 208 | -------------------------------------------------------------------------------- /.settings/org.eclipse.cdt.codan.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No return\\")",implicit\=>false} 3 | org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused return value\\")"} 4 | org.eclipse.cdt.codan.checkers.nocommentinside=-Error 5 | org.eclipse.cdt.codan.checkers.nocommentinside.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Nesting comments\\")"} 6 | org.eclipse.cdt.codan.checkers.nolinecomment=-Error 7 | org.eclipse.cdt.codan.checkers.nolinecomment.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Line comments\\")"} 8 | org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No return value\\")",implicit\=>false} 9 | org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Abstract class cannot be instantiated\\")"} 10 | org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Ambiguous problem\\")"} 11 | org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Assignment in condition\\")"} 12 | org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Assignment to itself\\")"} 13 | org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No break at end of case\\")",no_break_comment\=>"no break",last_case_param\=>true,empty_case_param\=>false,enable_fallthrough_quickfix_param\=>false} 14 | org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Catching by reference is recommended\\")",unknown\=>false,exceptions\=>()} 15 | org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Circular inheritance\\")"} 16 | org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Class members should be properly initialized\\")",skip\=>true} 17 | org.eclipse.cdt.codan.internal.checkers.DecltypeAutoProblem=Error 18 | org.eclipse.cdt.codan.internal.checkers.DecltypeAutoProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid 'decltype(auto)' specifier\\")"} 19 | org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Field cannot be resolved\\")"} 20 | org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Function cannot be resolved\\")"} 21 | org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid arguments\\")"} 22 | org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid template argument\\")"} 23 | org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Label statement not found\\")"} 24 | org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Member declaration not found\\")"} 25 | org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Method cannot be resolved\\")"} 26 | org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Name convention for function\\")",pattern\=>"^[a-z]",macro\=>true,exceptions\=>()} 27 | org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Class has a virtual method and non-virtual destructor\\")"} 28 | org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid overload\\")"} 29 | org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid redeclaration\\")"} 30 | org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid redefinition\\")"} 31 | org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Return with parenthesis\\")"} 32 | org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Format String Vulnerability\\")"} 33 | org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Statement has no effect\\")",macro\=>true,exceptions\=>()} 34 | org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Suggested parenthesis around expression\\")",paramNot\=>false} 35 | org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Suspicious semicolon\\")",else\=>false,afterelse\=>false} 36 | org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Type cannot be resolved\\")"} 37 | org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused function declaration\\")",macro\=>true} 38 | org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused static function\\")",macro\=>true} 39 | org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused variable declaration in file scope\\")",macro\=>true,exceptions\=>("@(\#)","$Id")} 40 | org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Symbol is not resolved\\")"} 41 | --------------------------------------------------------------------------------