Initial commit

This commit is contained in:
Nanosonde 2020-10-13 18:15:23 +02:00
parent e0bb23cd3f
commit 7141d4e154
37 changed files with 7299 additions and 20 deletions

152
examples/knx-cc1310/Board.h Normal file
View File

@ -0,0 +1,152 @@
/*
* Copyright (c) 2015-2019, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __BOARD_H
#define __BOARD_H
#define Board_CC1310_LAUNCHXL
#ifdef __cplusplus
extern "C" {
#endif
#include <ti/drivers/Board.h>
#define Board_initGeneral() Board_init() /* deprecated */
#include "CC1310_LAUNCHXL.h"
#define Board_shutDownExtFlash() CC1310_LAUNCHXL_shutDownExtFlash()
#define Board_wakeUpExtFlash() CC1310_LAUNCHXL_wakeUpExtFlash()
/* These #defines allow us to reuse TI-RTOS across other device families */
#define Board_ADC0 CC1310_LAUNCHXL_ADC0
#define Board_ADC1 CC1310_LAUNCHXL_ADC1
#define Board_ADCBUF0 CC1310_LAUNCHXL_ADCBUF0
#define Board_ADCBUF0CHANNEL0 CC1310_LAUNCHXL_ADCBUF0CHANNEL0
#define Board_ADCBUF0CHANNEL1 CC1310_LAUNCHXL_ADCBUF0CHANNEL1
#define Board_CRYPTO0 CC1310_LAUNCHXL_CRYPTO0
#define Board_AESCCM0 CC1310_LAUNCHXL_AESCCM0
#define Board_AESGCM0 CC1310_LAUNCHXL_AESGCM0
#define Board_AESCBC0 CC1310_LAUNCHXL_AESCBC0
#define Board_AESCTR0 CC1310_LAUNCHXL_AESCTR0
#define Board_AESECB0 CC1310_LAUNCHXL_AESECB0
#define Board_AESCTRDRBG0 CC1310_LAUNCHXL_AESCTRDRBG0
#define Board_TRNG0 CC1310_LAUNCHXL_TRNG0
#define Board_DIO0 CC1310_LAUNCHXL_DIO0
#define Board_DIO1 CC1310_LAUNCHXL_DIO1
#define Board_DIO12 CC1310_LAUNCHXL_DIO12
#define Board_DIO15 CC1310_LAUNCHXL_DIO15
#define Board_DIO16_TDO CC1310_LAUNCHXL_DIO16_TDO
#define Board_DIO17_TDI CC1310_LAUNCHXL_DIO17_TDI
#define Board_DIO21 CC1310_LAUNCHXL_DIO21
#define Board_DIO22 CC1310_LAUNCHXL_DIO22
#define Board_GPIO_BUTTON0 CC1310_LAUNCHXL_GPIO_S1
#define Board_GPIO_BUTTON1 CC1310_LAUNCHXL_GPIO_S2
#define Board_GPIO_BTN1 CC1310_LAUNCHXL_GPIO_S1
#define Board_GPIO_BTN2 CC1310_LAUNCHXL_GPIO_S2
#define Board_GPIO_LED0 CC1310_LAUNCHXL_GPIO_LED_RED
#define Board_GPIO_LED1 CC1310_LAUNCHXL_GPIO_LED_GREEN
#define Board_GPIO_RLED CC1310_LAUNCHXL_GPIO_LED_RED
#define Board_GPIO_GLED CC1310_LAUNCHXL_GPIO_LED_GREEN
#define Board_GPIO_LED_ON CC1310_LAUNCHXL_GPIO_LED_ON
#define Board_GPIO_LED_OFF CC1310_LAUNCHXL_GPIO_LED_OFF
#define Board_GPIO_TMP116_EN CC1310_LAUNCHXL_GPIO_TMP116_EN
#define Board_GPTIMER0A CC1310_LAUNCHXL_GPTIMER0A
#define Board_GPTIMER0B CC1310_LAUNCHXL_GPTIMER0B
#define Board_GPTIMER1A CC1310_LAUNCHXL_GPTIMER1A
#define Board_GPTIMER1B CC1310_LAUNCHXL_GPTIMER1B
#define Board_GPTIMER2A CC1310_LAUNCHXL_GPTIMER2A
#define Board_GPTIMER2B CC1310_LAUNCHXL_GPTIMER2B
#define Board_GPTIMER3A CC1310_LAUNCHXL_GPTIMER3A
#define Board_GPTIMER3B CC1310_LAUNCHXL_GPTIMER3B
#define Board_I2C0 CC1310_LAUNCHXL_I2C0
#define Board_I2C_TMP CC1310_LAUNCHXL_I2C0
#define Board_I2S0 CC1310_LAUNCHXL_I2S0
#define Board_I2S_ADO CC1310_LAUNCHXL_I2S_ADO
#define Board_I2S_ADI CC1310_LAUNCHXL_I2S_ADI
#define Board_I2S_BCLK CC1310_LAUNCHXL_I2S_BCLK
#define Board_I2S_MCLK CC1310_LAUNCHXL_I2S_MCLK
#define Board_I2S_WCLK CC1310_LAUNCHXL_I2S_WCLK
#define Board_NVSINTERNAL CC1310_LAUNCHXL_NVSCC26XX0
#define Board_NVSEXTERNAL CC1310_LAUNCHXL_NVSSPI25X0
#define Board_PIN_BUTTON0 CC1310_LAUNCHXL_PIN_BTN1
#define Board_PIN_BUTTON1 CC1310_LAUNCHXL_PIN_BTN2
#define Board_PIN_BTN1 CC1310_LAUNCHXL_PIN_BTN1
#define Board_PIN_BTN2 CC1310_LAUNCHXL_PIN_BTN2
#define Board_PIN_LED0 CC1310_LAUNCHXL_PIN_RLED
#define Board_PIN_LED1 CC1310_LAUNCHXL_PIN_GLED
#define Board_PIN_LED2 CC1310_LAUNCHXL_PIN_RLED
#define Board_PIN_RLED CC1310_LAUNCHXL_PIN_RLED
#define Board_PIN_GLED CC1310_LAUNCHXL_PIN_GLED
#define Board_PWM0 CC1310_LAUNCHXL_PWM0
#define Board_PWM1 CC1310_LAUNCHXL_PWM1
#define Board_PWM2 CC1310_LAUNCHXL_PWM2
#define Board_PWM3 CC1310_LAUNCHXL_PWM3
#define Board_PWM4 CC1310_LAUNCHXL_PWM4
#define Board_PWM5 CC1310_LAUNCHXL_PWM5
#define Board_PWM6 CC1310_LAUNCHXL_PWM6
#define Board_PWM7 CC1310_LAUNCHXL_PWM7
#define Board_SD0 CC1310_LAUNCHXL_SDSPI0
#define Board_SPI0 CC1310_LAUNCHXL_SPI0
#define Board_SPI1 CC1310_LAUNCHXL_SPI1
#define Board_SPI_FLASH_CS CC1310_LAUNCHXL_SPI_FLASH_CS
#define Board_FLASH_CS_ON 0
#define Board_FLASH_CS_OFF 1
#define Board_SPI_MASTER CC1310_LAUNCHXL_SPI0
#define Board_SPI_SLAVE CC1310_LAUNCHXL_SPI0
#define Board_SPI_MASTER_READY CC1310_LAUNCHXL_SPI_MASTER_READY
#define Board_SPI_SLAVE_READY CC1310_LAUNCHXL_SPI_SLAVE_READY
#define Board_UART0 CC1310_LAUNCHXL_UART0
#define Board_WATCHDOG0 CC1310_LAUNCHXL_WATCHDOG0
#ifdef __cplusplus
}
#endif
#endif /* __BOARD_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,451 @@
/*
* Copyright (c) 2015-2019, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/** ============================================================================
* @file CC1310_LAUNCHXL.h
*
* @brief CC1310 LaunchPad Board Specific header file.
*
* The CC1310_LAUNCHXL header file should be included in an application as
* follows:
* @code
* #include "CC1310_LAUNCHXL.h"
* @endcode
*
* ============================================================================
*/
#ifndef __CC1310_LAUNCHXL_BOARD_H__
#define __CC1310_LAUNCHXL_BOARD_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes */
#include <ti/drivers/PIN.h>
#include <ti/devices/cc13x0/driverlib/ioc.h>
/* Externs */
extern const PIN_Config BoardGpioInitTable[];
/* Defines */
#define CC1310_LAUNCHXL
/* Mapping of pins to board signals using general board aliases
* <board signal alias> <pin mapping> <comments>
*/
/* Analog capable DIOs */
#define CC1310_LAUNCHXL_DIO23_ANALOG IOID_23
#define CC1310_LAUNCHXL_DIO24_ANALOG IOID_24
#define CC1310_LAUNCHXL_DIO25_ANALOG IOID_25
#define CC1310_LAUNCHXL_DIO26_ANALOG IOID_26
#define CC1310_LAUNCHXL_DIO27_ANALOG IOID_27
#define CC1310_LAUNCHXL_DIO28_ANALOG IOID_28
#define CC1310_LAUNCHXL_DIO29_ANALOG IOID_29
#define CC1310_LAUNCHXL_DIO30_ANALOG IOID_30
/* Digital IOs */
#define CC1310_LAUNCHXL_DIO0 IOID_0
#define CC1310_LAUNCHXL_DIO1 IOID_1
#define CC1310_LAUNCHXL_DIO12 IOID_12
#define CC1310_LAUNCHXL_DIO15 IOID_15
#define CC1310_LAUNCHXL_DIO16_TDO IOID_16
#define CC1310_LAUNCHXL_DIO17_TDI IOID_17
#define CC1310_LAUNCHXL_DIO21 IOID_21
#define CC1310_LAUNCHXL_DIO22 IOID_22
/* Discrete Inputs */
#define CC1310_LAUNCHXL_PIN_BTN1 IOID_13
#define CC1310_LAUNCHXL_PIN_BTN2 IOID_14
/* GPIO */
#define CC1310_LAUNCHXL_GPIO_LED_ON 1
#define CC1310_LAUNCHXL_GPIO_LED_OFF 0
/* I2C */
#define CC1310_LAUNCHXL_I2C0_SCL0 IOID_4
#define CC1310_LAUNCHXL_I2C0_SDA0 IOID_5
/* I2S */
#define CC1310_LAUNCHXL_I2S_ADO IOID_25
#define CC1310_LAUNCHXL_I2S_ADI IOID_26
#define CC1310_LAUNCHXL_I2S_BCLK IOID_27
#define CC1310_LAUNCHXL_I2S_MCLK PIN_UNASSIGNED
#define CC1310_LAUNCHXL_I2S_WCLK IOID_28
/* LEDs */
#define CC1310_LAUNCHXL_PIN_LED_ON 1
#define CC1310_LAUNCHXL_PIN_LED_OFF 0
#define CC1310_LAUNCHXL_PIN_RLED IOID_6
#define CC1310_LAUNCHXL_PIN_GLED IOID_7
/* PWM Outputs */
#define CC1310_LAUNCHXL_PWMPIN0 CC1310_LAUNCHXL_PIN_RLED
#define CC1310_LAUNCHXL_PWMPIN1 CC1310_LAUNCHXL_PIN_GLED
#define CC1310_LAUNCHXL_PWMPIN2 PIN_UNASSIGNED
#define CC1310_LAUNCHXL_PWMPIN3 PIN_UNASSIGNED
#define CC1310_LAUNCHXL_PWMPIN4 PIN_UNASSIGNED
#define CC1310_LAUNCHXL_PWMPIN5 PIN_UNASSIGNED
#define CC1310_LAUNCHXL_PWMPIN6 PIN_UNASSIGNED
#define CC1310_LAUNCHXL_PWMPIN7 PIN_UNASSIGNED
/* SPI */
#define CC1310_LAUNCHXL_SPI_FLASH_CS IOID_20
#define CC1310_LAUNCHXL_FLASH_CS_ON 0
#define CC1310_LAUNCHXL_FLASH_CS_OFF 1
/* SPI Board */
#define CC1310_LAUNCHXL_SPI0_MISO IOID_8 /* RF1.20 */
#define CC1310_LAUNCHXL_SPI0_MOSI IOID_9 /* RF1.18 */
#define CC1310_LAUNCHXL_SPI0_CLK IOID_10 /* RF1.16 */
#define CC1310_LAUNCHXL_SPI0_CSN IOID_11
#define CC1310_LAUNCHXL_SPI1_MISO PIN_UNASSIGNED
#define CC1310_LAUNCHXL_SPI1_MOSI PIN_UNASSIGNED
#define CC1310_LAUNCHXL_SPI1_CLK PIN_UNASSIGNED
#define CC1310_LAUNCHXL_SPI1_CSN PIN_UNASSIGNED
/* UART Board */
#define CC1310_LAUNCHXL_UART_RX IOID_2 /* RXD */
#define CC1310_LAUNCHXL_UART_TX IOID_3 /* TXD */
#define CC1310_LAUNCHXL_UART_CTS IOID_19 /* CTS */
#define CC1310_LAUNCHXL_UART_RTS IOID_18 /* RTS */
/*!
* @brief Initialize the general board specific settings
*
* This function initializes the general board specific settings.
*/
void CC1310_LAUNCHXL_initGeneral(void);
/*!
* @brief Turn off the external flash on LaunchPads
*
*/
void CC1310_LAUNCHXL_shutDownExtFlash(void);
/*!
* @brief Wake up the external flash present on the board files
*
* This function toggles the chip select for the amount of time needed
* to wake the chip up.
*/
void CC1310_LAUNCHXL_wakeUpExtFlash(void);
/*!
* @def CC1310_LAUNCHXL_ADCBufName
* @brief Enum of ADCBufs
*/
typedef enum CC1310_LAUNCHXL_ADCBufName {
CC1310_LAUNCHXL_ADCBUF0 = 0,
CC1310_LAUNCHXL_ADCBUFCOUNT
} CC1310_LAUNCHXL_ADCBufName;
/*!
* @def CC1310_LAUNCHXL_ADCBuf0SourceName
* @brief Enum of ADCBuf channels
*/
typedef enum CC1310_LAUNCHXL_ADCBuf0ChannelName {
CC1310_LAUNCHXL_ADCBUF0CHANNEL0 = 0,
CC1310_LAUNCHXL_ADCBUF0CHANNEL1,
CC1310_LAUNCHXL_ADCBUF0CHANNEL2,
CC1310_LAUNCHXL_ADCBUF0CHANNEL3,
CC1310_LAUNCHXL_ADCBUF0CHANNEL4,
CC1310_LAUNCHXL_ADCBUF0CHANNEL5,
CC1310_LAUNCHXL_ADCBUF0CHANNEL6,
CC1310_LAUNCHXL_ADCBUF0CHANNEL7,
CC1310_LAUNCHXL_ADCBUF0CHANNELVDDS,
CC1310_LAUNCHXL_ADCBUF0CHANNELDCOUPL,
CC1310_LAUNCHXL_ADCBUF0CHANNELVSS,
CC1310_LAUNCHXL_ADCBUF0CHANNELCOUNT
} CC1310_LAUNCHXL_ADCBuf0ChannelName;
/*!
* @def CC1310_LAUNCHXL_ADCName
* @brief Enum of ADCs
*/
typedef enum CC1310_LAUNCHXL_ADCName {
CC1310_LAUNCHXL_ADC0 = 0,
CC1310_LAUNCHXL_ADC1,
CC1310_LAUNCHXL_ADC2,
CC1310_LAUNCHXL_ADC3,
CC1310_LAUNCHXL_ADC4,
CC1310_LAUNCHXL_ADC5,
CC1310_LAUNCHXL_ADC6,
CC1310_LAUNCHXL_ADC7,
CC1310_LAUNCHXL_ADCDCOUPL,
CC1310_LAUNCHXL_ADCVSS,
CC1310_LAUNCHXL_ADCVDDS,
CC1310_LAUNCHXL_ADCCOUNT
} CC1310_LAUNCHXL_ADCName;
/*!
* @def CC1310_LAUNCHXL_CryptoName
* @brief Enum of Crypto names
*/
typedef enum CC1310_LAUNCHXL_CryptoName {
CC1310_LAUNCHXL_CRYPTO0 = 0,
CC1310_LAUNCHXL_CRYPTOCOUNT
} CC1310_LAUNCHXL_CryptoName;
/*!
* @def CC1310_LAUNCHXL_AESCCMName
* @brief Enum of AESCCM names
*/
typedef enum CC1310_LAUNCHXL_AESCCMName {
CC1310_LAUNCHXL_AESCCM0 = 0,
CC1310_LAUNCHXL_AESCCMCOUNT
} CC1310_LAUNCHXL_AESCCMName;
/*!
* @def CC1310_LAUNCHXL_AESGCMName
* @brief Enum of AESGCM names
*/
typedef enum CC1310_LAUNCHXL_AESGCMName {
CC1310_LAUNCHXL_AESGCM0 = 0,
CC1310_LAUNCHXL_AESGCMCOUNT
} CC1310_LAUNCHXL_AESGCMName;
/*!
* @def CC1310_LAUNCHXL_AESCBCName
* @brief Enum of AESCBC names
*/
typedef enum CC1310_LAUNCHXL_AESCBCName {
CC1310_LAUNCHXL_AESCBC0 = 0,
CC1310_LAUNCHXL_AESCBCCOUNT
} CC1310_LAUNCHXL_AESCBCName;
/*!
* @def CC1310_LAUNCHXL_AESCTRName
* @brief Enum of AESCTR names
*/
typedef enum CC1310_LAUNCHXL_AESCTRName {
CC1310_LAUNCHXL_AESCTR0 = 0,
CC1310_LAUNCHXL_AESCTRCOUNT
} CC1310_LAUNCHXL_AESCTRName;
/*!
* @def CC1310_LAUNCHXL_AESECBName
* @brief Enum of AESECB names
*/
typedef enum CC1310_LAUNCHXL_AESECBName {
CC1310_LAUNCHXL_AESECB0 = 0,
CC1310_LAUNCHXL_AESECBCOUNT
} CC1310_LAUNCHXL_AESECBName;
/*!
* @def CC1310_LAUNCHXL_AESCTRDRBGName
* @brief Enum of AESCTRDRBG names
*/
typedef enum CC1310_LAUNCHXL_AESCTRDRBGName {
CC1310_LAUNCHXL_AESCTRDRBG0 = 0,
CC1310_LAUNCHXL_AESCTRDRBGCOUNT
} CC1310_LAUNCHXL_AESCTRDRBGName;
/*!
* @def CC1310_LAUNCHXL_TRNGName
* @brief Enum of TRNG names
*/
typedef enum CC1310_LAUNCHXL_TRNGName {
CC1310_LAUNCHXL_TRNG0 = 0,
CC1310_LAUNCHXL_TRNGCOUNT
} CC1310_LAUNCHXL_TRNGName;
/*!
* @def CC1310_LAUNCHXL_GPIOName
* @brief Enum of GPIO names
*/
typedef enum CC1310_LAUNCHXL_GPIOName {
CC1310_LAUNCHXL_GPIO_S1 = 0,
CC1310_LAUNCHXL_GPIO_S2,
CC1310_LAUNCHXL_SPI_MASTER_READY,
CC1310_LAUNCHXL_SPI_SLAVE_READY,
CC1310_LAUNCHXL_GPIO_LED_GREEN,
CC1310_LAUNCHXL_GPIO_LED_RED,
CC1310_LAUNCHXL_GPIO_TMP116_EN,
CC1310_LAUNCHXL_GPIO_SPI_FLASH_CS,
CC1310_LAUNCHXL_SDSPI_CS,
CC1310_LAUNCHXL_GPIO_LCD_CS,
CC1310_LAUNCHXL_GPIO_LCD_POWER,
CC1310_LAUNCHXL_GPIO_LCD_ENABLE,
CC1310_LAUNCHXL_GPIOCOUNT
} CC1310_LAUNCHXL_GPIOName;
/*!
* @def CC1310_LAUNCHXL_GPTimerName
* @brief Enum of GPTimer parts
*/
typedef enum CC1310_LAUNCHXL_GPTimerName {
CC1310_LAUNCHXL_GPTIMER0A = 0,
CC1310_LAUNCHXL_GPTIMER0B,
CC1310_LAUNCHXL_GPTIMER1A,
CC1310_LAUNCHXL_GPTIMER1B,
CC1310_LAUNCHXL_GPTIMER2A,
CC1310_LAUNCHXL_GPTIMER2B,
CC1310_LAUNCHXL_GPTIMER3A,
CC1310_LAUNCHXL_GPTIMER3B,
CC1310_LAUNCHXL_GPTIMERPARTSCOUNT
} CC1310_LAUNCHXL_GPTimerName;
/*!
* @def CC1310_LAUNCHXL_GPTimers
* @brief Enum of GPTimers
*/
typedef enum CC1310_LAUNCHXL_GPTimers {
CC1310_LAUNCHXL_GPTIMER0 = 0,
CC1310_LAUNCHXL_GPTIMER1,
CC1310_LAUNCHXL_GPTIMER2,
CC1310_LAUNCHXL_GPTIMER3,
CC1310_LAUNCHXL_GPTIMERCOUNT
} CC1310_LAUNCHXL_GPTimers;
/*!
* @def CC1310_LAUNCHXL_I2CName
* @brief Enum of I2C names
*/
typedef enum CC1310_LAUNCHXL_I2CName {
CC1310_LAUNCHXL_I2C0 = 0,
CC1310_LAUNCHXL_I2CCOUNT
} CC1310_LAUNCHXL_I2CName;
/*!
* @def CC1310_LAUNCHXL_I2SName
* @brief Enum of I2S names
*/
typedef enum CC1310_LAUNCHXL_I2SName {
CC1310_LAUNCHXL_I2S0 = 0,
CC1310_LAUNCHXL_I2SCOUNT
} CC1310_LAUNCHXL_I2SName;
/*!
* @def CC1310_LAUNCHXL_NVSName
* @brief Enum of NVS names
*/
typedef enum CC1310_LAUNCHXL_NVSName {
#ifndef Board_EXCLUDE_NVS_INTERNAL_FLASH
CC1310_LAUNCHXL_NVSCC26XX0 = 0,
#endif
#ifndef Board_EXCLUDE_NVS_EXTERNAL_FLASH
CC1310_LAUNCHXL_NVSSPI25X0,
#endif
CC1310_LAUNCHXL_NVSCOUNT
} CC1310_LAUNCHXL_NVSName;
/*!
* @def CC1310_LAUNCHXL_PWM
* @brief Enum of PWM outputs
*/
typedef enum CC1310_LAUNCHXL_PWMName {
CC1310_LAUNCHXL_PWM0 = 0,
CC1310_LAUNCHXL_PWM1,
CC1310_LAUNCHXL_PWM2,
CC1310_LAUNCHXL_PWM3,
CC1310_LAUNCHXL_PWM4,
CC1310_LAUNCHXL_PWM5,
CC1310_LAUNCHXL_PWM6,
CC1310_LAUNCHXL_PWM7,
CC1310_LAUNCHXL_PWMCOUNT
} CC1310_LAUNCHXL_PWMName;
/*!
* @def CC1310_LAUNCHXL_SDName
* @brief Enum of SD names
*/
typedef enum CC1310_LAUNCHXL_SDName {
CC1310_LAUNCHXL_SDSPI0 = 0,
CC1310_LAUNCHXL_SDCOUNT
} CC1310_LAUNCHXL_SDName;
/*!
* @def CC1310_LAUNCHXL_SPIName
* @brief Enum of SPI names
*/
typedef enum CC1310_LAUNCHXL_SPIName {
CC1310_LAUNCHXL_SPI0 = 0,
CC1310_LAUNCHXL_SPI1,
CC1310_LAUNCHXL_SPICOUNT
} CC1310_LAUNCHXL_SPIName;
/*!
* @def CC1310_LAUNCHXL_UARTName
* @brief Enum of UARTs
*/
typedef enum CC1310_LAUNCHXL_UARTName {
CC1310_LAUNCHXL_UART0 = 0,
CC1310_LAUNCHXL_UARTCOUNT
} CC1310_LAUNCHXL_UARTName;
/*!
* @def CC1310_LAUNCHXL_UDMAName
* @brief Enum of DMA buffers
*/
typedef enum CC1310_LAUNCHXL_UDMAName {
CC1310_LAUNCHXL_UDMA0 = 0,
CC1310_LAUNCHXL_UDMACOUNT
} CC1310_LAUNCHXL_UDMAName;
/*!
* @def CC1310_LAUNCHXL_WatchdogName
* @brief Enum of Watchdogs
*/
typedef enum CC1310_LAUNCHXL_WatchdogName {
CC1310_LAUNCHXL_WATCHDOG0 = 0,
CC1310_LAUNCHXL_WATCHDOGCOUNT
} CC1310_LAUNCHXL_WatchdogName;
#ifdef __cplusplus
}
#endif
#endif /* __CC1310_LAUNCHXL_BOARD_H__ */

View File

@ -0,0 +1,203 @@
/*
* Copyright (c) 2017-2018, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* ======== CC1310_LAUNCHXL_NoRTOS.lds ========
* Default Linker script for the Texas Instruments CC1310
*/
STACKSIZE = 2048;
HEAPSIZE = 4096;
MEMORY
{
FLASH (RX) : ORIGIN = 0x00000000, LENGTH = 0x0001ffa8
/*
* Customer Configuration Area and Bootloader Backdoor configuration in
* flash, 40 bytes
*/
FLASH_CCFG (RX) : ORIGIN = 0x0001ffa8, LENGTH = 0x00000058
SRAM (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00005000
}
REGION_ALIAS("REGION_TEXT", FLASH);
REGION_ALIAS("REGION_BSS", SRAM);
REGION_ALIAS("REGION_DATA", SRAM);
REGION_ALIAS("REGION_STACK", SRAM);
REGION_ALIAS("REGION_HEAP", SRAM);
REGION_ALIAS("REGION_ARM_EXIDX", FLASH);
REGION_ALIAS("REGION_ARM_EXTAB", FLASH);
SECTIONS {
PROVIDE (_resetVecs_base_address =
DEFINED(_resetVecs_base_address) ? _resetVecs_base_address : 0x0);
.resetVecs (_resetVecs_base_address) : AT (_resetVecs_base_address) {
KEEP (*(.resetVecs))
} > REGION_TEXT
.ramVecs (NOLOAD) : ALIGN(1024){
KEEP (*(.ramVecs))
} > REGION_DATA
/*
* UDMACC26XX_CONFIG_BASE below must match UDMACC26XX_CONFIG_BASE defined
* by ti/drivers/dma/UDMACC26XX.h
* The user is allowed to change UDMACC26XX_CONFIG_BASE to move it away from
* the default address 0x2000_0400, but remember it must be 1024 bytes aligned.
*/
UDMACC26XX_CONFIG_BASE = 0x20000400;
/*
* Define absolute addresses for the DMA channels.
* DMA channels must always be allocated at a fixed offset from the DMA base address.
* --------- DO NOT MODIFY -----------
*/
DMA_SPI0_RX_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x30);
DMA_SPI0_TX_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x40);
DMA_ADC_PRI_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x70);
DMA_GPT0A_PRI_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x90);
DMA_SPI1_RX_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x100);
DMA_SPI1_TX_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x110);
DMA_ADC_ALT_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x270);
DMA_GPT0A_ALT_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x290);
/*
* Allocate SPI0, SPI1, ADC, and GPTimer0 DMA descriptors at absolute addresses.
* --------- DO NOT MODIFY -----------
*/
UDMACC26XX_dmaSpi0RxControlTableEntry_is_placed = 0;
.dmaSpi0RxControlTableEntry DMA_SPI0_RX_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_SPI0_RX_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaSpi0RxControlTableEntry)} > REGION_DATA
UDMACC26XX_dmaSpi0TxControlTableEntry_is_placed = 0;
.dmaSpi0TxControlTableEntry DMA_SPI0_TX_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_SPI0_TX_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaSpi0TxControlTableEntry)} > REGION_DATA
UDMACC26XX_dmaADCPriControlTableEntry_is_placed = 0;
.dmaADCPriControlTableEntry DMA_ADC_PRI_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_ADC_PRI_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaADCPriControlTableEntry)} > REGION_DATA
UDMACC26XX_dmaGPT0APriControlTableEntry_is_placed = 0;
.dmaGPT0APriControlTableEntry DMA_GPT0A_PRI_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_GPT0A_PRI_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaGPT0APriControlTableEntry)} > REGION_DATA
UDMACC26XX_dmaSpi1RxControlTableEntry_is_placed = 0;
.dmaSpi1RxControlTableEntry DMA_SPI1_RX_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_SPI1_RX_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaSpi1RxControlTableEntry)} > REGION_DATA
UDMACC26XX_dmaSpi1TxControlTableEntry_is_placed = 0;
.dmaSpi1TxControlTableEntry DMA_SPI1_TX_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_SPI1_TX_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaSpi1TxControlTableEntry)} > REGION_DATA
UDMACC26XX_dmaADCAltControlTableEntry_is_placed = 0;
.dmaADCAltControlTableEntry DMA_ADC_ALT_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_ADC_ALT_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaADCAltControlTableEntry)} > REGION_DATA
UDMACC26XX_dmaGPT0AAltControlTableEntry_is_placed = 0;
.dmaGPT0AAltControlTableEntry DMA_GPT0A_ALT_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_GPT0A_ALT_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaGPT0AAltControlTableEntry)} > REGION_DATA
.text : {
CREATE_OBJECT_SYMBOLS
*(.text)
*(.text.*)
. = ALIGN(0x4);
KEEP (*(.ctors))
. = ALIGN(0x4);
KEEP (*(.dtors))
. = ALIGN(0x4);
__init_array_start = .;
KEEP (*(.init_array*))
__init_array_end = .;
*(.init)
*(.fini*)
} > REGION_TEXT AT> REGION_TEXT
PROVIDE (__etext = .);
PROVIDE (_etext = .);
PROVIDE (etext = .);
.rodata : {
*(.rodata)
*(.rodata.*)
} > REGION_TEXT AT> REGION_TEXT
.data : ALIGN(4) {
__data_load__ = LOADADDR (.data);
__data_start__ = .;
*(.data)
*(.data.*)
. = ALIGN (4);
__data_end__ = .;
} > REGION_DATA AT> REGION_TEXT
.ARM.exidx : {
__exidx_start = .;
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
__exidx_end = .;
} > REGION_ARM_EXIDX AT> REGION_ARM_EXIDX
.ARM.extab : {
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > REGION_ARM_EXTAB AT> REGION_ARM_EXTAB
.nvs (NOLOAD) : ALIGN(0x1000) {
*(.nvs)
} > REGION_TEXT
.ccfg : {
KEEP (*(.ccfg))
} > FLASH_CCFG AT> FLASH_CCFG
.bss : {
__bss_start__ = .;
*(.shbss)
*(.bss)
*(.bss.*)
*(COMMON)
. = ALIGN (4);
__bss_end__ = .;
} > REGION_BSS AT> REGION_BSS
.heap : {
__heap_start__ = .;
end = __heap_start__;
_end = end;
__end = end;
. = . + HEAPSIZE;
KEEP(*(.heap))
__heap_end__ = .;
__HeapLimit = __heap_end__;
} > REGION_HEAP AT> REGION_HEAP
.stack (NOLOAD) : ALIGN(0x8) {
_stack = .;
__stack = .;
KEEP(*(.stack))
. += STACKSIZE;
_stack_end = .;
__stack_end = .;
} > REGION_STACK AT> REGION_STACK
}

View File

@ -0,0 +1,157 @@
/*
* Copyright (c) 2018-2019, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* ======== CC1310_LAUNCHXL_fxns.c ========
* This file contains the board-specific initialization functions.
*/
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <ti/devices/cc13x0/driverlib/ioc.h>
#include <ti/devices/cc13x0/driverlib/cpu.h>
#include <ti/drivers/pin/PINCC26XX.h>
#include <ti/drivers/Board.h>
/*
* ======== CC1310_LAUNCHXL_sendExtFlashByte ========
*/
void CC1310_LAUNCHXL_sendExtFlashByte(PIN_Handle pinHandle, uint8_t byte)
{
uint8_t i;
/* SPI Flash CS */
PIN_setOutputValue(pinHandle, IOID_20, 0);
for (i = 0; i < 8; i++) {
PIN_setOutputValue(pinHandle, IOID_10, 0); /* SPI Flash CLK */
/* SPI Flash MOSI */
PIN_setOutputValue(pinHandle, IOID_9, (byte >> (7 - i)) & 0x01);
PIN_setOutputValue(pinHandle, IOID_10, 1); /* SPI Flash CLK */
/*
* Waste a few cycles to keep the CLK high for at
* least 45% of the period.
* 3 cycles per loop: 8 loops @ 48 Mhz = 0.5 us.
*/
CPUdelay(8);
}
PIN_setOutputValue(pinHandle, IOID_10, 0); /* CLK */
PIN_setOutputValue(pinHandle, IOID_20, 1); /* CS */
/*
* Keep CS high at least 40 us
* 3 cycles per loop: 700 loops @ 48 Mhz ~= 44 us
*/
CPUdelay(700);
}
/*
* ======== CC1310_LAUNCHXL_wakeUpExtFlash ========
*/
void CC1310_LAUNCHXL_wakeUpExtFlash(void)
{
PIN_Config extFlashPinTable[] = {
/* SPI Flash CS */
IOID_20 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL |
PIN_INPUT_DIS | PIN_DRVSTR_MED,
PIN_TERMINATE
};
PIN_State extFlashPinState;
PIN_Handle extFlashPinHandle = PIN_open(&extFlashPinState, extFlashPinTable);
/*
* To wake up we need to toggle the chip select at
* least 20 ns and ten wait at least 35 us.
*/
/* Toggle chip select for ~20ns to wake ext. flash */
PIN_setOutputValue(extFlashPinHandle, IOID_20, 0);
/* 3 cycles per loop: 1 loop @ 48 Mhz ~= 62 ns */
CPUdelay(1);
PIN_setOutputValue(extFlashPinHandle, IOID_20, 1);
/* 3 cycles per loop: 560 loops @ 48 Mhz ~= 35 us */
CPUdelay(560);
PIN_close(extFlashPinHandle);
}
/*
* ======== CC1310_LAUNCHXL_shutDownExtFlash ========
*/
void CC1310_LAUNCHXL_shutDownExtFlash(void)
{
/*
* To be sure we are putting the flash into sleep and not waking it,
* we first have to make a wake up call
*/
CC1310_LAUNCHXL_wakeUpExtFlash();
PIN_Config extFlashPinTable[] = {
/* SPI Flash CS*/
IOID_20 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL |
PIN_INPUT_DIS | PIN_DRVSTR_MED,
/* SPI Flash CLK */
IOID_10 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL |
PIN_INPUT_DIS | PIN_DRVSTR_MED,
/* SPI Flash MOSI */
IOID_9 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL |
PIN_INPUT_DIS | PIN_DRVSTR_MED,
/* SPI Flash MISO */
IOID_8 | PIN_INPUT_EN | PIN_PULLDOWN,
PIN_TERMINATE
};
PIN_State extFlashPinState;
PIN_Handle extFlashPinHandle = PIN_open(&extFlashPinState, extFlashPinTable);
uint8_t extFlashShutdown = 0xB9;
CC1310_LAUNCHXL_sendExtFlashByte(extFlashPinHandle, extFlashShutdown);
PIN_close(extFlashPinHandle);
}
/*
* ======== Board_initHook ========
* Called by Board_init() to perform board-specific initialization.
*/
void Board_initHook()
{
CC1310_LAUNCHXL_shutDownExtFlash();
}

View File

@ -0,0 +1,57 @@
##
## Uatecho Example
##
project(knx-cc1310 C CXX ASM)
cmake_minimum_required(VERSION 3.6)
message("CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}")
# Configure Toolchain for CC13xx
set(LINKER_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/CC1310_LAUNCHXL_NoRTOS.lds")
include(cc13xx)
# Find dependencies
find_package(SimpleLinkCC13X0SDK_nortos REQUIRED)
find_package(Xdctools REQUIRED)
#
# Target
#
file(GLOB ${PROJECT_NAME}_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/../../src/cc1310_platform.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../../src/knx_facade.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../../src/knx/*.c*"
"${CMAKE_CURRENT_SOURCE_DIR}/RTT/*.c*"
"${CMAKE_CURRENT_SOURCE_DIR}/RTT/*.S"
"${CMAKE_CURRENT_SOURCE_DIR}/*.c*"
)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
"${CMAKE_CURRENT_SOURCE_DIR}/../../src"
"${CMAKE_CURRENT_SOURCE_DIR}/../../src/knx"
"${CMAKE_CURRENT_SOURCE_DIR}/RTT"
${SimpleLinkCC13X0SDK_INCLUDE_DIRS}
${Xdctools_INCLUDE_DIRS}
)
add_definitions(-DMASK_VERSION=0x07B0 -Wno-unknown-pragmas)
add_executable(${PROJECT_NAME}
${${PROJECT_NAME}_SOURCES}
)
target_link_libraries(${PROJECT_NAME}
${SimpleLinkCC13X0SDK_drivers_cc13x0_LIBRARY}
${SimpleLinkCC13X0SDK_dpl_cc13x0_LIBRARY}
${SimpleLinkCC13X0SDK_driverlib_LIBRARY}
gcc
m
nosys
c
)
target_compile_definitions(${PROJECT_NAME} PUBLIC -DDeviceFamily_CC13X0 )

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,372 @@
/*********************************************************************
* SEGGER Microcontroller GmbH *
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* SEGGER RTT * Real Time Transfer for embedded targets *
* *
**********************************************************************
* *
* All rights reserved. *
* *
* SEGGER strongly recommends to not make any changes *
* to or modify the source code of this software in order to stay *
* compatible with the RTT protocol and J-Link. *
* *
* Redistribution and use in source and binary forms, with or *
* without modification, are permitted provided that the following *
* condition is met: *
* *
* o Redistributions of source code must retain the above copyright *
* notice, this condition and the following disclaimer. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
* DAMAGE. *
* *
**********************************************************************
---------------------------END-OF-HEADER------------------------------
File : SEGGER_RTT.h
Purpose : Implementation of SEGGER real-time transfer which allows
real-time communication on targets which support debugger
memory accesses while the CPU is running.
Revision: $Rev: 20159 $
----------------------------------------------------------------------
*/
#ifndef SEGGER_RTT_H
#define SEGGER_RTT_H
#include "SEGGER_RTT_Conf.h"
/*********************************************************************
*
* Defines, defaults
*
**********************************************************************
*/
#ifndef RTT_USE_ASM
#if (defined __SES_ARM) // SEGGER Embedded Studio
#define _CC_HAS_RTT_ASM_SUPPORT 1
#elif (defined __CROSSWORKS_ARM) // Rowley Crossworks
#define _CC_HAS_RTT_ASM_SUPPORT 1
#elif (defined __ARMCC_VERSION)
#define _CC_HAS_RTT_ASM_SUPPORT 0
#elif (defined __GNUC__) // GCC
#define _CC_HAS_RTT_ASM_SUPPORT 1
#elif (defined __clang__) // Clang compiler
#define _CC_HAS_RTT_ASM_SUPPORT 1
#elif ((defined __IASMARM__) || (defined __ICCARM__)) // IAR assembler/compiler
#define _CC_HAS_RTT_ASM_SUPPORT 1
#else
#define _CC_HAS_RTT_ASM_SUPPORT 0
#endif
#if ((defined __IASMARM__) || (defined __ICCARM__)) // IAR assembler/compiler
//
// IAR assembler / compiler
//
#if (defined __ARM7M__) // Needed for old versions that do not know the define yet
#if (__CORE__ == __ARM7M__) // Cortex-M3
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#endif
#endif
#if (defined __ARM7EM__) // Needed for old versions that do not know the define yet
#if (__CORE__ == __ARM7EM__) // Cortex-M4/M7
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() asm("DMB");
#endif
#endif
#if (defined __ARM8M_BASELINE__) // Needed for old versions that do not know the define yet
#if (__CORE__ == __ARM8M_BASELINE__) // Cortex-M23
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() asm("DMB");
#endif
#endif
#if (defined __ARM8M_MAINLINE__) // Needed for old versions that do not know the define yet
#if (__CORE__ == __ARM8M_MAINLINE__) // Cortex-M33
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() asm("DMB");
#endif
#endif
#else
//
// GCC / Clang
//
#if (defined __ARM_ARCH_7M__) // Cortex-M3
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#elif (defined __ARM_ARCH_7EM__) // Cortex-M4/M7
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#elif (defined __ARM_ARCH_8M_BASE__) // Cortex-M23
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#elif (defined __ARM_ARCH_8M_MAIN__) // Cortex-M33
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#else
#define _CORE_HAS_RTT_ASM_SUPPORT 0
#endif
#endif
//
// If IDE and core support the ASM version, enable ASM version by default
//
#ifndef _CORE_HAS_RTT_ASM_SUPPORT
#define _CORE_HAS_RTT_ASM_SUPPORT 0 // Default for unknown cores
#endif
#if (_CC_HAS_RTT_ASM_SUPPORT && _CORE_HAS_RTT_ASM_SUPPORT)
#define RTT_USE_ASM (1)
#else
#define RTT_USE_ASM (0)
#endif
#endif
//
// We need to know if a DMB is needed to make sure that on Cortex-M7 etc.
// the order of accesses to the ring buffers is guaranteed
// Needed for: Cortex-M7, Cortex-M23, Cortex-M33
//
#ifndef _CORE_NEEDS_DMB
#define _CORE_NEEDS_DMB 0
#endif
#ifndef RTT__DMB
#if _CORE_NEEDS_DMB
#error "Don't know how to place inline assembly for DMB"
#else
#define RTT__DMB()
#endif
#endif
#ifndef SEGGER_RTT_ASM // defined when SEGGER_RTT.h is included from assembly file
#include <stdlib.h>
#include <stdarg.h>
/*********************************************************************
*
* Defines, fixed
*
**********************************************************************
*/
/*********************************************************************
*
* Types
*
**********************************************************************
*/
//
// Description for a circular buffer (also called "ring buffer")
// which is used as up-buffer (T->H)
//
typedef struct {
const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4"
char* pBuffer; // Pointer to start of buffer
unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty.
unsigned WrOff; // Position of next item to be written by either target.
volatile unsigned RdOff; // Position of next item to be read by host. Must be volatile since it may be modified by host.
unsigned Flags; // Contains configuration flags
} SEGGER_RTT_BUFFER_UP;
//
// Description for a circular buffer (also called "ring buffer")
// which is used as down-buffer (H->T)
//
typedef struct {
const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4"
char* pBuffer; // Pointer to start of buffer
unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty.
volatile unsigned WrOff; // Position of next item to be written by host. Must be volatile since it may be modified by host.
unsigned RdOff; // Position of next item to be read by target (down-buffer).
unsigned Flags; // Contains configuration flags
} SEGGER_RTT_BUFFER_DOWN;
//
// RTT control block which describes the number of buffers available
// as well as the configuration for each buffer
//
//
typedef struct {
char acID[16]; // Initialized to "SEGGER RTT"
int MaxNumUpBuffers; // Initialized to SEGGER_RTT_MAX_NUM_UP_BUFFERS (type. 2)
int MaxNumDownBuffers; // Initialized to SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (type. 2)
SEGGER_RTT_BUFFER_UP aUp[SEGGER_RTT_MAX_NUM_UP_BUFFERS]; // Up buffers, transferring information up from target via debug probe to host
SEGGER_RTT_BUFFER_DOWN aDown[SEGGER_RTT_MAX_NUM_DOWN_BUFFERS]; // Down buffers, transferring information down from host via debug probe to target
} SEGGER_RTT_CB;
/*********************************************************************
*
* Global data
*
**********************************************************************
*/
extern SEGGER_RTT_CB _SEGGER_RTT;
/*********************************************************************
*
* RTT API functions
*
**********************************************************************
*/
#ifdef __cplusplus
extern "C" {
#endif
int SEGGER_RTT_AllocDownBuffer (const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
int SEGGER_RTT_AllocUpBuffer (const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
int SEGGER_RTT_ConfigUpBuffer (unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
int SEGGER_RTT_ConfigDownBuffer (unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
int SEGGER_RTT_GetKey (void);
unsigned SEGGER_RTT_HasData (unsigned BufferIndex);
int SEGGER_RTT_HasKey (void);
unsigned SEGGER_RTT_HasDataUp (unsigned BufferIndex);
void SEGGER_RTT_Init (void);
unsigned SEGGER_RTT_Read (unsigned BufferIndex, void* pBuffer, unsigned BufferSize);
unsigned SEGGER_RTT_ReadNoLock (unsigned BufferIndex, void* pData, unsigned BufferSize);
int SEGGER_RTT_SetNameDownBuffer (unsigned BufferIndex, const char* sName);
int SEGGER_RTT_SetNameUpBuffer (unsigned BufferIndex, const char* sName);
int SEGGER_RTT_SetFlagsDownBuffer (unsigned BufferIndex, unsigned Flags);
int SEGGER_RTT_SetFlagsUpBuffer (unsigned BufferIndex, unsigned Flags);
int SEGGER_RTT_WaitKey (void);
unsigned SEGGER_RTT_Write (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
unsigned SEGGER_RTT_WriteNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
unsigned SEGGER_RTT_WriteSkipNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
unsigned SEGGER_RTT_ASM_WriteSkipNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
unsigned SEGGER_RTT_WriteString (unsigned BufferIndex, const char* s);
void SEGGER_RTT_WriteWithOverwriteNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
unsigned SEGGER_RTT_PutChar (unsigned BufferIndex, char c);
unsigned SEGGER_RTT_PutCharSkip (unsigned BufferIndex, char c);
unsigned SEGGER_RTT_PutCharSkipNoLock (unsigned BufferIndex, char c);
unsigned SEGGER_RTT_GetAvailWriteSpace (unsigned BufferIndex);
unsigned SEGGER_RTT_GetBytesInBuffer (unsigned BufferIndex);
//
// Function macro for performance optimization
//
#define SEGGER_RTT_HASDATA(n) (_SEGGER_RTT.aDown[n].WrOff - _SEGGER_RTT.aDown[n].RdOff)
#if RTT_USE_ASM
#define SEGGER_RTT_WriteSkipNoLock SEGGER_RTT_ASM_WriteSkipNoLock
#endif
/*********************************************************************
*
* RTT transfer functions to send RTT data via other channels.
*
**********************************************************************
*/
unsigned SEGGER_RTT_ReadUpBuffer (unsigned BufferIndex, void* pBuffer, unsigned BufferSize);
unsigned SEGGER_RTT_ReadUpBufferNoLock (unsigned BufferIndex, void* pData, unsigned BufferSize);
unsigned SEGGER_RTT_WriteDownBuffer (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
unsigned SEGGER_RTT_WriteDownBufferNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
#define SEGGER_RTT_HASDATA_UP(n) (_SEGGER_RTT.aUp[n].WrOff - _SEGGER_RTT.aUp[n].RdOff)
/*********************************************************************
*
* RTT "Terminal" API functions
*
**********************************************************************
*/
int SEGGER_RTT_SetTerminal (unsigned char TerminalId);
int SEGGER_RTT_TerminalOut (unsigned char TerminalId, const char* s);
/*********************************************************************
*
* RTT printf functions (require SEGGER_RTT_printf.c)
*
**********************************************************************
*/
int SEGGER_RTT_printf(unsigned BufferIndex, const char * sFormat, ...);
int SEGGER_RTT_vprintf(unsigned BufferIndex, const char * sFormat, va_list * pParamList);
#ifdef __cplusplus
}
#endif
#endif // ifndef(SEGGER_RTT_ASM)
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
//
// Operating modes. Define behavior if buffer is full (not enough space for entire message)
//
#define SEGGER_RTT_MODE_NO_BLOCK_SKIP (0) // Skip. Do not block, output nothing. (Default)
#define SEGGER_RTT_MODE_NO_BLOCK_TRIM (1) // Trim: Do not block, output as much as fits.
#define SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL (2) // Block: Wait until there is space in the buffer.
#define SEGGER_RTT_MODE_MASK (3)
//
// Control sequences, based on ANSI.
// Can be used to control color, and clear the screen
//
#define RTT_CTRL_RESET "\x1B[0m" // Reset to default colors
#define RTT_CTRL_CLEAR "\x1B[2J" // Clear screen, reposition cursor to top left
#define RTT_CTRL_TEXT_BLACK "\x1B[2;30m"
#define RTT_CTRL_TEXT_RED "\x1B[2;31m"
#define RTT_CTRL_TEXT_GREEN "\x1B[2;32m"
#define RTT_CTRL_TEXT_YELLOW "\x1B[2;33m"
#define RTT_CTRL_TEXT_BLUE "\x1B[2;34m"
#define RTT_CTRL_TEXT_MAGENTA "\x1B[2;35m"
#define RTT_CTRL_TEXT_CYAN "\x1B[2;36m"
#define RTT_CTRL_TEXT_WHITE "\x1B[2;37m"
#define RTT_CTRL_TEXT_BRIGHT_BLACK "\x1B[1;30m"
#define RTT_CTRL_TEXT_BRIGHT_RED "\x1B[1;31m"
#define RTT_CTRL_TEXT_BRIGHT_GREEN "\x1B[1;32m"
#define RTT_CTRL_TEXT_BRIGHT_YELLOW "\x1B[1;33m"
#define RTT_CTRL_TEXT_BRIGHT_BLUE "\x1B[1;34m"
#define RTT_CTRL_TEXT_BRIGHT_MAGENTA "\x1B[1;35m"
#define RTT_CTRL_TEXT_BRIGHT_CYAN "\x1B[1;36m"
#define RTT_CTRL_TEXT_BRIGHT_WHITE "\x1B[1;37m"
#define RTT_CTRL_BG_BLACK "\x1B[24;40m"
#define RTT_CTRL_BG_RED "\x1B[24;41m"
#define RTT_CTRL_BG_GREEN "\x1B[24;42m"
#define RTT_CTRL_BG_YELLOW "\x1B[24;43m"
#define RTT_CTRL_BG_BLUE "\x1B[24;44m"
#define RTT_CTRL_BG_MAGENTA "\x1B[24;45m"
#define RTT_CTRL_BG_CYAN "\x1B[24;46m"
#define RTT_CTRL_BG_WHITE "\x1B[24;47m"
#define RTT_CTRL_BG_BRIGHT_BLACK "\x1B[4;40m"
#define RTT_CTRL_BG_BRIGHT_RED "\x1B[4;41m"
#define RTT_CTRL_BG_BRIGHT_GREEN "\x1B[4;42m"
#define RTT_CTRL_BG_BRIGHT_YELLOW "\x1B[4;43m"
#define RTT_CTRL_BG_BRIGHT_BLUE "\x1B[4;44m"
#define RTT_CTRL_BG_BRIGHT_MAGENTA "\x1B[4;45m"
#define RTT_CTRL_BG_BRIGHT_CYAN "\x1B[4;46m"
#define RTT_CTRL_BG_BRIGHT_WHITE "\x1B[4;47m"
#endif
/*************************** End of file ****************************/

View File

@ -0,0 +1,241 @@
/*********************************************************************
* (c) SEGGER Microcontroller GmbH *
* The Embedded Experts *
* www.segger.com *
**********************************************************************
-------------------------- END-OF-HEADER -----------------------------
File : SEGGER_RTT_ASM_ARMv7M.S
Purpose : Assembler implementation of RTT functions for ARMv7M
Additional information:
This module is written to be assembler-independent and works with
GCC and clang (Embedded Studio) and IAR.
*/
#define SEGGER_RTT_ASM // Used to control processed input from header file
#include "SEGGER_RTT.h"
/*********************************************************************
*
* Defines, fixed
*
**********************************************************************
*/
#define _CCIAR 0
#define _CCCLANG 1
#if (defined __SES_ARM) || (defined __GNUC__) || (defined __clang__)
#define _CC_TYPE _CCCLANG
#define _PUB_SYM .global
#define _EXT_SYM .extern
#define _END .end
#define _WEAK .weak
#define _THUMB_FUNC .thumb_func
#define _THUMB_CODE .code 16
#define _WORD .word
#define _SECTION(Sect, Type, AlignExp) .section Sect ##, "ax"
#define _ALIGN(Exp) .align Exp
#define _PLACE_LITS .ltorg
#define _DATA_SECT_START
#define _C_STARTUP _start
#define _STACK_END __stack_end__
#define _RAMFUNC
//
// .text => Link to flash
// .fast => Link to RAM
// OtherSect => Usually link to RAM
// Alignment is 2^x
//
#elif defined (__IASMARM__)
#define _CC_TYPE _CCIAR
#define _PUB_SYM PUBLIC
#define _EXT_SYM EXTERN
#define _END END
#define _WEAK _WEAK
#define _THUMB_FUNC
#define _THUMB_CODE THUMB
#define _WORD DCD
#define _SECTION(Sect, Type, AlignExp) SECTION Sect ## : ## Type ## :REORDER:NOROOT ## (AlignExp)
#define _ALIGN(Exp) alignrom Exp
#define _PLACE_LITS
#define _DATA_SECT_START DATA
#define _C_STARTUP __iar_program_start
#define _STACK_END sfe(CSTACK)
#define _RAMFUNC SECTION_TYPE SHT_PROGBITS, SHF_WRITE | SHF_EXECINSTR
//
// .text => Link to flash
// .textrw => Link to RAM
// OtherSect => Usually link to RAM
// NOROOT => Allows linker to throw away the function, if not referenced
// Alignment is 2^x
//
#endif
#if (_CC_TYPE == _CCIAR)
NAME SEGGER_RTT_ASM_ARMv7M
#else
.syntax unified
#endif
#if defined (RTT_USE_ASM) && (RTT_USE_ASM == 1)
#define SHT_PROGBITS 0x1
/*********************************************************************
*
* Public / external symbols
*
**********************************************************************
*/
_EXT_SYM __aeabi_memcpy
_EXT_SYM __aeabi_memcpy4
_EXT_SYM _SEGGER_RTT
_PUB_SYM SEGGER_RTT_ASM_WriteSkipNoLock
/*********************************************************************
*
* SEGGER_RTT_WriteSkipNoLock
*
* Function description
* Stores a specified number of characters in SEGGER RTT
* control block which is then read by the host.
* SEGGER_RTT_WriteSkipNoLock does not lock the application and
* skips all data, if the data does not fit into the buffer.
*
* Parameters
* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal").
* pBuffer Pointer to character array. Does not need to point to a \0 terminated string.
* NumBytes Number of bytes to be stored in the SEGGER RTT control block.
* MUST be > 0!!!
* This is done for performance reasons, so no initial check has do be done.
*
* Return value
* 1: Data has been copied
* 0: No space, data has not been copied
*
* Notes
* (1) If there is not enough space in the "Up"-buffer, all data is dropped.
* (2) For performance reasons this function does not call Init()
* and may only be called after RTT has been initialized.
* Either by calling SEGGER_RTT_Init() or calling another RTT API function first.
*/
_SECTION(.text, CODE, 2)
_ALIGN(2)
_THUMB_FUNC
SEGGER_RTT_ASM_WriteSkipNoLock: // unsigned SEGGER_RTT_WriteSkipNoLock(unsigned BufferIndex, const void* pData, unsigned NumBytes) {
//
// Cases:
// 1) RdOff <= WrOff => Space until wrap-around is sufficient
// 2) RdOff <= WrOff => Space after wrap-around needed (copy in 2 chunks)
// 3) RdOff < WrOff => No space in buf
// 4) RdOff > WrOff => Space is sufficient
// 5) RdOff > WrOff => No space in buf
//
// 1) is the most common case for large buffers and assuming that J-Link reads the data fast enough
//
// Register usage:
// R0 Temporary needed as RdOff, <Tmp> register later on
// R1 pData
// R2 <NumBytes>
// R3 <Tmp> register. Hold free for subroutine calls
// R4 <Rem>
// R5 pRing->pBuffer
// R6 pRing (Points to active struct SEGGER_RTT_BUFFER_DOWN)
// R7 WrOff
//
PUSH {R4-R7}
ADD R3,R0,R0, LSL #+1
LDR.W R0,=_SEGGER_RTT // pRing = &_SEGGER_RTT.aUp[BufferIndex];
ADD R0,R0,R3, LSL #+3
ADD R6,R0,#+24
LDR R0,[R6, #+16] // RdOff = pRing->RdOff;
LDR R7,[R6, #+12] // WrOff = pRing->WrOff;
LDR R5,[R6, #+4] // pRing->pBuffer
CMP R7,R0
BCC.N _CheckCase4 // if (RdOff <= WrOff) { => Case 1), 2) or 3)
//
// Handling for case 1, later on identical to case 4
//
LDR R3,[R6, #+8] // Avail = pRing->SizeOfBuffer - WrOff - 1u; => Space until wrap-around (assume 1 byte not usable for case that RdOff == 0)
SUBS R4,R3,R7 // <Rem> (Used in case we jump into case 2 afterwards)
SUBS R3,R4,#+1 // <Avail>
CMP R3,R2
BCC.N _CheckCase2 // if (Avail >= NumBytes) { => Case 1)?
_Case4:
ADDS R5,R7,R5 // pBuffer += WrOff
ADDS R0,R2,R7 // v = WrOff + NumBytes
//
// 2x unrolling for the copy loop that is used most of the time
// This is a special optimization for small SystemView packets and makes them even faster
//
_ALIGN(2)
_LoopCopyStraight: // memcpy(pRing->pBuffer + WrOff, pData, NumBytes);
LDRB R3,[R1], #+1
STRB R3,[R5], #+1 // *pDest++ = *pSrc++
SUBS R2,R2,#+1
BEQ _CSDone
LDRB R3,[R1], #+1
STRB R3,[R5], #+1 // *pDest++ = *pSrc++
SUBS R2,R2,#+1
BNE _LoopCopyStraight
_CSDone:
#if _CORE_NEEDS_DMB // Do not slow down cores that do not need a DMB instruction here
DMB // Cortex-M7 may delay memory writes and also change the order in which the writes happen. Therefore, make sure that all buffer writes are finished, before updating the <WrOff> in the struct
#endif
STR R0,[R6, #+12] // pRing->WrOff = WrOff + NumBytes;
MOVS R0,#+1
POP {R4-R7}
BX LR // Return 1
_CheckCase2:
ADDS R0,R0,R3 // Avail += RdOff; => Space incl. wrap-around
CMP R0,R2
BCC.N _Case3 // if (Avail >= NumBytes) { => Case 2? => If not, we have case 3) (does not fit)
//
// Handling for case 2
//
ADDS R0,R7,R5 // v = pRing->pBuffer + WrOff => Do not change pRing->pBuffer here because 2nd chunk needs org. value
SUBS R2,R2,R4 // NumBytes -= Rem; (Rem = pRing->SizeOfBuffer - WrOff; => Space until end of buffer)
_LoopCopyBeforeWrapAround: // memcpy(pRing->pBuffer + WrOff, pData, Rem); => Copy 1st chunk
LDRB R3,[R1], #+1
STRB R3,[R0], #+1 // *pDest++ = *pSrc++
SUBS R4,R4,#+1
BNE _LoopCopyBeforeWrapAround
//
// Special case: First check that assumed RdOff == 0 calculated that last element before wrap-around could not be used
// But 2nd check (considering space until wrap-around and until RdOff) revealed that RdOff is not 0, so we can use the last element
// In this case, we may use a copy straight until buffer end anyway without needing to copy 2 chunks
// Therefore, check if 2nd memcpy is necessary at all
//
ADDS R4,R2,#+0 // Save <NumBytes> (needed as counter in loop but must be written to <WrOff> after the loop). Also use this inst to update the flags to skip 2nd loop if possible
BEQ.N _No2ChunkNeeded // if (NumBytes) {
_LoopCopyAfterWrapAround: // memcpy(pRing->pBuffer, pData + Rem, NumBytes);
LDRB R3,[R1], #+1 // pData already points to the next src byte due to copy loop increment before this loop
STRB R3,[R5], #+1 // *pDest++ = *pSrc++
SUBS R2,R2,#+1
BNE _LoopCopyAfterWrapAround
_No2ChunkNeeded:
#if _CORE_NEEDS_DMB // Do not slow down cores that do not need a DMB instruction here
DMB // Cortex-M7 may delay memory writes and also change the order in which the writes happen. Therefore, make sure that all buffer writes are finished, before updating the <WrOff> in the struct
#endif
STR R4,[R6, #+12] // pRing->WrOff = NumBytes; => Must be written after copying data because J-Link may read control block asynchronously while writing into buffer
MOVS R0,#+1
POP {R4-R7}
BX LR // Return 1
_CheckCase4:
SUBS R0,R0,R7
SUBS R0,R0,#+1 // Avail = RdOff - WrOff - 1u;
CMP R0,R2
BCS.N _Case4 // if (Avail >= NumBytes) { => Case 4) == 1) ? => If not, we have case 5) == 3) (does not fit)
_Case3:
MOVS R0,#+0
POP {R4-R7}
BX LR // Return 0
_PLACE_LITS
#endif // defined (RTT_USE_ASM) && (RTT_USE_ASM == 1)
_END
/*************************** End of file ****************************/

View File

@ -0,0 +1,384 @@
/*********************************************************************
* SEGGER Microcontroller GmbH *
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* SEGGER RTT * Real Time Transfer for embedded targets *
* *
**********************************************************************
* *
* All rights reserved. *
* *
* SEGGER strongly recommends to not make any changes *
* to or modify the source code of this software in order to stay *
* compatible with the RTT protocol and J-Link. *
* *
* Redistribution and use in source and binary forms, with or *
* without modification, are permitted provided that the following *
* condition is met: *
* *
* o Redistributions of source code must retain the above copyright *
* notice, this condition and the following disclaimer. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
* DAMAGE. *
* *
**********************************************************************
---------------------------END-OF-HEADER------------------------------
File : SEGGER_RTT_Conf.h
Purpose : Implementation of SEGGER real-time transfer (RTT) which
allows real-time communication on targets which support
debugger memory accesses while the CPU is running.
Revision: $Rev: 18601 $
*/
#ifndef SEGGER_RTT_CONF_H
#define SEGGER_RTT_CONF_H
#ifdef __IAR_SYSTEMS_ICC__
#include <intrinsics.h>
#endif
/*********************************************************************
*
* Defines, configurable
*
**********************************************************************
*/
#ifndef SEGGER_RTT_MAX_NUM_UP_BUFFERS
#define SEGGER_RTT_MAX_NUM_UP_BUFFERS (3) // Max. number of up-buffers (T->H) available on this target (Default: 3)
#endif
#ifndef SEGGER_RTT_MAX_NUM_DOWN_BUFFERS
#define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (3) // Max. number of down-buffers (H->T) available on this target (Default: 3)
#endif
#ifndef BUFFER_SIZE_UP
#define BUFFER_SIZE_UP (1024) // Size of the buffer for terminal output of target, up to host (Default: 1k)
#endif
#ifndef BUFFER_SIZE_DOWN
#define BUFFER_SIZE_DOWN (16) // Size of the buffer for terminal input to target from host (Usually keyboard input) (Default: 16)
#endif
#ifndef SEGGER_RTT_PRINTF_BUFFER_SIZE
#define SEGGER_RTT_PRINTF_BUFFER_SIZE (64u) // Size of buffer for RTT printf to bulk-send chars via RTT (Default: 64)
#endif
#ifndef SEGGER_RTT_MODE_DEFAULT
#define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_NO_BLOCK_SKIP // Mode for pre-initialized terminal channel (buffer 0)
#endif
/*********************************************************************
*
* RTT memcpy configuration
*
* memcpy() is good for large amounts of data,
* but the overhead is big for small amounts, which are usually stored via RTT.
* With SEGGER_RTT_MEMCPY_USE_BYTELOOP a simple byte loop can be used instead.
*
* SEGGER_RTT_MEMCPY() can be used to replace standard memcpy() in RTT functions.
* This is may be required with memory access restrictions,
* such as on Cortex-A devices with MMU.
*/
#ifndef SEGGER_RTT_MEMCPY_USE_BYTELOOP
#define SEGGER_RTT_MEMCPY_USE_BYTELOOP 0 // 0: Use memcpy/SEGGER_RTT_MEMCPY, 1: Use a simple byte-loop
#endif
//
// Example definition of SEGGER_RTT_MEMCPY to external memcpy with GCC toolchains and Cortex-A targets
//
//#if ((defined __SES_ARM) || (defined __CROSSWORKS_ARM) || (defined __GNUC__)) && (defined (__ARM_ARCH_7A__))
// #define SEGGER_RTT_MEMCPY(pDest, pSrc, NumBytes) SEGGER_memcpy((pDest), (pSrc), (NumBytes))
//#endif
//
// Target is not allowed to perform other RTT operations while string still has not been stored completely.
// Otherwise we would probably end up with a mixed string in the buffer.
// If using RTT from within interrupts, multiple tasks or multi processors, define the SEGGER_RTT_LOCK() and SEGGER_RTT_UNLOCK() function here.
//
// SEGGER_RTT_MAX_INTERRUPT_PRIORITY can be used in the sample lock routines on Cortex-M3/4.
// Make sure to mask all interrupts which can send RTT data, i.e. generate SystemView events, or cause task switches.
// When high-priority interrupts must not be masked while sending RTT data, SEGGER_RTT_MAX_INTERRUPT_PRIORITY needs to be adjusted accordingly.
// (Higher priority = lower priority number)
// Default value for embOS: 128u
// Default configuration in FreeRTOS: configMAX_SYSCALL_INTERRUPT_PRIORITY: ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
// In case of doubt mask all interrupts: 1 << (8 - BASEPRI_PRIO_BITS) i.e. 1 << 5 when 3 bits are implemented in NVIC
// or define SEGGER_RTT_LOCK() to completely disable interrupts.
//
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) // Interrupt priority to lock on SEGGER_RTT_LOCK on Cortex-M3/4 (Default: 0x20)
#endif
/*********************************************************************
*
* RTT lock configuration for SEGGER Embedded Studio,
* Rowley CrossStudio and GCC
*/
#if ((defined(__SES_ARM) || defined(__SES_RISCV) || defined(__CROSSWORKS_ARM) || defined(__GNUC__) || defined(__clang__)) && !defined (__CC_ARM) && !defined(WIN32))
#if (defined(__ARM_ARCH_6M__) || defined(__ARM_ARCH_8M_BASE__))
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
__asm volatile ("mrs %0, primask \n\t" \
"movs r1, $1 \n\t" \
"msr primask, r1 \n\t" \
: "=r" (LockState) \
: \
: "r1" \
);
#define SEGGER_RTT_UNLOCK() __asm volatile ("msr primask, %0 \n\t" \
: \
: "r" (LockState) \
: \
); \
}
#elif (defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_8M_MAIN__))
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
#endif
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
__asm volatile ("mrs %0, basepri \n\t" \
"mov r1, %1 \n\t" \
"msr basepri, r1 \n\t" \
: "=r" (LockState) \
: "i"(SEGGER_RTT_MAX_INTERRUPT_PRIORITY) \
: "r1" \
);
#define SEGGER_RTT_UNLOCK() __asm volatile ("msr basepri, %0 \n\t" \
: \
: "r" (LockState) \
: \
); \
}
#elif defined(__ARM_ARCH_7A__)
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
__asm volatile ("mrs r1, CPSR \n\t" \
"mov %0, r1 \n\t" \
"orr r1, r1, #0xC0 \n\t" \
"msr CPSR_c, r1 \n\t" \
: "=r" (LockState) \
: \
: "r1" \
);
#define SEGGER_RTT_UNLOCK() __asm volatile ("mov r0, %0 \n\t" \
"mrs r1, CPSR \n\t" \
"bic r1, r1, #0xC0 \n\t" \
"and r0, r0, #0xC0 \n\t" \
"orr r1, r1, r0 \n\t" \
"msr CPSR_c, r1 \n\t" \
: \
: "r" (LockState) \
: "r0", "r1" \
); \
}
#elif defined(__riscv) || defined(__riscv_xlen)
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
__asm volatile ("csrr %0, mstatus \n\t" \
"csrci mstatus, 8 \n\t" \
"andi %0, %0, 8 \n\t" \
: "=r" (LockState) \
: \
: \
);
#define SEGGER_RTT_UNLOCK() __asm volatile ("csrr a1, mstatus \n\t" \
"or %0, %0, a1 \n\t" \
"csrs mstatus, %0 \n\t" \
: \
: "r" (LockState) \
: "a1" \
); \
}
#else
#define SEGGER_RTT_LOCK()
#define SEGGER_RTT_UNLOCK()
#endif
#endif
/*********************************************************************
*
* RTT lock configuration for IAR EWARM
*/
#ifdef __ICCARM__
#if (defined (__ARM6M__) && (__CORE__ == __ARM6M__)) || \
(defined (__ARM8M_BASELINE__) && (__CORE__ == __ARM8M_BASELINE__))
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
LockState = __get_PRIMASK(); \
__set_PRIMASK(1);
#define SEGGER_RTT_UNLOCK() __set_PRIMASK(LockState); \
}
#elif (defined (__ARM7EM__) && (__CORE__ == __ARM7EM__)) || \
(defined (__ARM7M__) && (__CORE__ == __ARM7M__)) || \
(defined (__ARM8M_MAINLINE__) && (__CORE__ == __ARM8M_MAINLINE__)) || \
(defined (__ARM8M_MAINLINE__) && (__CORE__ == __ARM8M_MAINLINE__))
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
#endif
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
LockState = __get_BASEPRI(); \
__set_BASEPRI(SEGGER_RTT_MAX_INTERRUPT_PRIORITY);
#define SEGGER_RTT_UNLOCK() __set_BASEPRI(LockState); \
}
#endif
#endif
/*********************************************************************
*
* RTT lock configuration for IAR RX
*/
#ifdef __ICCRX__
#define SEGGER_RTT_LOCK() { \
unsigned long LockState; \
LockState = __get_interrupt_state(); \
__disable_interrupt();
#define SEGGER_RTT_UNLOCK() __set_interrupt_state(LockState); \
}
#endif
/*********************************************************************
*
* RTT lock configuration for IAR RL78
*/
#ifdef __ICCRL78__
#define SEGGER_RTT_LOCK() { \
__istate_t LockState; \
LockState = __get_interrupt_state(); \
__disable_interrupt();
#define SEGGER_RTT_UNLOCK() __set_interrupt_state(LockState); \
}
#endif
/*********************************************************************
*
* RTT lock configuration for KEIL ARM
*/
#ifdef __CC_ARM
#if (defined __TARGET_ARCH_6S_M)
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
register unsigned char PRIMASK __asm( "primask"); \
LockState = PRIMASK; \
PRIMASK = 1u; \
__schedule_barrier();
#define SEGGER_RTT_UNLOCK() PRIMASK = LockState; \
__schedule_barrier(); \
}
#elif (defined(__TARGET_ARCH_7_M) || defined(__TARGET_ARCH_7E_M))
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
#endif
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
register unsigned char BASEPRI __asm( "basepri"); \
LockState = BASEPRI; \
BASEPRI = SEGGER_RTT_MAX_INTERRUPT_PRIORITY; \
__schedule_barrier();
#define SEGGER_RTT_UNLOCK() BASEPRI = LockState; \
__schedule_barrier(); \
}
#endif
#endif
/*********************************************************************
*
* RTT lock configuration for TI ARM
*/
#ifdef __TI_ARM__
#if defined (__TI_ARM_V6M0__)
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
LockState = __get_PRIMASK(); \
__set_PRIMASK(1);
#define SEGGER_RTT_UNLOCK() __set_PRIMASK(LockState); \
}
#elif (defined (__TI_ARM_V7M3__) || defined (__TI_ARM_V7M4__))
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
#endif
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
LockState = _set_interrupt_priority(SEGGER_RTT_MAX_INTERRUPT_PRIORITY);
#define SEGGER_RTT_UNLOCK() _set_interrupt_priority(LockState); \
}
#endif
#endif
/*********************************************************************
*
* RTT lock configuration for CCRX
*/
#ifdef __RX
#define SEGGER_RTT_LOCK() { \
unsigned long LockState; \
LockState = get_psw() & 0x010000; \
clrpsw_i();
#define SEGGER_RTT_UNLOCK() set_psw(get_psw() | LockState); \
}
#endif
/*********************************************************************
*
* RTT lock configuration for embOS Simulation on Windows
* (Can also be used for generic RTT locking with embOS)
*/
#if defined(WIN32) || defined(SEGGER_RTT_LOCK_EMBOS)
void OS_SIM_EnterCriticalSection(void);
void OS_SIM_LeaveCriticalSection(void);
#define SEGGER_RTT_LOCK() { \
OS_SIM_EnterCriticalSection();
#define SEGGER_RTT_UNLOCK() OS_SIM_LeaveCriticalSection(); \
}
#endif
/*********************************************************************
*
* RTT lock configuration fallback
*/
#ifndef SEGGER_RTT_LOCK
#define SEGGER_RTT_LOCK() // Lock RTT (nestable) (i.e. disable interrupts)
#endif
#ifndef SEGGER_RTT_UNLOCK
#define SEGGER_RTT_UNLOCK() // Unlock RTT (nestable) (i.e. enable previous interrupt lock state)
#endif
#endif
/*************************** End of file ****************************/

View File

@ -0,0 +1,120 @@
/*********************************************************************
* SEGGER Microcontroller GmbH *
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* SEGGER RTT * Real Time Transfer for embedded targets *
* *
**********************************************************************
* *
* All rights reserved. *
* *
* SEGGER strongly recommends to not make any changes *
* to or modify the source code of this software in order to stay *
* compatible with the RTT protocol and J-Link. *
* *
* Redistribution and use in source and binary forms, with or *
* without modification, are permitted provided that the following *
* condition is met: *
* *
* o Redistributions of source code must retain the above copyright *
* notice, this condition and the following disclaimer. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
* DAMAGE. *
* *
**********************************************************************
---------------------------END-OF-HEADER------------------------------
File : SEGGER_RTT_Syscalls_GCC.c
Purpose : Low-level functions for using printf() via RTT in GCC.
To use RTT for printf output, include this file in your
application.
Revision: $Rev: 20159 $
----------------------------------------------------------------------
*/
#if (defined __GNUC__) && !(defined __SES_ARM) && !(defined __CROSSWORKS_ARM) && !(defined __ARMCC_VERSION) && !(defined __CC_ARM)
#include <reent.h> // required for _write_r
#include "SEGGER_RTT.h"
/*********************************************************************
*
* Types
*
**********************************************************************
*/
//
// If necessary define the _reent struct
// to match the one passed by the used standard library.
//
struct _reent;
/*********************************************************************
*
* Function prototypes
*
**********************************************************************
*/
int _write(int file, char *ptr, int len);
int _write_r(struct _reent *r, int file, const void *ptr, size_t len);
/*********************************************************************
*
* Global functions
*
**********************************************************************
*/
/*********************************************************************
*
* _write()
*
* Function description
* Low-level write function.
* libc subroutines will use this system routine for output to all files,
* including stdout.
* Write data via RTT.
*/
int _write(int file, char *ptr, int len) {
(void) file; /* Not used, avoid warning */
SEGGER_RTT_Write(0, ptr, len);
return len;
}
/*********************************************************************
*
* _write_r()
*
* Function description
* Low-level reentrant write function.
* libc subroutines will use this system routine for output to all files,
* including stdout.
* Write data via RTT.
*/
int _write_r(struct _reent *r, int file, const void *ptr, size_t len) {
(void) file; /* Not used, avoid warning */
(void) r; /* Not used, avoid warning */
SEGGER_RTT_Write(0, ptr, len);
return len;
}
#endif
/****** End Of File *************************************************/

View File

@ -0,0 +1,500 @@
/*********************************************************************
* SEGGER Microcontroller GmbH *
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* SEGGER RTT * Real Time Transfer for embedded targets *
* *
**********************************************************************
* *
* All rights reserved. *
* *
* SEGGER strongly recommends to not make any changes *
* to or modify the source code of this software in order to stay *
* compatible with the RTT protocol and J-Link. *
* *
* Redistribution and use in source and binary forms, with or *
* without modification, are permitted provided that the following *
* condition is met: *
* *
* o Redistributions of source code must retain the above copyright *
* notice, this condition and the following disclaimer. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
* DAMAGE. *
* *
**********************************************************************
---------------------------END-OF-HEADER------------------------------
File : SEGGER_RTT_printf.c
Purpose : Replacement for printf to write formatted data via RTT
Revision: $Rev: 17697 $
----------------------------------------------------------------------
*/
#include "SEGGER_RTT.h"
#include "SEGGER_RTT_Conf.h"
/*********************************************************************
*
* Defines, configurable
*
**********************************************************************
*/
#ifndef SEGGER_RTT_PRINTF_BUFFER_SIZE
#define SEGGER_RTT_PRINTF_BUFFER_SIZE (64)
#endif
#include <stdlib.h>
#include <stdarg.h>
#define FORMAT_FLAG_LEFT_JUSTIFY (1u << 0)
#define FORMAT_FLAG_PAD_ZERO (1u << 1)
#define FORMAT_FLAG_PRINT_SIGN (1u << 2)
#define FORMAT_FLAG_ALTERNATE (1u << 3)
/*********************************************************************
*
* Types
*
**********************************************************************
*/
typedef struct {
char* pBuffer;
unsigned BufferSize;
unsigned Cnt;
int ReturnValue;
unsigned RTTBufferIndex;
} SEGGER_RTT_PRINTF_DESC;
/*********************************************************************
*
* Function prototypes
*
**********************************************************************
*/
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _StoreChar
*/
static void _StoreChar(SEGGER_RTT_PRINTF_DESC * p, char c) {
unsigned Cnt;
Cnt = p->Cnt;
if ((Cnt + 1u) <= p->BufferSize) {
*(p->pBuffer + Cnt) = c;
p->Cnt = Cnt + 1u;
p->ReturnValue++;
}
//
// Write part of string, when the buffer is full
//
if (p->Cnt == p->BufferSize) {
if (SEGGER_RTT_Write(p->RTTBufferIndex, p->pBuffer, p->Cnt) != p->Cnt) {
p->ReturnValue = -1;
} else {
p->Cnt = 0u;
}
}
}
/*********************************************************************
*
* _PrintUnsigned
*/
static void _PrintUnsigned(SEGGER_RTT_PRINTF_DESC * pBufferDesc, unsigned v, unsigned Base, unsigned NumDigits, unsigned FieldWidth, unsigned FormatFlags) {
static const char _aV2C[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
unsigned Div;
unsigned Digit;
unsigned Number;
unsigned Width;
char c;
Number = v;
Digit = 1u;
//
// Get actual field width
//
Width = 1u;
while (Number >= Base) {
Number = (Number / Base);
Width++;
}
if (NumDigits > Width) {
Width = NumDigits;
}
//
// Print leading chars if necessary
//
if ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == 0u) {
if (FieldWidth != 0u) {
if (((FormatFlags & FORMAT_FLAG_PAD_ZERO) == FORMAT_FLAG_PAD_ZERO) && (NumDigits == 0u)) {
c = '0';
} else {
c = ' ';
}
while ((FieldWidth != 0u) && (Width < FieldWidth)) {
FieldWidth--;
_StoreChar(pBufferDesc, c);
if (pBufferDesc->ReturnValue < 0) {
break;
}
}
}
}
if (pBufferDesc->ReturnValue >= 0) {
//
// Compute Digit.
// Loop until Digit has the value of the highest digit required.
// Example: If the output is 345 (Base 10), loop 2 times until Digit is 100.
//
while (1) {
if (NumDigits > 1u) { // User specified a min number of digits to print? => Make sure we loop at least that often, before checking anything else (> 1 check avoids problems with NumDigits being signed / unsigned)
NumDigits--;
} else {
Div = v / Digit;
if (Div < Base) { // Is our divider big enough to extract the highest digit from value? => Done
break;
}
}
Digit *= Base;
}
//
// Output digits
//
do {
Div = v / Digit;
v -= Div * Digit;
_StoreChar(pBufferDesc, _aV2C[Div]);
if (pBufferDesc->ReturnValue < 0) {
break;
}
Digit /= Base;
} while (Digit);
//
// Print trailing spaces if necessary
//
if ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == FORMAT_FLAG_LEFT_JUSTIFY) {
if (FieldWidth != 0u) {
while ((FieldWidth != 0u) && (Width < FieldWidth)) {
FieldWidth--;
_StoreChar(pBufferDesc, ' ');
if (pBufferDesc->ReturnValue < 0) {
break;
}
}
}
}
}
}
/*********************************************************************
*
* _PrintInt
*/
static void _PrintInt(SEGGER_RTT_PRINTF_DESC * pBufferDesc, int v, unsigned Base, unsigned NumDigits, unsigned FieldWidth, unsigned FormatFlags) {
unsigned Width;
int Number;
Number = (v < 0) ? -v : v;
//
// Get actual field width
//
Width = 1u;
while (Number >= (int)Base) {
Number = (Number / (int)Base);
Width++;
}
if (NumDigits > Width) {
Width = NumDigits;
}
if ((FieldWidth > 0u) && ((v < 0) || ((FormatFlags & FORMAT_FLAG_PRINT_SIGN) == FORMAT_FLAG_PRINT_SIGN))) {
FieldWidth--;
}
//
// Print leading spaces if necessary
//
if ((((FormatFlags & FORMAT_FLAG_PAD_ZERO) == 0u) || (NumDigits != 0u)) && ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == 0u)) {
if (FieldWidth != 0u) {
while ((FieldWidth != 0u) && (Width < FieldWidth)) {
FieldWidth--;
_StoreChar(pBufferDesc, ' ');
if (pBufferDesc->ReturnValue < 0) {
break;
}
}
}
}
//
// Print sign if necessary
//
if (pBufferDesc->ReturnValue >= 0) {
if (v < 0) {
v = -v;
_StoreChar(pBufferDesc, '-');
} else if ((FormatFlags & FORMAT_FLAG_PRINT_SIGN) == FORMAT_FLAG_PRINT_SIGN) {
_StoreChar(pBufferDesc, '+');
} else {
}
if (pBufferDesc->ReturnValue >= 0) {
//
// Print leading zeros if necessary
//
if (((FormatFlags & FORMAT_FLAG_PAD_ZERO) == FORMAT_FLAG_PAD_ZERO) && ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == 0u) && (NumDigits == 0u)) {
if (FieldWidth != 0u) {
while ((FieldWidth != 0u) && (Width < FieldWidth)) {
FieldWidth--;
_StoreChar(pBufferDesc, '0');
if (pBufferDesc->ReturnValue < 0) {
break;
}
}
}
}
if (pBufferDesc->ReturnValue >= 0) {
//
// Print number without sign
//
_PrintUnsigned(pBufferDesc, (unsigned)v, Base, NumDigits, FieldWidth, FormatFlags);
}
}
}
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* SEGGER_RTT_vprintf
*
* Function description
* Stores a formatted string in SEGGER RTT control block.
* This data is read by the host.
*
* Parameters
* BufferIndex Index of "Up"-buffer to be used. (e.g. 0 for "Terminal")
* sFormat Pointer to format string
* pParamList Pointer to the list of arguments for the format string
*
* Return values
* >= 0: Number of bytes which have been stored in the "Up"-buffer.
* < 0: Error
*/
int SEGGER_RTT_vprintf(unsigned BufferIndex, const char * sFormat, va_list * pParamList) {
char c;
SEGGER_RTT_PRINTF_DESC BufferDesc;
int v;
unsigned NumDigits;
unsigned FormatFlags;
unsigned FieldWidth;
char acBuffer[SEGGER_RTT_PRINTF_BUFFER_SIZE];
BufferDesc.pBuffer = acBuffer;
BufferDesc.BufferSize = SEGGER_RTT_PRINTF_BUFFER_SIZE;
BufferDesc.Cnt = 0u;
BufferDesc.RTTBufferIndex = BufferIndex;
BufferDesc.ReturnValue = 0;
do {
c = *sFormat;
sFormat++;
if (c == 0u) {
break;
}
if (c == '%') {
//
// Filter out flags
//
FormatFlags = 0u;
v = 1;
do {
c = *sFormat;
switch (c) {
case '-': FormatFlags |= FORMAT_FLAG_LEFT_JUSTIFY; sFormat++; break;
case '0': FormatFlags |= FORMAT_FLAG_PAD_ZERO; sFormat++; break;
case '+': FormatFlags |= FORMAT_FLAG_PRINT_SIGN; sFormat++; break;
case '#': FormatFlags |= FORMAT_FLAG_ALTERNATE; sFormat++; break;
default: v = 0; break;
}
} while (v);
//
// filter out field with
//
FieldWidth = 0u;
do {
c = *sFormat;
if ((c < '0') || (c > '9')) {
break;
}
sFormat++;
FieldWidth = (FieldWidth * 10u) + ((unsigned)c - '0');
} while (1);
//
// Filter out precision (number of digits to display)
//
NumDigits = 0u;
c = *sFormat;
if (c == '.') {
sFormat++;
do {
c = *sFormat;
if ((c < '0') || (c > '9')) {
break;
}
sFormat++;
NumDigits = NumDigits * 10u + ((unsigned)c - '0');
} while (1);
}
//
// Filter out length modifier
//
c = *sFormat;
do {
if ((c == 'l') || (c == 'h')) {
sFormat++;
c = *sFormat;
} else {
break;
}
} while (1);
//
// Handle specifiers
//
switch (c) {
case 'c': {
char c0;
v = va_arg(*pParamList, int);
c0 = (char)v;
_StoreChar(&BufferDesc, c0);
break;
}
case 'd':
v = va_arg(*pParamList, int);
_PrintInt(&BufferDesc, v, 10u, NumDigits, FieldWidth, FormatFlags);
break;
case 'u':
v = va_arg(*pParamList, int);
_PrintUnsigned(&BufferDesc, (unsigned)v, 10u, NumDigits, FieldWidth, FormatFlags);
break;
case 'x':
case 'X':
v = va_arg(*pParamList, int);
_PrintUnsigned(&BufferDesc, (unsigned)v, 16u, NumDigits, FieldWidth, FormatFlags);
break;
case 's':
{
const char * s = va_arg(*pParamList, const char *);
do {
c = *s;
s++;
if (c == '\0') {
break;
}
_StoreChar(&BufferDesc, c);
} while (BufferDesc.ReturnValue >= 0);
}
break;
case 'p':
v = va_arg(*pParamList, int);
_PrintUnsigned(&BufferDesc, (unsigned)v, 16u, 8u, 8u, 0u);
break;
case '%':
_StoreChar(&BufferDesc, '%');
break;
default:
break;
}
sFormat++;
} else {
_StoreChar(&BufferDesc, c);
}
} while (BufferDesc.ReturnValue >= 0);
if (BufferDesc.ReturnValue > 0) {
//
// Write remaining data, if any
//
if (BufferDesc.Cnt != 0u) {
SEGGER_RTT_Write(BufferIndex, acBuffer, BufferDesc.Cnt);
}
BufferDesc.ReturnValue += (int)BufferDesc.Cnt;
}
return BufferDesc.ReturnValue;
}
/*********************************************************************
*
* SEGGER_RTT_printf
*
* Function description
* Stores a formatted string in SEGGER RTT control block.
* This data is read by the host.
*
* Parameters
* BufferIndex Index of "Up"-buffer to be used. (e.g. 0 for "Terminal")
* sFormat Pointer to format string, followed by the arguments for conversion
*
* Return values
* >= 0: Number of bytes which have been stored in the "Up"-buffer.
* < 0: Error
*
* Notes
* (1) Conversion specifications have following syntax:
* %[flags][FieldWidth][.Precision]ConversionSpecifier
* (2) Supported flags:
* -: Left justify within the field width
* +: Always print sign extension for signed conversions
* 0: Pad with 0 instead of spaces. Ignored when using '-'-flag or precision
* Supported conversion specifiers:
* c: Print the argument as one char
* d: Print the argument as a signed integer
* u: Print the argument as an unsigned integer
* x: Print the argument as an hexadecimal integer
* s: Print the string pointed to by the argument
* p: Print the argument as an 8-digit hexadecimal integer. (Argument shall be a pointer to void.)
*/
int SEGGER_RTT_printf(unsigned BufferIndex, const char * sFormat, ...) {
int r;
va_list ParamList;
va_start(ParamList, sFormat);
r = SEGGER_RTT_vprintf(BufferIndex, sFormat, &ParamList);
va_end(ParamList);
return r;
}
/*************************** End of file ****************************/

2
examples/knx-cc1310/build.sh Executable file
View File

@ -0,0 +1,2 @@
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_PREFIX_PATH="~/ti/simplelink_cc13x0_sdk_4_10_02_04;~/ti/xdctools_3_51_03_28_core" -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-arm-none-eabi.cmake ..

View File

@ -0,0 +1,74 @@
/*
* Copyright (c) 2015-2017, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* ======== ccfg.c ========
* Customer Configuration for CC26xx and CC13xx devices. This file is used to
* configure Boot ROM, start-up code, and SW radio behaviour.
*
* By default, driverlib startup_files/ccfg.c settings are used. However, if
* changes are required there are two means to do so:
*
* 1. Remove this file and copy driverlib's startup_files/ccfg.c file in
* its place. Make all changes to the file. Changes made are local to
* the project and will not affect other projects.
*
* 2. Perform changes to driverlib startup_files/ccfg.c file. Changes
* made to this file will be applied to all projects. This file must
* remain unmodified.
*/
/*---------------------------------------------------------------------------*/
/**
* \name ROM Bootloader configuration
*
* Enable/Disable the ROM bootloader in your image, if the board supports it.
* Look in Board.h to choose the DIO and corresponding level that will cause
* the chip to enter bootloader mode.
* @{
*/
#ifndef CCFG_CONF_ROM_BOOTLOADER_ENABLE
#define CCFG_CONF_ROM_BOOTLOADER_ENABLE 0
#endif
#if CCFG_CONF_ROM_BOOTLOADER_ENABLE
#define SET_CCFG_BL_CONFIG_BOOTLOADER_ENABLE 0xC5
#define SET_CCFG_BL_CONFIG_BL_LEVEL 0x00
#if defined(CCFG_CONF_BL_PIN_NUMBER)
#define SET_CCFG_BL_CONFIG_BL_PIN_NUMBER CCFG_CONF_BL_PIN_NUMBER
#endif
#define SET_CCFG_BL_CONFIG_BL_ENABLE 0xC5
#endif /* CCFG_CONF_ROM_BOOTLOADER_ENABLE */
/** @} */
#include <ti/devices/DeviceFamily.h>
#include DeviceFamily_constructPath(startup_files/ccfg.c)

View File

@ -0,0 +1,65 @@
##
## Author: Johannes Bruder
## License: See LICENSE.TXT file included in the project
##
## Find TI's SimpleLink CC13X0 SDK
##
include(FindPackageHandleStandardArgs)
find_path(SimpleLinkCC13X0SDK_DEVICES_DIR NAMES "DeviceFamily.h" PATH_SUFFIXES "source/ti/devices")
# Add suffix when looking for libraries
list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES "am3g" "lib")
# Find TI's drivers lib
find_library(SimpleLinkCC13X0SDK_drivers_cc13x0_LIBRARY
NAMES drivers_cc13x0.am3g
PATH_SUFFIXES "source/ti/drivers/lib"
)
# Find cc13x0 radio single mode lib
find_library(SimpleLinkCC13X0SDK_rf_singleMode_cc13x0_LIBRARY
NAMES rf_singleMode_cc13x0.am3g
PATH_SUFFIXES "source/ti/drivers/rf/lib"
)
# Find cc13x0 radio multi mode lib
#find_library(SimpleLinkCC13X0SDK_rf_multiMode_cc13x0_LIBRARY
# NAMES rf_multiMode_cc13x0.am3g
# PATH_SUFFIXES "source/ti/drivers/rf/lib"
#)
# Find driver porting layer (NoRTOS) lib
find_library(SimpleLinkCC13X0SDK_dpl_cc13x0_LIBRARY
NAMES nortos_cc13x0.am3g
PATH_SUFFIXES "kernel/nortos/lib"
)
# Find Driverlib
find_library(SimpleLinkCC13X0SDK_driverlib_LIBRARY
NAMES driverlib.lib
PATH_SUFFIXES "source/ti/devices/cc13x0/driverlib/bin/gcc"
)
set(SimpleLinkCC13X0SDK_INCLUDE_DIRS
"${SimpleLinkCC13X0SDK_DEVICES_DIR}/../.."
"${SimpleLinkCC13X0SDK_DEVICES_DIR}/../../../kernel/nortos"
)
message("Content of SimpleLinkCC13X0SDK_INCLUDE_DIRS " ${SimpleLinkCC13X0SDK_INCLUDE_DIRS})
# Handle arguments and set SimpleLinkCC13X0SDK_FOUND to TRUE if all listed variables are TRUE
find_package_handle_standard_args(SimpleLinkCC13X0SDK DEFAULT_MSG
SimpleLinkCC13X0SDK_drivers_cc13x0_LIBRARY
SimpleLinkCC13X0SDK_rf_singleMode_cc13x0_LIBRARY
SimpleLinkCC13X0SDK_dpl_cc13x0_LIBRARY
SimpleLinkCC13X0SDK_driverlib_LIBRARY
SimpleLinkCC13X0SDK_INCLUDE_DIRS
)
set(SimpleLinkCC13X0SDK_LIBRARIES
${SimpleLinkCC13X0SDK_drivers_cc13x0_LIBRARY}
${SimpleLinkCC13X0SDK_rf_singleMode_cc13x0_LIBRARY}
${SimpleLinkCC13X0SDK_dpl_cc13x0_LIBRARY}
${SimpleLinkCC13X0SDK_driverlib_LIBRARY}
)

View File

@ -0,0 +1,23 @@
##
## Author: Johannes Bruder
## License: See LICENSE.TXT file included in the project
##
##
## Find TI's xdctools
##
include(FindPackageHandleStandardArgs)
# Find the path to xdc headers
find_path(Xdctools_HEADER_DIR NAMES "std.h" PATH_SUFFIXES "packages/xdc")
message("Content of Xdctools_HEADER_DIR:" ${Xdctools_HEADER_DIR})
# Set according include path
set(Xdctools_INCLUDE_DIR "${Xdctools_HEADER_DIR}/../../packages")
message("Content of Xdctools_INCLUDE_DIR:" ${Xdctools_INCLUDE_DIR})
find_package_handle_standard_args(Xdctools DEFAULT_MSG
Xdctools_INCLUDE_DIR)
set(Xdctools_INCLUDE_DIRS ${Xdctools_INCLUDE_DIR})

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Johannes Bruder
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:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
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.

View File

@ -0,0 +1,45 @@
# About
The aim of this project is to provide a software development environment based on CMake, GCC and openOCD for several bare metal ARM platforms.
# Requirements
* CMake >= 3.6
* GCC arm-none-abi
* Linux Arch: `arm-none-eabi-gcc` `arm-none-eabi-binutils` `arm-none-eabi-newlib`
* Ubuntu packages: Since the package of the official repo is very old it is recommended to use this [PPA](https://launchpad.net/~team-gcc-arm-embedded/+archive/ubuntu/ppa)
# Features
* General CMake Toolchain file for arm-none-eabi-gcc
* Target specific extension of Toolchain file
# Usage
Add this project as git submodule to your repository:
git submodule add https://github.com/jobroe/cmake-arm-embedded.git cmake
Set the Linker Script and include the target specific cmake module in your project CMakeLists.txt e.g.:
```
set(LINKER_SCRIPT "${Gecko_SDK_PATH}/platform/Device/SiliconLabs/EFR32MG12P/Source/GCC/efr32mg12p.ld")
include(efr32mg)
```
Go to your project root directory, create build directory and enter it:
mkdir build
cd build
run to configure:
cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm-none-eabi.cmake ..
and finally to build:
make

View File

@ -0,0 +1,36 @@
##
## Author: Johannes Bruder
## License: See LICENSE.TXT file included in the project
##
## CMake arm-none-eabi binutils integration and helper functions
##
#---------------------------------------------------------------------------------------
# Set tools
#---------------------------------------------------------------------------------------
set(CMAKE_OBJCOPY ${TOOLCHAIN_BIN_DIR}/${TOOLCHAIN}-objcopy${TOOLCHAIN_EXT})
set(CMAKE_OBJDUMP ${TOOLCHAIN_BIN_DIR}/${TOOLCHAIN}-objdump${TOOLCHAIN_EXT})
set(CMAKE_SIZE ${TOOLCHAIN_BIN_DIR}/${TOOLCHAIN}-size${TOOLCHAIN_EXT})
#---------------------------------------------------------------------------------------
# Prints the section sizes
#---------------------------------------------------------------------------------------
function(print_section_sizes TARGET)
add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_SIZE} ${TARGET})
endfunction()
#---------------------------------------------------------------------------------------
# Creates output in hex format
#---------------------------------------------------------------------------------------
function(create_hex_output TARGET)
add_custom_target(${TARGET}.hex ALL DEPENDS ${TARGET} COMMAND ${CMAKE_OBJCOPY} -Oihex ${TARGET} ${TARGET}.hex)
endfunction()
#---------------------------------------------------------------------------------------
# Creates output in binary format
#---------------------------------------------------------------------------------------
function(create_bin_output TARGET)
add_custom_target(${TARGET}.bin ALL DEPENDS ${TARGET} COMMAND ${CMAKE_OBJCOPY} -Obinary ${TARGET} ${TARGET}.bin)
endfunction()

View File

@ -0,0 +1,26 @@
##
## Author: Johannes Bruder
## License: See LICENSE.TXT file included in the project
##
##
## CC13xx target specific CMake file
##
if(NOT DEFINED LINKER_SCRIPT)
message(FATAL_ERROR "No linker script defined")
endif(NOT DEFINED LINKER_SCRIPT)
message("Linker script: ${LINKER_SCRIPT}")
#---------------------------------------------------------------------------------------
# Set target specific compiler/linker flags
#---------------------------------------------------------------------------------------
# Object build Options
set(OBJECT_GEN_FLAGS "-mcpu=cortex-m3")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OBJECT_GEN_FLAGS}" CACHE INTERNAL "C Compiler options")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OBJECT_GEN_FLAGS}" CACHE INTERNAL "C++ Compiler options")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${OBJECT_GEN_FLAGS}" CACHE INTERNAL "ASM Compiler options")
# Linker flags
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -eresetISR -T${LINKER_SCRIPT} -nostartfiles" CACHE INTERNAL "Linker options")

View File

@ -0,0 +1,30 @@
##
## Author: Johannes Bruder
## License: See LICENSE.TXT file included in the project
##
##
## EFR32MG target specific CMake file
##
if(NOT DEFINED LINKER_SCRIPT)
message(FATAL_ERROR "No linker script defined")
endif(NOT DEFINED LINKER_SCRIPT)
message("Linker script: ${LINKER_SCRIPT}")
#---------------------------------------------------------------------------------------
# Set target specific compiler/linker flags
#---------------------------------------------------------------------------------------
# Object build options
# -mcpu=cortex-m4 SepcifiesTarget ARM processor.
# -mfpu=fpv4-sp-d16 Specifies floating-point hardware.
# -mfloat-abi=softfp Allows the generation of code using hardware floating-point instructions, but still uses the soft-float calling conventions.
set(OBJECT_GEN_FLAGS "-mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OBJECT_GEN_FLAGS}" CACHE INTERNAL "C Compiler options")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${OBJECT_GEN_FLAGS}" CACHE INTERNAL "C++ Compiler options")
set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS} ${OBJECT_GEN_FLAGS}" CACHE INTERNAL "ASM Compiler options")
# Linker flags
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -T${LINKER_SCRIPT}" CACHE INTERNAL "Linker options")

View File

@ -0,0 +1,40 @@
##
## Author: Johannes Bruder
## License: See LICENSE.TXT file included in the project
##
## Collection of functions to generate different GDB debugging configurations
##
# Get the path of this module
set(CURRENT_MODULE_DIR ${CMAKE_CURRENT_LIST_DIR})
#---------------------------------------------------------------------------------------
# Set tools
#---------------------------------------------------------------------------------------
set(GDB_BIN ${TOOLCHAIN_BIN_DIR}/${TOOLCHAIN}-gdb${TOOLCHAIN_EXT})
if(NOT OPENOCD_BIN)
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Linux)
set(OPENOCD_BIN "/usr/bin/openocd" CACHE STRING "OpenOCD executable")
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin)
set(OPENOCD_BIN "/usr/local/bin/openocd" CACHE STRING "OpenOCD executable")
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
set(OPENOCD_BIN "C:/openocd/bin/openocd.exe" CACHE STRING "OpenOCD executable")
endif()
endif()
#---------------------------------------------------------------------------------------
# Generates a GDB run script for debugging with STLINKv1/v2/v2-1 programmer and texane stlink tool.
# More infos check: https://github.com/texane/stlink
#---------------------------------------------------------------------------------------
function(generate_run_gdb_stlink TARGET)
get_target_property( TARGET_NAME ${TARGET} NAME )
configure_file(${CURRENT_MODULE_DIR}/stlink-run.gdb.in ${PROJECT_BINARY_DIR}/stlink-run.gdb @ONLY)
endfunction()
#---------------------------------------------------------------------------------------
# Generates a GDB run script for debugging with any supported programmer and openOCD.
#---------------------------------------------------------------------------------------
function(generate_run_gdb_openocd TARGET)
get_target_property( TARGET_NAME ${TARGET} NAME )
configure_file(${CURRENT_MODULE_DIR}/openocd-run.gdb.in ${PROJECT_BINARY_DIR}/openocd-run.gdb @ONLY)
endfunction()

View File

@ -0,0 +1,5 @@
file @TARGET_NAME@
target extended-remote localhost:3333
monitor reset halt
load
thbreak main

View File

@ -0,0 +1,6 @@
file @TARGET_NAME@
target extended localhost:4242
monitor reset halt
shell sleep 1
load
thbreak main

View File

@ -0,0 +1,104 @@
##
## Author: Johannes Bruder
## License: See LICENSE.TXT file included in the project
##
##
## CMake arm-none-eabi toolchain file
##
# Append current directory to CMAKE_MODULE_PATH for making device specific cmake modules visible
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
# Target definition
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR ARM)
#---------------------------------------------------------------------------------------
# Set toolchain paths
#---------------------------------------------------------------------------------------
set(TOOLCHAIN arm-none-eabi)
if(NOT DEFINED TOOLCHAIN_PREFIX)
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Linux)
set(TOOLCHAIN_PREFIX "/usr")
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin)
set(TOOLCHAIN_PREFIX "/usr/local")
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
message(STATUS "Please specify the TOOLCHAIN_PREFIX !\n For example: -DTOOLCHAIN_PREFIX=\"C:/Program Files/GNU Tools ARM Embedded\" ")
else()
set(TOOLCHAIN_PREFIX "/usr")
message(STATUS "No TOOLCHAIN_PREFIX specified, using default: " ${TOOLCHAIN_PREFIX})
endif()
endif()
set(TOOLCHAIN_BIN_DIR ${TOOLCHAIN_PREFIX}/bin)
set(TOOLCHAIN_INC_DIR ${TOOLCHAIN_PREFIX}/${TOOLCHAIN}/include)
set(TOOLCHAIN_LIB_DIR ${TOOLCHAIN_PREFIX}/${TOOLCHAIN}/lib)
# Set system depended extensions
if(WIN32)
set(TOOLCHAIN_EXT ".exe" )
else()
set(TOOLCHAIN_EXT "" )
endif()
# Perform compiler test with static library
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
#---------------------------------------------------------------------------------------
# Set compiler/linker flags
#---------------------------------------------------------------------------------------
# Object build options
# -O0 No optimizations, reduce compilation time and make debugging produce the expected results.
# -mthumb Generat thumb instructions.
# -fno-builtin Do not use built-in functions provided by GCC.
# -Wall Print only standard warnings, for all use Wextra
# -ffunction-sections Place each function item into its own section in the output file.
# -fdata-sections Place each data item into its own section in the output file.
# -fomit-frame-pointer Omit the frame pointer in functions that dont need one.
# -mabi=aapcs Defines enums to be a variable sized type.
set(OBJECT_GEN_FLAGS "-O0 -mthumb -fno-builtin -Wall -ffunction-sections -fdata-sections -fomit-frame-pointer -mabi=aapcs")
set(CMAKE_C_FLAGS "${OBJECT_GEN_FLAGS} -std=gnu99 " CACHE INTERNAL "C Compiler options")
set(CMAKE_CXX_FLAGS "${OBJECT_GEN_FLAGS} -std=c++11 -fno-threadsafe-statics -fno-rtti -fno-exceptions" CACHE INTERNAL "C++ Compiler options")
set(CMAKE_ASM_FLAGS "${OBJECT_GEN_FLAGS} -x assembler-with-cpp " CACHE INTERNAL "ASM Compiler options")
# -Wl,--gc-sections Perform the dead code elimination.
# --specs=nano.specs Link with newlib-nano.
# --specs=nosys.specs No syscalls, provide empty implementations for the POSIX system calls.
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--gc-sections --specs=nano.specs --specs=nosys.specs -mthumb -mabi=aapcs -Wl,-Map=${CMAKE_PROJECT_NAME}.map" CACHE INTERNAL "Linker options")
#---------------------------------------------------------------------------------------
# Set debug/release build configuration Options
#---------------------------------------------------------------------------------------
# Options for DEBUG build
# -Og Enables optimizations that do not interfere with debugging.
# -g Produce debugging information in the operating systems native format.
set(CMAKE_C_FLAGS_DEBUG "-O0 -g -gstrict-dwarf" CACHE INTERNAL "C Compiler options for debug build type")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -gstrict-dwarf" CACHE INTERNAL "C++ Compiler options for debug build type")
set(CMAKE_ASM_FLAGS_DEBUG "-g -gstrict-dwarf" CACHE INTERNAL "ASM Compiler options for debug build type")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "" CACHE INTERNAL "Linker options for debug build type")
# Options for RELEASE build
# -Os Optimize for size. -Os enables all -O2 optimizations.
# -flto Runs the standard link-time optimizer.
set(CMAKE_C_FLAGS_RELEASE "-Os -flto" CACHE INTERNAL "C Compiler options for release build type")
set(CMAKE_CXX_FLAGS_RELEASE "-Os -flto" CACHE INTERNAL "C++ Compiler options for release build type")
set(CMAKE_ASM_FLAGS_RELEASE "" CACHE INTERNAL "ASM Compiler options for release build type")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-flto" CACHE INTERNAL "Linker options for release build type")
#---------------------------------------------------------------------------------------
# Set compilers
#---------------------------------------------------------------------------------------
set(CMAKE_C_COMPILER ${TOOLCHAIN_BIN_DIR}/${TOOLCHAIN}-gcc${TOOLCHAIN_EXT} CACHE INTERNAL "C Compiler")
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_BIN_DIR}/${TOOLCHAIN}-g++${TOOLCHAIN_EXT} CACHE INTERNAL "C++ Compiler")
set(CMAKE_ASM_COMPILER ${TOOLCHAIN_BIN_DIR}/${TOOLCHAIN}-gcc${TOOLCHAIN_EXT} CACHE INTERNAL "ASM Compiler")
set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN_PREFIX}/${${TOOLCHAIN}} ${CMAKE_PREFIX_PATH})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

View File

@ -0,0 +1,34 @@
#include "knx.h"
#include <cstdio>
#include "knx_wrapper.h"
KnxFacade<CC1310Platform, Bau07B0> *pKnx = nullptr;
void setup()
{
pKnx = new KnxFacade<CC1310Platform, Bau07B0>;
KnxFacade<CC1310Platform, Bau07B0> &knx = *pKnx;
knx.platform().earlyInit();
knx.readMemory();
if (knx.induvidualAddress() == 0)
knx.progMode(true);
if (knx.configured())
{
printf("configured %d\n", knx.paramByte(5));
}
else
println("not configured");
knx.start();
}
void loop()
{
KnxFacade<CC1310Platform, Bau07B0> &knx = *pKnx;
knx.loop();
}

View File

@ -0,0 +1,12 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
extern void setup();
extern void loop();
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,117 @@
/*
* Copyright (c) 2017-2019, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* ======== main_nortos.c ========
*/
#include <stdint.h>
#include <stddef.h>
#include "SEGGER_RTT.h"
#include <NoRTOS.h>
/* Example/Board Header files */
#include <ti/drivers/Board.h>
#include <ti/drivers/NVS.h>
#include <ti/drivers/UART.h>
#include <ti/drivers/pin/PINCC26XX.h>
#include <ti/devices/DeviceFamily.h>
#include DeviceFamily_constructPath(driverlib/driverlib_release.h)
#include DeviceFamily_constructPath(driverlib/sys_ctrl.h)
#include DeviceFamily_constructPath(driverlib/vims.h)
#include "knx_wrapper.h"
#define USE_32KHZ_XTAL_AS_LF_CLOCK false
extern void *mainThread(void *arg0);
void __cxa_pure_virtual()
{
SEGGER_RTT_WriteString(0, "Pure virtual method called! System halted.\r\n");
while (1);
}
/*
* ======== mainThread ========
*/
void *mainThread(void *arg0)
{
setup();
/* Loop forever echoing */
while (1) {
loop();
}
}
/*
* ======== main ========
*/
int main(void)
{
SEGGER_RTT_ConfigUpBuffer(0, NULL, NULL, 0, SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL);
SEGGER_RTT_WriteString(0, "System startup.\r\n");
DRIVERLIB_ASSERT_CURR_RELEASE();
// Enable flash cache
VIMSModeSet(VIMS_BASE, VIMS_MODE_ENABLED);
// Configure round robin arbitration and prefetching
VIMSConfigure(VIMS_BASE, true, true);
// set LF clock source needed for low power deepSleep() function further below
//OSCClockSourceSet(OSC_SRC_CLK_LF, USE_32KHZ_XTAL_AS_LF_CLOCK ? OSC_XOSC_LF : OSC_RCOSC_LF);
// Call driver init functions
Board_init();
// TI Drivers init before starting NoRTOS/RTOS
UART_init();
NVS_init();
//I2C_init();
//SPI_init();
//TRNG_init();
// Start NoRTOS
NoRTOS_start();
// Call mainThread function
mainThread(NULL);
// Shall not be reached
while (1) {}
}

View File

@ -0,0 +1,308 @@
/*
* Copyright (c) 2017, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//*****************************************************************************
//
// Check if compiler is GNU Compiler
//
//*****************************************************************************
#if !(defined(__GNUC__))
#error "startup_cc13xx_cc26xx_gcc.c: Unsupported compiler!"
#endif
#include <string.h>
#include <ti/devices/DeviceFamily.h>
#include DeviceFamily_constructPath(inc/hw_types.h)
#include DeviceFamily_constructPath(driverlib/interrupt.h)
#include DeviceFamily_constructPath(driverlib/setup.h)
//*****************************************************************************
//
// Forward declaration of the default fault handlers.
//
//*****************************************************************************
void resetISR(void);
static void nmiISR(void);
static void faultISR(void);
static void defaultHandler(void);
static void busFaultHandler(void);
//*****************************************************************************
//
// External declaration for the reset handler that is to be called when the
// processor is started
//
//*****************************************************************************
extern void _c_int00(void);
//*****************************************************************************
//
// The entry point for the application.
//
//*****************************************************************************
extern int main(void);
//*****************************************************************************
//
// linker variable that marks the top of stack.
//
//*****************************************************************************
extern unsigned long _stack_end;
//*****************************************************************************
//
// The vector table. Note that the proper constructs must be placed on this to
// ensure that it ends up at physical address 0x0000.0000.
//
//*****************************************************************************
__attribute__ ((section(".resetVecs"))) __attribute__ ((used))
static void (* const resetVectors[16])(void) =
{
(void (*)(void))((uint32_t)&_stack_end),
// The initial stack pointer
resetISR, // The reset handler
nmiISR, // The NMI handler
faultISR, // The hard fault handler
defaultHandler, // The MPU fault handler
busFaultHandler, // The bus fault handler
defaultHandler, // The usage fault handler
0, // Reserved
0, // Reserved
0, // Reserved
0, // Reserved
defaultHandler, // SVCall handler
defaultHandler, // Debug monitor handler
0, // Reserved
defaultHandler, // The PendSV handler
defaultHandler // The SysTick handler
};
__attribute__ ((section(".ramVecs")))
static unsigned long ramVectors[50];
//*****************************************************************************
//
// The following are arrays of pointers to constructor functions that need to
// be called during startup to initialize global objects.
//
//*****************************************************************************
extern void (*__init_array_start []) (void);
extern void (*__init_array_end []) (void);
//*****************************************************************************
//
// The following global variable is required for C++ support.
//
//*****************************************************************************
void * __dso_handle = (void *) &__dso_handle;
//*****************************************************************************
//
// The following are constructs created by the linker, indicating where the
// the "data" and "bss" segments reside in memory. The initializers for the
// for the "data" segment resides immediately following the "text" segment.
//
//*****************************************************************************
extern uint32_t __bss_start__, __bss_end__;
extern uint32_t __data_load__, __data_start__, __data_end__;
//
//*****************************************************************************
//
// Initialize the .data and .bss sections and copy the first 16 vectors from
// the read-only/reset table to the runtime RAM table. Fill the remaining
// vectors with a stub. This vector table will be updated at runtime.
//
//*****************************************************************************
//
void localProgramStart(void)
{
uint32_t * bs;
uint32_t * be;
uint32_t * dl;
uint32_t * ds;
uint32_t * de;
uint32_t count;
uint32_t i;
#if defined (__ARM_ARCH_7EM__) && defined(__VFP_FP__) && !defined(__SOFTFP__)
volatile uint32_t * pui32Cpacr = (uint32_t *) 0xE000ED88;
/* Enable Coprocessor Access Control (CPAC) */
*pui32Cpacr |= (0xF << 20);
#endif
IntMasterDisable();
/* Final trim of device */
SetupTrimDevice();
/* initiailize .bss to zero */
bs = & __bss_start__;
be = & __bss_end__;
while (bs < be) {
*bs = 0;
bs++;
}
/* relocate the .data section */
dl = & __data_load__;
ds = & __data_start__;
de = & __data_end__;
if (dl != ds) {
while (ds < de) {
*ds = *dl;
dl++;
ds++;
}
}
/* Run any constructors */
count = (uint32_t)(__init_array_end - __init_array_start);
for (i = 0; i < count; i++) {
__init_array_start[i]();
}
/* Copy from reset vector table into RAM vector table */
memcpy(ramVectors, resetVectors, 16*4);
/* fill remaining vectors with default handler */
for (i=16; i < 50; i++) {
ramVectors[i] = (unsigned long)defaultHandler;
}
/* Call the application's entry point. */
main();
/* If we ever return signal Error */
faultISR();
}
//*****************************************************************************
//
// This is the code that gets called when the processor first starts execution
// following a reset event. Only the absolutely necessary set is performed,
// after which the application supplied entry() routine is called. Any fancy
// actions (such as making decisions based on the reset cause register, and
// resetting the bits in that register) are left solely in the hands of the
// application.
//
//*****************************************************************************
void __attribute__((naked)) resetISR(void)
{
__asm__ __volatile__ (
" movw r0, #:lower16:resetVectors\n"
" movt r0, #:upper16:resetVectors\n"
" ldr r0, [r0]\n"
" mov sp, r0\n"
" bl localProgramStart"
);
}
//*****************************************************************************
//
// This is the code that gets called when the processor receives a NMI. This
// simply enters an infinite loop, preserving the system state for examination
// by a debugger.
//
//*****************************************************************************
static void
nmiISR(void)
{
/* Enter an infinite loop. */
while(1)
{
}
}
//*****************************************************************************
//
// This is the code that gets called when the processor receives a fault
// interrupt. This simply enters an infinite loop, preserving the system state
// for examination by a debugger.
//
//*****************************************************************************
static void
faultISR(void)
{
/* Enter an infinite loop. */
while(1)
{
}
}
//*****************************************************************************
//
// This is the code that gets called when the processor receives an unexpected
// interrupt. This simply enters an infinite loop, preserving the system state
// for examination by a debugger.
//
//*****************************************************************************
static void
busFaultHandler(void)
{
/* Enter an infinite loop. */
while(1)
{
}
}
//*****************************************************************************
//
// This is the code that gets called when the processor receives an unexpected
// interrupt. This simply enters an infinite loop, preserving the system state
// for examination by a debugger.
//
//*****************************************************************************
static void
defaultHandler(void)
{
/* Enter an infinite loop. */
while(1)
{
}
}
//*****************************************************************************
//
// This function is called by __libc_fini_array which gets called when exit()
// is called. In order to support exit(), an empty _fini() stub function is
// required.
//
//*****************************************************************************
void _fini(void)
{
/* Function body left empty intentionally */
}

563
src/cc1310_platform.cpp Normal file
View File

@ -0,0 +1,563 @@
#include <cstdio>
#include <cstdarg>
#include <cstring>
#include <cmath>
#include <ti/devices/DeviceFamily.h>
#include DeviceFamily_constructPath(driverlib/sys_ctrl.h)
#include "SEGGER_RTT.h"
#include "Board.h"
#include "knx/bits.h"
#include "cc1310_platform.h"
#define printf(args...) (SEGGER_RTT_printf(0, args))
volatile uint32_t CC1310Platform::msCounter = 0;
void CC1310Platform::clk0Fxn(uintptr_t arg0)
{
msCounter++;
}
void CC1310Platform::msClockInit()
{
ClockP_Params clkParams;
ClockP_Params_init(&clkParams);
clkParams.period = 1000/ClockP_tickPeriod;
clkParams.startFlag = true;
ClockP_construct(&clk0Struct, (ClockP_Fxn)CC1310Platform::clk0Fxn, 1000/ClockP_tickPeriod, &clkParams);
clk0Handle = ClockP_handle(&clk0Struct);
}
void CC1310Platform::InitUART()
{
UART_Params uartParams;
UART_Params_init(&uartParams);
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.baudRate = 115200;
uart = UART_open(Board_UART0, &uartParams);
if (uart == NULL)
{
while(true)
{}
}
}
void CC1310Platform::InitNVS()
{
NVS_Params nvsParams;
NVS_Params_init(&nvsParams);
nvsHandle = NVS_open(Board_NVSINTERNAL, &nvsParams);
if (nvsHandle == NULL)
{
print("NVS_open() failed.\n");
return;
}
NVS_Attrs attrs;
NVS_getAttrs(nvsHandle, &attrs);
printf("NVS flash size: %d\r\n", attrs.regionSize);
printf("NVS flash sector size: %d\r\n", attrs.sectorSize);
}
CC1310Platform::CC1310Platform()
{
// build serialNumber from IEEE MAC Address (MAC is 8 bytes, serialNumber 6 bytes only)
*(uint32_t*)(_serialNumber+2) = HWREG(FCFG1_BASE+FCFG1_O_MAC_15_4_0) ^ HWREG(FCFG1_BASE+FCFG1_O_MAC_15_4_1); // make a 6 byte hash from 8 bytes
}
CC1310Platform::~CC1310Platform()
{
}
void CC1310Platform::earlyInit()
{
// Init UART
InitUART();
// tick Period on this controller 10us so we use our own millisecond clock
msClockInit();
// Init flash
InitNVS();
}
uint8_t* CC1310Platform::getEepromBuffer(uint16_t size)
{
if(size > EEPROM_EMULATION_SIZE)
fatalError();
#if 1
NVS_read(nvsHandle, 0, (void *) _NVS_buffer, size);
for (int i=0; i<size; i++)
{
if (_NVS_buffer[i] != 0)
{
return _NVS_buffer;
}
}
#endif
memset(_NVS_buffer, 0xff, size);
return _NVS_buffer;
}
void CC1310Platform::commitToEeprom()
{
println("CC1310Platform::commitToEeprom() ...");
#if 1
int_fast16_t res = NVS_write(nvsHandle, 0, (void *)_NVS_buffer, EEPROM_EMULATION_SIZE, NVS_WRITE_ERASE | NVS_WRITE_POST_VERIFY);
if (res != NVS_STATUS_SUCCESS)
{
printf("Error writing to NVS, ret = %d\n", res);
}
else
{
println("NVS successfully written\n");
}
delay(500);
#endif
}
void CC1310Platform::restart()
{
println("System restart.");
SysCtrlSystemReset();
}
void CC1310Platform::fatalError()
{
println("A fatal error occured. Stopped.");
while(true)
{}
//restart();
}
uint32_t CC1310Platform::millis()
{
return msCounter;
}
void sleep(uint32_t sec)
{
ClockP_sleep(sec);
}
void usleep(uint32_t usec)
{
ClockP_usleep(usec);
}
uint32_t millis()
{
return CC1310Platform::millis();
// we use our own ms clock because the Os tick counter has counts 10us ticks and following calculation would not wrap correctly at 32bit boundary
//return Clock_getTicks() * (uint64_t) Clock_tickPeriod / 1000; // rtos
//return ClockP_getTicks( * (uint64_t) Clock_tickPeriod / 1000); //nortos
}
void delay(uint32_t ms)
{
ClockP_usleep(ms * 1000);
//sleep(ms * (1000 / ClockP_tickPeriod)); //rtos
//sleepTicks(millis * 1000ULL / ClockP_tickPeriod); //nortos
}
void delayMicroseconds (unsigned int howLong)
{
ClockP_usleep(howLong);
}
#if 0
/* Buffer size for string operations (e.g. snprintf())*/
#define MAX_STRBUF_SIZE 100
int UART_printf(const char * fmt, ...)
{
char s[MAX_STRBUF_SIZE];
va_list ap;
va_start(ap, fmt);
int n = vsnprintf(s, sizeof(s), fmt, ap);
va_end(ap);
if (uart)
{
UART_write(uart, s, strlen(s));
}
return n;
}
void print(const char* s)
{
if (uart)
{
UART_write(uart, s, strlen(s));
}
}
void print(int num, int base)
{
char s[MAX_STRBUF_SIZE];
if (base == HEX)
snprintf(s, sizeof(s),"%X", num);
else
snprintf(s, sizeof(s),"%d", num);
if (uart)
{
UART_write(uart, s, strlen(s));
}
}
#endif
/*
int printf(const char * fmt, ...)
{
char s[MAX_STRBUF_SIZE];
va_list ap;
va_start(ap, fmt);
int n = vsnprintf(s, sizeof(s), fmt, ap);
va_end(ap);
SEGGER_RTT_printf(0, s, strlen(s));
return n;
}
*/
void printUint64(uint64_t value, int base = DEC)
{
char buf[8 * sizeof(uint64_t) + 1];
char* str = &buf[sizeof(buf) - 1];
*str = '\0';
uint64_t n = value;
do {
char c = n % base;
n /= base;
*--str = c < 10 ? c + '0' : c + 'A' - 10;
} while (n > 0);
print(str);
}
void printFloat(double number, uint8_t digits)
{
if (std::isnan(number))
{
print("nan");
return;
}
if (std::isinf(number))
{
print("inf");
return;
}
if (number > 4294967040.0)
{
print ("ovf"); // constant determined empirically
return;
}
if (number <-4294967040.0)
{
print ("ovf"); // constant determined empirically
return;
}
// Handle negative numbers
if (number < 0.0)
{
print('-');
number = -number;
}
// Round correctly so that print(1.999, 2) prints as "2.00"
double rounding = 0.5;
for (uint8_t i=0; i<digits; ++i)
rounding /= 10.0;
number += rounding;
// Extract the integer part of the number and print it
unsigned long int_part = (unsigned long)number;
double remainder = number - (double)int_part;
print(int_part);
// Print the decimal point, but only if there are digits beyond
if (digits > 0)
{
print('.');
}
// Extract digits from the remainder one at a time
while (digits-- > 0)
{
remainder *= 10.0;
unsigned int toPrint = (unsigned int)(remainder);
print(toPrint);
remainder -= toPrint;
}
}
void print(const char* s)
{
printf("%s", s);
}
void print(char c)
{
printf("%c", c);
}
void print(unsigned char num)
{
print(num, DEC);
}
void print(unsigned char num, int base)
{
if (base == HEX)
printf("%X", num);
else
printf("%d", num);
}
void print(int num)
{
print(num, DEC);
}
void print(int num, int base)
{
if (base == HEX)
printf("%X", num);
else
printf("%d", num);
}
void print(unsigned int num)
{
print(num, DEC);
}
void print(unsigned int num, int base)
{
if (base == HEX)
printf("%X", num);
else
printf("%d", num);
}
void print(long num)
{
print(num, DEC);
}
void print(long num, int base)
{
if (base == HEX)
printf("%lX", num);
else
printf("%ld", num);
}
void print(unsigned long num)
{
print(num, DEC);
}
void print(unsigned long num, int base)
{
if (base == HEX)
printf("%lX", num);
else
printf("%ld", num);
}
void print(unsigned long long num)
{
printUint64(num);
}
void print(unsigned long long num, int base)
{
printUint64(num, base);
}
void print(double num)
{
printf("%f", num);
}
void println(const char* s)
{
printf("%s\n", s);
}
void println(char c)
{
printf("%c\n", c);
}
void println(unsigned char num)
{
println(num, DEC);
}
void println(unsigned char num, int base)
{
if (base == HEX)
printf("%X\n", num);
else
printf("%d\n", num);
}
void println(int num)
{
println(num, DEC);
}
void println(int num, int base)
{
if (base == HEX)
printf("%X\n", num);
else
printf("%d\n", num);
}
void println(unsigned int num)
{
println(num, DEC);
}
void println(unsigned int num, int base)
{
if (base == HEX)
printf("%X\n", num);
else
printf("%d\n", num);
}
void println(long num)
{
println(num, DEC);
}
void println(long num, int base)
{
if (base == HEX)
printf("%lX\n", num);
else
printf("%ld\n", num);
}
void println(unsigned long num)
{
println(num, DEC);
}
void println(unsigned long num, int base)
{
if (base == HEX)
printf("%lX\n", num);
else
printf("%ld\n", num);
}
void println(unsigned long long num)
{
printUint64(num);
println("");
}
void println(unsigned long long num, int base)
{
printUint64(num, base);
println("");
}
void println(double num)
{
printf("%f\n", num);
}
void println(double num, int places)
{
printf("%f\n", num);
}
void println(void)
{
printf("\n");
}
uint32_t digitalRead(uint32_t dwPin)
{
#if 0
if (dwPin == IOID_UNUSED)
return -1;
return GPIO_readDio(dwPin);
#endif
return -1;
}
void digitalWrite(unsigned long port, unsigned long value)
{
#if 0
if (port == IOID_UNUSED)
return;
GPIO_writeDio(port, value);
#endif
}
#define IOC_STD_INPUT (IOC_CURRENT_2MA | IOC_STRENGTH_AUTO | \
IOC_NO_IOPULL | IOC_SLEW_DISABLE | \
IOC_HYST_DISABLE | IOC_NO_EDGE | \
IOC_INT_DISABLE | IOC_IOMODE_NORMAL | \
IOC_NO_WAKE_UP | IOC_INPUT_ENABLE )
#define IOC_PULLUP_INPUT (IOC_CURRENT_2MA | IOC_STRENGTH_AUTO | \
IOC_IOPULL_UP | IOC_SLEW_DISABLE | \
IOC_HYST_DISABLE | IOC_NO_EDGE | \
IOC_INT_DISABLE | IOC_IOMODE_NORMAL | \
IOC_NO_WAKE_UP | IOC_INPUT_ENABLE )
void pinMode(unsigned long port, unsigned long value)
{
#if 0
if (port == IOID_UNUSED)
return;
switch (value) {
case OUTPUT:
//GPIO_setConfig(port, GPIO_CFG_OUT_STD);
IOCPortConfigureSet(port, IOC_PORT_GPIO, IOC_STD_OUTPUT);
//GPIO_setOutputEnableDio(IOID_7, GPIO_OUTPUT_ENABLE);
break;
case INPUT:
//GPIO_setConfig(port, GPIO_CFG_IN_NOPULL);
IOCPortConfigureSet(port, IOC_PORT_GPIO, IOC_STD_INPUT);
//GPIO_setOutputEnableDio(IOID_7, GPIO_OUTPUT_DISABLE);
case INPUT_PULLUP:
//GPIO_setConfig(port, GPIO_CFG_IN_PU);
IOCPortConfigureSet(port, IOC_PORT_GPIO, IOC_PULLUP_INPUT);
break;
}
#endif
}
typedef void (*IsrFuncPtr)();
void attachInterrupt(uint32_t pin, IsrFuncPtr callback, uint32_t mode)
{
#if 0
if (pin == IOID_UNUSED)
return;
println("attachInterrupt() - untested!");
//IOCPortConfigureSet(port, IOC_PORT_GPIO, IOC_PULLUP_INPUT|IOC_RISING_EDGE|IOC_INT_ENABLE);
IOCIOModeSet(pin, IOC_RISING_EDGE|IOC_INT_ENABLE);
IntRegister(INT_AON_GPIO_EDGE, callback);
IntEnable(INT_AON_GPIO_EDGE);
IntMasterEnable();
#endif
}

43
src/cc1310_platform.h Normal file
View File

@ -0,0 +1,43 @@
#pragma once
#include <ti/drivers/NVS.h>
#include <ti/drivers/UART.h>
#include <ti/drivers/dpl/ClockP.h>
#include "knx/platform.h"
#define EEPROM_EMULATION_SIZE 2048
class CC1310Platform : public Platform
{
public:
CC1310Platform();
virtual ~CC1310Platform();
void earlyInit();
// basic stuff
virtual void restart() final;
virtual void fatalError() final;
virtual uint8_t* getEepromBuffer(uint16_t size) final;
virtual void commitToEeprom() final;
static uint32_t millis();
private:
void msClockInit();
void InitUART();
void InitNVS();
static void clk0Fxn(uintptr_t arg0);
static volatile uint32_t msCounter;
uint8_t _serialNumber[6];
uint8_t _NVS_buffer[EEPROM_EMULATION_SIZE];
ClockP_Struct clk0Struct;
ClockP_Handle clk0Handle;
UART_Handle uart;
NVS_Handle nvsHandle;
};

View File

@ -142,7 +142,7 @@ BauSystemBDevice<--KnxFacade
knx-->Platform
@enduml
/** \page Classdiagramm KNX coupler
* \page Classdiagramm KNX coupler
* This diagramm shows the most important classes of a KNX coupler.
@startuml

View File

@ -5,7 +5,23 @@
#ifdef __linux__
#include <arpa/inet.h>
#else
#define getbyte(x,n) (*(((uint8_t*)&(x))+n))
#define htons(x) ( (getbyte(x,0)<<8) | getbyte(x,1) )
#define htonl(x) ( (getbyte(x,0)<<24) | (getbyte(x,1)<<16) | (getbyte(x,2)<<8) | getbyte(x,3) )
#define ntohs(x) htons(x)
#define ntohl(x) htonl(x)
#endif
#if ARDUINO_ARCH_SAMD || ARDUINO_ARCH_STM32
#include <Arduino.h>
#elif ARDUINO_ARCH_ESP8266
#include <Arduino.h>
#include <user_interface.h>
#elif ARDUINO_ARCH_ESP32
#include <Arduino.h>
#include <esp_wifi.h>
#else // Non-Arduino platforms
#define lowByte(val) ((val)&255)
#define highByte(val) (((val) >> ((sizeof(val) - 1) << 3)) & 255)
#define bitRead(val, bitno) (((val) >> (bitno)) & 1)
@ -33,22 +49,6 @@ void digitalWrite(uint32_t dwPin, uint32_t dwVal);
uint32_t digitalRead(uint32_t dwPin);
typedef void (*voidFuncPtr)(void);
void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode);
#elif ARDUINO_ARCH_SAMD || ARDUINO_ARCH_STM32
#include <Arduino.h>
#define getbyte(x,n) (*(((uint8_t*)&(x))+n))
#define htons(x) ( (getbyte(x,0)<<8) | getbyte(x,1) )
#define htonl(x) ( (getbyte(x,0)<<24) | (getbyte(x,1)<<16) | (getbyte(x,2)<<8) | getbyte(x,3) )
#define ntohs(x) htons(x)
#define ntohl(x) htonl(x)
#elif ARDUINO_ARCH_ESP8266
#include <Arduino.h>
#include <user_interface.h>
#elif ARDUINO_ARCH_ESP32
#include <Arduino.h>
#include <esp_wifi.h>
#endif
void print(const char[]);

View File

@ -3,7 +3,7 @@
#include "bits.h"
#ifndef KNX_FLASH_SIZE
# define KNX_FLASH_SIZE 8192
# define KNX_FLASH_SIZE 2048
#endif
Memory::Memory(Platform& platform, DeviceObject& deviceObject)

View File

@ -14,6 +14,7 @@ class Platform
{
public:
virtual ~Platform() {}
// ip config
virtual uint32_t currentIpAddress();
virtual uint32_t currentSubnetMask();

View File

@ -42,6 +42,8 @@
#endif
#elif __linux__
// no predefined global instance
#else // Non-Arduino platforms
// no predefined global instance
#endif
#ifndef ICACHE_RAM_ATTR
@ -49,7 +51,10 @@
#endif
ICACHE_RAM_ATTR void buttonUp()
{
#ifndef __linux__
#if !defined(__linux__) && (defined(ARDUINO_ARCH_STM32) || \
defined(ARDUINO_ARCH_ESP32) || \
defined(ARDUINO_ARCH_ESP8266) || \
defined(ARDUINO_ARCH_SAMD))
static uint32_t lastpressed=0;
if (millis() - lastpressed > 200){
knx._toogleProgMode = true;

View File

@ -20,7 +20,7 @@
#elif ARDUINO_ARCH_STM32
#include "stm32_platform.h"
#include "knx/bau07B0.h"
#else
#elif __linux__
#define LED_BUILTIN 0
#include "linux_platform.h"
#include "knx/bau57B0.h"
@ -28,6 +28,14 @@
#include "knx/bau07B0.h"
#include "knx/bau091A.h"
#include "knx/bau2920.h"
#else
#define LED_BUILTIN 0
#include "cc1310_platform.h"
#include "knx/bau57B0.h"
#include "knx/bau27B0.h"
#include "knx/bau07B0.h"
#include "knx/bau091A.h"
#include "knx/bau2920.h"
#endif
void buttonUp();
@ -359,4 +367,6 @@ template <class P, class B> class KnxFacade : private SaveRestore
#endif
#elif __linux__
// no predefined global instance
#else // Non-Arduino platforms
// no predefined global instance
#endif