├── .gitignore ├── README.md ├── empty_peripheral_template_blog_adc ├── Eclipse │ ├── .cproject │ ├── .project │ └── makefile.targets └── src │ ├── config │ ├── da1458x_config_advanced.h │ ├── da1458x_config_basic.h │ ├── user_callback_config.h │ ├── user_config.h │ ├── user_modules_config.h │ ├── user_periph_setup.h │ └── user_profiles_config.h │ ├── custom_profile │ ├── user_custs1_def.c │ ├── user_custs1_def.h │ ├── user_custs_config.c │ └── user_custs_config.h │ ├── platform │ └── user_periph_setup.c │ ├── user_empty_peripheral_template.c │ └── user_empty_peripheral_template.h ├── empty_peripheral_template_blog_gpio ├── Eclipse │ ├── .cproject │ ├── .project │ └── makefile.targets └── src │ ├── config │ ├── da1458x_config_advanced.h │ ├── da1458x_config_basic.h │ ├── user_callback_config.h │ ├── user_config.h │ ├── user_modules_config.h │ ├── user_periph_setup.h │ └── user_profiles_config.h │ ├── custom_profile │ ├── user_custs1_def.c │ ├── user_custs1_def.h │ ├── user_custs_config.c │ └── user_custs_config.h │ ├── platform │ └── user_periph_setup.c │ ├── user_empty_peripheral_template.c │ └── user_empty_peripheral_template.h ├── empty_peripheral_template_blog_i2c ├── Eclipse │ ├── .cproject │ ├── .project │ └── makefile.targets └── src │ ├── config │ ├── da1458x_config_advanced.h │ ├── da1458x_config_basic.h │ ├── user_callback_config.h │ ├── user_config.h │ ├── user_modules_config.h │ ├── user_periph_setup.h │ └── user_profiles_config.h │ ├── custom_profile │ ├── user_custs1_def.c │ ├── user_custs1_def.h │ ├── user_custs_config.c │ └── user_custs_config.h │ ├── platform │ └── user_periph_setup.c │ ├── user_empty_peripheral_template.c │ └── user_empty_peripheral_template.h ├── empty_peripheral_template_blog_interrupts ├── Eclipse │ ├── .cproject │ ├── .project │ └── makefile.targets └── src │ ├── config │ ├── da1458x_config_advanced.h │ ├── da1458x_config_basic.h │ ├── user_callback_config.h │ ├── user_config.h │ ├── user_modules_config.h │ ├── user_periph_setup.h │ └── user_profiles_config.h │ ├── custom_profile │ ├── user_custs1_def.c │ ├── user_custs1_def.h │ ├── user_custs_config.c │ └── user_custs_config.h │ ├── lsm6ds3_reg.c │ ├── lsm6ds3_reg.h │ ├── platform │ └── user_periph_setup.c │ ├── user_empty_peripheral_template.c │ └── user_empty_peripheral_template.h ├── empty_peripheral_template_blog_pwm ├── Eclipse │ ├── .cproject │ ├── .project │ └── makefile.targets └── src │ ├── config │ ├── da1458x_config_advanced.h │ ├── da1458x_config_basic.h │ ├── user_callback_config.h │ ├── user_config.h │ ├── user_modules_config.h │ ├── user_periph_setup.h │ └── user_profiles_config.h │ ├── custom_profile │ ├── user_custs1_def.c │ ├── user_custs1_def.h │ ├── user_custs_config.c │ └── user_custs_config.h │ ├── platform │ └── user_periph_setup.c │ ├── user_empty_peripheral_template.c │ └── user_empty_peripheral_template.h ├── empty_peripheral_template_blog_spi ├── Eclipse │ ├── .cproject │ ├── .project │ └── makefile.targets └── src │ ├── config │ ├── da1458x_config_advanced.h │ ├── da1458x_config_basic.h │ ├── user_callback_config.h │ ├── user_config.h │ ├── user_modules_config.h │ ├── user_periph_setup.h │ └── user_profiles_config.h │ ├── custom_profile │ ├── user_custs1_def.c │ ├── user_custs1_def.h │ ├── user_custs_config.c │ └── user_custs_config.h │ ├── platform │ └── user_periph_setup.c │ ├── user_empty_peripheral_template.c │ └── user_empty_peripheral_template.h ├── empty_peripheral_template_blog_timer ├── Eclipse │ ├── .cproject │ ├── .project │ └── makefile.targets └── src │ ├── config │ ├── da1458x_config_advanced.h │ ├── da1458x_config_basic.h │ ├── user_callback_config.h │ ├── user_config.h │ ├── user_modules_config.h │ ├── user_periph_setup.h │ └── user_profiles_config.h │ ├── custom_profile │ ├── user_custs1_def.c │ ├── user_custs1_def.h │ ├── user_custs_config.c │ └── user_custs_config.h │ ├── platform │ └── user_periph_setup.c │ ├── user_empty_peripheral_template.c │ └── user_empty_peripheral_template.h └── empty_peripheral_template_blog_uart ├── Eclipse ├── .cproject ├── .project └── makefile.targets └── src ├── config ├── da1458x_config_advanced.h ├── da1458x_config_basic.h ├── user_callback_config.h ├── user_config.h ├── user_modules_config.h ├── user_periph_setup.h └── user_profiles_config.h ├── custom_profile ├── user_custs1_def.c ├── user_custs1_def.h ├── user_custs_config.c └── user_custs_config.h ├── platform └── user_periph_setup.c ├── user_empty_peripheral_template.c └── user_empty_peripheral_template.h /.gitignore: -------------------------------------------------------------------------------- 1 | *.d 2 | *.o 3 | *.hex 4 | *.bin 5 | *.elf 6 | .settings 7 | DA14531/ 8 | DA14585/ 9 | DA14586/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DA14531-tutorials 2 | 3 | This repository contains the project folders for the medium tutorial series. You can find the links to the tutorial below: 4 | 5 | * GPIO -> https://medium.com/vicara-hardware-university/dialog-da14531-gpio-buttons-and-leds-39f38804db8a 6 | * Timers -> https://medium.com/vicara-hardware-university/dialog-da14531-timers-b83a485745bd 7 | * UART -> https://medium.com/vicara-hardware-university/dialog-da14531-uart-a7591fd9fb2c 8 | * PWM -> https://medium.com/vicara-hardware-university/dialog-da14531-pwm-c6c13a463bb5 9 | * I2C -> https://medium.com/vicara-hardware-university/dialog-da14531-i2c-c2f6d12d0a8d 10 | * SPI -> https://medium.com/vicara-hardware-university/dialog-da14531-spi-d5b34fd3cc5b 11 | * ADC -> https://medium.com/vicara-hardware-university/dialog-da14531-adc-655c0194ea36 12 | * Interrupts -> https://medium.com/vicara-hardware-university/dialog-da14531-interrupts-c3b0dc5d9e00 13 | * WDT -> https://medium.com/vicara-hardware-university/dialog-da14531-wdt-cb5437b44af6 -------------------------------------------------------------------------------- /empty_peripheral_template_blog_adc/Eclipse/makefile.targets: -------------------------------------------------------------------------------- 1 | .PHONY: main-build pre-build generate_ldscripts FORCE 2 | main-build : | pre-build 3 | 4 | FORCE: 5 | 6 | INC_PARAMS=$(foreach d, $(LDSCRIPT_INCLUDE_DIR), -I "$d") 7 | 8 | generate_ldscripts : $(LDSCRIPT_FILES) 9 | 10 | %.lds : $(LDSCRIPT_PATH)/%.lds.S FORCE 11 | "$(CC)" ${INC_PARAMS} $(PRE_BUILD_EXTRA_DEFS) $(LD_DEFS) -E -P -c "$<" -o "$@" 12 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_adc/src/config/user_modules_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_modules_config.h 5 | * 6 | * @brief User modules configuration file. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_MODULES_CONFIG_H_ 16 | #define _USER_MODULES_CONFIG_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @addtogroup APP 21 | * @ingroup RICOW 22 | * 23 | * @brief User modules configuration. 24 | * 25 | * @{ 26 | **************************************************************************************** 27 | */ 28 | 29 | /* 30 | * DEFINES 31 | **************************************************************************************** 32 | */ 33 | 34 | /***************************************************************************************/ 35 | /* Exclude or not a module in user's application code. */ 36 | /* */ 37 | /* (0) - The module is included. The module's messages are handled by the SDK. */ 38 | /* */ 39 | /* (1) - The module is excluded. The user must handle the module's messages. */ 40 | /* */ 41 | /* Note: */ 42 | /* This setting has no effect if the respective module is a BLE Profile */ 43 | /* that is not used included in the user's application. */ 44 | /***************************************************************************************/ 45 | #define EXCLUDE_DLG_GAP (0) 46 | #define EXCLUDE_DLG_TIMER (0) 47 | #define EXCLUDE_DLG_MSG (0) 48 | #define EXCLUDE_DLG_SEC (0) 49 | #define EXCLUDE_DLG_DISS (0) 50 | #define EXCLUDE_DLG_PROXR (0) 51 | #define EXCLUDE_DLG_BASS (0) 52 | #define EXCLUDE_DLG_FINDL (0) 53 | #define EXCLUDE_DLG_FINDT (0) 54 | #define EXCLUDE_DLG_SUOTAR (0) 55 | #define EXCLUDE_DLG_CUSTS1 (0) 56 | #define EXCLUDE_DLG_CUSTS2 (0) 57 | 58 | /// @} APP 59 | 60 | #endif // _USER_MODULES_CONFIG_H_ 61 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_adc/src/config/user_periph_setup.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_periph_setup.h 5 | * 6 | * @brief Peripherals setup header file. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_PERIPH_SETUP_H_ 16 | #define _USER_PERIPH_SETUP_H_ 17 | 18 | /* 19 | * INCLUDE FILES 20 | **************************************************************************************** 21 | */ 22 | 23 | #include "arch.h" 24 | #include "gpio.h" 25 | #include "uart.h" 26 | 27 | 28 | /* 29 | * DEFINES 30 | **************************************************************************************** 31 | */ 32 | 33 | 34 | /****************************************************************************************/ 35 | /* UART2 configuration to use with arch_console print messages */ 36 | /****************************************************************************************/ 37 | // Define UART2 Tx Pad 38 | #if defined (__DA14531__) 39 | #define UART2_TX_PORT GPIO_PORT_0 40 | #define UART2_TX_PIN GPIO_PIN_6 41 | #else 42 | #define UART2_TX_PORT GPIO_PORT_0 43 | #define UART2_TX_PIN GPIO_PIN_4 44 | #endif 45 | 46 | // Define UART2 Settings 47 | #define UART2_BAUDRATE UART_BAUDRATE_115200 48 | #define UART2_DATABITS UART_DATABITS_8 49 | #define UART2_PARITY UART_PARITY_NONE 50 | #define UART2_STOPBITS UART_STOPBITS_1 51 | #define UART2_AFCE UART_AFCE_DIS 52 | #define UART2_FIFO UART_FIFO_EN 53 | #define UART2_TX_FIFO_LEVEL UART_TX_FIFO_LEVEL_0 54 | #define UART2_RX_FIFO_LEVEL UART_RX_FIFO_LEVEL_0 55 | 56 | 57 | /***************************************************************************************/ 58 | /* Production debug output configuration */ 59 | /***************************************************************************************/ 60 | #if PRODUCTION_DEBUG_OUTPUT 61 | #if defined (__DA14531__) 62 | #define PRODUCTION_DEBUG_PORT GPIO_PORT_0 63 | #define PRODUCTION_DEBUG_PIN GPIO_PIN_11 64 | #else 65 | #define PRODUCTION_DEBUG_PORT GPIO_PORT_2 66 | #define PRODUCTION_DEBUG_PIN GPIO_PIN_5 67 | #endif 68 | #endif 69 | 70 | /* 71 | * FUNCTION DECLARATIONS 72 | **************************************************************************************** 73 | */ 74 | 75 | #if DEVELOPMENT_DEBUG 76 | /** 77 | **************************************************************************************** 78 | * @brief Reserves application's specific GPIOs 79 | * @details Used only in Development mode (#if DEVELOPMENT_DEBUG) 80 | * i.e. to reserve P0_1 as Generic Purpose I/O: 81 | * RESERVE_GPIO(DESCRIPTIVE_NAME, GPIO_PORT_0, GPIO_PIN_1, PID_GPIO); 82 | **************************************************************************************** 83 | */ 84 | void GPIO_reservations(void); 85 | #endif 86 | 87 | /** 88 | **************************************************************************************** 89 | * @brief Sets the functionality of application pads 90 | * @details i.e. to set P0_1 as Generic purpose Output: 91 | * GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_1, OUTPUT, PID_GPIO, false); 92 | **************************************************************************************** 93 | */ 94 | void set_pad_functions(void); 95 | 96 | /** 97 | **************************************************************************************** 98 | * @brief Initializes application's peripherals and pins 99 | **************************************************************************************** 100 | */ 101 | void periph_init(void); 102 | 103 | 104 | #endif // _USER_PERIPH_SETUP_H_ 105 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_adc/src/config/user_profiles_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_profiles_config.h 5 | * 6 | * @brief Configuration file for the profiles used in the application. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_PROFILES_CONFIG_H_ 16 | #define _USER_PROFILES_CONFIG_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @defgroup APP_CONFIG 21 | * @ingroup APP 22 | * @brief Application configuration file 23 | * 24 | * This file contains the configuration of the profiles used by the application. 25 | * 26 | * @{ 27 | **************************************************************************************** 28 | */ 29 | 30 | /* 31 | * DEFINITIONS 32 | **************************************************************************************** 33 | */ 34 | 35 | /***************************************************************************************/ 36 | /* Used BLE profiles (used by "rwprf_config.h"). */ 37 | /***************************************************************************************/ 38 | 39 | #define CFG_PRF_DISS 40 | #define CFG_PRF_CUST1 41 | 42 | /***************************************************************************************/ 43 | /* Profile application configuration section */ 44 | /***************************************************************************************/ 45 | 46 | /* 47 | **************************************************************************************** 48 | * DISS application profile configuration 49 | **************************************************************************************** 50 | */ 51 | 52 | #define APP_DIS_FEATURES (DIS_MANUFACTURER_NAME_CHAR_SUP | \ 53 | DIS_MODEL_NB_STR_CHAR_SUP | \ 54 | DIS_SYSTEM_ID_CHAR_SUP | \ 55 | DIS_SW_REV_STR_CHAR_SUP | \ 56 | DIS_FIRM_REV_STR_CHAR_SUP | \ 57 | DIS_PNP_ID_CHAR_SUP) 58 | 59 | /// Manufacturer Name (up to 18 chars) 60 | #define APP_DIS_MANUFACTURER_NAME ("Dialog Semi") 61 | #define APP_DIS_MANUFACTURER_NAME_LEN (11) 62 | 63 | /// Model Number String (up to 18 chars) 64 | #if defined (__DA14586__) 65 | #define APP_DIS_MODEL_NB_STR ("DA14586") 66 | #elif defined (__DA14531__) 67 | #define APP_DIS_MODEL_NB_STR ("DA14531") 68 | #else 69 | #define APP_DIS_MODEL_NB_STR ("DA14585") 70 | #endif 71 | #define APP_DIS_MODEL_NB_STR_LEN (7) 72 | 73 | /// System ID - LSB -> MSB 74 | #define APP_DIS_SYSTEM_ID ("\x12\x34\x56\xFF\xFE\x9A\xBC\xDE") 75 | #define APP_DIS_SYSTEM_ID_LEN (8) 76 | 77 | #define APP_DIS_SW_REV SDK_VERSION 78 | #define APP_DIS_FIRM_REV SDK_VERSION 79 | 80 | /// Serial Number 81 | #define APP_DIS_SERIAL_NB_STR ("1.0.0.0-LE") 82 | #define APP_DIS_SERIAL_NB_STR_LEN (10) 83 | 84 | /// Hardware Revision String 85 | #if defined (__DA14586__) 86 | #define APP_DIS_HARD_REV_STR ("DA14586") 87 | #elif defined (__DA14531__) 88 | #define APP_DIS_HARD_REV_STR ("DA14531") 89 | #else 90 | #define APP_DIS_HARD_REV_STR ("DA14585") 91 | #endif 92 | #define APP_DIS_HARD_REV_STR_LEN (7) 93 | 94 | /// Firmware Revision 95 | #define APP_DIS_FIRM_REV_STR SDK_VERSION 96 | #define APP_DIS_FIRM_REV_STR_LEN (sizeof(APP_DIS_FIRM_REV_STR) - 1) 97 | 98 | /// Software Revision String 99 | #define APP_DIS_SW_REV_STR SDK_VERSION 100 | #define APP_DIS_SW_REV_STR_LEN (sizeof(APP_DIS_SW_REV_STR) - 1) 101 | 102 | /// IEEE 103 | #define APP_DIS_IEEE ("\xFF\xEE\xDD\xCC\xBB\xAA") 104 | #define APP_DIS_IEEE_LEN (6) 105 | 106 | /** 107 | * PNP ID Value - LSB -> MSB 108 | * Vendor ID Source : 0x02 (USB Implementers Forum assigned Vendor ID value) 109 | * Vendor ID : 0x045E (Microsoft Corp) 110 | * Product ID : 0x0040 111 | * Product Version : 0x0300 112 | * e.g. #define APP_DIS_PNP_ID ("\x02\x5E\x04\x40\x00\x00\x03") 113 | */ 114 | #define APP_DIS_PNP_ID ("\x01\xD2\x00\x80\x05\x00\x01") 115 | #define APP_DIS_PNP_ID_LEN (7) 116 | 117 | /// @} APP_CONFIG 118 | 119 | #endif // _USER_PROFILES_CONFIG_H_ 120 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_adc/src/custom_profile/user_custs1_def.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_custs1_def.h 5 | * 6 | * @brief Custom Server 1 (CUSTS1) profile database definitions. 7 | * 8 | * Copyright (C) 2016-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_CUSTS1_DEF_H_ 16 | #define _USER_CUSTS1_DEF_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @defgroup USER_CONFIG 21 | * @ingroup USER 22 | * @brief Custom Server 1 (CUSTS1) profile database definitions. 23 | * 24 | * @{ 25 | **************************************************************************************** 26 | */ 27 | 28 | /* 29 | * INCLUDE FILES 30 | **************************************************************************************** 31 | */ 32 | 33 | #include "attm_db_128.h" 34 | 35 | /* 36 | * DEFINES 37 | **************************************************************************************** 38 | */ 39 | 40 | // Service 1 of the custom server 1 41 | #define DEF_SVC1_UUID_128 {0x59, 0x5a, 0x08, 0xe4, 0x86, 0x2a, 0x9e, 0x8f, 0xe9, 0x11, 0xbc, 0x7c, 0x98, 0x43, 0x42, 0x18} 42 | 43 | #define DEF_SVC1_CTRL_POINT_UUID_128 {0x20, 0xEE, 0x8D, 0x0C, 0xE1, 0xF0, 0x4A, 0x0C, 0xB3, 0x25, 0xDC, 0x53, 0x6A, 0x68, 0x86, 0x2D} 44 | #define DEF_SVC1_LED_STATE_UUID_128 {0x4F, 0x43, 0x31, 0x3C, 0x93, 0x92, 0x42, 0xE6, 0xA8, 0x76, 0xFA, 0x3B, 0xEF, 0xB4, 0x87, 0x5A} 45 | #define DEF_SVC1_ADC_VAL_1_UUID_128 {0x17, 0xB9, 0x67, 0x98, 0x4C, 0x66, 0x4C, 0x01, 0x96, 0x33, 0x31, 0xB1, 0x91, 0x59, 0x00, 0x15} 46 | #define DEF_SVC1_ADC_VAL_2_UUID_128 {0x23, 0x68, 0xEC, 0x52, 0x1E, 0x62, 0x44, 0x74, 0x9A, 0x1B, 0xD1, 0x8B, 0xAB, 0x75, 0xB6, 0x6E} 47 | #define DEF_SVC1_BUTTON_STATE_UUID_128 {0x9E, 0xE7, 0xBA, 0x08, 0xB9, 0xA9, 0x48, 0xAB, 0xA1, 0xAC, 0x03, 0x1C, 0x2E, 0x0D, 0x29, 0x6C} 48 | #define DEF_SVC1_INDICATEABLE_UUID_128 {0x28, 0xD5, 0xE1, 0xC1, 0xE1, 0xC5, 0x47, 0x29, 0xB5, 0x57, 0x65, 0xC3, 0xBA, 0x47, 0x15, 0x9E} 49 | #define DEF_SVC1_LONG_VALUE_UUID_128 {0x8C, 0x09, 0xE0, 0xD1, 0x81, 0x54, 0x42, 0x40, 0x8E, 0x4F, 0xD2, 0xB3, 0x77, 0xE3, 0x2A, 0x77} 50 | 51 | #define DEF_SVC1_CTRL_POINT_CHAR_LEN 1 52 | #define DEF_SVC1_LED_STATE_CHAR_LEN 1 53 | #define DEF_SVC1_ADC_VAL_1_CHAR_LEN 2 54 | #define DEF_SVC1_ADC_VAL_2_CHAR_LEN 2 55 | #define DEF_SVC1_BUTTON_STATE_CHAR_LEN 1 56 | #define DEF_SVC1_INDICATEABLE_CHAR_LEN 20 57 | #define DEF_SVC1_LONG_VALUE_CHAR_LEN 50 58 | 59 | #define DEF_SVC1_CONTROL_POINT_USER_DESC "Control Point" 60 | #define DEF_SVC1_LED_STATE_USER_DESC "LED State" 61 | #define DEF_SVC1_ADC_VAL_1_USER_DESC "ADC Value 1" 62 | #define DEF_SVC1_ADC_VAL_2_USER_DESC "ADC Value 2" 63 | #define DEF_SVC1_BUTTON_STATE_USER_DESC "Button State" 64 | #define DEF_SVC1_INDICATEABLE_USER_DESC "Indicateable" 65 | #define DEF_SVC1_LONG_VALUE_CHAR_USER_DESC "Long Value" 66 | 67 | // Service 2 of the custom server 1 68 | #define DEF_SVC2_UUID_128 {0x59, 0x5a, 0x08, 0xe4, 0x86, 0x2a, 0x9e, 0x8f, 0xe9, 0x11, 0xbc, 0x7c, 0x7c, 0x46, 0x42, 0x18} 69 | 70 | #define DEF_SVC2_WRITE_VAL_1_UUID_128 {0x20, 0xEE, 0x8D, 0x0C, 0xE1, 0xF0, 0x4A, 0x0C, 0xB3, 0x25, 0xDC, 0x53, 0x6A, 0x68, 0x86, 0x2C} 71 | #define DEF_SVC2_WRITE_VAL_2_UUID_128 {0x4F, 0x43, 0x31, 0x3C, 0x93, 0x92, 0x42, 0xE6, 0xA8, 0x76, 0xFA, 0x3B, 0xEF, 0xB4, 0x87, 0x59} 72 | 73 | #define DEF_SVC2_WRITE_VAL_1_CHAR_LEN 1 74 | #define DEF_SVC2_WRITE_VAL_2_CHAR_LEN 1 75 | 76 | #define DEF_SVC2_WRITE_VAL_1_USER_DESC "Write me" 77 | #define DEF_SVC2_WRITE_VAL_2_USER_DESC "Write me (no rsp)" 78 | 79 | // Service 3 of the custom server 1 80 | #define DEF_SVC3_UUID_128 {0x59, 0x5a, 0x08, 0xe4, 0x86, 0x2a, 0x9e, 0x8, 0xe9, 0x11, 0xbc, 0x7c, 0xd0, 0x47, 0x42, 0x18} 81 | 82 | #define DEF_SVC3_READ_VAL_1_UUID_128 {0x17, 0xB9, 0x67, 0x98, 0x4C, 0x66, 0x4C, 0x01, 0x96, 0x33, 0x31, 0xB1, 0x91, 0x59, 0x00, 0x14} 83 | #define DEF_SVC3_READ_VAL_2_UUID_128 {0x23, 0x68, 0xEC, 0x52, 0x1E, 0x62, 0x44, 0x74, 0x9A, 0x1B, 0xD1, 0x8B, 0xAB, 0x75, 0xB6, 0x6D} 84 | #define DEF_SVC3_READ_VAL_3_UUID_128 {0x28, 0xD5, 0xE1, 0xC1, 0xE1, 0xC5, 0x47, 0x29, 0xB5, 0x57, 0x65, 0xC3, 0xBA, 0x47, 0x15, 0x9D} 85 | 86 | #define DEF_SVC3_READ_VAL_1_CHAR_LEN 2 87 | #define DEF_SVC3_READ_VAL_2_CHAR_LEN 2 88 | #define DEF_SVC3_READ_VAL_3_CHAR_LEN 2 89 | 90 | #define DEF_SVC3_READ_VAL_1_USER_DESC "Read me (notify)" 91 | #define DEF_SVC3_READ_VAL_2_USER_DESC "Read me" 92 | #define DEF_SVC3_READ_VAL_3_USER_DESC "Read me (indicate)" 93 | 94 | /// Custom1 Service Data Base Characteristic enum 95 | enum 96 | { 97 | // Custom Service 1 98 | SVC1_IDX_SVC = 0, 99 | 100 | SVC1_IDX_CONTROL_POINT_CHAR, 101 | SVC1_IDX_CONTROL_POINT_VAL, 102 | SVC1_IDX_CONTROL_POINT_USER_DESC, 103 | 104 | SVC1_IDX_LED_STATE_CHAR, 105 | SVC1_IDX_LED_STATE_VAL, 106 | SVC1_IDX_LED_STATE_USER_DESC, 107 | 108 | SVC1_IDX_ADC_VAL_1_CHAR, 109 | SVC1_IDX_ADC_VAL_1_VAL, 110 | SVC1_IDX_ADC_VAL_1_NTF_CFG, 111 | SVC1_IDX_ADC_VAL_1_USER_DESC, 112 | 113 | SVC1_IDX_ADC_VAL_2_CHAR, 114 | SVC1_IDX_ADC_VAL_2_VAL, 115 | SVC1_IDX_ADC_VAL_2_USER_DESC, 116 | 117 | SVC1_IDX_BUTTON_STATE_CHAR, 118 | SVC1_IDX_BUTTON_STATE_VAL, 119 | SVC1_IDX_BUTTON_STATE_NTF_CFG, 120 | SVC1_IDX_BUTTON_STATE_USER_DESC, 121 | 122 | SVC1_IDX_INDICATEABLE_CHAR, 123 | SVC1_IDX_INDICATEABLE_VAL, 124 | SVC1_IDX_INDICATEABLE_IND_CFG, 125 | SVC1_IDX_INDICATEABLE_USER_DESC, 126 | 127 | SVC1_IDX_LONG_VALUE_CHAR, 128 | SVC1_IDX_LONG_VALUE_VAL, 129 | SVC1_IDX_LONG_VALUE_NTF_CFG, 130 | SVC1_IDX_LONG_VALUE_USER_DESC, 131 | 132 | // Custom Service 2 133 | SVC2_IDX_SVC, 134 | 135 | SVC2_WRITE_1_CHAR, 136 | SVC2_WRITE_1_VAL, 137 | SVC2_WRITE_1_USER_DESC, 138 | 139 | SVC2_WRITE_2_CHAR, 140 | SVC2_WRITE_2_VAL, 141 | SVC2_WRITE_2_USER_DESC, 142 | 143 | // Custom Service 3 144 | SVC3_IDX_SVC, 145 | 146 | SVC3_IDX_READ_1_CHAR, 147 | SVC3_IDX_READ_1_VAL, 148 | SVC3_IDX_READ_1_NTF_CFG, 149 | SVC3_IDX_READ_1_USER_DESC, 150 | 151 | SVC3_IDX_READ_2_CHAR, 152 | SVC3_IDX_READ_2_VAL, 153 | SVC3_IDX_READ_2_USER_DESC, 154 | 155 | SVC3_IDX_READ_3_CHAR, 156 | SVC3_IDX_READ_3_VAL, 157 | SVC3_IDX_READ_3_IND_CFG, 158 | SVC3_IDX_READ_3_USER_DESC, 159 | 160 | CUSTS1_IDX_NB 161 | }; 162 | 163 | /// @} USER_CONFIG 164 | 165 | #endif // _USER_CUSTS1_DEF_H_ 166 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_adc/src/custom_profile/user_custs_config.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_custs_config.c 5 | * 6 | * @brief Custom1/2 Server (CUSTS1/2) profile database structure and initialization. 7 | * 8 | * Copyright (C) 2016-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | /** 16 | **************************************************************************************** 17 | * @defgroup USER_CONFIG 18 | * @ingroup USER 19 | * @brief Custom1/2 Server (CUSTS1/2) profile database structure and initialization. 20 | * 21 | * @{ 22 | **************************************************************************************** 23 | */ 24 | 25 | /* 26 | * INCLUDE FILES 27 | **************************************************************************************** 28 | */ 29 | 30 | #include "app_prf_types.h" 31 | #include "app_customs.h" 32 | #include "user_custs1_def.h" 33 | 34 | /* 35 | * GLOBAL VARIABLE DEFINITIONS 36 | **************************************************************************************** 37 | */ 38 | 39 | #if (BLE_CUSTOM1_SERVER) 40 | extern const struct attm_desc_128 custs1_att_db[CUSTS1_IDX_NB]; 41 | #endif 42 | 43 | /// Custom1/2 server function callback table 44 | const struct cust_prf_func_callbacks cust_prf_funcs[] = 45 | { 46 | #if (BLE_CUSTOM1_SERVER) 47 | { TASK_ID_CUSTS1, 48 | custs1_att_db, 49 | CUSTS1_IDX_NB, 50 | #if (BLE_APP_PRESENT) 51 | app_custs1_create_db, NULL, 52 | #else 53 | NULL, NULL, 54 | #endif 55 | NULL, NULL, 56 | }, 57 | #endif 58 | #if (BLE_CUSTOM2_SERVER) 59 | { TASK_ID_CUSTS2, 60 | NULL, 61 | 0, 62 | #if (BLE_APP_PRESENT) 63 | app_custs2_create_db, NULL, 64 | #else 65 | NULL, NULL, 66 | #endif 67 | NULL, NULL, 68 | }, 69 | #endif 70 | {TASK_ID_INVALID, NULL, 0, NULL, NULL, NULL, NULL}, // DO NOT MOVE. Must always be last 71 | }; 72 | 73 | /// @} USER_CONFIG 74 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_adc/src/custom_profile/user_custs_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_custs_config.h 5 | * 6 | * @brief Custom1/2 Server (CUSTS1/2) profile database initialization. 7 | * 8 | * Copyright (C) 2016-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_CUSTS_CONFIG_H_ 16 | #define _USER_CUSTS_CONFIG_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @defgroup USER_CONFIG 21 | * @ingroup USER 22 | * @brief Custom1/2 Server (CUSTS1/2) profile database initialization. 23 | * 24 | * @{ 25 | **************************************************************************************** 26 | */ 27 | 28 | /* 29 | * INCLUDE FILES 30 | **************************************************************************************** 31 | */ 32 | 33 | #include "app_prf_types.h" 34 | 35 | /* 36 | * GLOBAL VARIABLE DECLARATIONS 37 | **************************************************************************************** 38 | */ 39 | 40 | extern const struct cust_prf_func_callbacks cust_prf_funcs[]; 41 | 42 | /// @} USER_CONFIG 43 | 44 | #endif // _USER_CUSTS_CONFIG_H_ 45 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_adc/src/platform/user_periph_setup.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_periph_setup.c 5 | * 6 | * @brief Peripherals setup and initialization. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | /* 16 | * INCLUDE FILES 17 | **************************************************************************************** 18 | */ 19 | 20 | #include "user_periph_setup.h" 21 | #include "datasheet.h" 22 | #include "system_library.h" 23 | #include "rwip_config.h" 24 | #include "gpio.h" 25 | #include "uart.h" 26 | #include "syscntl.h" 27 | #include "adc.h" 28 | 29 | /* 30 | * GLOBAL VARIABLE DEFINITIONS 31 | **************************************************************************************** 32 | */ 33 | 34 | #if DEVELOPMENT_DEBUG 35 | 36 | void GPIO_reservations(void) 37 | { 38 | /* 39 | i.e. to reserve P0_1 as Generic Purpose I/O: 40 | RESERVE_GPIO(DESCRIPTIVE_NAME, GPIO_PORT_0, GPIO_PIN_1, PID_GPIO); 41 | */ 42 | RESERVE_GPIO(BUTTON, GPIO_PORT_0, GPIO_PIN_7, PID_ADC); 43 | #if defined (CFG_PRINTF_UART2) 44 | RESERVE_GPIO(UART2_TX, UART2_TX_PORT, UART2_TX_PIN, PID_UART2_TX); 45 | #endif 46 | } 47 | 48 | #endif 49 | 50 | void set_pad_functions(void) 51 | { 52 | /* 53 | i.e. to set P0_1 as Generic purpose Output: 54 | GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_1, OUTPUT, PID_GPIO, false); 55 | */ 56 | GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_7, INPUT, PID_ADC, false); 57 | #if defined (__DA14586__) 58 | // Disallow spontaneous DA14586 SPI Flash wake-up 59 | GPIO_ConfigurePin(GPIO_PORT_2, GPIO_PIN_3, OUTPUT, PID_GPIO, true); 60 | #endif 61 | 62 | #if defined (CFG_PRINTF_UART2) 63 | // Configure UART2 TX Pad 64 | GPIO_ConfigurePin(UART2_TX_PORT, UART2_TX_PIN, OUTPUT, PID_UART2_TX, false); 65 | #endif 66 | 67 | } 68 | 69 | #if defined (CFG_PRINTF_UART2) 70 | // Configuration struct for UART2 71 | static const uart_cfg_t uart_cfg = { 72 | .baud_rate = UART2_BAUDRATE, 73 | .data_bits = UART2_DATABITS, 74 | .parity = UART2_PARITY, 75 | .stop_bits = UART2_STOPBITS, 76 | .auto_flow_control = UART2_AFCE, 77 | .use_fifo = UART2_FIFO, 78 | .tx_fifo_tr_lvl = UART2_TX_FIFO_LEVEL, 79 | .rx_fifo_tr_lvl = UART2_RX_FIFO_LEVEL, 80 | .intr_priority = 2, 81 | }; 82 | #endif 83 | 84 | void periph_init(void) 85 | { 86 | #if defined (__DA14531__) 87 | // In Boost mode enable the DCDC converter to supply VBAT_HIGH for the used GPIOs 88 | syscntl_dcdc_turn_on_in_boost(SYSCNTL_DCDC_LEVEL_3V0); 89 | #else 90 | // Power up peripherals' power domain 91 | SetBits16(PMU_CTRL_REG, PERIPH_SLEEP, 0); 92 | while (!(GetWord16(SYS_STAT_REG) & PER_IS_UP)); 93 | SetBits16(CLK_16M_REG, XTAL16_BIAS_SH_ENABLE, 1); 94 | #endif 95 | 96 | // ROM patch 97 | patch_func(); 98 | 99 | // Initialize peripherals 100 | #if defined (CFG_PRINTF_UART2) 101 | // Initialize UART2 102 | uart_initialize(UART2, &uart_cfg); 103 | #endif 104 | 105 | adc_config_t adc_cfg = 106 | { 107 | .input_mode = ADC_INPUT_MODE_SINGLE_ENDED, 108 | .input = ADC_INPUT_SE_P0_7, 109 | .smpl_time_mult = 2, 110 | .continuous = false, 111 | .interval_mult = 0, 112 | .input_attenuator = ADC_INPUT_ATTN_2X, 113 | .chopping = false, 114 | .oversampling = 0 115 | }; 116 | 117 | adc_offset_calibrate(ADC_INPUT_MODE_SINGLE_ENDED); 118 | 119 | adc_init(&adc_cfg); 120 | 121 | // Set pad functionality 122 | set_pad_functions(); 123 | 124 | // Enable the pads 125 | GPIO_set_pad_latch_en(true); 126 | } 127 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_adc/src/user_empty_peripheral_template.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_empty_peripheral_template.c 5 | * 6 | * @brief Empty peripheral template project source code. 7 | * 8 | * Copyright (C) 2012-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | /** 16 | **************************************************************************************** 17 | * @addtogroup APP 18 | * @{ 19 | **************************************************************************************** 20 | */ 21 | #include "rwip_config.h" // SW configuration 22 | 23 | 24 | /* 25 | * INCLUDE FILES 26 | **************************************************************************************** 27 | */ 28 | 29 | #include "app_api.h" 30 | #include "user_empty_peripheral_template.h" 31 | #include "adc.h" 32 | 33 | /* 34 | * FUNCTION DEFINITIONS 35 | **************************************************************************************** 36 | */ 37 | uint16_t adc_sample; 38 | 39 | void user_on_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param) 40 | { 41 | default_app_on_connection(connection_idx, param); 42 | } 43 | 44 | void user_on_disconnect( struct gapc_disconnect_ind const *param ) 45 | { 46 | default_app_on_disconnect(param); 47 | } 48 | 49 | void user_app_on_init(void) 50 | { 51 | adc_sample = adc_get_sample(); 52 | adc_sample = adc_correct_sample(adc_sample); 53 | 54 | default_app_on_init(); 55 | } 56 | 57 | 58 | /// @} APP 59 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_adc/src/user_empty_peripheral_template.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_empty_peripheral_template.h 5 | * 6 | * @brief Empty peripheral template project header file. 7 | * 8 | * Copyright (C) 2012-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_EMPTY_PERIPHERAL_TEMPLATE_H_ 16 | #define _USER_EMPTY_PERIPHERAL_TEMPLATE_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @addtogroup APP 21 | * @ingroup RICOW 22 | * 23 | * @brief 24 | * 25 | * @{ 26 | **************************************************************************************** 27 | */ 28 | 29 | /* 30 | * INCLUDE FILES 31 | **************************************************************************************** 32 | */ 33 | 34 | #include "rwble_config.h" 35 | #include "app_task.h" // application task 36 | #include "gapc_task.h" // gap functions and messages 37 | #include "gapm_task.h" // gap functions and messages 38 | #include "app.h" // application definitions 39 | #include "co_error.h" // error code definitions 40 | 41 | 42 | /**************************************************************************** 43 | Add here supported profiles' application header files. 44 | i.e. 45 | #if (BLE_DIS_SERVER) 46 | #include "app_dis.h" 47 | #include "app_dis_task.h" 48 | #endif 49 | *****************************************************************************/ 50 | 51 | /* 52 | * TYPE DEFINITIONS 53 | **************************************************************************************** 54 | */ 55 | 56 | /* 57 | * DEFINES 58 | **************************************************************************************** 59 | */ 60 | 61 | /* 62 | * FUNCTION DECLARATIONS 63 | **************************************************************************************** 64 | */ 65 | 66 | void user_on_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param); 67 | 68 | void user_on_disconnect( struct gapc_disconnect_ind const *param ); 69 | 70 | void user_app_on_init(void); 71 | 72 | /// @} APP 73 | 74 | #endif // _USER_EMPTY_PERIPHERAL_TEMPLATE_H_ 75 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_gpio/Eclipse/makefile.targets: -------------------------------------------------------------------------------- 1 | .PHONY: main-build pre-build generate_ldscripts FORCE 2 | main-build : | pre-build 3 | 4 | FORCE: 5 | 6 | INC_PARAMS=$(foreach d, $(LDSCRIPT_INCLUDE_DIR), -I "$d") 7 | 8 | generate_ldscripts : $(LDSCRIPT_FILES) 9 | 10 | %.lds : $(LDSCRIPT_PATH)/%.lds.S FORCE 11 | "$(CC)" ${INC_PARAMS} $(PRE_BUILD_EXTRA_DEFS) $(LD_DEFS) -E -P -c "$<" -o "$@" 12 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_gpio/src/config/user_modules_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_modules_config.h 5 | * 6 | * @brief User modules configuration file. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_MODULES_CONFIG_H_ 16 | #define _USER_MODULES_CONFIG_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @addtogroup APP 21 | * @ingroup RICOW 22 | * 23 | * @brief User modules configuration. 24 | * 25 | * @{ 26 | **************************************************************************************** 27 | */ 28 | 29 | /* 30 | * DEFINES 31 | **************************************************************************************** 32 | */ 33 | 34 | /***************************************************************************************/ 35 | /* Exclude or not a module in user's application code. */ 36 | /* */ 37 | /* (0) - The module is included. The module's messages are handled by the SDK. */ 38 | /* */ 39 | /* (1) - The module is excluded. The user must handle the module's messages. */ 40 | /* */ 41 | /* Note: */ 42 | /* This setting has no effect if the respective module is a BLE Profile */ 43 | /* that is not used included in the user's application. */ 44 | /***************************************************************************************/ 45 | #define EXCLUDE_DLG_GAP (0) 46 | #define EXCLUDE_DLG_TIMER (0) 47 | #define EXCLUDE_DLG_MSG (0) 48 | #define EXCLUDE_DLG_SEC (0) 49 | #define EXCLUDE_DLG_DISS (0) 50 | #define EXCLUDE_DLG_PROXR (0) 51 | #define EXCLUDE_DLG_BASS (0) 52 | #define EXCLUDE_DLG_FINDL (0) 53 | #define EXCLUDE_DLG_FINDT (0) 54 | #define EXCLUDE_DLG_SUOTAR (0) 55 | #define EXCLUDE_DLG_CUSTS1 (0) 56 | #define EXCLUDE_DLG_CUSTS2 (0) 57 | 58 | /// @} APP 59 | 60 | #endif // _USER_MODULES_CONFIG_H_ 61 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_gpio/src/config/user_periph_setup.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_periph_setup.h 5 | * 6 | * @brief Peripherals setup header file. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_PERIPH_SETUP_H_ 16 | #define _USER_PERIPH_SETUP_H_ 17 | 18 | /* 19 | * INCLUDE FILES 20 | **************************************************************************************** 21 | */ 22 | 23 | #include "arch.h" 24 | #include "gpio.h" 25 | #include "uart.h" 26 | 27 | 28 | /* 29 | * DEFINES 30 | **************************************************************************************** 31 | */ 32 | 33 | 34 | /****************************************************************************************/ 35 | /* UART2 configuration to use with arch_console print messages */ 36 | /****************************************************************************************/ 37 | // Define UART2 Tx Pad 38 | #if defined (__DA14531__) 39 | #define UART2_TX_PORT GPIO_PORT_0 40 | #define UART2_TX_PIN GPIO_PIN_6 41 | #else 42 | #define UART2_TX_PORT GPIO_PORT_0 43 | #define UART2_TX_PIN GPIO_PIN_4 44 | #endif 45 | 46 | // Define UART2 Settings 47 | #define UART2_BAUDRATE UART_BAUDRATE_115200 48 | #define UART2_DATABITS UART_DATABITS_8 49 | #define UART2_PARITY UART_PARITY_NONE 50 | #define UART2_STOPBITS UART_STOPBITS_1 51 | #define UART2_AFCE UART_AFCE_DIS 52 | #define UART2_FIFO UART_FIFO_EN 53 | #define UART2_TX_FIFO_LEVEL UART_TX_FIFO_LEVEL_0 54 | #define UART2_RX_FIFO_LEVEL UART_RX_FIFO_LEVEL_0 55 | 56 | 57 | /***************************************************************************************/ 58 | /* Production debug output configuration */ 59 | /***************************************************************************************/ 60 | #if PRODUCTION_DEBUG_OUTPUT 61 | #if defined (__DA14531__) 62 | #define PRODUCTION_DEBUG_PORT GPIO_PORT_0 63 | #define PRODUCTION_DEBUG_PIN GPIO_PIN_11 64 | #else 65 | #define PRODUCTION_DEBUG_PORT GPIO_PORT_2 66 | #define PRODUCTION_DEBUG_PIN GPIO_PIN_5 67 | #endif 68 | #endif 69 | 70 | /* 71 | * FUNCTION DECLARATIONS 72 | **************************************************************************************** 73 | */ 74 | 75 | #if DEVELOPMENT_DEBUG 76 | /** 77 | **************************************************************************************** 78 | * @brief Reserves application's specific GPIOs 79 | * @details Used only in Development mode (#if DEVELOPMENT_DEBUG) 80 | * i.e. to reserve P0_1 as Generic Purpose I/O: 81 | * RESERVE_GPIO(DESCRIPTIVE_NAME, GPIO_PORT_0, GPIO_PIN_1, PID_GPIO); 82 | **************************************************************************************** 83 | */ 84 | void GPIO_reservations(void); 85 | #endif 86 | 87 | /** 88 | **************************************************************************************** 89 | * @brief Sets the functionality of application pads 90 | * @details i.e. to set P0_1 as Generic purpose Output: 91 | * GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_1, OUTPUT, PID_GPIO, false); 92 | **************************************************************************************** 93 | */ 94 | void set_pad_functions(void); 95 | 96 | /** 97 | **************************************************************************************** 98 | * @brief Initializes application's peripherals and pins 99 | **************************************************************************************** 100 | */ 101 | void periph_init(void); 102 | 103 | 104 | #endif // _USER_PERIPH_SETUP_H_ 105 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_gpio/src/config/user_profiles_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_profiles_config.h 5 | * 6 | * @brief Configuration file for the profiles used in the application. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_PROFILES_CONFIG_H_ 16 | #define _USER_PROFILES_CONFIG_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @defgroup APP_CONFIG 21 | * @ingroup APP 22 | * @brief Application configuration file 23 | * 24 | * This file contains the configuration of the profiles used by the application. 25 | * 26 | * @{ 27 | **************************************************************************************** 28 | */ 29 | 30 | /* 31 | * DEFINITIONS 32 | **************************************************************************************** 33 | */ 34 | 35 | /***************************************************************************************/ 36 | /* Used BLE profiles (used by "rwprf_config.h"). */ 37 | /***************************************************************************************/ 38 | 39 | #define CFG_PRF_DISS 40 | #define CFG_PRF_CUST1 41 | 42 | /***************************************************************************************/ 43 | /* Profile application configuration section */ 44 | /***************************************************************************************/ 45 | 46 | /* 47 | **************************************************************************************** 48 | * DISS application profile configuration 49 | **************************************************************************************** 50 | */ 51 | 52 | #define APP_DIS_FEATURES (DIS_MANUFACTURER_NAME_CHAR_SUP | \ 53 | DIS_MODEL_NB_STR_CHAR_SUP | \ 54 | DIS_SYSTEM_ID_CHAR_SUP | \ 55 | DIS_SW_REV_STR_CHAR_SUP | \ 56 | DIS_FIRM_REV_STR_CHAR_SUP | \ 57 | DIS_PNP_ID_CHAR_SUP) 58 | 59 | /// Manufacturer Name (up to 18 chars) 60 | #define APP_DIS_MANUFACTURER_NAME ("Dialog Semi") 61 | #define APP_DIS_MANUFACTURER_NAME_LEN (11) 62 | 63 | /// Model Number String (up to 18 chars) 64 | #if defined (__DA14586__) 65 | #define APP_DIS_MODEL_NB_STR ("DA14586") 66 | #elif defined (__DA14531__) 67 | #define APP_DIS_MODEL_NB_STR ("DA14531") 68 | #else 69 | #define APP_DIS_MODEL_NB_STR ("DA14585") 70 | #endif 71 | #define APP_DIS_MODEL_NB_STR_LEN (7) 72 | 73 | /// System ID - LSB -> MSB 74 | #define APP_DIS_SYSTEM_ID ("\x12\x34\x56\xFF\xFE\x9A\xBC\xDE") 75 | #define APP_DIS_SYSTEM_ID_LEN (8) 76 | 77 | #define APP_DIS_SW_REV SDK_VERSION 78 | #define APP_DIS_FIRM_REV SDK_VERSION 79 | 80 | /// Serial Number 81 | #define APP_DIS_SERIAL_NB_STR ("1.0.0.0-LE") 82 | #define APP_DIS_SERIAL_NB_STR_LEN (10) 83 | 84 | /// Hardware Revision String 85 | #if defined (__DA14586__) 86 | #define APP_DIS_HARD_REV_STR ("DA14586") 87 | #elif defined (__DA14531__) 88 | #define APP_DIS_HARD_REV_STR ("DA14531") 89 | #else 90 | #define APP_DIS_HARD_REV_STR ("DA14585") 91 | #endif 92 | #define APP_DIS_HARD_REV_STR_LEN (7) 93 | 94 | /// Firmware Revision 95 | #define APP_DIS_FIRM_REV_STR SDK_VERSION 96 | #define APP_DIS_FIRM_REV_STR_LEN (sizeof(APP_DIS_FIRM_REV_STR) - 1) 97 | 98 | /// Software Revision String 99 | #define APP_DIS_SW_REV_STR SDK_VERSION 100 | #define APP_DIS_SW_REV_STR_LEN (sizeof(APP_DIS_SW_REV_STR) - 1) 101 | 102 | /// IEEE 103 | #define APP_DIS_IEEE ("\xFF\xEE\xDD\xCC\xBB\xAA") 104 | #define APP_DIS_IEEE_LEN (6) 105 | 106 | /** 107 | * PNP ID Value - LSB -> MSB 108 | * Vendor ID Source : 0x02 (USB Implementers Forum assigned Vendor ID value) 109 | * Vendor ID : 0x045E (Microsoft Corp) 110 | * Product ID : 0x0040 111 | * Product Version : 0x0300 112 | * e.g. #define APP_DIS_PNP_ID ("\x02\x5E\x04\x40\x00\x00\x03") 113 | */ 114 | #define APP_DIS_PNP_ID ("\x01\xD2\x00\x80\x05\x00\x01") 115 | #define APP_DIS_PNP_ID_LEN (7) 116 | 117 | /// @} APP_CONFIG 118 | 119 | #endif // _USER_PROFILES_CONFIG_H_ 120 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_gpio/src/custom_profile/user_custs1_def.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_custs1_def.h 5 | * 6 | * @brief Custom Server 1 (CUSTS1) profile database definitions. 7 | * 8 | * Copyright (C) 2016-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_CUSTS1_DEF_H_ 16 | #define _USER_CUSTS1_DEF_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @defgroup USER_CONFIG 21 | * @ingroup USER 22 | * @brief Custom Server 1 (CUSTS1) profile database definitions. 23 | * 24 | * @{ 25 | **************************************************************************************** 26 | */ 27 | 28 | /* 29 | * INCLUDE FILES 30 | **************************************************************************************** 31 | */ 32 | 33 | #include "attm_db_128.h" 34 | 35 | /* 36 | * DEFINES 37 | **************************************************************************************** 38 | */ 39 | 40 | // Service 1 of the custom server 1 41 | #define DEF_SVC1_UUID_128 {0x59, 0x5a, 0x08, 0xe4, 0x86, 0x2a, 0x9e, 0x8f, 0xe9, 0x11, 0xbc, 0x7c, 0x98, 0x43, 0x42, 0x18} 42 | 43 | #define DEF_SVC1_CTRL_POINT_UUID_128 {0x20, 0xEE, 0x8D, 0x0C, 0xE1, 0xF0, 0x4A, 0x0C, 0xB3, 0x25, 0xDC, 0x53, 0x6A, 0x68, 0x86, 0x2D} 44 | #define DEF_SVC1_LED_STATE_UUID_128 {0x4F, 0x43, 0x31, 0x3C, 0x93, 0x92, 0x42, 0xE6, 0xA8, 0x76, 0xFA, 0x3B, 0xEF, 0xB4, 0x87, 0x5A} 45 | #define DEF_SVC1_ADC_VAL_1_UUID_128 {0x17, 0xB9, 0x67, 0x98, 0x4C, 0x66, 0x4C, 0x01, 0x96, 0x33, 0x31, 0xB1, 0x91, 0x59, 0x00, 0x15} 46 | #define DEF_SVC1_ADC_VAL_2_UUID_128 {0x23, 0x68, 0xEC, 0x52, 0x1E, 0x62, 0x44, 0x74, 0x9A, 0x1B, 0xD1, 0x8B, 0xAB, 0x75, 0xB6, 0x6E} 47 | #define DEF_SVC1_BUTTON_STATE_UUID_128 {0x9E, 0xE7, 0xBA, 0x08, 0xB9, 0xA9, 0x48, 0xAB, 0xA1, 0xAC, 0x03, 0x1C, 0x2E, 0x0D, 0x29, 0x6C} 48 | #define DEF_SVC1_INDICATEABLE_UUID_128 {0x28, 0xD5, 0xE1, 0xC1, 0xE1, 0xC5, 0x47, 0x29, 0xB5, 0x57, 0x65, 0xC3, 0xBA, 0x47, 0x15, 0x9E} 49 | #define DEF_SVC1_LONG_VALUE_UUID_128 {0x8C, 0x09, 0xE0, 0xD1, 0x81, 0x54, 0x42, 0x40, 0x8E, 0x4F, 0xD2, 0xB3, 0x77, 0xE3, 0x2A, 0x77} 50 | 51 | #define DEF_SVC1_CTRL_POINT_CHAR_LEN 1 52 | #define DEF_SVC1_LED_STATE_CHAR_LEN 1 53 | #define DEF_SVC1_ADC_VAL_1_CHAR_LEN 2 54 | #define DEF_SVC1_ADC_VAL_2_CHAR_LEN 2 55 | #define DEF_SVC1_BUTTON_STATE_CHAR_LEN 1 56 | #define DEF_SVC1_INDICATEABLE_CHAR_LEN 20 57 | #define DEF_SVC1_LONG_VALUE_CHAR_LEN 50 58 | 59 | #define DEF_SVC1_CONTROL_POINT_USER_DESC "Control Point" 60 | #define DEF_SVC1_LED_STATE_USER_DESC "LED State" 61 | #define DEF_SVC1_ADC_VAL_1_USER_DESC "ADC Value 1" 62 | #define DEF_SVC1_ADC_VAL_2_USER_DESC "ADC Value 2" 63 | #define DEF_SVC1_BUTTON_STATE_USER_DESC "Button State" 64 | #define DEF_SVC1_INDICATEABLE_USER_DESC "Indicateable" 65 | #define DEF_SVC1_LONG_VALUE_CHAR_USER_DESC "Long Value" 66 | 67 | // Service 2 of the custom server 1 68 | #define DEF_SVC2_UUID_128 {0x59, 0x5a, 0x08, 0xe4, 0x86, 0x2a, 0x9e, 0x8f, 0xe9, 0x11, 0xbc, 0x7c, 0x7c, 0x46, 0x42, 0x18} 69 | 70 | #define DEF_SVC2_WRITE_VAL_1_UUID_128 {0x20, 0xEE, 0x8D, 0x0C, 0xE1, 0xF0, 0x4A, 0x0C, 0xB3, 0x25, 0xDC, 0x53, 0x6A, 0x68, 0x86, 0x2C} 71 | #define DEF_SVC2_WRITE_VAL_2_UUID_128 {0x4F, 0x43, 0x31, 0x3C, 0x93, 0x92, 0x42, 0xE6, 0xA8, 0x76, 0xFA, 0x3B, 0xEF, 0xB4, 0x87, 0x59} 72 | 73 | #define DEF_SVC2_WRITE_VAL_1_CHAR_LEN 1 74 | #define DEF_SVC2_WRITE_VAL_2_CHAR_LEN 1 75 | 76 | #define DEF_SVC2_WRITE_VAL_1_USER_DESC "Write me" 77 | #define DEF_SVC2_WRITE_VAL_2_USER_DESC "Write me (no rsp)" 78 | 79 | // Service 3 of the custom server 1 80 | #define DEF_SVC3_UUID_128 {0x59, 0x5a, 0x08, 0xe4, 0x86, 0x2a, 0x9e, 0x8, 0xe9, 0x11, 0xbc, 0x7c, 0xd0, 0x47, 0x42, 0x18} 81 | 82 | #define DEF_SVC3_READ_VAL_1_UUID_128 {0x17, 0xB9, 0x67, 0x98, 0x4C, 0x66, 0x4C, 0x01, 0x96, 0x33, 0x31, 0xB1, 0x91, 0x59, 0x00, 0x14} 83 | #define DEF_SVC3_READ_VAL_2_UUID_128 {0x23, 0x68, 0xEC, 0x52, 0x1E, 0x62, 0x44, 0x74, 0x9A, 0x1B, 0xD1, 0x8B, 0xAB, 0x75, 0xB6, 0x6D} 84 | #define DEF_SVC3_READ_VAL_3_UUID_128 {0x28, 0xD5, 0xE1, 0xC1, 0xE1, 0xC5, 0x47, 0x29, 0xB5, 0x57, 0x65, 0xC3, 0xBA, 0x47, 0x15, 0x9D} 85 | 86 | #define DEF_SVC3_READ_VAL_1_CHAR_LEN 2 87 | #define DEF_SVC3_READ_VAL_2_CHAR_LEN 2 88 | #define DEF_SVC3_READ_VAL_3_CHAR_LEN 2 89 | 90 | #define DEF_SVC3_READ_VAL_1_USER_DESC "Read me (notify)" 91 | #define DEF_SVC3_READ_VAL_2_USER_DESC "Read me" 92 | #define DEF_SVC3_READ_VAL_3_USER_DESC "Read me (indicate)" 93 | 94 | /// Custom1 Service Data Base Characteristic enum 95 | enum 96 | { 97 | // Custom Service 1 98 | SVC1_IDX_SVC = 0, 99 | 100 | SVC1_IDX_CONTROL_POINT_CHAR, 101 | SVC1_IDX_CONTROL_POINT_VAL, 102 | SVC1_IDX_CONTROL_POINT_USER_DESC, 103 | 104 | SVC1_IDX_LED_STATE_CHAR, 105 | SVC1_IDX_LED_STATE_VAL, 106 | SVC1_IDX_LED_STATE_USER_DESC, 107 | 108 | SVC1_IDX_ADC_VAL_1_CHAR, 109 | SVC1_IDX_ADC_VAL_1_VAL, 110 | SVC1_IDX_ADC_VAL_1_NTF_CFG, 111 | SVC1_IDX_ADC_VAL_1_USER_DESC, 112 | 113 | SVC1_IDX_ADC_VAL_2_CHAR, 114 | SVC1_IDX_ADC_VAL_2_VAL, 115 | SVC1_IDX_ADC_VAL_2_USER_DESC, 116 | 117 | SVC1_IDX_BUTTON_STATE_CHAR, 118 | SVC1_IDX_BUTTON_STATE_VAL, 119 | SVC1_IDX_BUTTON_STATE_NTF_CFG, 120 | SVC1_IDX_BUTTON_STATE_USER_DESC, 121 | 122 | SVC1_IDX_INDICATEABLE_CHAR, 123 | SVC1_IDX_INDICATEABLE_VAL, 124 | SVC1_IDX_INDICATEABLE_IND_CFG, 125 | SVC1_IDX_INDICATEABLE_USER_DESC, 126 | 127 | SVC1_IDX_LONG_VALUE_CHAR, 128 | SVC1_IDX_LONG_VALUE_VAL, 129 | SVC1_IDX_LONG_VALUE_NTF_CFG, 130 | SVC1_IDX_LONG_VALUE_USER_DESC, 131 | 132 | // Custom Service 2 133 | SVC2_IDX_SVC, 134 | 135 | SVC2_WRITE_1_CHAR, 136 | SVC2_WRITE_1_VAL, 137 | SVC2_WRITE_1_USER_DESC, 138 | 139 | SVC2_WRITE_2_CHAR, 140 | SVC2_WRITE_2_VAL, 141 | SVC2_WRITE_2_USER_DESC, 142 | 143 | // Custom Service 3 144 | SVC3_IDX_SVC, 145 | 146 | SVC3_IDX_READ_1_CHAR, 147 | SVC3_IDX_READ_1_VAL, 148 | SVC3_IDX_READ_1_NTF_CFG, 149 | SVC3_IDX_READ_1_USER_DESC, 150 | 151 | SVC3_IDX_READ_2_CHAR, 152 | SVC3_IDX_READ_2_VAL, 153 | SVC3_IDX_READ_2_USER_DESC, 154 | 155 | SVC3_IDX_READ_3_CHAR, 156 | SVC3_IDX_READ_3_VAL, 157 | SVC3_IDX_READ_3_IND_CFG, 158 | SVC3_IDX_READ_3_USER_DESC, 159 | 160 | CUSTS1_IDX_NB 161 | }; 162 | 163 | /// @} USER_CONFIG 164 | 165 | #endif // _USER_CUSTS1_DEF_H_ 166 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_gpio/src/custom_profile/user_custs_config.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_custs_config.c 5 | * 6 | * @brief Custom1/2 Server (CUSTS1/2) profile database structure and initialization. 7 | * 8 | * Copyright (C) 2016-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | /** 16 | **************************************************************************************** 17 | * @defgroup USER_CONFIG 18 | * @ingroup USER 19 | * @brief Custom1/2 Server (CUSTS1/2) profile database structure and initialization. 20 | * 21 | * @{ 22 | **************************************************************************************** 23 | */ 24 | 25 | /* 26 | * INCLUDE FILES 27 | **************************************************************************************** 28 | */ 29 | 30 | #include "app_prf_types.h" 31 | #include "app_customs.h" 32 | #include "user_custs1_def.h" 33 | 34 | /* 35 | * GLOBAL VARIABLE DEFINITIONS 36 | **************************************************************************************** 37 | */ 38 | 39 | #if (BLE_CUSTOM1_SERVER) 40 | extern const struct attm_desc_128 custs1_att_db[CUSTS1_IDX_NB]; 41 | #endif 42 | 43 | /// Custom1/2 server function callback table 44 | const struct cust_prf_func_callbacks cust_prf_funcs[] = 45 | { 46 | #if (BLE_CUSTOM1_SERVER) 47 | { TASK_ID_CUSTS1, 48 | custs1_att_db, 49 | CUSTS1_IDX_NB, 50 | #if (BLE_APP_PRESENT) 51 | app_custs1_create_db, NULL, 52 | #else 53 | NULL, NULL, 54 | #endif 55 | NULL, NULL, 56 | }, 57 | #endif 58 | #if (BLE_CUSTOM2_SERVER) 59 | { TASK_ID_CUSTS2, 60 | NULL, 61 | 0, 62 | #if (BLE_APP_PRESENT) 63 | app_custs2_create_db, NULL, 64 | #else 65 | NULL, NULL, 66 | #endif 67 | NULL, NULL, 68 | }, 69 | #endif 70 | {TASK_ID_INVALID, NULL, 0, NULL, NULL, NULL, NULL}, // DO NOT MOVE. Must always be last 71 | }; 72 | 73 | /// @} USER_CONFIG 74 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_gpio/src/custom_profile/user_custs_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_custs_config.h 5 | * 6 | * @brief Custom1/2 Server (CUSTS1/2) profile database initialization. 7 | * 8 | * Copyright (C) 2016-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_CUSTS_CONFIG_H_ 16 | #define _USER_CUSTS_CONFIG_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @defgroup USER_CONFIG 21 | * @ingroup USER 22 | * @brief Custom1/2 Server (CUSTS1/2) profile database initialization. 23 | * 24 | * @{ 25 | **************************************************************************************** 26 | */ 27 | 28 | /* 29 | * INCLUDE FILES 30 | **************************************************************************************** 31 | */ 32 | 33 | #include "app_prf_types.h" 34 | 35 | /* 36 | * GLOBAL VARIABLE DECLARATIONS 37 | **************************************************************************************** 38 | */ 39 | 40 | extern const struct cust_prf_func_callbacks cust_prf_funcs[]; 41 | 42 | /// @} USER_CONFIG 43 | 44 | #endif // _USER_CUSTS_CONFIG_H_ 45 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_gpio/src/platform/user_periph_setup.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_periph_setup.c 5 | * 6 | * @brief Peripherals setup and initialization. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | /* 16 | * INCLUDE FILES 17 | **************************************************************************************** 18 | */ 19 | 20 | #include "user_periph_setup.h" 21 | #include "datasheet.h" 22 | #include "system_library.h" 23 | #include "rwip_config.h" 24 | #include "gpio.h" 25 | #include "uart.h" 26 | #include "syscntl.h" 27 | 28 | /* 29 | * GLOBAL VARIABLE DEFINITIONS 30 | **************************************************************************************** 31 | */ 32 | 33 | #if DEVELOPMENT_DEBUG 34 | 35 | void GPIO_reservations(void) 36 | { 37 | /* 38 | i.e. to reserve P0_1 as Generic Purpose I/O: 39 | RESERVE_GPIO(DESCRIPTIVE_NAME, GPIO_PORT_0, GPIO_PIN_1, PID_GPIO); 40 | */ 41 | RESERVE_GPIO(BUTTON, GPIO_PORT_0, GPIO_PIN_11, PID_GPIO); 42 | RESERVE_GPIO(LED, GPIO_PORT_0, GPIO_PIN_9, PID_GPIO); 43 | #if defined (CFG_PRINTF_UART2) 44 | RESERVE_GPIO(UART2_TX, UART2_TX_PORT, UART2_TX_PIN, PID_UART2_TX); 45 | #endif 46 | } 47 | 48 | #endif 49 | 50 | void set_pad_functions(void) 51 | { 52 | /* 53 | i.e. to set P0_1 as Generic purpose Output: 54 | GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_1, OUTPUT, PID_GPIO, false); 55 | */ 56 | GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_11, INPUT_PULLUP, PID_GPIO, false); 57 | GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_9, OUTPUT, PID_GPIO, false); 58 | #if defined (__DA14586__) 59 | // Disallow spontaneous DA14586 SPI Flash wake-up 60 | GPIO_ConfigurePin(GPIO_PORT_2, GPIO_PIN_3, OUTPUT, PID_GPIO, true); 61 | #endif 62 | 63 | #if defined (CFG_PRINTF_UART2) 64 | // Configure UART2 TX Pad 65 | GPIO_ConfigurePin(UART2_TX_PORT, UART2_TX_PIN, OUTPUT, PID_UART2_TX, false); 66 | #endif 67 | 68 | } 69 | 70 | #if defined (CFG_PRINTF_UART2) 71 | // Configuration struct for UART2 72 | static const uart_cfg_t uart_cfg = { 73 | .baud_rate = UART2_BAUDRATE, 74 | .data_bits = UART2_DATABITS, 75 | .parity = UART2_PARITY, 76 | .stop_bits = UART2_STOPBITS, 77 | .auto_flow_control = UART2_AFCE, 78 | .use_fifo = UART2_FIFO, 79 | .tx_fifo_tr_lvl = UART2_TX_FIFO_LEVEL, 80 | .rx_fifo_tr_lvl = UART2_RX_FIFO_LEVEL, 81 | .intr_priority = 2, 82 | }; 83 | #endif 84 | 85 | void periph_init(void) 86 | { 87 | #if defined (__DA14531__) 88 | // In Boost mode enable the DCDC converter to supply VBAT_HIGH for the used GPIOs 89 | syscntl_dcdc_turn_on_in_boost(SYSCNTL_DCDC_LEVEL_3V0); 90 | #else 91 | // Power up peripherals' power domain 92 | SetBits16(PMU_CTRL_REG, PERIPH_SLEEP, 0); 93 | while (!(GetWord16(SYS_STAT_REG) & PER_IS_UP)); 94 | SetBits16(CLK_16M_REG, XTAL16_BIAS_SH_ENABLE, 1); 95 | #endif 96 | 97 | // ROM patch 98 | patch_func(); 99 | 100 | // Initialize peripherals 101 | #if defined (CFG_PRINTF_UART2) 102 | // Initialize UART2 103 | uart_initialize(UART2, &uart_cfg); 104 | #endif 105 | 106 | // Set pad functionality 107 | set_pad_functions(); 108 | 109 | // Enable the pads 110 | GPIO_set_pad_latch_en(true); 111 | } 112 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_gpio/src/user_empty_peripheral_template.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_empty_peripheral_template.c 5 | * 6 | * @brief Empty peripheral template project source code. 7 | * 8 | * Copyright (C) 2012-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | /** 16 | **************************************************************************************** 17 | * @addtogroup APP 18 | * @{ 19 | **************************************************************************************** 20 | */ 21 | #include "rwip_config.h" // SW configuration 22 | 23 | 24 | /* 25 | * INCLUDE FILES 26 | **************************************************************************************** 27 | */ 28 | 29 | #include "app_api.h" 30 | #include "user_empty_peripheral_template.h" 31 | #include "gpio.h" 32 | 33 | /* 34 | * FUNCTION DEFINITIONS 35 | **************************************************************************************** 36 | */ 37 | uint8_t last_led_state = 0; 38 | 39 | void user_on_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param) 40 | { 41 | default_app_on_connection(connection_idx, param); 42 | } 43 | 44 | void user_on_disconnect( struct gapc_disconnect_ind const *param ) 45 | { 46 | default_app_on_disconnect(param); 47 | } 48 | 49 | void button_callback() 50 | { 51 | if(last_led_state == 0) 52 | { 53 | last_led_state = 1; 54 | GPIO_SetActive(GPIO_PORT_0, GPIO_PIN_9); 55 | } 56 | else 57 | { 58 | last_led_state = 0; 59 | GPIO_SetInactive(GPIO_PORT_0, GPIO_PIN_9); 60 | } 61 | } 62 | 63 | void user_app_on_init(void) 64 | { 65 | GPIO_EnableIRQ(GPIO_PORT_0, GPIO_PIN_11, GPIO0_IRQn, true, true, 150); 66 | GPIO_RegisterCallback(GPIO0_IRQn, button_callback); 67 | default_app_on_init(); 68 | } 69 | 70 | 71 | /// @} APP 72 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_gpio/src/user_empty_peripheral_template.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_empty_peripheral_template.h 5 | * 6 | * @brief Empty peripheral template project header file. 7 | * 8 | * Copyright (C) 2012-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_EMPTY_PERIPHERAL_TEMPLATE_H_ 16 | #define _USER_EMPTY_PERIPHERAL_TEMPLATE_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @addtogroup APP 21 | * @ingroup RICOW 22 | * 23 | * @brief 24 | * 25 | * @{ 26 | **************************************************************************************** 27 | */ 28 | 29 | /* 30 | * INCLUDE FILES 31 | **************************************************************************************** 32 | */ 33 | 34 | #include "rwble_config.h" 35 | #include "app_task.h" // application task 36 | #include "gapc_task.h" // gap functions and messages 37 | #include "gapm_task.h" // gap functions and messages 38 | #include "app.h" // application definitions 39 | #include "co_error.h" // error code definitions 40 | 41 | 42 | /**************************************************************************** 43 | Add here supported profiles' application header files. 44 | i.e. 45 | #if (BLE_DIS_SERVER) 46 | #include "app_dis.h" 47 | #include "app_dis_task.h" 48 | #endif 49 | *****************************************************************************/ 50 | 51 | /* 52 | * TYPE DEFINITIONS 53 | **************************************************************************************** 54 | */ 55 | 56 | /* 57 | * DEFINES 58 | **************************************************************************************** 59 | */ 60 | 61 | /* 62 | * FUNCTION DECLARATIONS 63 | **************************************************************************************** 64 | */ 65 | 66 | void user_on_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param); 67 | 68 | void user_on_disconnect( struct gapc_disconnect_ind const *param ); 69 | 70 | void user_app_on_init(void); 71 | 72 | /// @} APP 73 | 74 | #endif // _USER_EMPTY_PERIPHERAL_TEMPLATE_H_ 75 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_i2c/Eclipse/makefile.targets: -------------------------------------------------------------------------------- 1 | .PHONY: main-build pre-build generate_ldscripts FORCE 2 | main-build : | pre-build 3 | 4 | FORCE: 5 | 6 | INC_PARAMS=$(foreach d, $(LDSCRIPT_INCLUDE_DIR), -I "$d") 7 | 8 | generate_ldscripts : $(LDSCRIPT_FILES) 9 | 10 | %.lds : $(LDSCRIPT_PATH)/%.lds.S FORCE 11 | "$(CC)" ${INC_PARAMS} $(PRE_BUILD_EXTRA_DEFS) $(LD_DEFS) -E -P -c "$<" -o "$@" 12 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_i2c/src/config/user_modules_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_modules_config.h 5 | * 6 | * @brief User modules configuration file. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_MODULES_CONFIG_H_ 16 | #define _USER_MODULES_CONFIG_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @addtogroup APP 21 | * @ingroup RICOW 22 | * 23 | * @brief User modules configuration. 24 | * 25 | * @{ 26 | **************************************************************************************** 27 | */ 28 | 29 | /* 30 | * DEFINES 31 | **************************************************************************************** 32 | */ 33 | 34 | /***************************************************************************************/ 35 | /* Exclude or not a module in user's application code. */ 36 | /* */ 37 | /* (0) - The module is included. The module's messages are handled by the SDK. */ 38 | /* */ 39 | /* (1) - The module is excluded. The user must handle the module's messages. */ 40 | /* */ 41 | /* Note: */ 42 | /* This setting has no effect if the respective module is a BLE Profile */ 43 | /* that is not used included in the user's application. */ 44 | /***************************************************************************************/ 45 | #define EXCLUDE_DLG_GAP (0) 46 | #define EXCLUDE_DLG_TIMER (0) 47 | #define EXCLUDE_DLG_MSG (0) 48 | #define EXCLUDE_DLG_SEC (0) 49 | #define EXCLUDE_DLG_DISS (0) 50 | #define EXCLUDE_DLG_PROXR (0) 51 | #define EXCLUDE_DLG_BASS (0) 52 | #define EXCLUDE_DLG_FINDL (0) 53 | #define EXCLUDE_DLG_FINDT (0) 54 | #define EXCLUDE_DLG_SUOTAR (0) 55 | #define EXCLUDE_DLG_CUSTS1 (0) 56 | #define EXCLUDE_DLG_CUSTS2 (0) 57 | 58 | /// @} APP 59 | 60 | #endif // _USER_MODULES_CONFIG_H_ 61 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_i2c/src/config/user_periph_setup.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_periph_setup.h 5 | * 6 | * @brief Peripherals setup header file. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_PERIPH_SETUP_H_ 16 | #define _USER_PERIPH_SETUP_H_ 17 | 18 | /* 19 | * INCLUDE FILES 20 | **************************************************************************************** 21 | */ 22 | 23 | #include "arch.h" 24 | #include "gpio.h" 25 | #include "uart.h" 26 | 27 | 28 | /* 29 | * DEFINES 30 | **************************************************************************************** 31 | */ 32 | 33 | 34 | /****************************************************************************************/ 35 | /* UART2 configuration to use with arch_console print messages */ 36 | /****************************************************************************************/ 37 | // Define UART2 Tx Pad 38 | #if defined (__DA14531__) 39 | #define UART2_TX_PORT GPIO_PORT_0 40 | #define UART2_TX_PIN GPIO_PIN_6 41 | #else 42 | #define UART2_TX_PORT GPIO_PORT_0 43 | #define UART2_TX_PIN GPIO_PIN_4 44 | #endif 45 | 46 | // Define UART2 Settings 47 | #define UART2_BAUDRATE UART_BAUDRATE_115200 48 | #define UART2_DATABITS UART_DATABITS_8 49 | #define UART2_PARITY UART_PARITY_NONE 50 | #define UART2_STOPBITS UART_STOPBITS_1 51 | #define UART2_AFCE UART_AFCE_DIS 52 | #define UART2_FIFO UART_FIFO_EN 53 | #define UART2_TX_FIFO_LEVEL UART_TX_FIFO_LEVEL_0 54 | #define UART2_RX_FIFO_LEVEL UART_RX_FIFO_LEVEL_0 55 | 56 | 57 | /***************************************************************************************/ 58 | /* Production debug output configuration */ 59 | /***************************************************************************************/ 60 | #if PRODUCTION_DEBUG_OUTPUT 61 | #if defined (__DA14531__) 62 | #define PRODUCTION_DEBUG_PORT GPIO_PORT_0 63 | #define PRODUCTION_DEBUG_PIN GPIO_PIN_11 64 | #else 65 | #define PRODUCTION_DEBUG_PORT GPIO_PORT_2 66 | #define PRODUCTION_DEBUG_PIN GPIO_PIN_5 67 | #endif 68 | #endif 69 | 70 | /* 71 | * FUNCTION DECLARATIONS 72 | **************************************************************************************** 73 | */ 74 | 75 | #if DEVELOPMENT_DEBUG 76 | /** 77 | **************************************************************************************** 78 | * @brief Reserves application's specific GPIOs 79 | * @details Used only in Development mode (#if DEVELOPMENT_DEBUG) 80 | * i.e. to reserve P0_1 as Generic Purpose I/O: 81 | * RESERVE_GPIO(DESCRIPTIVE_NAME, GPIO_PORT_0, GPIO_PIN_1, PID_GPIO); 82 | **************************************************************************************** 83 | */ 84 | void GPIO_reservations(void); 85 | #endif 86 | 87 | /** 88 | **************************************************************************************** 89 | * @brief Sets the functionality of application pads 90 | * @details i.e. to set P0_1 as Generic purpose Output: 91 | * GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_1, OUTPUT, PID_GPIO, false); 92 | **************************************************************************************** 93 | */ 94 | void set_pad_functions(void); 95 | 96 | /** 97 | **************************************************************************************** 98 | * @brief Initializes application's peripherals and pins 99 | **************************************************************************************** 100 | */ 101 | void periph_init(void); 102 | 103 | 104 | #endif // _USER_PERIPH_SETUP_H_ 105 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_i2c/src/config/user_profiles_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_profiles_config.h 5 | * 6 | * @brief Configuration file for the profiles used in the application. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_PROFILES_CONFIG_H_ 16 | #define _USER_PROFILES_CONFIG_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @defgroup APP_CONFIG 21 | * @ingroup APP 22 | * @brief Application configuration file 23 | * 24 | * This file contains the configuration of the profiles used by the application. 25 | * 26 | * @{ 27 | **************************************************************************************** 28 | */ 29 | 30 | /* 31 | * DEFINITIONS 32 | **************************************************************************************** 33 | */ 34 | 35 | /***************************************************************************************/ 36 | /* Used BLE profiles (used by "rwprf_config.h"). */ 37 | /***************************************************************************************/ 38 | 39 | #define CFG_PRF_DISS 40 | #define CFG_PRF_CUST1 41 | 42 | /***************************************************************************************/ 43 | /* Profile application configuration section */ 44 | /***************************************************************************************/ 45 | 46 | /* 47 | **************************************************************************************** 48 | * DISS application profile configuration 49 | **************************************************************************************** 50 | */ 51 | 52 | #define APP_DIS_FEATURES (DIS_MANUFACTURER_NAME_CHAR_SUP | \ 53 | DIS_MODEL_NB_STR_CHAR_SUP | \ 54 | DIS_SYSTEM_ID_CHAR_SUP | \ 55 | DIS_SW_REV_STR_CHAR_SUP | \ 56 | DIS_FIRM_REV_STR_CHAR_SUP | \ 57 | DIS_PNP_ID_CHAR_SUP) 58 | 59 | /// Manufacturer Name (up to 18 chars) 60 | #define APP_DIS_MANUFACTURER_NAME ("Dialog Semi") 61 | #define APP_DIS_MANUFACTURER_NAME_LEN (11) 62 | 63 | /// Model Number String (up to 18 chars) 64 | #if defined (__DA14586__) 65 | #define APP_DIS_MODEL_NB_STR ("DA14586") 66 | #elif defined (__DA14531__) 67 | #define APP_DIS_MODEL_NB_STR ("DA14531") 68 | #else 69 | #define APP_DIS_MODEL_NB_STR ("DA14585") 70 | #endif 71 | #define APP_DIS_MODEL_NB_STR_LEN (7) 72 | 73 | /// System ID - LSB -> MSB 74 | #define APP_DIS_SYSTEM_ID ("\x12\x34\x56\xFF\xFE\x9A\xBC\xDE") 75 | #define APP_DIS_SYSTEM_ID_LEN (8) 76 | 77 | #define APP_DIS_SW_REV SDK_VERSION 78 | #define APP_DIS_FIRM_REV SDK_VERSION 79 | 80 | /// Serial Number 81 | #define APP_DIS_SERIAL_NB_STR ("1.0.0.0-LE") 82 | #define APP_DIS_SERIAL_NB_STR_LEN (10) 83 | 84 | /// Hardware Revision String 85 | #if defined (__DA14586__) 86 | #define APP_DIS_HARD_REV_STR ("DA14586") 87 | #elif defined (__DA14531__) 88 | #define APP_DIS_HARD_REV_STR ("DA14531") 89 | #else 90 | #define APP_DIS_HARD_REV_STR ("DA14585") 91 | #endif 92 | #define APP_DIS_HARD_REV_STR_LEN (7) 93 | 94 | /// Firmware Revision 95 | #define APP_DIS_FIRM_REV_STR SDK_VERSION 96 | #define APP_DIS_FIRM_REV_STR_LEN (sizeof(APP_DIS_FIRM_REV_STR) - 1) 97 | 98 | /// Software Revision String 99 | #define APP_DIS_SW_REV_STR SDK_VERSION 100 | #define APP_DIS_SW_REV_STR_LEN (sizeof(APP_DIS_SW_REV_STR) - 1) 101 | 102 | /// IEEE 103 | #define APP_DIS_IEEE ("\xFF\xEE\xDD\xCC\xBB\xAA") 104 | #define APP_DIS_IEEE_LEN (6) 105 | 106 | /** 107 | * PNP ID Value - LSB -> MSB 108 | * Vendor ID Source : 0x02 (USB Implementers Forum assigned Vendor ID value) 109 | * Vendor ID : 0x045E (Microsoft Corp) 110 | * Product ID : 0x0040 111 | * Product Version : 0x0300 112 | * e.g. #define APP_DIS_PNP_ID ("\x02\x5E\x04\x40\x00\x00\x03") 113 | */ 114 | #define APP_DIS_PNP_ID ("\x01\xD2\x00\x80\x05\x00\x01") 115 | #define APP_DIS_PNP_ID_LEN (7) 116 | 117 | /// @} APP_CONFIG 118 | 119 | #endif // _USER_PROFILES_CONFIG_H_ 120 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_i2c/src/custom_profile/user_custs1_def.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_custs1_def.h 5 | * 6 | * @brief Custom Server 1 (CUSTS1) profile database definitions. 7 | * 8 | * Copyright (C) 2016-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_CUSTS1_DEF_H_ 16 | #define _USER_CUSTS1_DEF_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @defgroup USER_CONFIG 21 | * @ingroup USER 22 | * @brief Custom Server 1 (CUSTS1) profile database definitions. 23 | * 24 | * @{ 25 | **************************************************************************************** 26 | */ 27 | 28 | /* 29 | * INCLUDE FILES 30 | **************************************************************************************** 31 | */ 32 | 33 | #include "attm_db_128.h" 34 | 35 | /* 36 | * DEFINES 37 | **************************************************************************************** 38 | */ 39 | 40 | // Service 1 of the custom server 1 41 | #define DEF_SVC1_UUID_128 {0x59, 0x5a, 0x08, 0xe4, 0x86, 0x2a, 0x9e, 0x8f, 0xe9, 0x11, 0xbc, 0x7c, 0x98, 0x43, 0x42, 0x18} 42 | 43 | #define DEF_SVC1_CTRL_POINT_UUID_128 {0x20, 0xEE, 0x8D, 0x0C, 0xE1, 0xF0, 0x4A, 0x0C, 0xB3, 0x25, 0xDC, 0x53, 0x6A, 0x68, 0x86, 0x2D} 44 | #define DEF_SVC1_LED_STATE_UUID_128 {0x4F, 0x43, 0x31, 0x3C, 0x93, 0x92, 0x42, 0xE6, 0xA8, 0x76, 0xFA, 0x3B, 0xEF, 0xB4, 0x87, 0x5A} 45 | #define DEF_SVC1_ADC_VAL_1_UUID_128 {0x17, 0xB9, 0x67, 0x98, 0x4C, 0x66, 0x4C, 0x01, 0x96, 0x33, 0x31, 0xB1, 0x91, 0x59, 0x00, 0x15} 46 | #define DEF_SVC1_ADC_VAL_2_UUID_128 {0x23, 0x68, 0xEC, 0x52, 0x1E, 0x62, 0x44, 0x74, 0x9A, 0x1B, 0xD1, 0x8B, 0xAB, 0x75, 0xB6, 0x6E} 47 | #define DEF_SVC1_BUTTON_STATE_UUID_128 {0x9E, 0xE7, 0xBA, 0x08, 0xB9, 0xA9, 0x48, 0xAB, 0xA1, 0xAC, 0x03, 0x1C, 0x2E, 0x0D, 0x29, 0x6C} 48 | #define DEF_SVC1_INDICATEABLE_UUID_128 {0x28, 0xD5, 0xE1, 0xC1, 0xE1, 0xC5, 0x47, 0x29, 0xB5, 0x57, 0x65, 0xC3, 0xBA, 0x47, 0x15, 0x9E} 49 | #define DEF_SVC1_LONG_VALUE_UUID_128 {0x8C, 0x09, 0xE0, 0xD1, 0x81, 0x54, 0x42, 0x40, 0x8E, 0x4F, 0xD2, 0xB3, 0x77, 0xE3, 0x2A, 0x77} 50 | 51 | #define DEF_SVC1_CTRL_POINT_CHAR_LEN 1 52 | #define DEF_SVC1_LED_STATE_CHAR_LEN 1 53 | #define DEF_SVC1_ADC_VAL_1_CHAR_LEN 2 54 | #define DEF_SVC1_ADC_VAL_2_CHAR_LEN 2 55 | #define DEF_SVC1_BUTTON_STATE_CHAR_LEN 1 56 | #define DEF_SVC1_INDICATEABLE_CHAR_LEN 20 57 | #define DEF_SVC1_LONG_VALUE_CHAR_LEN 50 58 | 59 | #define DEF_SVC1_CONTROL_POINT_USER_DESC "Control Point" 60 | #define DEF_SVC1_LED_STATE_USER_DESC "LED State" 61 | #define DEF_SVC1_ADC_VAL_1_USER_DESC "ADC Value 1" 62 | #define DEF_SVC1_ADC_VAL_2_USER_DESC "ADC Value 2" 63 | #define DEF_SVC1_BUTTON_STATE_USER_DESC "Button State" 64 | #define DEF_SVC1_INDICATEABLE_USER_DESC "Indicateable" 65 | #define DEF_SVC1_LONG_VALUE_CHAR_USER_DESC "Long Value" 66 | 67 | // Service 2 of the custom server 1 68 | #define DEF_SVC2_UUID_128 {0x59, 0x5a, 0x08, 0xe4, 0x86, 0x2a, 0x9e, 0x8f, 0xe9, 0x11, 0xbc, 0x7c, 0x7c, 0x46, 0x42, 0x18} 69 | 70 | #define DEF_SVC2_WRITE_VAL_1_UUID_128 {0x20, 0xEE, 0x8D, 0x0C, 0xE1, 0xF0, 0x4A, 0x0C, 0xB3, 0x25, 0xDC, 0x53, 0x6A, 0x68, 0x86, 0x2C} 71 | #define DEF_SVC2_WRITE_VAL_2_UUID_128 {0x4F, 0x43, 0x31, 0x3C, 0x93, 0x92, 0x42, 0xE6, 0xA8, 0x76, 0xFA, 0x3B, 0xEF, 0xB4, 0x87, 0x59} 72 | 73 | #define DEF_SVC2_WRITE_VAL_1_CHAR_LEN 1 74 | #define DEF_SVC2_WRITE_VAL_2_CHAR_LEN 1 75 | 76 | #define DEF_SVC2_WRITE_VAL_1_USER_DESC "Write me" 77 | #define DEF_SVC2_WRITE_VAL_2_USER_DESC "Write me (no rsp)" 78 | 79 | // Service 3 of the custom server 1 80 | #define DEF_SVC3_UUID_128 {0x59, 0x5a, 0x08, 0xe4, 0x86, 0x2a, 0x9e, 0x8, 0xe9, 0x11, 0xbc, 0x7c, 0xd0, 0x47, 0x42, 0x18} 81 | 82 | #define DEF_SVC3_READ_VAL_1_UUID_128 {0x17, 0xB9, 0x67, 0x98, 0x4C, 0x66, 0x4C, 0x01, 0x96, 0x33, 0x31, 0xB1, 0x91, 0x59, 0x00, 0x14} 83 | #define DEF_SVC3_READ_VAL_2_UUID_128 {0x23, 0x68, 0xEC, 0x52, 0x1E, 0x62, 0x44, 0x74, 0x9A, 0x1B, 0xD1, 0x8B, 0xAB, 0x75, 0xB6, 0x6D} 84 | #define DEF_SVC3_READ_VAL_3_UUID_128 {0x28, 0xD5, 0xE1, 0xC1, 0xE1, 0xC5, 0x47, 0x29, 0xB5, 0x57, 0x65, 0xC3, 0xBA, 0x47, 0x15, 0x9D} 85 | 86 | #define DEF_SVC3_READ_VAL_1_CHAR_LEN 2 87 | #define DEF_SVC3_READ_VAL_2_CHAR_LEN 2 88 | #define DEF_SVC3_READ_VAL_3_CHAR_LEN 2 89 | 90 | #define DEF_SVC3_READ_VAL_1_USER_DESC "Read me (notify)" 91 | #define DEF_SVC3_READ_VAL_2_USER_DESC "Read me" 92 | #define DEF_SVC3_READ_VAL_3_USER_DESC "Read me (indicate)" 93 | 94 | /// Custom1 Service Data Base Characteristic enum 95 | enum 96 | { 97 | // Custom Service 1 98 | SVC1_IDX_SVC = 0, 99 | 100 | SVC1_IDX_CONTROL_POINT_CHAR, 101 | SVC1_IDX_CONTROL_POINT_VAL, 102 | SVC1_IDX_CONTROL_POINT_USER_DESC, 103 | 104 | SVC1_IDX_LED_STATE_CHAR, 105 | SVC1_IDX_LED_STATE_VAL, 106 | SVC1_IDX_LED_STATE_USER_DESC, 107 | 108 | SVC1_IDX_ADC_VAL_1_CHAR, 109 | SVC1_IDX_ADC_VAL_1_VAL, 110 | SVC1_IDX_ADC_VAL_1_NTF_CFG, 111 | SVC1_IDX_ADC_VAL_1_USER_DESC, 112 | 113 | SVC1_IDX_ADC_VAL_2_CHAR, 114 | SVC1_IDX_ADC_VAL_2_VAL, 115 | SVC1_IDX_ADC_VAL_2_USER_DESC, 116 | 117 | SVC1_IDX_BUTTON_STATE_CHAR, 118 | SVC1_IDX_BUTTON_STATE_VAL, 119 | SVC1_IDX_BUTTON_STATE_NTF_CFG, 120 | SVC1_IDX_BUTTON_STATE_USER_DESC, 121 | 122 | SVC1_IDX_INDICATEABLE_CHAR, 123 | SVC1_IDX_INDICATEABLE_VAL, 124 | SVC1_IDX_INDICATEABLE_IND_CFG, 125 | SVC1_IDX_INDICATEABLE_USER_DESC, 126 | 127 | SVC1_IDX_LONG_VALUE_CHAR, 128 | SVC1_IDX_LONG_VALUE_VAL, 129 | SVC1_IDX_LONG_VALUE_NTF_CFG, 130 | SVC1_IDX_LONG_VALUE_USER_DESC, 131 | 132 | // Custom Service 2 133 | SVC2_IDX_SVC, 134 | 135 | SVC2_WRITE_1_CHAR, 136 | SVC2_WRITE_1_VAL, 137 | SVC2_WRITE_1_USER_DESC, 138 | 139 | SVC2_WRITE_2_CHAR, 140 | SVC2_WRITE_2_VAL, 141 | SVC2_WRITE_2_USER_DESC, 142 | 143 | // Custom Service 3 144 | SVC3_IDX_SVC, 145 | 146 | SVC3_IDX_READ_1_CHAR, 147 | SVC3_IDX_READ_1_VAL, 148 | SVC3_IDX_READ_1_NTF_CFG, 149 | SVC3_IDX_READ_1_USER_DESC, 150 | 151 | SVC3_IDX_READ_2_CHAR, 152 | SVC3_IDX_READ_2_VAL, 153 | SVC3_IDX_READ_2_USER_DESC, 154 | 155 | SVC3_IDX_READ_3_CHAR, 156 | SVC3_IDX_READ_3_VAL, 157 | SVC3_IDX_READ_3_IND_CFG, 158 | SVC3_IDX_READ_3_USER_DESC, 159 | 160 | CUSTS1_IDX_NB 161 | }; 162 | 163 | /// @} USER_CONFIG 164 | 165 | #endif // _USER_CUSTS1_DEF_H_ 166 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_i2c/src/custom_profile/user_custs_config.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_custs_config.c 5 | * 6 | * @brief Custom1/2 Server (CUSTS1/2) profile database structure and initialization. 7 | * 8 | * Copyright (C) 2016-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | /** 16 | **************************************************************************************** 17 | * @defgroup USER_CONFIG 18 | * @ingroup USER 19 | * @brief Custom1/2 Server (CUSTS1/2) profile database structure and initialization. 20 | * 21 | * @{ 22 | **************************************************************************************** 23 | */ 24 | 25 | /* 26 | * INCLUDE FILES 27 | **************************************************************************************** 28 | */ 29 | 30 | #include "app_prf_types.h" 31 | #include "app_customs.h" 32 | #include "user_custs1_def.h" 33 | 34 | /* 35 | * GLOBAL VARIABLE DEFINITIONS 36 | **************************************************************************************** 37 | */ 38 | 39 | #if (BLE_CUSTOM1_SERVER) 40 | extern const struct attm_desc_128 custs1_att_db[CUSTS1_IDX_NB]; 41 | #endif 42 | 43 | /// Custom1/2 server function callback table 44 | const struct cust_prf_func_callbacks cust_prf_funcs[] = 45 | { 46 | #if (BLE_CUSTOM1_SERVER) 47 | { TASK_ID_CUSTS1, 48 | custs1_att_db, 49 | CUSTS1_IDX_NB, 50 | #if (BLE_APP_PRESENT) 51 | app_custs1_create_db, NULL, 52 | #else 53 | NULL, NULL, 54 | #endif 55 | NULL, NULL, 56 | }, 57 | #endif 58 | #if (BLE_CUSTOM2_SERVER) 59 | { TASK_ID_CUSTS2, 60 | NULL, 61 | 0, 62 | #if (BLE_APP_PRESENT) 63 | app_custs2_create_db, NULL, 64 | #else 65 | NULL, NULL, 66 | #endif 67 | NULL, NULL, 68 | }, 69 | #endif 70 | {TASK_ID_INVALID, NULL, 0, NULL, NULL, NULL, NULL}, // DO NOT MOVE. Must always be last 71 | }; 72 | 73 | /// @} USER_CONFIG 74 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_i2c/src/custom_profile/user_custs_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_custs_config.h 5 | * 6 | * @brief Custom1/2 Server (CUSTS1/2) profile database initialization. 7 | * 8 | * Copyright (C) 2016-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_CUSTS_CONFIG_H_ 16 | #define _USER_CUSTS_CONFIG_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @defgroup USER_CONFIG 21 | * @ingroup USER 22 | * @brief Custom1/2 Server (CUSTS1/2) profile database initialization. 23 | * 24 | * @{ 25 | **************************************************************************************** 26 | */ 27 | 28 | /* 29 | * INCLUDE FILES 30 | **************************************************************************************** 31 | */ 32 | 33 | #include "app_prf_types.h" 34 | 35 | /* 36 | * GLOBAL VARIABLE DECLARATIONS 37 | **************************************************************************************** 38 | */ 39 | 40 | extern const struct cust_prf_func_callbacks cust_prf_funcs[]; 41 | 42 | /// @} USER_CONFIG 43 | 44 | #endif // _USER_CUSTS_CONFIG_H_ 45 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_i2c/src/platform/user_periph_setup.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_periph_setup.c 5 | * 6 | * @brief Peripherals setup and initialization. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | /* 16 | * INCLUDE FILES 17 | **************************************************************************************** 18 | */ 19 | 20 | #include "user_periph_setup.h" 21 | #include "datasheet.h" 22 | #include "system_library.h" 23 | #include "rwip_config.h" 24 | #include "gpio.h" 25 | #include "uart.h" 26 | #include "syscntl.h" 27 | #include "i2c.h" 28 | 29 | /* 30 | * GLOBAL VARIABLE DEFINITIONS 31 | **************************************************************************************** 32 | */ 33 | 34 | #if DEVELOPMENT_DEBUG 35 | 36 | void GPIO_reservations(void) 37 | { 38 | /* 39 | i.e. to reserve P0_1 as Generic Purpose I/O: 40 | RESERVE_GPIO(DESCRIPTIVE_NAME, GPIO_PORT_0, GPIO_PIN_1, PID_GPIO); 41 | */ 42 | RESERVE_GPIO(SDA, GPIO_PORT_0, GPIO_PIN_11, PID_I2C_SDA); 43 | RESERVE_GPIO(SCL, GPIO_PORT_0, GPIO_PIN_8, PID_I2C_SCL); 44 | #if defined (CFG_PRINTF_UART2) 45 | RESERVE_GPIO(UART2_TX, UART2_TX_PORT, UART2_TX_PIN, PID_UART2_TX); 46 | #endif 47 | } 48 | 49 | #endif 50 | 51 | void set_pad_functions(void) 52 | { 53 | /* 54 | i.e. to set P0_1 as Generic purpose Output: 55 | GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_1, OUTPUT, PID_GPIO, false); 56 | */ 57 | GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_11, INPUT, PID_I2C_SDA, true); 58 | GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_8, OUTPUT, PID_I2C_SCL, true); 59 | #if defined (__DA14586__) 60 | // Disallow spontaneous DA14586 SPI Flash wake-up 61 | GPIO_ConfigurePin(GPIO_PORT_2, GPIO_PIN_3, OUTPUT, PID_GPIO, true); 62 | #endif 63 | 64 | #if defined (CFG_PRINTF_UART2) 65 | // Configure UART2 TX Pad 66 | GPIO_ConfigurePin(UART2_TX_PORT, UART2_TX_PIN, OUTPUT, PID_UART2_TX, false); 67 | #endif 68 | 69 | } 70 | 71 | #if defined (CFG_PRINTF_UART2) 72 | // Configuration struct for UART2 73 | static const uart_cfg_t uart_cfg = { 74 | .baud_rate = UART2_BAUDRATE, 75 | .data_bits = UART2_DATABITS, 76 | .parity = UART2_PARITY, 77 | .stop_bits = UART2_STOPBITS, 78 | .auto_flow_control = UART2_AFCE, 79 | .use_fifo = UART2_FIFO, 80 | .tx_fifo_tr_lvl = UART2_TX_FIFO_LEVEL, 81 | .rx_fifo_tr_lvl = UART2_RX_FIFO_LEVEL, 82 | .intr_priority = 2, 83 | }; 84 | #endif 85 | 86 | void periph_init(void) 87 | { 88 | #if defined (__DA14531__) 89 | // In Boost mode enable the DCDC converter to supply VBAT_HIGH for the used GPIOs 90 | syscntl_dcdc_turn_on_in_boost(SYSCNTL_DCDC_LEVEL_3V0); 91 | #else 92 | // Power up peripherals' power domain 93 | SetBits16(PMU_CTRL_REG, PERIPH_SLEEP, 0); 94 | while (!(GetWord16(SYS_STAT_REG) & PER_IS_UP)); 95 | SetBits16(CLK_16M_REG, XTAL16_BIAS_SH_ENABLE, 1); 96 | #endif 97 | 98 | static const i2c_cfg_t i2c_cfg = { 99 | .clock_cfg.ss_hcnt = I2C_SS_SCL_HCNT_REG_RESET, 100 | .clock_cfg.ss_lcnt = I2C_SS_SCL_LCNT_REG_RESET, 101 | .clock_cfg.fs_hcnt = I2C_FS_SCL_HCNT_REG_RESET, 102 | .clock_cfg.fs_lcnt = I2C_FS_SCL_LCNT_REG_RESET, 103 | .restart_en = I2C_RESTART_ENABLE, 104 | .speed = I2C_SPEED_FAST, 105 | .mode = I2C_MODE_MASTER, 106 | .addr_mode = I2C_ADDRESSING_7B, 107 | .address = 0x6A, 108 | .tx_fifo_level = 1, 109 | .rx_fifo_level = 1, 110 | }; 111 | 112 | // ROM patch 113 | patch_func(); 114 | 115 | // Initialize peripherals 116 | #if defined (CFG_PRINTF_UART2) 117 | // Initialize UART2 118 | uart_initialize(UART2, &uart_cfg); 119 | #endif 120 | 121 | i2c_init(&i2c_cfg); 122 | 123 | // Set pad functionality 124 | set_pad_functions(); 125 | 126 | // Enable the pads 127 | GPIO_set_pad_latch_en(true); 128 | } 129 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_i2c/src/user_empty_peripheral_template.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_empty_peripheral_template.c 5 | * 6 | * @brief Empty peripheral template project source code. 7 | * 8 | * Copyright (C) 2012-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | /** 16 | **************************************************************************************** 17 | * @addtogroup APP 18 | * @{ 19 | **************************************************************************************** 20 | */ 21 | #include "rwip_config.h" // SW configuration 22 | 23 | 24 | /* 25 | * INCLUDE FILES 26 | **************************************************************************************** 27 | */ 28 | 29 | #include "app_api.h" 30 | #include "user_empty_peripheral_template.h" 31 | #include "gpio.h" 32 | #include "i2c.h" 33 | 34 | /* 35 | * FUNCTION DEFINITIONS 36 | **************************************************************************************** 37 | */ 38 | uint8_t last_led_state = 0; 39 | 40 | void user_on_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param) 41 | { 42 | default_app_on_connection(connection_idx, param); 43 | } 44 | 45 | void user_on_disconnect( struct gapc_disconnect_ind const *param ) 46 | { 47 | default_app_on_disconnect(param); 48 | } 49 | 50 | void i2c_write(uint8_t reg, uint8_t *bufp, uint16_t len) 51 | { 52 | 53 | i2c_abort_t abort_code; 54 | i2c_master_transmit_buffer_sync(®, 1, &abort_code, I2C_F_NONE); 55 | i2c_master_transmit_buffer_sync(bufp, len, &abort_code, I2C_F_ADD_STOP); 56 | } 57 | 58 | void i2c_read(uint8_t reg, uint8_t *bufp, uint16_t len) 59 | { 60 | i2c_abort_t abort_code; 61 | i2c_master_transmit_buffer_sync(®, 1, &abort_code, I2C_F_NONE); 62 | i2c_master_receive_buffer_sync(bufp, len, &abort_code, I2C_F_ADD_STOP); 63 | } 64 | 65 | void read_who_am_i_reg() 66 | { 67 | uint8_t reg_val = 0; 68 | while(reg_val != 0x69) 69 | { 70 | i2c_read(0x0F, ®_val, 1); 71 | } 72 | } 73 | 74 | void imu_reset() 75 | { 76 | uint8_t reg_val = 0; 77 | i2c_read(0x12, ®_val, 1); 78 | reg_val |= 0x01; 79 | i2c_write(0x12, ®_val, 1); 80 | } 81 | 82 | void user_app_on_init(void) 83 | { 84 | read_who_am_i_reg(); 85 | imu_reset(); 86 | read_who_am_i_reg(); 87 | default_app_on_init(); 88 | } 89 | 90 | 91 | /// @} APP 92 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_i2c/src/user_empty_peripheral_template.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_empty_peripheral_template.h 5 | * 6 | * @brief Empty peripheral template project header file. 7 | * 8 | * Copyright (C) 2012-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_EMPTY_PERIPHERAL_TEMPLATE_H_ 16 | #define _USER_EMPTY_PERIPHERAL_TEMPLATE_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @addtogroup APP 21 | * @ingroup RICOW 22 | * 23 | * @brief 24 | * 25 | * @{ 26 | **************************************************************************************** 27 | */ 28 | 29 | /* 30 | * INCLUDE FILES 31 | **************************************************************************************** 32 | */ 33 | 34 | #include "rwble_config.h" 35 | #include "app_task.h" // application task 36 | #include "gapc_task.h" // gap functions and messages 37 | #include "gapm_task.h" // gap functions and messages 38 | #include "app.h" // application definitions 39 | #include "co_error.h" // error code definitions 40 | 41 | 42 | /**************************************************************************** 43 | Add here supported profiles' application header files. 44 | i.e. 45 | #if (BLE_DIS_SERVER) 46 | #include "app_dis.h" 47 | #include "app_dis_task.h" 48 | #endif 49 | *****************************************************************************/ 50 | 51 | /* 52 | * TYPE DEFINITIONS 53 | **************************************************************************************** 54 | */ 55 | 56 | /* 57 | * DEFINES 58 | **************************************************************************************** 59 | */ 60 | 61 | /* 62 | * FUNCTION DECLARATIONS 63 | **************************************************************************************** 64 | */ 65 | 66 | void user_on_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param); 67 | 68 | void user_on_disconnect( struct gapc_disconnect_ind const *param ); 69 | 70 | void user_app_on_init(void); 71 | 72 | /// @} APP 73 | 74 | #endif // _USER_EMPTY_PERIPHERAL_TEMPLATE_H_ 75 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_interrupts/Eclipse/makefile.targets: -------------------------------------------------------------------------------- 1 | .PHONY: main-build pre-build generate_ldscripts FORCE 2 | main-build : | pre-build 3 | 4 | FORCE: 5 | 6 | INC_PARAMS=$(foreach d, $(LDSCRIPT_INCLUDE_DIR), -I "$d") 7 | 8 | generate_ldscripts : $(LDSCRIPT_FILES) 9 | 10 | %.lds : $(LDSCRIPT_PATH)/%.lds.S FORCE 11 | "$(CC)" ${INC_PARAMS} $(PRE_BUILD_EXTRA_DEFS) $(LD_DEFS) -E -P -c "$<" -o "$@" 12 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_interrupts/src/config/user_modules_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_modules_config.h 5 | * 6 | * @brief User modules configuration file. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_MODULES_CONFIG_H_ 16 | #define _USER_MODULES_CONFIG_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @addtogroup APP 21 | * @ingroup RICOW 22 | * 23 | * @brief User modules configuration. 24 | * 25 | * @{ 26 | **************************************************************************************** 27 | */ 28 | 29 | /* 30 | * DEFINES 31 | **************************************************************************************** 32 | */ 33 | 34 | /***************************************************************************************/ 35 | /* Exclude or not a module in user's application code. */ 36 | /* */ 37 | /* (0) - The module is included. The module's messages are handled by the SDK. */ 38 | /* */ 39 | /* (1) - The module is excluded. The user must handle the module's messages. */ 40 | /* */ 41 | /* Note: */ 42 | /* This setting has no effect if the respective module is a BLE Profile */ 43 | /* that is not used included in the user's application. */ 44 | /***************************************************************************************/ 45 | #define EXCLUDE_DLG_GAP (0) 46 | #define EXCLUDE_DLG_TIMER (0) 47 | #define EXCLUDE_DLG_MSG (0) 48 | #define EXCLUDE_DLG_SEC (0) 49 | #define EXCLUDE_DLG_DISS (0) 50 | #define EXCLUDE_DLG_PROXR (0) 51 | #define EXCLUDE_DLG_BASS (0) 52 | #define EXCLUDE_DLG_FINDL (0) 53 | #define EXCLUDE_DLG_FINDT (0) 54 | #define EXCLUDE_DLG_SUOTAR (0) 55 | #define EXCLUDE_DLG_CUSTS1 (0) 56 | #define EXCLUDE_DLG_CUSTS2 (0) 57 | 58 | /// @} APP 59 | 60 | #endif // _USER_MODULES_CONFIG_H_ 61 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_interrupts/src/config/user_periph_setup.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_periph_setup.h 5 | * 6 | * @brief Peripherals setup header file. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_PERIPH_SETUP_H_ 16 | #define _USER_PERIPH_SETUP_H_ 17 | 18 | /* 19 | * INCLUDE FILES 20 | **************************************************************************************** 21 | */ 22 | 23 | #include "arch.h" 24 | #include "gpio.h" 25 | #include "uart.h" 26 | 27 | 28 | /* 29 | * DEFINES 30 | **************************************************************************************** 31 | */ 32 | 33 | 34 | /****************************************************************************************/ 35 | /* UART2 configuration to use with arch_console print messages */ 36 | /****************************************************************************************/ 37 | // Define UART2 Tx Pad 38 | #if defined (__DA14531__) 39 | #define UART2_TX_PORT GPIO_PORT_0 40 | #define UART2_TX_PIN GPIO_PIN_6 41 | #else 42 | #define UART2_TX_PORT GPIO_PORT_0 43 | #define UART2_TX_PIN GPIO_PIN_4 44 | #endif 45 | 46 | // Define UART2 Settings 47 | #define UART2_BAUDRATE UART_BAUDRATE_115200 48 | #define UART2_DATABITS UART_DATABITS_8 49 | #define UART2_PARITY UART_PARITY_NONE 50 | #define UART2_STOPBITS UART_STOPBITS_1 51 | #define UART2_AFCE UART_AFCE_DIS 52 | #define UART2_FIFO UART_FIFO_EN 53 | #define UART2_TX_FIFO_LEVEL UART_TX_FIFO_LEVEL_0 54 | #define UART2_RX_FIFO_LEVEL UART_RX_FIFO_LEVEL_0 55 | 56 | 57 | /***************************************************************************************/ 58 | /* Production debug output configuration */ 59 | /***************************************************************************************/ 60 | #if PRODUCTION_DEBUG_OUTPUT 61 | #if defined (__DA14531__) 62 | #define PRODUCTION_DEBUG_PORT GPIO_PORT_0 63 | #define PRODUCTION_DEBUG_PIN GPIO_PIN_11 64 | #else 65 | #define PRODUCTION_DEBUG_PORT GPIO_PORT_2 66 | #define PRODUCTION_DEBUG_PIN GPIO_PIN_5 67 | #endif 68 | #endif 69 | 70 | /* 71 | * FUNCTION DECLARATIONS 72 | **************************************************************************************** 73 | */ 74 | 75 | #if DEVELOPMENT_DEBUG 76 | /** 77 | **************************************************************************************** 78 | * @brief Reserves application's specific GPIOs 79 | * @details Used only in Development mode (#if DEVELOPMENT_DEBUG) 80 | * i.e. to reserve P0_1 as Generic Purpose I/O: 81 | * RESERVE_GPIO(DESCRIPTIVE_NAME, GPIO_PORT_0, GPIO_PIN_1, PID_GPIO); 82 | **************************************************************************************** 83 | */ 84 | void GPIO_reservations(void); 85 | #endif 86 | 87 | /** 88 | **************************************************************************************** 89 | * @brief Sets the functionality of application pads 90 | * @details i.e. to set P0_1 as Generic purpose Output: 91 | * GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_1, OUTPUT, PID_GPIO, false); 92 | **************************************************************************************** 93 | */ 94 | void set_pad_functions(void); 95 | 96 | /** 97 | **************************************************************************************** 98 | * @brief Initializes application's peripherals and pins 99 | **************************************************************************************** 100 | */ 101 | void periph_init(void); 102 | 103 | 104 | #endif // _USER_PERIPH_SETUP_H_ 105 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_interrupts/src/config/user_profiles_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_profiles_config.h 5 | * 6 | * @brief Configuration file for the profiles used in the application. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_PROFILES_CONFIG_H_ 16 | #define _USER_PROFILES_CONFIG_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @defgroup APP_CONFIG 21 | * @ingroup APP 22 | * @brief Application configuration file 23 | * 24 | * This file contains the configuration of the profiles used by the application. 25 | * 26 | * @{ 27 | **************************************************************************************** 28 | */ 29 | 30 | /* 31 | * DEFINITIONS 32 | **************************************************************************************** 33 | */ 34 | 35 | /***************************************************************************************/ 36 | /* Used BLE profiles (used by "rwprf_config.h"). */ 37 | /***************************************************************************************/ 38 | 39 | #define CFG_PRF_DISS 40 | #define CFG_PRF_CUST1 41 | 42 | /***************************************************************************************/ 43 | /* Profile application configuration section */ 44 | /***************************************************************************************/ 45 | 46 | /* 47 | **************************************************************************************** 48 | * DISS application profile configuration 49 | **************************************************************************************** 50 | */ 51 | 52 | #define APP_DIS_FEATURES (DIS_MANUFACTURER_NAME_CHAR_SUP | \ 53 | DIS_MODEL_NB_STR_CHAR_SUP | \ 54 | DIS_SYSTEM_ID_CHAR_SUP | \ 55 | DIS_SW_REV_STR_CHAR_SUP | \ 56 | DIS_FIRM_REV_STR_CHAR_SUP | \ 57 | DIS_PNP_ID_CHAR_SUP) 58 | 59 | /// Manufacturer Name (up to 18 chars) 60 | #define APP_DIS_MANUFACTURER_NAME ("Dialog Semi") 61 | #define APP_DIS_MANUFACTURER_NAME_LEN (11) 62 | 63 | /// Model Number String (up to 18 chars) 64 | #if defined (__DA14586__) 65 | #define APP_DIS_MODEL_NB_STR ("DA14586") 66 | #elif defined (__DA14531__) 67 | #define APP_DIS_MODEL_NB_STR ("DA14531") 68 | #else 69 | #define APP_DIS_MODEL_NB_STR ("DA14585") 70 | #endif 71 | #define APP_DIS_MODEL_NB_STR_LEN (7) 72 | 73 | /// System ID - LSB -> MSB 74 | #define APP_DIS_SYSTEM_ID ("\x12\x34\x56\xFF\xFE\x9A\xBC\xDE") 75 | #define APP_DIS_SYSTEM_ID_LEN (8) 76 | 77 | #define APP_DIS_SW_REV SDK_VERSION 78 | #define APP_DIS_FIRM_REV SDK_VERSION 79 | 80 | /// Serial Number 81 | #define APP_DIS_SERIAL_NB_STR ("1.0.0.0-LE") 82 | #define APP_DIS_SERIAL_NB_STR_LEN (10) 83 | 84 | /// Hardware Revision String 85 | #if defined (__DA14586__) 86 | #define APP_DIS_HARD_REV_STR ("DA14586") 87 | #elif defined (__DA14531__) 88 | #define APP_DIS_HARD_REV_STR ("DA14531") 89 | #else 90 | #define APP_DIS_HARD_REV_STR ("DA14585") 91 | #endif 92 | #define APP_DIS_HARD_REV_STR_LEN (7) 93 | 94 | /// Firmware Revision 95 | #define APP_DIS_FIRM_REV_STR SDK_VERSION 96 | #define APP_DIS_FIRM_REV_STR_LEN (sizeof(APP_DIS_FIRM_REV_STR) - 1) 97 | 98 | /// Software Revision String 99 | #define APP_DIS_SW_REV_STR SDK_VERSION 100 | #define APP_DIS_SW_REV_STR_LEN (sizeof(APP_DIS_SW_REV_STR) - 1) 101 | 102 | /// IEEE 103 | #define APP_DIS_IEEE ("\xFF\xEE\xDD\xCC\xBB\xAA") 104 | #define APP_DIS_IEEE_LEN (6) 105 | 106 | /** 107 | * PNP ID Value - LSB -> MSB 108 | * Vendor ID Source : 0x02 (USB Implementers Forum assigned Vendor ID value) 109 | * Vendor ID : 0x045E (Microsoft Corp) 110 | * Product ID : 0x0040 111 | * Product Version : 0x0300 112 | * e.g. #define APP_DIS_PNP_ID ("\x02\x5E\x04\x40\x00\x00\x03") 113 | */ 114 | #define APP_DIS_PNP_ID ("\x01\xD2\x00\x80\x05\x00\x01") 115 | #define APP_DIS_PNP_ID_LEN (7) 116 | 117 | /// @} APP_CONFIG 118 | 119 | #endif // _USER_PROFILES_CONFIG_H_ 120 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_interrupts/src/custom_profile/user_custs_config.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_custs_config.c 5 | * 6 | * @brief Custom1/2 Server (CUSTS1/2) profile database structure and initialization. 7 | * 8 | * Copyright (C) 2016-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | /** 16 | **************************************************************************************** 17 | * @defgroup USER_CONFIG 18 | * @ingroup USER 19 | * @brief Custom1/2 Server (CUSTS1/2) profile database structure and initialization. 20 | * 21 | * @{ 22 | **************************************************************************************** 23 | */ 24 | 25 | /* 26 | * INCLUDE FILES 27 | **************************************************************************************** 28 | */ 29 | 30 | #include "app_prf_types.h" 31 | #include "app_customs.h" 32 | #include "user_custs1_def.h" 33 | 34 | /* 35 | * GLOBAL VARIABLE DEFINITIONS 36 | **************************************************************************************** 37 | */ 38 | 39 | #if (BLE_CUSTOM1_SERVER) 40 | extern const struct attm_desc_128 custs1_att_db[CUSTS1_IDX_NB]; 41 | #endif 42 | 43 | /// Custom1/2 server function callback table 44 | const struct cust_prf_func_callbacks cust_prf_funcs[] = 45 | { 46 | #if (BLE_CUSTOM1_SERVER) 47 | { TASK_ID_CUSTS1, 48 | custs1_att_db, 49 | CUSTS1_IDX_NB, 50 | #if (BLE_APP_PRESENT) 51 | app_custs1_create_db, NULL, 52 | #else 53 | NULL, NULL, 54 | #endif 55 | NULL, NULL, 56 | }, 57 | #endif 58 | #if (BLE_CUSTOM2_SERVER) 59 | { TASK_ID_CUSTS2, 60 | NULL, 61 | 0, 62 | #if (BLE_APP_PRESENT) 63 | app_custs2_create_db, NULL, 64 | #else 65 | NULL, NULL, 66 | #endif 67 | NULL, NULL, 68 | }, 69 | #endif 70 | {TASK_ID_INVALID, NULL, 0, NULL, NULL, NULL, NULL}, // DO NOT MOVE. Must always be last 71 | }; 72 | 73 | /// @} USER_CONFIG 74 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_interrupts/src/custom_profile/user_custs_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_custs_config.h 5 | * 6 | * @brief Custom1/2 Server (CUSTS1/2) profile database initialization. 7 | * 8 | * Copyright (C) 2016-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_CUSTS_CONFIG_H_ 16 | #define _USER_CUSTS_CONFIG_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @defgroup USER_CONFIG 21 | * @ingroup USER 22 | * @brief Custom1/2 Server (CUSTS1/2) profile database initialization. 23 | * 24 | * @{ 25 | **************************************************************************************** 26 | */ 27 | 28 | /* 29 | * INCLUDE FILES 30 | **************************************************************************************** 31 | */ 32 | 33 | #include "app_prf_types.h" 34 | 35 | /* 36 | * GLOBAL VARIABLE DECLARATIONS 37 | **************************************************************************************** 38 | */ 39 | 40 | extern const struct cust_prf_func_callbacks cust_prf_funcs[]; 41 | 42 | /// @} USER_CONFIG 43 | 44 | #endif // _USER_CUSTS_CONFIG_H_ 45 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_interrupts/src/lsm6ds3_reg.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicara-hq/da14531-tutorials/96b009f9d6aae3a4e7e2391d7f0b3c174067eb7b/empty_peripheral_template_blog_interrupts/src/lsm6ds3_reg.c -------------------------------------------------------------------------------- /empty_peripheral_template_blog_interrupts/src/platform/user_periph_setup.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_periph_setup.c 5 | * 6 | * @brief Peripherals setup and initialization. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | /* 16 | * INCLUDE FILES 17 | **************************************************************************************** 18 | */ 19 | 20 | #include "user_periph_setup.h" 21 | #include "datasheet.h" 22 | #include "system_library.h" 23 | #include "rwip_config.h" 24 | #include "gpio.h" 25 | #include "uart.h" 26 | #include "syscntl.h" 27 | #include "i2c.h" 28 | #include "lsm6ds3_reg.h" 29 | 30 | /* 31 | * GLOBAL VARIABLE DEFINITIONS 32 | **************************************************************************************** 33 | */ 34 | 35 | stmdev_ctx_t dev_ctx; 36 | 37 | #if DEVELOPMENT_DEBUG 38 | 39 | void GPIO_reservations(void) 40 | { 41 | /* 42 | i.e. to reserve P0_1 as Generic Purpose I/O: 43 | RESERVE_GPIO(DESCRIPTIVE_NAME, GPIO_PORT_0, GPIO_PIN_1, PID_GPIO); 44 | */ 45 | RESERVE_GPIO(SDA, GPIO_PORT_0, GPIO_PIN_11, PID_I2C_SDA); 46 | RESERVE_GPIO(SCL, GPIO_PORT_0, GPIO_PIN_8, PID_I2C_SCL); 47 | RESERVE_GPIO(SCL, GPIO_PORT_0, GPIO_PIN_7, PID_GPIO); 48 | #if defined (CFG_PRINTF_UART2) 49 | RESERVE_GPIO(UART2_TX, UART2_TX_PORT, UART2_TX_PIN, PID_UART2_TX); 50 | #endif 51 | } 52 | 53 | #endif 54 | 55 | void set_pad_functions(void) 56 | { 57 | /* 58 | i.e. to set P0_1 as Generic purpose Output: 59 | GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_1, OUTPUT, PID_GPIO, false); 60 | */ 61 | GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_11, INPUT, PID_I2C_SDA, true); 62 | GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_8, OUTPUT, PID_I2C_SCL, true); 63 | GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_7, INPUT_PULLDOWN, PID_GPIO, false); 64 | #if defined (__DA14586__) 65 | // Disallow spontaneous DA14586 SPI Flash wake-up 66 | GPIO_ConfigurePin(GPIO_PORT_2, GPIO_PIN_3, OUTPUT, PID_GPIO, true); 67 | #endif 68 | 69 | #if defined (CFG_PRINTF_UART2) 70 | // Configure UART2 TX Pad 71 | GPIO_ConfigurePin(UART2_TX_PORT, UART2_TX_PIN, OUTPUT, PID_UART2_TX, false); 72 | #endif 73 | 74 | } 75 | 76 | #if defined (CFG_PRINTF_UART2) 77 | // Configuration struct for UART2 78 | static const uart_cfg_t uart_cfg = { 79 | .baud_rate = UART2_BAUDRATE, 80 | .data_bits = UART2_DATABITS, 81 | .parity = UART2_PARITY, 82 | .stop_bits = UART2_STOPBITS, 83 | .auto_flow_control = UART2_AFCE, 84 | .use_fifo = UART2_FIFO, 85 | .tx_fifo_tr_lvl = UART2_TX_FIFO_LEVEL, 86 | .rx_fifo_tr_lvl = UART2_RX_FIFO_LEVEL, 87 | .intr_priority = 2, 88 | }; 89 | #endif 90 | 91 | int32_t platform_i2c_write(void *handle, uint8_t reg, uint8_t *bufp, 92 | uint16_t len) 93 | { 94 | 95 | i2c_abort_t abort_code; 96 | i2c_master_transmit_buffer_sync(®, 1, &abort_code, I2C_F_NONE); 97 | i2c_master_transmit_buffer_sync(bufp, len, &abort_code, I2C_F_ADD_STOP); 98 | return 0; 99 | } 100 | 101 | int32_t platform_i2c_read(void *handle, uint8_t reg, uint8_t *bufp, 102 | uint16_t len) 103 | { 104 | i2c_abort_t abort_code; 105 | i2c_master_transmit_buffer_sync(®, 1, &abort_code, I2C_F_NONE); 106 | i2c_master_receive_buffer_sync(bufp, len, &abort_code, I2C_F_ADD_STOP); 107 | 108 | return 0; 109 | } 110 | 111 | void periph_init(void) 112 | { 113 | #if defined (__DA14531__) 114 | // In Boost mode enable the DCDC converter to supply VBAT_HIGH for the used GPIOs 115 | syscntl_dcdc_turn_on_in_boost(SYSCNTL_DCDC_LEVEL_3V0); 116 | #else 117 | // Power up peripherals' power domain 118 | SetBits16(PMU_CTRL_REG, PERIPH_SLEEP, 0); 119 | while (!(GetWord16(SYS_STAT_REG) & PER_IS_UP)); 120 | SetBits16(CLK_16M_REG, XTAL16_BIAS_SH_ENABLE, 1); 121 | #endif 122 | 123 | static const i2c_cfg_t i2c_cfg = { 124 | .clock_cfg.ss_hcnt = I2C_SS_SCL_HCNT_REG_RESET, 125 | .clock_cfg.ss_lcnt = I2C_SS_SCL_LCNT_REG_RESET, 126 | .clock_cfg.fs_hcnt = I2C_FS_SCL_HCNT_REG_RESET, 127 | .clock_cfg.fs_lcnt = I2C_FS_SCL_LCNT_REG_RESET, 128 | .restart_en = I2C_RESTART_ENABLE, 129 | .speed = I2C_SPEED_FAST, 130 | .mode = I2C_MODE_MASTER, 131 | .addr_mode = I2C_ADDRESSING_7B, 132 | .address = 0x6A, 133 | .tx_fifo_level = 1, 134 | .rx_fifo_level = 1, 135 | }; 136 | 137 | // ROM patch 138 | patch_func(); 139 | 140 | // Initialize peripherals 141 | #if defined (CFG_PRINTF_UART2) 142 | // Initialize UART2 143 | uart_initialize(UART2, &uart_cfg); 144 | #endif 145 | 146 | i2c_init(&i2c_cfg); 147 | 148 | // LSM6DS3 driver init 149 | dev_ctx.write_reg = platform_i2c_write; 150 | dev_ctx.read_reg = platform_i2c_read; 151 | dev_ctx.handle = NULL; 152 | 153 | // Set pad functionality 154 | set_pad_functions(); 155 | 156 | // Enable the pads 157 | GPIO_set_pad_latch_en(true); 158 | } 159 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_interrupts/src/user_empty_peripheral_template.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_empty_peripheral_template.c 5 | * 6 | * @brief Empty peripheral template project source code. 7 | * 8 | * Copyright (C) 2012-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | /** 16 | **************************************************************************************** 17 | * @addtogroup APP 18 | * @{ 19 | **************************************************************************************** 20 | */ 21 | #include "rwip_config.h" // SW configuration 22 | 23 | 24 | /* 25 | * INCLUDE FILES 26 | **************************************************************************************** 27 | */ 28 | 29 | #include "app_api.h" 30 | #include "user_empty_peripheral_template.h" 31 | #include "gpio.h" 32 | #include "i2c.h" 33 | #include "lsm6ds3_reg.h" 34 | 35 | /* 36 | * FUNCTION DEFINITIONS 37 | **************************************************************************************** 38 | */ 39 | extern stmdev_ctx_t dev_ctx; 40 | uint8_t accel_data_buffer[12] = {0}; 41 | 42 | void user_on_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param) 43 | { 44 | default_app_on_connection(connection_idx, param); 45 | } 46 | 47 | void user_on_disconnect( struct gapc_disconnect_ind const *param ) 48 | { 49 | default_app_on_disconnect(param); 50 | } 51 | 52 | void imu_init(void) 53 | { 54 | uint8_t raw_data_buffer[14] = {0}; 55 | 56 | uint8_t I2C_Response = 0xFF; 57 | lsm6ds3_int1_route_t int_1_reg; 58 | uint8_t who_am_i = 0; 59 | 60 | while(who_am_i != LSM6DS3_ID) 61 | { 62 | lsm6ds3_device_id_get(&dev_ctx, &who_am_i); 63 | } 64 | /* Reset IMU */ 65 | lsm6ds3_reset_set(&dev_ctx, PROPERTY_ENABLE); 66 | do 67 | { 68 | lsm6ds3_reset_get(&dev_ctx, &I2C_Response); 69 | } 70 | while (I2C_Response); 71 | 72 | /* Enable Block Data Update */ 73 | lsm6ds3_block_data_update_set(&dev_ctx, PROPERTY_ENABLE); 74 | 75 | /* Set full scale */ 76 | lsm6ds3_xl_full_scale_set(&dev_ctx, LSM6DS3_2g); 77 | lsm6ds3_gy_full_scale_set(&dev_ctx, LSM6DS3_2000dps); 78 | 79 | /* Set Output Data Rate */ 80 | lsm6ds3_xl_data_rate_set(&dev_ctx, LSM6DS3_XL_ODR_12Hz5); 81 | lsm6ds3_gy_data_rate_set(&dev_ctx, LSM6DS3_GY_ODR_12Hz5); 82 | 83 | lsm6ds3_xl_power_mode_set(&dev_ctx, LSM6DS3_XL_NORMAL); 84 | lsm6ds3_gy_power_mode_set(&dev_ctx, LSM6DS3_GY_NORMAL); 85 | 86 | /* Set Interrupt Pin Active High */ 87 | lsm6ds3_pin_polarity_set(&dev_ctx, LSM6DS3_ACTIVE_LOW); 88 | 89 | lsm6ds3_int_notification_set(&dev_ctx, LSM6DS3_INT_LATCHED); 90 | 91 | /* Set Accelerometer Data-Ready Interrupt */ 92 | lsm6ds3_pin_int1_route_get(&dev_ctx, &int_1_reg); 93 | int_1_reg.int1_drdy_xl = PROPERTY_ENABLE; 94 | lsm6ds3_pin_int1_route_set(&dev_ctx, &int_1_reg); 95 | 96 | /* Synchronise Interrupt Signal */ 97 | lsm6ds3_xl_flag_data_ready_get(&dev_ctx, &I2C_Response); 98 | do 99 | { 100 | lsm6ds3_xl_g_raw_get(&dev_ctx, raw_data_buffer); 101 | lsm6ds3_xl_flag_data_ready_get(&dev_ctx, &I2C_Response); 102 | } 103 | while(I2C_Response); 104 | } 105 | 106 | void interrupt_handler() 107 | { 108 | lsm6ds3_xl_g_raw_get(&dev_ctx, accel_data_buffer); 109 | NVIC_ClearPendingIRQ(GPIO0_IRQn); 110 | } 111 | 112 | void user_app_on_init(void) 113 | { 114 | imu_init(); 115 | GPIO_EnableIRQ(GPIO_PORT_0, GPIO_PIN_7, GPIO0_IRQn, true, false, 0); 116 | GPIO_RegisterCallback(GPIO0_IRQn, interrupt_handler); 117 | default_app_on_init(); 118 | } 119 | 120 | 121 | /// @} APP 122 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_interrupts/src/user_empty_peripheral_template.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_empty_peripheral_template.h 5 | * 6 | * @brief Empty peripheral template project header file. 7 | * 8 | * Copyright (C) 2012-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_EMPTY_PERIPHERAL_TEMPLATE_H_ 16 | #define _USER_EMPTY_PERIPHERAL_TEMPLATE_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @addtogroup APP 21 | * @ingroup RICOW 22 | * 23 | * @brief 24 | * 25 | * @{ 26 | **************************************************************************************** 27 | */ 28 | 29 | /* 30 | * INCLUDE FILES 31 | **************************************************************************************** 32 | */ 33 | 34 | #include "rwble_config.h" 35 | #include "app_task.h" // application task 36 | #include "gapc_task.h" // gap functions and messages 37 | #include "gapm_task.h" // gap functions and messages 38 | #include "app.h" // application definitions 39 | #include "co_error.h" // error code definitions 40 | 41 | 42 | /**************************************************************************** 43 | Add here supported profiles' application header files. 44 | i.e. 45 | #if (BLE_DIS_SERVER) 46 | #include "app_dis.h" 47 | #include "app_dis_task.h" 48 | #endif 49 | *****************************************************************************/ 50 | 51 | /* 52 | * TYPE DEFINITIONS 53 | **************************************************************************************** 54 | */ 55 | 56 | /* 57 | * DEFINES 58 | **************************************************************************************** 59 | */ 60 | 61 | /* 62 | * FUNCTION DECLARATIONS 63 | **************************************************************************************** 64 | */ 65 | 66 | void user_on_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param); 67 | 68 | void user_on_disconnect( struct gapc_disconnect_ind const *param ); 69 | 70 | void user_app_on_init(void); 71 | 72 | /// @} APP 73 | 74 | #endif // _USER_EMPTY_PERIPHERAL_TEMPLATE_H_ 75 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_pwm/Eclipse/makefile.targets: -------------------------------------------------------------------------------- 1 | .PHONY: main-build pre-build generate_ldscripts FORCE 2 | main-build : | pre-build 3 | 4 | FORCE: 5 | 6 | INC_PARAMS=$(foreach d, $(LDSCRIPT_INCLUDE_DIR), -I "$d") 7 | 8 | generate_ldscripts : $(LDSCRIPT_FILES) 9 | 10 | %.lds : $(LDSCRIPT_PATH)/%.lds.S FORCE 11 | "$(CC)" ${INC_PARAMS} $(PRE_BUILD_EXTRA_DEFS) $(LD_DEFS) -E -P -c "$<" -o "$@" 12 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_pwm/src/config/user_modules_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_modules_config.h 5 | * 6 | * @brief User modules configuration file. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_MODULES_CONFIG_H_ 16 | #define _USER_MODULES_CONFIG_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @addtogroup APP 21 | * @ingroup RICOW 22 | * 23 | * @brief User modules configuration. 24 | * 25 | * @{ 26 | **************************************************************************************** 27 | */ 28 | 29 | /* 30 | * DEFINES 31 | **************************************************************************************** 32 | */ 33 | 34 | /***************************************************************************************/ 35 | /* Exclude or not a module in user's application code. */ 36 | /* */ 37 | /* (0) - The module is included. The module's messages are handled by the SDK. */ 38 | /* */ 39 | /* (1) - The module is excluded. The user must handle the module's messages. */ 40 | /* */ 41 | /* Note: */ 42 | /* This setting has no effect if the respective module is a BLE Profile */ 43 | /* that is not used included in the user's application. */ 44 | /***************************************************************************************/ 45 | #define EXCLUDE_DLG_GAP (0) 46 | #define EXCLUDE_DLG_TIMER (0) 47 | #define EXCLUDE_DLG_MSG (0) 48 | #define EXCLUDE_DLG_SEC (0) 49 | #define EXCLUDE_DLG_DISS (0) 50 | #define EXCLUDE_DLG_PROXR (0) 51 | #define EXCLUDE_DLG_BASS (0) 52 | #define EXCLUDE_DLG_FINDL (0) 53 | #define EXCLUDE_DLG_FINDT (0) 54 | #define EXCLUDE_DLG_SUOTAR (0) 55 | #define EXCLUDE_DLG_CUSTS1 (0) 56 | #define EXCLUDE_DLG_CUSTS2 (0) 57 | 58 | /// @} APP 59 | 60 | #endif // _USER_MODULES_CONFIG_H_ 61 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_pwm/src/config/user_periph_setup.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_periph_setup.h 5 | * 6 | * @brief Peripherals setup header file. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_PERIPH_SETUP_H_ 16 | #define _USER_PERIPH_SETUP_H_ 17 | 18 | /* 19 | * INCLUDE FILES 20 | **************************************************************************************** 21 | */ 22 | 23 | #include "arch.h" 24 | #include "gpio.h" 25 | #include "uart.h" 26 | 27 | 28 | /* 29 | * DEFINES 30 | **************************************************************************************** 31 | */ 32 | 33 | 34 | /****************************************************************************************/ 35 | /* UART2 configuration to use with arch_console print messages */ 36 | /****************************************************************************************/ 37 | // Define UART2 Tx Pad 38 | #if defined (__DA14531__) 39 | #define UART2_TX_PORT GPIO_PORT_0 40 | #define UART2_TX_PIN GPIO_PIN_6 41 | #else 42 | #define UART2_TX_PORT GPIO_PORT_0 43 | #define UART2_TX_PIN GPIO_PIN_4 44 | #endif 45 | 46 | // Define UART2 Settings 47 | #define UART2_BAUDRATE UART_BAUDRATE_115200 48 | #define UART2_DATABITS UART_DATABITS_8 49 | #define UART2_PARITY UART_PARITY_NONE 50 | #define UART2_STOPBITS UART_STOPBITS_1 51 | #define UART2_AFCE UART_AFCE_DIS 52 | #define UART2_FIFO UART_FIFO_EN 53 | #define UART2_TX_FIFO_LEVEL UART_TX_FIFO_LEVEL_0 54 | #define UART2_RX_FIFO_LEVEL UART_RX_FIFO_LEVEL_0 55 | 56 | 57 | /***************************************************************************************/ 58 | /* Production debug output configuration */ 59 | /***************************************************************************************/ 60 | #if PRODUCTION_DEBUG_OUTPUT 61 | #if defined (__DA14531__) 62 | #define PRODUCTION_DEBUG_PORT GPIO_PORT_0 63 | #define PRODUCTION_DEBUG_PIN GPIO_PIN_11 64 | #else 65 | #define PRODUCTION_DEBUG_PORT GPIO_PORT_2 66 | #define PRODUCTION_DEBUG_PIN GPIO_PIN_5 67 | #endif 68 | #endif 69 | 70 | /* 71 | * FUNCTION DECLARATIONS 72 | **************************************************************************************** 73 | */ 74 | 75 | #if DEVELOPMENT_DEBUG 76 | /** 77 | **************************************************************************************** 78 | * @brief Reserves application's specific GPIOs 79 | * @details Used only in Development mode (#if DEVELOPMENT_DEBUG) 80 | * i.e. to reserve P0_1 as Generic Purpose I/O: 81 | * RESERVE_GPIO(DESCRIPTIVE_NAME, GPIO_PORT_0, GPIO_PIN_1, PID_GPIO); 82 | **************************************************************************************** 83 | */ 84 | void GPIO_reservations(void); 85 | #endif 86 | 87 | /** 88 | **************************************************************************************** 89 | * @brief Sets the functionality of application pads 90 | * @details i.e. to set P0_1 as Generic purpose Output: 91 | * GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_1, OUTPUT, PID_GPIO, false); 92 | **************************************************************************************** 93 | */ 94 | void set_pad_functions(void); 95 | 96 | /** 97 | **************************************************************************************** 98 | * @brief Initializes application's peripherals and pins 99 | **************************************************************************************** 100 | */ 101 | void periph_init(void); 102 | 103 | 104 | #endif // _USER_PERIPH_SETUP_H_ 105 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_pwm/src/config/user_profiles_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_profiles_config.h 5 | * 6 | * @brief Configuration file for the profiles used in the application. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_PROFILES_CONFIG_H_ 16 | #define _USER_PROFILES_CONFIG_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @defgroup APP_CONFIG 21 | * @ingroup APP 22 | * @brief Application configuration file 23 | * 24 | * This file contains the configuration of the profiles used by the application. 25 | * 26 | * @{ 27 | **************************************************************************************** 28 | */ 29 | 30 | /* 31 | * DEFINITIONS 32 | **************************************************************************************** 33 | */ 34 | 35 | /***************************************************************************************/ 36 | /* Used BLE profiles (used by "rwprf_config.h"). */ 37 | /***************************************************************************************/ 38 | 39 | #define CFG_PRF_DISS 40 | #define CFG_PRF_CUST1 41 | 42 | /***************************************************************************************/ 43 | /* Profile application configuration section */ 44 | /***************************************************************************************/ 45 | 46 | /* 47 | **************************************************************************************** 48 | * DISS application profile configuration 49 | **************************************************************************************** 50 | */ 51 | 52 | #define APP_DIS_FEATURES (DIS_MANUFACTURER_NAME_CHAR_SUP | \ 53 | DIS_MODEL_NB_STR_CHAR_SUP | \ 54 | DIS_SYSTEM_ID_CHAR_SUP | \ 55 | DIS_SW_REV_STR_CHAR_SUP | \ 56 | DIS_FIRM_REV_STR_CHAR_SUP | \ 57 | DIS_PNP_ID_CHAR_SUP) 58 | 59 | /// Manufacturer Name (up to 18 chars) 60 | #define APP_DIS_MANUFACTURER_NAME ("Dialog Semi") 61 | #define APP_DIS_MANUFACTURER_NAME_LEN (11) 62 | 63 | /// Model Number String (up to 18 chars) 64 | #if defined (__DA14586__) 65 | #define APP_DIS_MODEL_NB_STR ("DA14586") 66 | #elif defined (__DA14531__) 67 | #define APP_DIS_MODEL_NB_STR ("DA14531") 68 | #else 69 | #define APP_DIS_MODEL_NB_STR ("DA14585") 70 | #endif 71 | #define APP_DIS_MODEL_NB_STR_LEN (7) 72 | 73 | /// System ID - LSB -> MSB 74 | #define APP_DIS_SYSTEM_ID ("\x12\x34\x56\xFF\xFE\x9A\xBC\xDE") 75 | #define APP_DIS_SYSTEM_ID_LEN (8) 76 | 77 | #define APP_DIS_SW_REV SDK_VERSION 78 | #define APP_DIS_FIRM_REV SDK_VERSION 79 | 80 | /// Serial Number 81 | #define APP_DIS_SERIAL_NB_STR ("1.0.0.0-LE") 82 | #define APP_DIS_SERIAL_NB_STR_LEN (10) 83 | 84 | /// Hardware Revision String 85 | #if defined (__DA14586__) 86 | #define APP_DIS_HARD_REV_STR ("DA14586") 87 | #elif defined (__DA14531__) 88 | #define APP_DIS_HARD_REV_STR ("DA14531") 89 | #else 90 | #define APP_DIS_HARD_REV_STR ("DA14585") 91 | #endif 92 | #define APP_DIS_HARD_REV_STR_LEN (7) 93 | 94 | /// Firmware Revision 95 | #define APP_DIS_FIRM_REV_STR SDK_VERSION 96 | #define APP_DIS_FIRM_REV_STR_LEN (sizeof(APP_DIS_FIRM_REV_STR) - 1) 97 | 98 | /// Software Revision String 99 | #define APP_DIS_SW_REV_STR SDK_VERSION 100 | #define APP_DIS_SW_REV_STR_LEN (sizeof(APP_DIS_SW_REV_STR) - 1) 101 | 102 | /// IEEE 103 | #define APP_DIS_IEEE ("\xFF\xEE\xDD\xCC\xBB\xAA") 104 | #define APP_DIS_IEEE_LEN (6) 105 | 106 | /** 107 | * PNP ID Value - LSB -> MSB 108 | * Vendor ID Source : 0x02 (USB Implementers Forum assigned Vendor ID value) 109 | * Vendor ID : 0x045E (Microsoft Corp) 110 | * Product ID : 0x0040 111 | * Product Version : 0x0300 112 | * e.g. #define APP_DIS_PNP_ID ("\x02\x5E\x04\x40\x00\x00\x03") 113 | */ 114 | #define APP_DIS_PNP_ID ("\x01\xD2\x00\x80\x05\x00\x01") 115 | #define APP_DIS_PNP_ID_LEN (7) 116 | 117 | /// @} APP_CONFIG 118 | 119 | #endif // _USER_PROFILES_CONFIG_H_ 120 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_pwm/src/custom_profile/user_custs_config.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_custs_config.c 5 | * 6 | * @brief Custom1/2 Server (CUSTS1/2) profile database structure and initialization. 7 | * 8 | * Copyright (C) 2016-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | /** 16 | **************************************************************************************** 17 | * @defgroup USER_CONFIG 18 | * @ingroup USER 19 | * @brief Custom1/2 Server (CUSTS1/2) profile database structure and initialization. 20 | * 21 | * @{ 22 | **************************************************************************************** 23 | */ 24 | 25 | /* 26 | * INCLUDE FILES 27 | **************************************************************************************** 28 | */ 29 | 30 | #include "app_prf_types.h" 31 | #include "app_customs.h" 32 | #include "user_custs1_def.h" 33 | 34 | /* 35 | * GLOBAL VARIABLE DEFINITIONS 36 | **************************************************************************************** 37 | */ 38 | 39 | #if (BLE_CUSTOM1_SERVER) 40 | extern const struct attm_desc_128 custs1_att_db[CUSTS1_IDX_NB]; 41 | #endif 42 | 43 | /// Custom1/2 server function callback table 44 | const struct cust_prf_func_callbacks cust_prf_funcs[] = 45 | { 46 | #if (BLE_CUSTOM1_SERVER) 47 | { TASK_ID_CUSTS1, 48 | custs1_att_db, 49 | CUSTS1_IDX_NB, 50 | #if (BLE_APP_PRESENT) 51 | app_custs1_create_db, NULL, 52 | #else 53 | NULL, NULL, 54 | #endif 55 | NULL, NULL, 56 | }, 57 | #endif 58 | #if (BLE_CUSTOM2_SERVER) 59 | { TASK_ID_CUSTS2, 60 | NULL, 61 | 0, 62 | #if (BLE_APP_PRESENT) 63 | app_custs2_create_db, NULL, 64 | #else 65 | NULL, NULL, 66 | #endif 67 | NULL, NULL, 68 | }, 69 | #endif 70 | {TASK_ID_INVALID, NULL, 0, NULL, NULL, NULL, NULL}, // DO NOT MOVE. Must always be last 71 | }; 72 | 73 | /// @} USER_CONFIG 74 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_pwm/src/custom_profile/user_custs_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_custs_config.h 5 | * 6 | * @brief Custom1/2 Server (CUSTS1/2) profile database initialization. 7 | * 8 | * Copyright (C) 2016-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_CUSTS_CONFIG_H_ 16 | #define _USER_CUSTS_CONFIG_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @defgroup USER_CONFIG 21 | * @ingroup USER 22 | * @brief Custom1/2 Server (CUSTS1/2) profile database initialization. 23 | * 24 | * @{ 25 | **************************************************************************************** 26 | */ 27 | 28 | /* 29 | * INCLUDE FILES 30 | **************************************************************************************** 31 | */ 32 | 33 | #include "app_prf_types.h" 34 | 35 | /* 36 | * GLOBAL VARIABLE DECLARATIONS 37 | **************************************************************************************** 38 | */ 39 | 40 | extern const struct cust_prf_func_callbacks cust_prf_funcs[]; 41 | 42 | /// @} USER_CONFIG 43 | 44 | #endif // _USER_CUSTS_CONFIG_H_ 45 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_pwm/src/platform/user_periph_setup.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_periph_setup.c 5 | * 6 | * @brief Peripherals setup and initialization. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | /* 16 | * INCLUDE FILES 17 | **************************************************************************************** 18 | */ 19 | 20 | #include "user_periph_setup.h" 21 | #include "datasheet.h" 22 | #include "system_library.h" 23 | #include "rwip_config.h" 24 | #include "gpio.h" 25 | #include "uart.h" 26 | #include "syscntl.h" 27 | 28 | /* 29 | * GLOBAL VARIABLE DEFINITIONS 30 | **************************************************************************************** 31 | */ 32 | 33 | #if DEVELOPMENT_DEBUG 34 | 35 | void GPIO_reservations(void) 36 | { 37 | /* 38 | i.e. to reserve P0_1 as Generic Purpose I/O: 39 | RESERVE_GPIO(DESCRIPTIVE_NAME, GPIO_PORT_0, GPIO_PIN_1, PID_GPIO); 40 | */ 41 | RESERVE_GPIO(LED, GPIO_PORT_0, GPIO_PIN_9, PID_PWM0); 42 | #if defined (CFG_PRINTF_UART2) 43 | RESERVE_GPIO(UART2_TX, UART2_TX_PORT, UART2_TX_PIN, PID_UART2_TX); 44 | #endif 45 | } 46 | 47 | #endif 48 | 49 | void set_pad_functions(void) 50 | { 51 | /* 52 | i.e. to set P0_1 as Generic purpose Output: 53 | GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_1, OUTPUT, PID_GPIO, false); 54 | */ 55 | 56 | GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_9, OUTPUT, PID_PWM0, true); 57 | #if defined (__DA14586__) 58 | // Disallow spontaneous DA14586 SPI Flash wake-up 59 | GPIO_ConfigurePin(GPIO_PORT_2, GPIO_PIN_3, OUTPUT, PID_GPIO, true); 60 | #endif 61 | 62 | #if defined (CFG_PRINTF_UART2) 63 | // Configure UART2 TX Pad 64 | GPIO_ConfigurePin(UART2_TX_PORT, UART2_TX_PIN, OUTPUT, PID_UART2_TX, false); 65 | #endif 66 | 67 | } 68 | 69 | #if defined (CFG_PRINTF_UART2) 70 | // Configuration struct for UART2 71 | static const uart_cfg_t uart_cfg = { 72 | .baud_rate = UART2_BAUDRATE, 73 | .data_bits = UART2_DATABITS, 74 | .parity = UART2_PARITY, 75 | .stop_bits = UART2_STOPBITS, 76 | .auto_flow_control = UART2_AFCE, 77 | .use_fifo = UART2_FIFO, 78 | .tx_fifo_tr_lvl = UART2_TX_FIFO_LEVEL, 79 | .rx_fifo_tr_lvl = UART2_RX_FIFO_LEVEL, 80 | .intr_priority = 2, 81 | }; 82 | #endif 83 | 84 | void periph_init(void) 85 | { 86 | #if defined (__DA14531__) 87 | // In Boost mode enable the DCDC converter to supply VBAT_HIGH for the used GPIOs 88 | syscntl_dcdc_turn_on_in_boost(SYSCNTL_DCDC_LEVEL_3V0); 89 | #else 90 | // Power up peripherals' power domain 91 | SetBits16(PMU_CTRL_REG, PERIPH_SLEEP, 0); 92 | while (!(GetWord16(SYS_STAT_REG) & PER_IS_UP)); 93 | SetBits16(CLK_16M_REG, XTAL16_BIAS_SH_ENABLE, 1); 94 | #endif 95 | 96 | // ROM patch 97 | patch_func(); 98 | 99 | // Initialize peripherals 100 | #if defined (CFG_PRINTF_UART2) 101 | // Initialize UART2 102 | uart_initialize(UART2, &uart_cfg); 103 | #endif 104 | 105 | // Set pad functionality 106 | set_pad_functions(); 107 | 108 | // Enable the pads 109 | GPIO_set_pad_latch_en(true); 110 | } 111 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_pwm/src/user_empty_peripheral_template.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_empty_peripheral_template.c 5 | * 6 | * @brief Empty peripheral template project source code. 7 | * 8 | * Copyright (C) 2012-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | /** 16 | **************************************************************************************** 17 | * @addtogroup APP 18 | * @{ 19 | **************************************************************************************** 20 | */ 21 | #include "rwip_config.h" // SW configuration 22 | 23 | 24 | /* 25 | * INCLUDE FILES 26 | **************************************************************************************** 27 | */ 28 | 29 | #include "app_api.h" 30 | #include "user_empty_peripheral_template.h" 31 | #include "timer0_2.h" 32 | #include "timer0.h" 33 | 34 | /* 35 | * FUNCTION DEFINITIONS 36 | **************************************************************************************** 37 | */ 38 | uint16_t on_cycles = 0; 39 | uint16_t off_cycles = 100; 40 | 41 | void pwm_init(); 42 | 43 | static tim0_2_clk_div_config_t clk_div_config = 44 | { 45 | .clk_div = TIM0_2_CLK_DIV_8 46 | }; 47 | 48 | void user_on_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param) 49 | { 50 | default_app_on_connection(connection_idx, param); 51 | } 52 | 53 | void user_on_disconnect( struct gapc_disconnect_ind const *param ) 54 | { 55 | default_app_on_disconnect(param); 56 | } 57 | 58 | void user_app_on_init() 59 | { 60 | pwm_init(); 61 | default_app_on_init(); 62 | } 63 | 64 | void timer_update() 65 | { 66 | on_cycles += 2; 67 | off_cycles -= 2; 68 | 69 | if(on_cycles == 102) 70 | { 71 | on_cycles = 0; 72 | off_cycles = 100; 73 | } 74 | timer0_set_pwm_high_counter(on_cycles); 75 | timer0_set_pwm_low_counter(off_cycles); 76 | } 77 | 78 | void pwm_init() 79 | { 80 | timer0_stop(); 81 | timer0_register_callback(NULL); 82 | timer0_2_clk_enable(); 83 | timer0_2_clk_div_set(&clk_div_config); 84 | //Clock input frequency is 16 Mhz / (8 * 10) = 200 khz 85 | timer0_init(TIM0_CLK_FAST, PWM_MODE_ONE, TIM0_CLK_DIV_BY_10); 86 | 87 | //SWTIM interrupt is triggered every 20000 * (200 khz) = 100 ms 88 | timer0_set(20000, on_cycles, off_cycles); 89 | timer0_register_callback(timer_update); 90 | 91 | timer0_enable_irq(); 92 | timer0_start(); 93 | 94 | } 95 | /// @} APP 96 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_pwm/src/user_empty_peripheral_template.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_empty_peripheral_template.h 5 | * 6 | * @brief Empty peripheral template project header file. 7 | * 8 | * Copyright (C) 2012-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_EMPTY_PERIPHERAL_TEMPLATE_H_ 16 | #define _USER_EMPTY_PERIPHERAL_TEMPLATE_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @addtogroup APP 21 | * @ingroup RICOW 22 | * 23 | * @brief 24 | * 25 | * @{ 26 | **************************************************************************************** 27 | */ 28 | 29 | /* 30 | * INCLUDE FILES 31 | **************************************************************************************** 32 | */ 33 | 34 | #include "rwble_config.h" 35 | #include "app_task.h" // application task 36 | #include "gapc_task.h" // gap functions and messages 37 | #include "gapm_task.h" // gap functions and messages 38 | #include "app.h" // application definitions 39 | #include "co_error.h" // error code definitions 40 | 41 | 42 | /**************************************************************************** 43 | Add here supported profiles' application header files. 44 | i.e. 45 | #if (BLE_DIS_SERVER) 46 | #include "app_dis.h" 47 | #include "app_dis_task.h" 48 | #endif 49 | *****************************************************************************/ 50 | 51 | /* 52 | * TYPE DEFINITIONS 53 | **************************************************************************************** 54 | */ 55 | 56 | /* 57 | * DEFINES 58 | **************************************************************************************** 59 | */ 60 | 61 | /* 62 | * FUNCTION DECLARATIONS 63 | **************************************************************************************** 64 | */ 65 | 66 | void user_on_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param); 67 | 68 | void user_on_disconnect( struct gapc_disconnect_ind const *param ); 69 | 70 | void user_app_on_init(); 71 | /// @} APP 72 | 73 | #endif // _USER_EMPTY_PERIPHERAL_TEMPLATE_H_ 74 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_spi/Eclipse/makefile.targets: -------------------------------------------------------------------------------- 1 | .PHONY: main-build pre-build generate_ldscripts FORCE 2 | main-build : | pre-build 3 | 4 | FORCE: 5 | 6 | INC_PARAMS=$(foreach d, $(LDSCRIPT_INCLUDE_DIR), -I "$d") 7 | 8 | generate_ldscripts : $(LDSCRIPT_FILES) 9 | 10 | %.lds : $(LDSCRIPT_PATH)/%.lds.S FORCE 11 | "$(CC)" ${INC_PARAMS} $(PRE_BUILD_EXTRA_DEFS) $(LD_DEFS) -E -P -c "$<" -o "$@" 12 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_spi/src/config/user_modules_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_modules_config.h 5 | * 6 | * @brief User modules configuration file. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_MODULES_CONFIG_H_ 16 | #define _USER_MODULES_CONFIG_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @addtogroup APP 21 | * @ingroup RICOW 22 | * 23 | * @brief User modules configuration. 24 | * 25 | * @{ 26 | **************************************************************************************** 27 | */ 28 | 29 | /* 30 | * DEFINES 31 | **************************************************************************************** 32 | */ 33 | 34 | /***************************************************************************************/ 35 | /* Exclude or not a module in user's application code. */ 36 | /* */ 37 | /* (0) - The module is included. The module's messages are handled by the SDK. */ 38 | /* */ 39 | /* (1) - The module is excluded. The user must handle the module's messages. */ 40 | /* */ 41 | /* Note: */ 42 | /* This setting has no effect if the respective module is a BLE Profile */ 43 | /* that is not used included in the user's application. */ 44 | /***************************************************************************************/ 45 | #define EXCLUDE_DLG_GAP (0) 46 | #define EXCLUDE_DLG_TIMER (0) 47 | #define EXCLUDE_DLG_MSG (0) 48 | #define EXCLUDE_DLG_SEC (0) 49 | #define EXCLUDE_DLG_DISS (0) 50 | #define EXCLUDE_DLG_PROXR (0) 51 | #define EXCLUDE_DLG_BASS (0) 52 | #define EXCLUDE_DLG_FINDL (0) 53 | #define EXCLUDE_DLG_FINDT (0) 54 | #define EXCLUDE_DLG_SUOTAR (0) 55 | #define EXCLUDE_DLG_CUSTS1 (0) 56 | #define EXCLUDE_DLG_CUSTS2 (0) 57 | 58 | /// @} APP 59 | 60 | #endif // _USER_MODULES_CONFIG_H_ 61 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_spi/src/config/user_periph_setup.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_periph_setup.h 5 | * 6 | * @brief Peripherals setup header file. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_PERIPH_SETUP_H_ 16 | #define _USER_PERIPH_SETUP_H_ 17 | 18 | /* 19 | * INCLUDE FILES 20 | **************************************************************************************** 21 | */ 22 | 23 | #include "arch.h" 24 | #include "gpio.h" 25 | #include "uart.h" 26 | 27 | 28 | /* 29 | * DEFINES 30 | **************************************************************************************** 31 | */ 32 | 33 | 34 | /****************************************************************************************/ 35 | /* UART2 configuration to use with arch_console print messages */ 36 | /****************************************************************************************/ 37 | // Define UART2 Tx Pad 38 | #if defined (__DA14531__) 39 | #define UART2_TX_PORT GPIO_PORT_0 40 | #define UART2_TX_PIN GPIO_PIN_6 41 | #else 42 | #define UART2_TX_PORT GPIO_PORT_0 43 | #define UART2_TX_PIN GPIO_PIN_4 44 | #endif 45 | 46 | // Define UART2 Settings 47 | #define UART2_BAUDRATE UART_BAUDRATE_115200 48 | #define UART2_DATABITS UART_DATABITS_8 49 | #define UART2_PARITY UART_PARITY_NONE 50 | #define UART2_STOPBITS UART_STOPBITS_1 51 | #define UART2_AFCE UART_AFCE_DIS 52 | #define UART2_FIFO UART_FIFO_EN 53 | #define UART2_TX_FIFO_LEVEL UART_TX_FIFO_LEVEL_0 54 | #define UART2_RX_FIFO_LEVEL UART_RX_FIFO_LEVEL_0 55 | 56 | 57 | /***************************************************************************************/ 58 | /* Production debug output configuration */ 59 | /***************************************************************************************/ 60 | #if PRODUCTION_DEBUG_OUTPUT 61 | #if defined (__DA14531__) 62 | #define PRODUCTION_DEBUG_PORT GPIO_PORT_0 63 | #define PRODUCTION_DEBUG_PIN GPIO_PIN_11 64 | #else 65 | #define PRODUCTION_DEBUG_PORT GPIO_PORT_2 66 | #define PRODUCTION_DEBUG_PIN GPIO_PIN_5 67 | #endif 68 | #endif 69 | 70 | /* 71 | * FUNCTION DECLARATIONS 72 | **************************************************************************************** 73 | */ 74 | 75 | #if DEVELOPMENT_DEBUG 76 | /** 77 | **************************************************************************************** 78 | * @brief Reserves application's specific GPIOs 79 | * @details Used only in Development mode (#if DEVELOPMENT_DEBUG) 80 | * i.e. to reserve P0_1 as Generic Purpose I/O: 81 | * RESERVE_GPIO(DESCRIPTIVE_NAME, GPIO_PORT_0, GPIO_PIN_1, PID_GPIO); 82 | **************************************************************************************** 83 | */ 84 | void GPIO_reservations(void); 85 | #endif 86 | 87 | /** 88 | **************************************************************************************** 89 | * @brief Sets the functionality of application pads 90 | * @details i.e. to set P0_1 as Generic purpose Output: 91 | * GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_1, OUTPUT, PID_GPIO, false); 92 | **************************************************************************************** 93 | */ 94 | void set_pad_functions(void); 95 | 96 | /** 97 | **************************************************************************************** 98 | * @brief Initializes application's peripherals and pins 99 | **************************************************************************************** 100 | */ 101 | void periph_init(void); 102 | 103 | 104 | #endif // _USER_PERIPH_SETUP_H_ 105 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_spi/src/config/user_profiles_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_profiles_config.h 5 | * 6 | * @brief Configuration file for the profiles used in the application. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_PROFILES_CONFIG_H_ 16 | #define _USER_PROFILES_CONFIG_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @defgroup APP_CONFIG 21 | * @ingroup APP 22 | * @brief Application configuration file 23 | * 24 | * This file contains the configuration of the profiles used by the application. 25 | * 26 | * @{ 27 | **************************************************************************************** 28 | */ 29 | 30 | /* 31 | * DEFINITIONS 32 | **************************************************************************************** 33 | */ 34 | 35 | /***************************************************************************************/ 36 | /* Used BLE profiles (used by "rwprf_config.h"). */ 37 | /***************************************************************************************/ 38 | 39 | #define CFG_PRF_DISS 40 | #define CFG_PRF_CUST1 41 | 42 | /***************************************************************************************/ 43 | /* Profile application configuration section */ 44 | /***************************************************************************************/ 45 | 46 | /* 47 | **************************************************************************************** 48 | * DISS application profile configuration 49 | **************************************************************************************** 50 | */ 51 | 52 | #define APP_DIS_FEATURES (DIS_MANUFACTURER_NAME_CHAR_SUP | \ 53 | DIS_MODEL_NB_STR_CHAR_SUP | \ 54 | DIS_SYSTEM_ID_CHAR_SUP | \ 55 | DIS_SW_REV_STR_CHAR_SUP | \ 56 | DIS_FIRM_REV_STR_CHAR_SUP | \ 57 | DIS_PNP_ID_CHAR_SUP) 58 | 59 | /// Manufacturer Name (up to 18 chars) 60 | #define APP_DIS_MANUFACTURER_NAME ("Dialog Semi") 61 | #define APP_DIS_MANUFACTURER_NAME_LEN (11) 62 | 63 | /// Model Number String (up to 18 chars) 64 | #if defined (__DA14586__) 65 | #define APP_DIS_MODEL_NB_STR ("DA14586") 66 | #elif defined (__DA14531__) 67 | #define APP_DIS_MODEL_NB_STR ("DA14531") 68 | #else 69 | #define APP_DIS_MODEL_NB_STR ("DA14585") 70 | #endif 71 | #define APP_DIS_MODEL_NB_STR_LEN (7) 72 | 73 | /// System ID - LSB -> MSB 74 | #define APP_DIS_SYSTEM_ID ("\x12\x34\x56\xFF\xFE\x9A\xBC\xDE") 75 | #define APP_DIS_SYSTEM_ID_LEN (8) 76 | 77 | #define APP_DIS_SW_REV SDK_VERSION 78 | #define APP_DIS_FIRM_REV SDK_VERSION 79 | 80 | /// Serial Number 81 | #define APP_DIS_SERIAL_NB_STR ("1.0.0.0-LE") 82 | #define APP_DIS_SERIAL_NB_STR_LEN (10) 83 | 84 | /// Hardware Revision String 85 | #if defined (__DA14586__) 86 | #define APP_DIS_HARD_REV_STR ("DA14586") 87 | #elif defined (__DA14531__) 88 | #define APP_DIS_HARD_REV_STR ("DA14531") 89 | #else 90 | #define APP_DIS_HARD_REV_STR ("DA14585") 91 | #endif 92 | #define APP_DIS_HARD_REV_STR_LEN (7) 93 | 94 | /// Firmware Revision 95 | #define APP_DIS_FIRM_REV_STR SDK_VERSION 96 | #define APP_DIS_FIRM_REV_STR_LEN (sizeof(APP_DIS_FIRM_REV_STR) - 1) 97 | 98 | /// Software Revision String 99 | #define APP_DIS_SW_REV_STR SDK_VERSION 100 | #define APP_DIS_SW_REV_STR_LEN (sizeof(APP_DIS_SW_REV_STR) - 1) 101 | 102 | /// IEEE 103 | #define APP_DIS_IEEE ("\xFF\xEE\xDD\xCC\xBB\xAA") 104 | #define APP_DIS_IEEE_LEN (6) 105 | 106 | /** 107 | * PNP ID Value - LSB -> MSB 108 | * Vendor ID Source : 0x02 (USB Implementers Forum assigned Vendor ID value) 109 | * Vendor ID : 0x045E (Microsoft Corp) 110 | * Product ID : 0x0040 111 | * Product Version : 0x0300 112 | * e.g. #define APP_DIS_PNP_ID ("\x02\x5E\x04\x40\x00\x00\x03") 113 | */ 114 | #define APP_DIS_PNP_ID ("\x01\xD2\x00\x80\x05\x00\x01") 115 | #define APP_DIS_PNP_ID_LEN (7) 116 | 117 | /// @} APP_CONFIG 118 | 119 | #endif // _USER_PROFILES_CONFIG_H_ 120 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_spi/src/custom_profile/user_custs_config.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_custs_config.c 5 | * 6 | * @brief Custom1/2 Server (CUSTS1/2) profile database structure and initialization. 7 | * 8 | * Copyright (C) 2016-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | /** 16 | **************************************************************************************** 17 | * @defgroup USER_CONFIG 18 | * @ingroup USER 19 | * @brief Custom1/2 Server (CUSTS1/2) profile database structure and initialization. 20 | * 21 | * @{ 22 | **************************************************************************************** 23 | */ 24 | 25 | /* 26 | * INCLUDE FILES 27 | **************************************************************************************** 28 | */ 29 | 30 | #include "app_prf_types.h" 31 | #include "app_customs.h" 32 | #include "user_custs1_def.h" 33 | 34 | /* 35 | * GLOBAL VARIABLE DEFINITIONS 36 | **************************************************************************************** 37 | */ 38 | 39 | #if (BLE_CUSTOM1_SERVER) 40 | extern const struct attm_desc_128 custs1_att_db[CUSTS1_IDX_NB]; 41 | #endif 42 | 43 | /// Custom1/2 server function callback table 44 | const struct cust_prf_func_callbacks cust_prf_funcs[] = 45 | { 46 | #if (BLE_CUSTOM1_SERVER) 47 | { TASK_ID_CUSTS1, 48 | custs1_att_db, 49 | CUSTS1_IDX_NB, 50 | #if (BLE_APP_PRESENT) 51 | app_custs1_create_db, NULL, 52 | #else 53 | NULL, NULL, 54 | #endif 55 | NULL, NULL, 56 | }, 57 | #endif 58 | #if (BLE_CUSTOM2_SERVER) 59 | { TASK_ID_CUSTS2, 60 | NULL, 61 | 0, 62 | #if (BLE_APP_PRESENT) 63 | app_custs2_create_db, NULL, 64 | #else 65 | NULL, NULL, 66 | #endif 67 | NULL, NULL, 68 | }, 69 | #endif 70 | {TASK_ID_INVALID, NULL, 0, NULL, NULL, NULL, NULL}, // DO NOT MOVE. Must always be last 71 | }; 72 | 73 | /// @} USER_CONFIG 74 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_spi/src/custom_profile/user_custs_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_custs_config.h 5 | * 6 | * @brief Custom1/2 Server (CUSTS1/2) profile database initialization. 7 | * 8 | * Copyright (C) 2016-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_CUSTS_CONFIG_H_ 16 | #define _USER_CUSTS_CONFIG_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @defgroup USER_CONFIG 21 | * @ingroup USER 22 | * @brief Custom1/2 Server (CUSTS1/2) profile database initialization. 23 | * 24 | * @{ 25 | **************************************************************************************** 26 | */ 27 | 28 | /* 29 | * INCLUDE FILES 30 | **************************************************************************************** 31 | */ 32 | 33 | #include "app_prf_types.h" 34 | 35 | /* 36 | * GLOBAL VARIABLE DECLARATIONS 37 | **************************************************************************************** 38 | */ 39 | 40 | extern const struct cust_prf_func_callbacks cust_prf_funcs[]; 41 | 42 | /// @} USER_CONFIG 43 | 44 | #endif // _USER_CUSTS_CONFIG_H_ 45 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_spi/src/platform/user_periph_setup.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_periph_setup.c 5 | * 6 | * @brief Peripherals setup and initialization. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | /* 16 | * INCLUDE FILES 17 | **************************************************************************************** 18 | */ 19 | 20 | #include "user_periph_setup.h" 21 | #include "datasheet.h" 22 | #include "system_library.h" 23 | #include "rwip_config.h" 24 | #include "gpio.h" 25 | #include "uart.h" 26 | #include "syscntl.h" 27 | #include "spi.h" 28 | 29 | /* 30 | * GLOBAL VARIABLE DEFINITIONS 31 | **************************************************************************************** 32 | */ 33 | 34 | #if DEVELOPMENT_DEBUG 35 | 36 | void GPIO_reservations(void) 37 | { 38 | /* 39 | i.e. to reserve P0_1 as Generic Purpose I/O: 40 | RESERVE_GPIO(DESCRIPTIVE_NAME, GPIO_PORT_0, GPIO_PIN_1, PID_GPIO); 41 | */ 42 | RESERVE_GPIO(SDA, GPIO_PORT_0, GPIO_PIN_11, PID_SPI_DO); 43 | RESERVE_GPIO(SCL, GPIO_PORT_0, GPIO_PIN_6, PID_SPI_DI); 44 | RESERVE_GPIO(SCL, GPIO_PORT_0, GPIO_PIN_8, PID_SPI_CLK); 45 | RESERVE_GPIO(SCL, GPIO_PORT_0, GPIO_PIN_7, PID_SPI_EN); 46 | #if defined (CFG_PRINTF_UART2) 47 | RESERVE_GPIO(UART2_TX, UART2_TX_PORT, UART2_TX_PIN, PID_UART2_TX); 48 | #endif 49 | } 50 | 51 | #endif 52 | 53 | void set_pad_functions(void) 54 | { 55 | /* 56 | i.e. to set P0_1 as Generic purpose Output: 57 | GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_1, OUTPUT, PID_GPIO, false); 58 | */ 59 | GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_11, OUTPUT, PID_SPI_DO, true); 60 | GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_6, INPUT, PID_SPI_DI, true); 61 | GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_8, OUTPUT, PID_SPI_CLK, true); 62 | GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_7, OUTPUT, PID_SPI_EN, true); 63 | #if defined (__DA14586__) 64 | // Disallow spontaneous DA14586 SPI Flash wake-up 65 | GPIO_ConfigurePin(GPIO_PORT_2, GPIO_PIN_3, OUTPUT, PID_GPIO, true); 66 | #endif 67 | 68 | #if defined (CFG_PRINTF_UART2) 69 | // Configure UART2 TX Pad 70 | GPIO_ConfigurePin(UART2_TX_PORT, UART2_TX_PIN, OUTPUT, PID_UART2_TX, false); 71 | #endif 72 | 73 | } 74 | 75 | #if defined (CFG_PRINTF_UART2) 76 | // Configuration struct for UART2 77 | static const uart_cfg_t uart_cfg = { 78 | .baud_rate = UART2_BAUDRATE, 79 | .data_bits = UART2_DATABITS, 80 | .parity = UART2_PARITY, 81 | .stop_bits = UART2_STOPBITS, 82 | .auto_flow_control = UART2_AFCE, 83 | .use_fifo = UART2_FIFO, 84 | .tx_fifo_tr_lvl = UART2_TX_FIFO_LEVEL, 85 | .rx_fifo_tr_lvl = UART2_RX_FIFO_LEVEL, 86 | .intr_priority = 2, 87 | }; 88 | #endif 89 | 90 | void periph_init(void) 91 | { 92 | #if defined (__DA14531__) 93 | // In Boost mode enable the DCDC converter to supply VBAT_HIGH for the used GPIOs 94 | syscntl_dcdc_turn_on_in_boost(SYSCNTL_DCDC_LEVEL_3V0); 95 | #else 96 | // Power up peripherals' power domain 97 | SetBits16(PMU_CTRL_REG, PERIPH_SLEEP, 0); 98 | while (!(GetWord16(SYS_STAT_REG) & PER_IS_UP)); 99 | SetBits16(CLK_16M_REG, XTAL16_BIAS_SH_ENABLE, 1); 100 | #endif 101 | 102 | // ROM patch 103 | patch_func(); 104 | 105 | // Initialize peripherals 106 | #if defined (CFG_PRINTF_UART2) 107 | // Initialize UART2 108 | uart_initialize(UART2, &uart_cfg); 109 | #endif 110 | 111 | // Configuration struct for SPI 112 | static const spi_cfg_t spi_cfg = { 113 | .spi_ms = SPI_MS_MODE_MASTER, 114 | .spi_cp = SPI_CP_MODE_0, 115 | .spi_speed = SPI_SPEED_MODE_2MHz, 116 | .spi_wsz = SPI_MODE_8BIT, 117 | .spi_cs = SPI_CS_0, 118 | .cs_pad.port = GPIO_PORT_0, 119 | .cs_pad.pin = GPIO_PIN_7, 120 | #if defined (CFG_SPI_DMA_SUPPORT) 121 | .spi_dma_channel = SPI_DMA_CHANNEL_01, 122 | .spi_dma_priority = DMA_PRIO_0, 123 | #endif 124 | }; 125 | 126 | spi_initialize(&spi_cfg); 127 | 128 | // Set pad functionality 129 | set_pad_functions(); 130 | 131 | // Enable the pads 132 | GPIO_set_pad_latch_en(true); 133 | } 134 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_spi/src/user_empty_peripheral_template.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_empty_peripheral_template.c 5 | * 6 | * @brief Empty peripheral template project source code. 7 | * 8 | * Copyright (C) 2012-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | /** 16 | **************************************************************************************** 17 | * @addtogroup APP 18 | * @{ 19 | **************************************************************************************** 20 | */ 21 | #include "rwip_config.h" // SW configuration 22 | 23 | 24 | /* 25 | * INCLUDE FILES 26 | **************************************************************************************** 27 | */ 28 | 29 | #include "app_api.h" 30 | #include "user_empty_peripheral_template.h" 31 | #include "gpio.h" 32 | #include "spi.h" 33 | 34 | /* 35 | * FUNCTION DEFINITIONS 36 | **************************************************************************************** 37 | */ 38 | uint8_t last_led_state = 0; 39 | 40 | void user_on_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param) 41 | { 42 | default_app_on_connection(connection_idx, param); 43 | } 44 | 45 | void user_on_disconnect( struct gapc_disconnect_ind const *param ) 46 | { 47 | default_app_on_disconnect(param); 48 | } 49 | 50 | void read_who_am_i_reg() 51 | { 52 | uint8_t reg_val = 0; 53 | while(reg_val != 0x69) 54 | { 55 | uint8_t reg_addr = 0x80|0x0F; 56 | spi_cs_low(); 57 | spi_send(®_addr, 1, SPI_OP_BLOCKING); 58 | spi_receive(®_val, 1, SPI_OP_BLOCKING); 59 | spi_cs_high(); 60 | } 61 | } 62 | 63 | void user_app_on_init(void) 64 | { 65 | read_who_am_i_reg(); 66 | default_app_on_init(); 67 | } 68 | 69 | 70 | /// @} APP 71 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_spi/src/user_empty_peripheral_template.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_empty_peripheral_template.h 5 | * 6 | * @brief Empty peripheral template project header file. 7 | * 8 | * Copyright (C) 2012-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_EMPTY_PERIPHERAL_TEMPLATE_H_ 16 | #define _USER_EMPTY_PERIPHERAL_TEMPLATE_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @addtogroup APP 21 | * @ingroup RICOW 22 | * 23 | * @brief 24 | * 25 | * @{ 26 | **************************************************************************************** 27 | */ 28 | 29 | /* 30 | * INCLUDE FILES 31 | **************************************************************************************** 32 | */ 33 | 34 | #include "rwble_config.h" 35 | #include "app_task.h" // application task 36 | #include "gapc_task.h" // gap functions and messages 37 | #include "gapm_task.h" // gap functions and messages 38 | #include "app.h" // application definitions 39 | #include "co_error.h" // error code definitions 40 | 41 | 42 | /**************************************************************************** 43 | Add here supported profiles' application header files. 44 | i.e. 45 | #if (BLE_DIS_SERVER) 46 | #include "app_dis.h" 47 | #include "app_dis_task.h" 48 | #endif 49 | *****************************************************************************/ 50 | 51 | /* 52 | * TYPE DEFINITIONS 53 | **************************************************************************************** 54 | */ 55 | 56 | /* 57 | * DEFINES 58 | **************************************************************************************** 59 | */ 60 | 61 | /* 62 | * FUNCTION DECLARATIONS 63 | **************************************************************************************** 64 | */ 65 | 66 | void user_on_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param); 67 | 68 | void user_on_disconnect( struct gapc_disconnect_ind const *param ); 69 | 70 | void user_app_on_init(void); 71 | 72 | /// @} APP 73 | 74 | #endif // _USER_EMPTY_PERIPHERAL_TEMPLATE_H_ 75 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_timer/Eclipse/makefile.targets: -------------------------------------------------------------------------------- 1 | .PHONY: main-build pre-build generate_ldscripts FORCE 2 | main-build : | pre-build 3 | 4 | FORCE: 5 | 6 | INC_PARAMS=$(foreach d, $(LDSCRIPT_INCLUDE_DIR), -I "$d") 7 | 8 | generate_ldscripts : $(LDSCRIPT_FILES) 9 | 10 | %.lds : $(LDSCRIPT_PATH)/%.lds.S FORCE 11 | "$(CC)" ${INC_PARAMS} $(PRE_BUILD_EXTRA_DEFS) $(LD_DEFS) -E -P -c "$<" -o "$@" 12 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_timer/src/config/user_modules_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_modules_config.h 5 | * 6 | * @brief User modules configuration file. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_MODULES_CONFIG_H_ 16 | #define _USER_MODULES_CONFIG_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @addtogroup APP 21 | * @ingroup RICOW 22 | * 23 | * @brief User modules configuration. 24 | * 25 | * @{ 26 | **************************************************************************************** 27 | */ 28 | 29 | /* 30 | * DEFINES 31 | **************************************************************************************** 32 | */ 33 | 34 | /***************************************************************************************/ 35 | /* Exclude or not a module in user's application code. */ 36 | /* */ 37 | /* (0) - The module is included. The module's messages are handled by the SDK. */ 38 | /* */ 39 | /* (1) - The module is excluded. The user must handle the module's messages. */ 40 | /* */ 41 | /* Note: */ 42 | /* This setting has no effect if the respective module is a BLE Profile */ 43 | /* that is not used included in the user's application. */ 44 | /***************************************************************************************/ 45 | #define EXCLUDE_DLG_GAP (0) 46 | #define EXCLUDE_DLG_TIMER (0) 47 | #define EXCLUDE_DLG_MSG (0) 48 | #define EXCLUDE_DLG_SEC (0) 49 | #define EXCLUDE_DLG_DISS (0) 50 | #define EXCLUDE_DLG_PROXR (0) 51 | #define EXCLUDE_DLG_BASS (0) 52 | #define EXCLUDE_DLG_FINDL (0) 53 | #define EXCLUDE_DLG_FINDT (0) 54 | #define EXCLUDE_DLG_SUOTAR (0) 55 | #define EXCLUDE_DLG_CUSTS1 (0) 56 | #define EXCLUDE_DLG_CUSTS2 (0) 57 | 58 | /// @} APP 59 | 60 | #endif // _USER_MODULES_CONFIG_H_ 61 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_timer/src/config/user_periph_setup.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_periph_setup.h 5 | * 6 | * @brief Peripherals setup header file. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_PERIPH_SETUP_H_ 16 | #define _USER_PERIPH_SETUP_H_ 17 | 18 | /* 19 | * INCLUDE FILES 20 | **************************************************************************************** 21 | */ 22 | 23 | #include "arch.h" 24 | #include "gpio.h" 25 | #include "uart.h" 26 | 27 | 28 | /* 29 | * DEFINES 30 | **************************************************************************************** 31 | */ 32 | 33 | 34 | /****************************************************************************************/ 35 | /* UART2 configuration to use with arch_console print messages */ 36 | /****************************************************************************************/ 37 | // Define UART2 Tx Pad 38 | #if defined (__DA14531__) 39 | #define UART2_TX_PORT GPIO_PORT_0 40 | #define UART2_TX_PIN GPIO_PIN_6 41 | #else 42 | #define UART2_TX_PORT GPIO_PORT_0 43 | #define UART2_TX_PIN GPIO_PIN_4 44 | #endif 45 | 46 | // Define UART2 Settings 47 | #define UART2_BAUDRATE UART_BAUDRATE_115200 48 | #define UART2_DATABITS UART_DATABITS_8 49 | #define UART2_PARITY UART_PARITY_NONE 50 | #define UART2_STOPBITS UART_STOPBITS_1 51 | #define UART2_AFCE UART_AFCE_DIS 52 | #define UART2_FIFO UART_FIFO_EN 53 | #define UART2_TX_FIFO_LEVEL UART_TX_FIFO_LEVEL_0 54 | #define UART2_RX_FIFO_LEVEL UART_RX_FIFO_LEVEL_0 55 | 56 | 57 | /***************************************************************************************/ 58 | /* Production debug output configuration */ 59 | /***************************************************************************************/ 60 | #if PRODUCTION_DEBUG_OUTPUT 61 | #if defined (__DA14531__) 62 | #define PRODUCTION_DEBUG_PORT GPIO_PORT_0 63 | #define PRODUCTION_DEBUG_PIN GPIO_PIN_11 64 | #else 65 | #define PRODUCTION_DEBUG_PORT GPIO_PORT_2 66 | #define PRODUCTION_DEBUG_PIN GPIO_PIN_5 67 | #endif 68 | #endif 69 | 70 | /* 71 | * FUNCTION DECLARATIONS 72 | **************************************************************************************** 73 | */ 74 | 75 | #if DEVELOPMENT_DEBUG 76 | /** 77 | **************************************************************************************** 78 | * @brief Reserves application's specific GPIOs 79 | * @details Used only in Development mode (#if DEVELOPMENT_DEBUG) 80 | * i.e. to reserve P0_1 as Generic Purpose I/O: 81 | * RESERVE_GPIO(DESCRIPTIVE_NAME, GPIO_PORT_0, GPIO_PIN_1, PID_GPIO); 82 | **************************************************************************************** 83 | */ 84 | void GPIO_reservations(void); 85 | #endif 86 | 87 | /** 88 | **************************************************************************************** 89 | * @brief Sets the functionality of application pads 90 | * @details i.e. to set P0_1 as Generic purpose Output: 91 | * GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_1, OUTPUT, PID_GPIO, false); 92 | **************************************************************************************** 93 | */ 94 | void set_pad_functions(void); 95 | 96 | /** 97 | **************************************************************************************** 98 | * @brief Initializes application's peripherals and pins 99 | **************************************************************************************** 100 | */ 101 | void periph_init(void); 102 | 103 | 104 | #endif // _USER_PERIPH_SETUP_H_ 105 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_timer/src/config/user_profiles_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_profiles_config.h 5 | * 6 | * @brief Configuration file for the profiles used in the application. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_PROFILES_CONFIG_H_ 16 | #define _USER_PROFILES_CONFIG_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @defgroup APP_CONFIG 21 | * @ingroup APP 22 | * @brief Application configuration file 23 | * 24 | * This file contains the configuration of the profiles used by the application. 25 | * 26 | * @{ 27 | **************************************************************************************** 28 | */ 29 | 30 | /* 31 | * DEFINITIONS 32 | **************************************************************************************** 33 | */ 34 | 35 | /***************************************************************************************/ 36 | /* Used BLE profiles (used by "rwprf_config.h"). */ 37 | /***************************************************************************************/ 38 | 39 | #define CFG_PRF_DISS 40 | #define CFG_PRF_CUST1 41 | 42 | /***************************************************************************************/ 43 | /* Profile application configuration section */ 44 | /***************************************************************************************/ 45 | 46 | /* 47 | **************************************************************************************** 48 | * DISS application profile configuration 49 | **************************************************************************************** 50 | */ 51 | 52 | #define APP_DIS_FEATURES (DIS_MANUFACTURER_NAME_CHAR_SUP | \ 53 | DIS_MODEL_NB_STR_CHAR_SUP | \ 54 | DIS_SYSTEM_ID_CHAR_SUP | \ 55 | DIS_SW_REV_STR_CHAR_SUP | \ 56 | DIS_FIRM_REV_STR_CHAR_SUP | \ 57 | DIS_PNP_ID_CHAR_SUP) 58 | 59 | /// Manufacturer Name (up to 18 chars) 60 | #define APP_DIS_MANUFACTURER_NAME ("Dialog Semi") 61 | #define APP_DIS_MANUFACTURER_NAME_LEN (11) 62 | 63 | /// Model Number String (up to 18 chars) 64 | #if defined (__DA14586__) 65 | #define APP_DIS_MODEL_NB_STR ("DA14586") 66 | #elif defined (__DA14531__) 67 | #define APP_DIS_MODEL_NB_STR ("DA14531") 68 | #else 69 | #define APP_DIS_MODEL_NB_STR ("DA14585") 70 | #endif 71 | #define APP_DIS_MODEL_NB_STR_LEN (7) 72 | 73 | /// System ID - LSB -> MSB 74 | #define APP_DIS_SYSTEM_ID ("\x12\x34\x56\xFF\xFE\x9A\xBC\xDE") 75 | #define APP_DIS_SYSTEM_ID_LEN (8) 76 | 77 | #define APP_DIS_SW_REV SDK_VERSION 78 | #define APP_DIS_FIRM_REV SDK_VERSION 79 | 80 | /// Serial Number 81 | #define APP_DIS_SERIAL_NB_STR ("1.0.0.0-LE") 82 | #define APP_DIS_SERIAL_NB_STR_LEN (10) 83 | 84 | /// Hardware Revision String 85 | #if defined (__DA14586__) 86 | #define APP_DIS_HARD_REV_STR ("DA14586") 87 | #elif defined (__DA14531__) 88 | #define APP_DIS_HARD_REV_STR ("DA14531") 89 | #else 90 | #define APP_DIS_HARD_REV_STR ("DA14585") 91 | #endif 92 | #define APP_DIS_HARD_REV_STR_LEN (7) 93 | 94 | /// Firmware Revision 95 | #define APP_DIS_FIRM_REV_STR SDK_VERSION 96 | #define APP_DIS_FIRM_REV_STR_LEN (sizeof(APP_DIS_FIRM_REV_STR) - 1) 97 | 98 | /// Software Revision String 99 | #define APP_DIS_SW_REV_STR SDK_VERSION 100 | #define APP_DIS_SW_REV_STR_LEN (sizeof(APP_DIS_SW_REV_STR) - 1) 101 | 102 | /// IEEE 103 | #define APP_DIS_IEEE ("\xFF\xEE\xDD\xCC\xBB\xAA") 104 | #define APP_DIS_IEEE_LEN (6) 105 | 106 | /** 107 | * PNP ID Value - LSB -> MSB 108 | * Vendor ID Source : 0x02 (USB Implementers Forum assigned Vendor ID value) 109 | * Vendor ID : 0x045E (Microsoft Corp) 110 | * Product ID : 0x0040 111 | * Product Version : 0x0300 112 | * e.g. #define APP_DIS_PNP_ID ("\x02\x5E\x04\x40\x00\x00\x03") 113 | */ 114 | #define APP_DIS_PNP_ID ("\x01\xD2\x00\x80\x05\x00\x01") 115 | #define APP_DIS_PNP_ID_LEN (7) 116 | 117 | /// @} APP_CONFIG 118 | 119 | #endif // _USER_PROFILES_CONFIG_H_ 120 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_timer/src/custom_profile/user_custs_config.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_custs_config.c 5 | * 6 | * @brief Custom1/2 Server (CUSTS1/2) profile database structure and initialization. 7 | * 8 | * Copyright (C) 2016-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | /** 16 | **************************************************************************************** 17 | * @defgroup USER_CONFIG 18 | * @ingroup USER 19 | * @brief Custom1/2 Server (CUSTS1/2) profile database structure and initialization. 20 | * 21 | * @{ 22 | **************************************************************************************** 23 | */ 24 | 25 | /* 26 | * INCLUDE FILES 27 | **************************************************************************************** 28 | */ 29 | 30 | #include "app_prf_types.h" 31 | #include "app_customs.h" 32 | #include "user_custs1_def.h" 33 | 34 | /* 35 | * GLOBAL VARIABLE DEFINITIONS 36 | **************************************************************************************** 37 | */ 38 | 39 | #if (BLE_CUSTOM1_SERVER) 40 | extern const struct attm_desc_128 custs1_att_db[CUSTS1_IDX_NB]; 41 | #endif 42 | 43 | /// Custom1/2 server function callback table 44 | const struct cust_prf_func_callbacks cust_prf_funcs[] = 45 | { 46 | #if (BLE_CUSTOM1_SERVER) 47 | { TASK_ID_CUSTS1, 48 | custs1_att_db, 49 | CUSTS1_IDX_NB, 50 | #if (BLE_APP_PRESENT) 51 | app_custs1_create_db, NULL, 52 | #else 53 | NULL, NULL, 54 | #endif 55 | NULL, NULL, 56 | }, 57 | #endif 58 | #if (BLE_CUSTOM2_SERVER) 59 | { TASK_ID_CUSTS2, 60 | NULL, 61 | 0, 62 | #if (BLE_APP_PRESENT) 63 | app_custs2_create_db, NULL, 64 | #else 65 | NULL, NULL, 66 | #endif 67 | NULL, NULL, 68 | }, 69 | #endif 70 | {TASK_ID_INVALID, NULL, 0, NULL, NULL, NULL, NULL}, // DO NOT MOVE. Must always be last 71 | }; 72 | 73 | /// @} USER_CONFIG 74 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_timer/src/custom_profile/user_custs_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_custs_config.h 5 | * 6 | * @brief Custom1/2 Server (CUSTS1/2) profile database initialization. 7 | * 8 | * Copyright (C) 2016-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_CUSTS_CONFIG_H_ 16 | #define _USER_CUSTS_CONFIG_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @defgroup USER_CONFIG 21 | * @ingroup USER 22 | * @brief Custom1/2 Server (CUSTS1/2) profile database initialization. 23 | * 24 | * @{ 25 | **************************************************************************************** 26 | */ 27 | 28 | /* 29 | * INCLUDE FILES 30 | **************************************************************************************** 31 | */ 32 | 33 | #include "app_prf_types.h" 34 | 35 | /* 36 | * GLOBAL VARIABLE DECLARATIONS 37 | **************************************************************************************** 38 | */ 39 | 40 | extern const struct cust_prf_func_callbacks cust_prf_funcs[]; 41 | 42 | /// @} USER_CONFIG 43 | 44 | #endif // _USER_CUSTS_CONFIG_H_ 45 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_timer/src/platform/user_periph_setup.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_periph_setup.c 5 | * 6 | * @brief Peripherals setup and initialization. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | /* 16 | * INCLUDE FILES 17 | **************************************************************************************** 18 | */ 19 | 20 | #include "user_periph_setup.h" 21 | #include "datasheet.h" 22 | #include "system_library.h" 23 | #include "rwip_config.h" 24 | #include "gpio.h" 25 | #include "uart.h" 26 | #include "syscntl.h" 27 | 28 | /* 29 | * GLOBAL VARIABLE DEFINITIONS 30 | **************************************************************************************** 31 | */ 32 | 33 | #if DEVELOPMENT_DEBUG 34 | 35 | void GPIO_reservations(void) 36 | { 37 | /* 38 | i.e. to reserve P0_1 as Generic Purpose I/O: 39 | RESERVE_GPIO(DESCRIPTIVE_NAME, GPIO_PORT_0, GPIO_PIN_1, PID_GPIO); 40 | */ 41 | RESERVE_GPIO(LED, GPIO_PORT_0, GPIO_PIN_9, PID_GPIO); 42 | #if defined (CFG_PRINTF_UART2) 43 | RESERVE_GPIO(UART2_TX, UART2_TX_PORT, UART2_TX_PIN, PID_UART2_TX); 44 | #endif 45 | } 46 | 47 | #endif 48 | 49 | void set_pad_functions(void) 50 | { 51 | /* 52 | i.e. to set P0_1 as Generic purpose Output: 53 | GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_1, OUTPUT, PID_GPIO, false); 54 | */ 55 | GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_9, OUTPUT, PID_GPIO, false); 56 | #if defined (__DA14586__) 57 | // Disallow spontaneous DA14586 SPI Flash wake-up 58 | GPIO_ConfigurePin(GPIO_PORT_2, GPIO_PIN_3, OUTPUT, PID_GPIO, true); 59 | #endif 60 | 61 | #if defined (CFG_PRINTF_UART2) 62 | // Configure UART2 TX Pad 63 | GPIO_ConfigurePin(UART2_TX_PORT, UART2_TX_PIN, OUTPUT, PID_UART2_TX, false); 64 | #endif 65 | 66 | } 67 | 68 | #if defined (CFG_PRINTF_UART2) 69 | // Configuration struct for UART2 70 | static const uart_cfg_t uart_cfg = { 71 | .baud_rate = UART2_BAUDRATE, 72 | .data_bits = UART2_DATABITS, 73 | .parity = UART2_PARITY, 74 | .stop_bits = UART2_STOPBITS, 75 | .auto_flow_control = UART2_AFCE, 76 | .use_fifo = UART2_FIFO, 77 | .tx_fifo_tr_lvl = UART2_TX_FIFO_LEVEL, 78 | .rx_fifo_tr_lvl = UART2_RX_FIFO_LEVEL, 79 | .intr_priority = 2, 80 | }; 81 | #endif 82 | 83 | void periph_init(void) 84 | { 85 | #if defined (__DA14531__) 86 | // In Boost mode enable the DCDC converter to supply VBAT_HIGH for the used GPIOs 87 | syscntl_dcdc_turn_on_in_boost(SYSCNTL_DCDC_LEVEL_3V0); 88 | #else 89 | // Power up peripherals' power domain 90 | SetBits16(PMU_CTRL_REG, PERIPH_SLEEP, 0); 91 | while (!(GetWord16(SYS_STAT_REG) & PER_IS_UP)); 92 | SetBits16(CLK_16M_REG, XTAL16_BIAS_SH_ENABLE, 1); 93 | #endif 94 | 95 | // ROM patch 96 | patch_func(); 97 | 98 | // Initialize peripherals 99 | #if defined (CFG_PRINTF_UART2) 100 | // Initialize UART2 101 | uart_initialize(UART2, &uart_cfg); 102 | #endif 103 | 104 | // Set pad functionality 105 | set_pad_functions(); 106 | 107 | // Enable the pads 108 | GPIO_set_pad_latch_en(true); 109 | } 110 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_timer/src/user_empty_peripheral_template.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_empty_peripheral_template.c 5 | * 6 | * @brief Empty peripheral template project source code. 7 | * 8 | * Copyright (C) 2012-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | /** 16 | **************************************************************************************** 17 | * @addtogroup APP 18 | * @{ 19 | **************************************************************************************** 20 | */ 21 | #include "rwip_config.h" // SW configuration 22 | 23 | 24 | /* 25 | * INCLUDE FILES 26 | **************************************************************************************** 27 | */ 28 | 29 | #include "app_api.h" 30 | #include "user_empty_peripheral_template.h" 31 | #include "timer0_2.h" 32 | #include "timer0.h" 33 | #include "gpio.h" 34 | 35 | /* 36 | * FUNCTION DEFINITIONS 37 | **************************************************************************************** 38 | */ 39 | void timer_init(); 40 | 41 | void user_on_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param) 42 | { 43 | default_app_on_connection(connection_idx, param); 44 | } 45 | 46 | void user_on_disconnect( struct gapc_disconnect_ind const *param ) 47 | { 48 | default_app_on_disconnect(param); 49 | } 50 | 51 | void user_app_on_init() 52 | { 53 | timer_init(); 54 | default_app_on_init(); 55 | } 56 | 57 | static void timer_irq_handler() 58 | { 59 | if (GPIO_GetPinStatus(GPIO_PORT_0, GPIO_PIN_9)) 60 | { 61 | GPIO_SetInactive(GPIO_PORT_0, GPIO_PIN_9); 62 | } 63 | else 64 | { 65 | GPIO_SetActive(GPIO_PORT_0, GPIO_PIN_9); 66 | } 67 | } 68 | 69 | void timer_init() 70 | { 71 | 72 | static tim0_2_clk_div_config_t clk_div_config = 73 | { 74 | .clk_div = TIM0_2_CLK_DIV_8 75 | }; 76 | timer0_stop(); 77 | timer0_register_callback(timer_irq_handler); 78 | timer0_2_clk_enable(); 79 | timer0_2_clk_div_set(&clk_div_config); 80 | timer0_init(TIM0_CLK_FAST, PWM_MODE_ONE, TIM0_CLK_DIV_BY_10); 81 | 82 | timer0_set_pwm_high_counter(0); 83 | timer0_set_pwm_low_counter(0); 84 | 85 | timer0_set_pwm_on_counter(20000); 86 | timer0_enable_irq(); 87 | timer0_start(); 88 | 89 | } 90 | /// @} APP 91 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_timer/src/user_empty_peripheral_template.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_empty_peripheral_template.h 5 | * 6 | * @brief Empty peripheral template project header file. 7 | * 8 | * Copyright (C) 2012-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_EMPTY_PERIPHERAL_TEMPLATE_H_ 16 | #define _USER_EMPTY_PERIPHERAL_TEMPLATE_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @addtogroup APP 21 | * @ingroup RICOW 22 | * 23 | * @brief 24 | * 25 | * @{ 26 | **************************************************************************************** 27 | */ 28 | 29 | /* 30 | * INCLUDE FILES 31 | **************************************************************************************** 32 | */ 33 | 34 | #include "rwble_config.h" 35 | #include "app_task.h" // application task 36 | #include "gapc_task.h" // gap functions and messages 37 | #include "gapm_task.h" // gap functions and messages 38 | #include "app.h" // application definitions 39 | #include "co_error.h" // error code definitions 40 | 41 | 42 | /**************************************************************************** 43 | Add here supported profiles' application header files. 44 | i.e. 45 | #if (BLE_DIS_SERVER) 46 | #include "app_dis.h" 47 | #include "app_dis_task.h" 48 | #endif 49 | *****************************************************************************/ 50 | 51 | /* 52 | * TYPE DEFINITIONS 53 | **************************************************************************************** 54 | */ 55 | 56 | /* 57 | * DEFINES 58 | **************************************************************************************** 59 | */ 60 | 61 | /* 62 | * FUNCTION DECLARATIONS 63 | **************************************************************************************** 64 | */ 65 | 66 | void user_on_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param); 67 | 68 | void user_on_disconnect( struct gapc_disconnect_ind const *param ); 69 | 70 | void user_app_on_init(); 71 | /// @} APP 72 | 73 | #endif // _USER_EMPTY_PERIPHERAL_TEMPLATE_H_ 74 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_uart/Eclipse/makefile.targets: -------------------------------------------------------------------------------- 1 | .PHONY: main-build pre-build generate_ldscripts FORCE 2 | main-build : | pre-build 3 | 4 | FORCE: 5 | 6 | INC_PARAMS=$(foreach d, $(LDSCRIPT_INCLUDE_DIR), -I "$d") 7 | 8 | generate_ldscripts : $(LDSCRIPT_FILES) 9 | 10 | %.lds : $(LDSCRIPT_PATH)/%.lds.S FORCE 11 | "$(CC)" ${INC_PARAMS} $(PRE_BUILD_EXTRA_DEFS) $(LD_DEFS) -E -P -c "$<" -o "$@" 12 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_uart/src/config/user_modules_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_modules_config.h 5 | * 6 | * @brief User modules configuration file. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_MODULES_CONFIG_H_ 16 | #define _USER_MODULES_CONFIG_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @addtogroup APP 21 | * @ingroup RICOW 22 | * 23 | * @brief User modules configuration. 24 | * 25 | * @{ 26 | **************************************************************************************** 27 | */ 28 | 29 | /* 30 | * DEFINES 31 | **************************************************************************************** 32 | */ 33 | 34 | /***************************************************************************************/ 35 | /* Exclude or not a module in user's application code. */ 36 | /* */ 37 | /* (0) - The module is included. The module's messages are handled by the SDK. */ 38 | /* */ 39 | /* (1) - The module is excluded. The user must handle the module's messages. */ 40 | /* */ 41 | /* Note: */ 42 | /* This setting has no effect if the respective module is a BLE Profile */ 43 | /* that is not used included in the user's application. */ 44 | /***************************************************************************************/ 45 | #define EXCLUDE_DLG_GAP (0) 46 | #define EXCLUDE_DLG_TIMER (0) 47 | #define EXCLUDE_DLG_MSG (0) 48 | #define EXCLUDE_DLG_SEC (0) 49 | #define EXCLUDE_DLG_DISS (0) 50 | #define EXCLUDE_DLG_PROXR (0) 51 | #define EXCLUDE_DLG_BASS (0) 52 | #define EXCLUDE_DLG_FINDL (0) 53 | #define EXCLUDE_DLG_FINDT (0) 54 | #define EXCLUDE_DLG_SUOTAR (0) 55 | #define EXCLUDE_DLG_CUSTS1 (0) 56 | #define EXCLUDE_DLG_CUSTS2 (0) 57 | 58 | /// @} APP 59 | 60 | #endif // _USER_MODULES_CONFIG_H_ 61 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_uart/src/config/user_periph_setup.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_periph_setup.h 5 | * 6 | * @brief Peripherals setup header file. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_PERIPH_SETUP_H_ 16 | #define _USER_PERIPH_SETUP_H_ 17 | 18 | /* 19 | * INCLUDE FILES 20 | **************************************************************************************** 21 | */ 22 | 23 | #include "arch.h" 24 | #include "gpio.h" 25 | #include "uart.h" 26 | 27 | 28 | /* 29 | * DEFINES 30 | **************************************************************************************** 31 | */ 32 | 33 | 34 | /****************************************************************************************/ 35 | /* UART2 configuration to use with arch_console print messages */ 36 | /****************************************************************************************/ 37 | // Define UART2 Tx Pad 38 | #if defined (__DA14531__) 39 | #define UART2_TX_PORT GPIO_PORT_0 40 | #define UART2_TX_PIN GPIO_PIN_6 41 | #else 42 | #define UART2_TX_PORT GPIO_PORT_0 43 | #define UART2_TX_PIN GPIO_PIN_4 44 | #endif 45 | 46 | // Define UART2 Settings 47 | #define UART2_BAUDRATE UART_BAUDRATE_115200 48 | #define UART2_DATABITS UART_DATABITS_8 49 | #define UART2_PARITY UART_PARITY_NONE 50 | #define UART2_STOPBITS UART_STOPBITS_1 51 | #define UART2_AFCE UART_AFCE_DIS 52 | #define UART2_FIFO UART_FIFO_EN 53 | #define UART2_TX_FIFO_LEVEL UART_TX_FIFO_LEVEL_0 54 | #define UART2_RX_FIFO_LEVEL UART_RX_FIFO_LEVEL_0 55 | 56 | 57 | /***************************************************************************************/ 58 | /* Production debug output configuration */ 59 | /***************************************************************************************/ 60 | #if PRODUCTION_DEBUG_OUTPUT 61 | #if defined (__DA14531__) 62 | #define PRODUCTION_DEBUG_PORT GPIO_PORT_0 63 | #define PRODUCTION_DEBUG_PIN GPIO_PIN_11 64 | #else 65 | #define PRODUCTION_DEBUG_PORT GPIO_PORT_2 66 | #define PRODUCTION_DEBUG_PIN GPIO_PIN_5 67 | #endif 68 | #endif 69 | 70 | /* 71 | * FUNCTION DECLARATIONS 72 | **************************************************************************************** 73 | */ 74 | 75 | #if DEVELOPMENT_DEBUG 76 | /** 77 | **************************************************************************************** 78 | * @brief Reserves application's specific GPIOs 79 | * @details Used only in Development mode (#if DEVELOPMENT_DEBUG) 80 | * i.e. to reserve P0_1 as Generic Purpose I/O: 81 | * RESERVE_GPIO(DESCRIPTIVE_NAME, GPIO_PORT_0, GPIO_PIN_1, PID_GPIO); 82 | **************************************************************************************** 83 | */ 84 | void GPIO_reservations(void); 85 | #endif 86 | 87 | /** 88 | **************************************************************************************** 89 | * @brief Sets the functionality of application pads 90 | * @details i.e. to set P0_1 as Generic purpose Output: 91 | * GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_1, OUTPUT, PID_GPIO, false); 92 | **************************************************************************************** 93 | */ 94 | void set_pad_functions(void); 95 | 96 | /** 97 | **************************************************************************************** 98 | * @brief Initializes application's peripherals and pins 99 | **************************************************************************************** 100 | */ 101 | void periph_init(void); 102 | 103 | 104 | #endif // _USER_PERIPH_SETUP_H_ 105 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_uart/src/config/user_profiles_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_profiles_config.h 5 | * 6 | * @brief Configuration file for the profiles used in the application. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_PROFILES_CONFIG_H_ 16 | #define _USER_PROFILES_CONFIG_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @defgroup APP_CONFIG 21 | * @ingroup APP 22 | * @brief Application configuration file 23 | * 24 | * This file contains the configuration of the profiles used by the application. 25 | * 26 | * @{ 27 | **************************************************************************************** 28 | */ 29 | 30 | /* 31 | * DEFINITIONS 32 | **************************************************************************************** 33 | */ 34 | 35 | /***************************************************************************************/ 36 | /* Used BLE profiles (used by "rwprf_config.h"). */ 37 | /***************************************************************************************/ 38 | 39 | #define CFG_PRF_DISS 40 | #define CFG_PRF_CUST1 41 | 42 | /***************************************************************************************/ 43 | /* Profile application configuration section */ 44 | /***************************************************************************************/ 45 | 46 | /* 47 | **************************************************************************************** 48 | * DISS application profile configuration 49 | **************************************************************************************** 50 | */ 51 | 52 | #define APP_DIS_FEATURES (DIS_MANUFACTURER_NAME_CHAR_SUP | \ 53 | DIS_MODEL_NB_STR_CHAR_SUP | \ 54 | DIS_SYSTEM_ID_CHAR_SUP | \ 55 | DIS_SW_REV_STR_CHAR_SUP | \ 56 | DIS_FIRM_REV_STR_CHAR_SUP | \ 57 | DIS_PNP_ID_CHAR_SUP) 58 | 59 | /// Manufacturer Name (up to 18 chars) 60 | #define APP_DIS_MANUFACTURER_NAME ("Dialog Semi") 61 | #define APP_DIS_MANUFACTURER_NAME_LEN (11) 62 | 63 | /// Model Number String (up to 18 chars) 64 | #if defined (__DA14586__) 65 | #define APP_DIS_MODEL_NB_STR ("DA14586") 66 | #elif defined (__DA14531__) 67 | #define APP_DIS_MODEL_NB_STR ("DA14531") 68 | #else 69 | #define APP_DIS_MODEL_NB_STR ("DA14585") 70 | #endif 71 | #define APP_DIS_MODEL_NB_STR_LEN (7) 72 | 73 | /// System ID - LSB -> MSB 74 | #define APP_DIS_SYSTEM_ID ("\x12\x34\x56\xFF\xFE\x9A\xBC\xDE") 75 | #define APP_DIS_SYSTEM_ID_LEN (8) 76 | 77 | #define APP_DIS_SW_REV SDK_VERSION 78 | #define APP_DIS_FIRM_REV SDK_VERSION 79 | 80 | /// Serial Number 81 | #define APP_DIS_SERIAL_NB_STR ("1.0.0.0-LE") 82 | #define APP_DIS_SERIAL_NB_STR_LEN (10) 83 | 84 | /// Hardware Revision String 85 | #if defined (__DA14586__) 86 | #define APP_DIS_HARD_REV_STR ("DA14586") 87 | #elif defined (__DA14531__) 88 | #define APP_DIS_HARD_REV_STR ("DA14531") 89 | #else 90 | #define APP_DIS_HARD_REV_STR ("DA14585") 91 | #endif 92 | #define APP_DIS_HARD_REV_STR_LEN (7) 93 | 94 | /// Firmware Revision 95 | #define APP_DIS_FIRM_REV_STR SDK_VERSION 96 | #define APP_DIS_FIRM_REV_STR_LEN (sizeof(APP_DIS_FIRM_REV_STR) - 1) 97 | 98 | /// Software Revision String 99 | #define APP_DIS_SW_REV_STR SDK_VERSION 100 | #define APP_DIS_SW_REV_STR_LEN (sizeof(APP_DIS_SW_REV_STR) - 1) 101 | 102 | /// IEEE 103 | #define APP_DIS_IEEE ("\xFF\xEE\xDD\xCC\xBB\xAA") 104 | #define APP_DIS_IEEE_LEN (6) 105 | 106 | /** 107 | * PNP ID Value - LSB -> MSB 108 | * Vendor ID Source : 0x02 (USB Implementers Forum assigned Vendor ID value) 109 | * Vendor ID : 0x045E (Microsoft Corp) 110 | * Product ID : 0x0040 111 | * Product Version : 0x0300 112 | * e.g. #define APP_DIS_PNP_ID ("\x02\x5E\x04\x40\x00\x00\x03") 113 | */ 114 | #define APP_DIS_PNP_ID ("\x01\xD2\x00\x80\x05\x00\x01") 115 | #define APP_DIS_PNP_ID_LEN (7) 116 | 117 | /// @} APP_CONFIG 118 | 119 | #endif // _USER_PROFILES_CONFIG_H_ 120 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_uart/src/custom_profile/user_custs_config.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_custs_config.c 5 | * 6 | * @brief Custom1/2 Server (CUSTS1/2) profile database structure and initialization. 7 | * 8 | * Copyright (C) 2016-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | /** 16 | **************************************************************************************** 17 | * @defgroup USER_CONFIG 18 | * @ingroup USER 19 | * @brief Custom1/2 Server (CUSTS1/2) profile database structure and initialization. 20 | * 21 | * @{ 22 | **************************************************************************************** 23 | */ 24 | 25 | /* 26 | * INCLUDE FILES 27 | **************************************************************************************** 28 | */ 29 | 30 | #include "app_prf_types.h" 31 | #include "app_customs.h" 32 | #include "user_custs1_def.h" 33 | 34 | /* 35 | * GLOBAL VARIABLE DEFINITIONS 36 | **************************************************************************************** 37 | */ 38 | 39 | #if (BLE_CUSTOM1_SERVER) 40 | extern const struct attm_desc_128 custs1_att_db[CUSTS1_IDX_NB]; 41 | #endif 42 | 43 | /// Custom1/2 server function callback table 44 | const struct cust_prf_func_callbacks cust_prf_funcs[] = 45 | { 46 | #if (BLE_CUSTOM1_SERVER) 47 | { TASK_ID_CUSTS1, 48 | custs1_att_db, 49 | CUSTS1_IDX_NB, 50 | #if (BLE_APP_PRESENT) 51 | app_custs1_create_db, NULL, 52 | #else 53 | NULL, NULL, 54 | #endif 55 | NULL, NULL, 56 | }, 57 | #endif 58 | #if (BLE_CUSTOM2_SERVER) 59 | { TASK_ID_CUSTS2, 60 | NULL, 61 | 0, 62 | #if (BLE_APP_PRESENT) 63 | app_custs2_create_db, NULL, 64 | #else 65 | NULL, NULL, 66 | #endif 67 | NULL, NULL, 68 | }, 69 | #endif 70 | {TASK_ID_INVALID, NULL, 0, NULL, NULL, NULL, NULL}, // DO NOT MOVE. Must always be last 71 | }; 72 | 73 | /// @} USER_CONFIG 74 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_uart/src/custom_profile/user_custs_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_custs_config.h 5 | * 6 | * @brief Custom1/2 Server (CUSTS1/2) profile database initialization. 7 | * 8 | * Copyright (C) 2016-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_CUSTS_CONFIG_H_ 16 | #define _USER_CUSTS_CONFIG_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @defgroup USER_CONFIG 21 | * @ingroup USER 22 | * @brief Custom1/2 Server (CUSTS1/2) profile database initialization. 23 | * 24 | * @{ 25 | **************************************************************************************** 26 | */ 27 | 28 | /* 29 | * INCLUDE FILES 30 | **************************************************************************************** 31 | */ 32 | 33 | #include "app_prf_types.h" 34 | 35 | /* 36 | * GLOBAL VARIABLE DECLARATIONS 37 | **************************************************************************************** 38 | */ 39 | 40 | extern const struct cust_prf_func_callbacks cust_prf_funcs[]; 41 | 42 | /// @} USER_CONFIG 43 | 44 | #endif // _USER_CUSTS_CONFIG_H_ 45 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_uart/src/platform/user_periph_setup.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_periph_setup.c 5 | * 6 | * @brief Peripherals setup and initialization. 7 | * 8 | * Copyright (C) 2015-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | /* 16 | * INCLUDE FILES 17 | **************************************************************************************** 18 | */ 19 | 20 | #include "user_periph_setup.h" 21 | #include "datasheet.h" 22 | #include "system_library.h" 23 | #include "rwip_config.h" 24 | #include "gpio.h" 25 | #include "uart.h" 26 | #include "syscntl.h" 27 | 28 | /* 29 | * GLOBAL VARIABLE DEFINITIONS 30 | **************************************************************************************** 31 | */ 32 | 33 | #if DEVELOPMENT_DEBUG 34 | 35 | void GPIO_reservations(void) 36 | { 37 | /* 38 | i.e. to reserve P0_1 as Generic Purpose I/O: 39 | RESERVE_GPIO(DESCRIPTIVE_NAME, GPIO_PORT_0, GPIO_PIN_1, PID_GPIO); 40 | */ 41 | RESERVE_GPIO(UART_TX, GPIO_PORT_0, GPIO_PIN_6, PID_UART2_TX); 42 | RESERVE_GPIO(UART_RX, GPIO_PORT_0, GPIO_PIN_5, PID_UART2_RX); 43 | #if defined (CFG_PRINTF_UART2) 44 | RESERVE_GPIO(UART2_TX, UART2_TX_PORT, UART2_TX_PIN, PID_UART2_TX); 45 | #endif 46 | } 47 | 48 | #endif 49 | 50 | void set_pad_functions(void) 51 | { 52 | /* 53 | i.e. to set P0_1 as Generic purpose Output: 54 | GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_1, OUTPUT, PID_GPIO, false); 55 | */ 56 | GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_6, OUTPUT, PID_UART2_TX, false); 57 | GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_5, INPUT, PID_UART2_RX, false); 58 | #if defined (__DA14586__) 59 | // Disallow spontaneous DA14586 SPI Flash wake-up 60 | GPIO_ConfigurePin(GPIO_PORT_2, GPIO_PIN_3, OUTPUT, PID_GPIO, true); 61 | #endif 62 | 63 | #if defined (CFG_PRINTF_UART2) 64 | // Configure UART2 TX Pad 65 | GPIO_ConfigurePin(UART2_TX_PORT, UART2_TX_PIN, OUTPUT, PID_UART2_TX, false); 66 | #endif 67 | 68 | } 69 | 70 | #if defined (CFG_PRINTF_UART2) 71 | // Configuration struct for UART2 72 | static const uart_cfg_t uart_cfg = { 73 | .baud_rate = UART2_BAUDRATE, 74 | .data_bits = UART2_DATABITS, 75 | .parity = UART2_PARITY, 76 | .stop_bits = UART2_STOPBITS, 77 | .auto_flow_control = UART2_AFCE, 78 | .use_fifo = UART2_FIFO, 79 | .tx_fifo_tr_lvl = UART2_TX_FIFO_LEVEL, 80 | .rx_fifo_tr_lvl = UART2_RX_FIFO_LEVEL, 81 | .intr_priority = 2, 82 | }; 83 | #endif 84 | 85 | void periph_init(void) 86 | { 87 | #if defined (__DA14531__) 88 | // In Boost mode enable the DCDC converter to supply VBAT_HIGH for the used GPIOs 89 | syscntl_dcdc_turn_on_in_boost(SYSCNTL_DCDC_LEVEL_3V0); 90 | #else 91 | // Power up peripherals' power domain 92 | SetBits16(PMU_CTRL_REG, PERIPH_SLEEP, 0); 93 | while (!(GetWord16(SYS_STAT_REG) & PER_IS_UP)); 94 | SetBits16(CLK_16M_REG, XTAL16_BIAS_SH_ENABLE, 1); 95 | #endif 96 | 97 | // ROM patch 98 | patch_func(); 99 | 100 | static const uart_cfg_t uart_cfg = { 101 | .baud_rate = UART_BAUDRATE_115200, 102 | .data_bits = UART_DATABITS_8, 103 | .parity = UART_PARITY_NONE, 104 | .stop_bits = UART_STOPBITS_1, 105 | .auto_flow_control = UART_AFCE_DIS, 106 | .use_fifo = UART_FIFO_DIS, 107 | .tx_fifo_tr_lvl = UART_TX_FIFO_LEVEL_0, 108 | .rx_fifo_tr_lvl = UART_RX_FIFO_LEVEL_0, 109 | .intr_priority = 2, 110 | }; 111 | 112 | uart_initialize(UART2, &uart_cfg); 113 | 114 | // Initialize peripherals 115 | #if defined (CFG_PRINTF_UART2) 116 | // Initialize UART2 117 | uart_initialize(UART2, &uart_cfg); 118 | #endif 119 | 120 | // Set pad functionality 121 | set_pad_functions(); 122 | 123 | // Enable the pads 124 | GPIO_set_pad_latch_en(true); 125 | } 126 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_uart/src/user_empty_peripheral_template.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_empty_peripheral_template.c 5 | * 6 | * @brief Empty peripheral template project source code. 7 | * 8 | * Copyright (C) 2012-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | /** 16 | **************************************************************************************** 17 | * @addtogroup APP 18 | * @{ 19 | **************************************************************************************** 20 | */ 21 | #include "rwip_config.h" // SW configuration 22 | 23 | 24 | /* 25 | * INCLUDE FILES 26 | **************************************************************************************** 27 | */ 28 | 29 | #include "app_api.h" 30 | #include "user_empty_peripheral_template.h" 31 | #include "uart.h" 32 | 33 | /* 34 | * FUNCTION DEFINITIONS 35 | **************************************************************************************** 36 | */ 37 | #define RX_BUFFER_LENGTH 5 38 | uint8_t uart_rx_buffer[RX_BUFFER_LENGTH] = {0}; 39 | 40 | void user_on_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param) 41 | { 42 | default_app_on_connection(connection_idx, param); 43 | } 44 | 45 | void user_on_disconnect( struct gapc_disconnect_ind const *param ) 46 | { 47 | default_app_on_disconnect(param); 48 | } 49 | 50 | static void uart_rx_handler(uint16_t length) 51 | { 52 | char print_str[] = "\r\nChar received = " ; 53 | uart_send(UART2, print_str, strlen(print_str), UART_OP_BLOCKING); 54 | uart_send(UART2, uart_rx_buffer, RX_BUFFER_LENGTH, UART_OP_BLOCKING); 55 | } 56 | 57 | void user_app_on_init() 58 | { 59 | char print_str[] = "Enter 5 characters: "; 60 | default_app_on_init(); 61 | uart_send(UART2, print_str, strlen(print_str), UART_OP_BLOCKING); 62 | uart_register_rx_cb(UART2, uart_rx_handler); 63 | uart_receive(UART2, uart_rx_buffer, RX_BUFFER_LENGTH, UART_OP_INTR); 64 | } 65 | /// @} APP 66 | -------------------------------------------------------------------------------- /empty_peripheral_template_blog_uart/src/user_empty_peripheral_template.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_empty_peripheral_template.h 5 | * 6 | * @brief Empty peripheral template project header file. 7 | * 8 | * Copyright (C) 2012-2019 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #ifndef _USER_EMPTY_PERIPHERAL_TEMPLATE_H_ 16 | #define _USER_EMPTY_PERIPHERAL_TEMPLATE_H_ 17 | 18 | /** 19 | **************************************************************************************** 20 | * @addtogroup APP 21 | * @ingroup RICOW 22 | * 23 | * @brief 24 | * 25 | * @{ 26 | **************************************************************************************** 27 | */ 28 | 29 | /* 30 | * INCLUDE FILES 31 | **************************************************************************************** 32 | */ 33 | 34 | #include "rwble_config.h" 35 | #include "app_task.h" // application task 36 | #include "gapc_task.h" // gap functions and messages 37 | #include "gapm_task.h" // gap functions and messages 38 | #include "app.h" // application definitions 39 | #include "co_error.h" // error code definitions 40 | 41 | 42 | /**************************************************************************** 43 | Add here supported profiles' application header files. 44 | i.e. 45 | #if (BLE_DIS_SERVER) 46 | #include "app_dis.h" 47 | #include "app_dis_task.h" 48 | #endif 49 | *****************************************************************************/ 50 | 51 | /* 52 | * TYPE DEFINITIONS 53 | **************************************************************************************** 54 | */ 55 | 56 | /* 57 | * DEFINES 58 | **************************************************************************************** 59 | */ 60 | 61 | /* 62 | * FUNCTION DECLARATIONS 63 | **************************************************************************************** 64 | */ 65 | 66 | void user_on_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param); 67 | 68 | void user_on_disconnect( struct gapc_disconnect_ind const *param ); 69 | 70 | void user_app_on_init(); 71 | /// @} APP 72 | 73 | #endif // _USER_EMPTY_PERIPHERAL_TEMPLATE_H_ 74 | --------------------------------------------------------------------------------