found irext example project

This commit is contained in:
2017-05-09 11:36:49 +08:00
parent 285a7b3a42
commit a51640d037
835 changed files with 265091 additions and 0 deletions

View File

@@ -0,0 +1,233 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- ***************************************************************************************************************** -->
<!--
Boundary Config XML file
<For Advanced User's Only>
Valid ranges only indicate the range accepted by this application.
It is possible to enter xml values that will not work for your device at run time.
It is possible to enter xml values that prevent your device from building.
It is possible to enter xml values that cause unpredictable results.
The flexibility in values is provided to support future changes in the targets.
<Key for tag data notes>
(1) String cannot be empty or all white space
(2) If string is set to "not_used" target data operations are supressed
Summary of XML tags:
====================
<boundary_config>Config File Data<\boundary_config>
===================================================================
XML Version
===================================================================
<version>XML layout version</version>
Do Not Modify
===================================================================
General Settings
===================================================================
<general_cfg_data> Start general config data
<create_flash_boundary>true or false</create_flash_boundary>
<backup_cfg_files>true or false</backup_cfg_files>
<create_ram_boundary>true or false</create_ram_boundary>
<ram_margin_bytes>UInt16</ram_margin_bytes>
<ram_alignment_value>byte - valid values = 0,2,4,8,16</ram_alignment_value>
<create_nv_boundary>true or false</create_nv_boundary>
</general_cfg_data> End general config data
===================================================================
Shared Settings
===================================================================
Contains Sharedsettings
<shared>
Target strings used to find the indicated data and generate output data
Valid Entries:
Ascii Text
<flash_boundary_head>target string (1)</flash_boundary_head>
<ram_boundary_head>target string (1)</ram_boundary_head>
<nv_boundary_head>target string (1)</nv_boundary_head>
<boundary_mid>target string</boundary_mid>
<boundary_tail>target string</boundary_tail>
</shared>
===================================================================
IAR Settings
===================================================================
Contains Iar handing settings
<iar>
Target strings used to find the indicated data
Valid Entries:
Ascii Text
<map_file_data>
<read_only_code>target string (1)(2)</read_only_code>
<read_only_data>target string (1)(2)</read_only_data>
<read_write_data>target string (1)(2)</read_write_data>
<ram_end_addr>target string (1)(2)</ram_end_addr>
</map_file_data>
Target strings used to find the indicated data
Valid Entries:
Ascii Text
<lcf_file_data>
<chip_name>target string (1)</chip_name>
<flash_size>target string (1)(2)</flash_size>
<ram_size>target string (1)(2)</ram_size>
<page_size>target string (1)(2)</page_size>
<reserved_pages>target string (1)(2)</reserved_pages>
<nv_pages>target string (1)(2)</nv_pages>
</lcf_file_data>
Target strings used to find the indicated data and generate output data
Valid Entries:
Ascii Text
<cfg_file_data>
<auto_gen_marker>string (1)(2)</auto_gen_marker>
<compiler_comment1>string (2)</compiler_comment1>
<compiler_comment2>string (2)</compiler_comment2>
<compiler_option>string</compiler_option>
<linker_comment1>string (2)</linker_comment1>
<linker_comment2>string (2)</linker_comment2>
<linker_option>string</linker_option>
</cfg_file_data>
</iar>
===================================================================
CCS Settings
===================================================================
Contains Ccs handing settings
<ccs>
Target strings used to find the indicated data
Valid Entries:
Ascii Text
<map_file_data>
<read_only_code>target string (1)(2)</read_only_code>
<read_only_data>target string (1)(2)</read_only_data>
<read_write_data>target string (1)(2)</read_write_data>
<ram_end_addr>target string (1)(2)</ram_end_addr>
</map_file_data>
Target strings used to find the indicated data
Valid Entries:
Ascii Text
<lcf_file_data>
<chip_name>target string (1)</chip_name>
<flash_size>target string (1)(2)</flash_size>
<ram_size>target string (1)(2)</ram_size>
<page_size>target string (1)(2)</page_size>
<reserved_pages>target string (1)(2)</reserved_pages>
<nv_pages>target string (1)(2)</nv_pages>
</lcf_file_data>
Target strings used to find the indicated data and generate output data
Valid Entries:
Ascii Text
<cfg_file_data>
<auto_gen_marker>string (1)(2)</auto_gen_marker>
<compiler_comment1>string (2)</compiler_comment1>
<compiler_comment2>string (2)</compiler_comment2>
<compiler_option>string</compiler_option>
<linker_comment1>string (2)</linker_comment1>
<linker_comment2>string (2)</linker_comment2>
<linker_option>string</linker_option>
</cfg_file_data>
</ccs>
===================================================================
===================================================================
-->
<!-- ***************************************************************************************************************** -->
<boundary_config>
<!-- ***************************************************************************************************************** -->
<!-- XML Version -->
<!-- ***************************************************************************************************************** -->
<version>1.0.2</version>
<!-- ***************************************************************************************************************** -->
<!-- General -->
<!-- ***************************************************************************************************************** -->
<general_cfg_data>
<create_flash_boundary>true</create_flash_boundary>
<backup_cfg_files>true</backup_cfg_files>
<create_ram_boundary>true</create_ram_boundary>
<ram_margin_bytes>42</ram_margin_bytes>
<ram_alignment_value>4</ram_alignment_value>
<create_nv_boundary>true</create_nv_boundary>
</general_cfg_data>
<!-- ***************************************************************************************************************** -->
<!-- Shared -->
<!-- ***************************************************************************************************************** -->
<shared>
<flash_boundary_head>ICALL_STACK0_ADDR=</flash_boundary_head>
<ram_boundary_head>ICALL_RAM0_ADDR=</ram_boundary_head>
<nv_boundary_head>SNV_FIRST_PAGE=</nv_boundary_head>
<boundary_mid>0x</boundary_mid>
<boundary_tail></boundary_tail>
</shared>
<!-- ***************************************************************************************************************** -->
<!-- IAR Settings -->
<!-- ***************************************************************************************************************** -->
<iar>
<map_file_data>
<read_only_code>bytes of readonly code memory</read_only_code>
<read_only_data>bytes of readonly data memory</read_only_data>
<read_write_data>bytes of readwrite data memory</read_write_data>
<ram_end_addr>"P2": place in [from</ram_end_addr>
</map_file_data>
<lcf_file_data>
<chip_name>isdefinedsymbol(</chip_name>
<flash_size>define symbol FLASH_SIZE</flash_size>
<ram_size>define symbol RAM_SIZE</ram_size>
<page_size>define symbol PAGE_SIZE</page_size>
<reserved_pages>define symbol NUM_RESERVED_PAGES</reserved_pages>
<nv_pages>not_used</nv_pages>
</lcf_file_data>
<cfg_file_data>
<auto_gen_marker>/* WARNING - Do not modify this line. Modifications below this line can be overwritten by the Boundary tool */</auto_gen_marker>
<compiler_line1>/* IAR Compiler Command Line Options */</compiler_line1>
<compiler_line2>/* Auto-generated compiler option(s) */</compiler_line2>
<compiler_line3> </compiler_line3>
<compiler_option>-D </compiler_option>
<linker_line1>/* IAR Linker Command Line Options */</linker_line1>
<linker_line2>/* Auto-generated linker option(s) */</linker_line2>
<linker_line3> </linker_line3>
<linker_option>--config_def </linker_option>
</cfg_file_data>
</iar>
<!-- ***************************************************************************************************************** -->
<!-- CCS Settings -->
<!-- ***************************************************************************************************************** -->
<ccs>
<map_file_data>
<read_only_code> FLASH </read_only_code>
<read_only_data>not_used</read_only_data>
<read_write_data> SRAM </read_write_data>
<ram_end_addr> SRAM </ram_end_addr>
</map_file_data>
<lcf_file_data>
<chip_name>not_used</chip_name>
<flash_size>#define FLASH_SIZE</flash_size>
<ram_size>#define RAM_SIZE</ram_size>
<page_size>#define PAGE_SIZE</page_size>
<reserved_pages>#define NUM_RESERVED_PAGES</reserved_pages>
<nv_pages>not_used</nv_pages>
</lcf_file_data>
<cfg_file_data>
<auto_gen_marker>/* WARNING - Do not modify this line. Modifications below this line can be overwritten by the Boundary tool */</auto_gen_marker>
<compiler_line1>/* CCS Compiler Command Line Options */</compiler_line1>
<compiler_line2>/* Auto-generated compiler option(s) */</compiler_line2>
<compiler_line3> </compiler_line3>
<compiler_option>--define=</compiler_option>
<linker_line1>/* CCS Linker Command Line Options */</linker_line1>
<linker_line2>/* Auto-generated linker option(s) */</linker_line2>
<linker_line3> </linker_line3>
<linker_option>--define=</linker_option>
</cfg_file_data>
</ccs>
<!-- ***************************************************************************************************************** -->
<!-- ***************************************************************************************************************** -->
</boundary_config>

View File

@@ -0,0 +1,124 @@
//*****************************************************************************
//! @file cc26xx_ble_app.cmd
//! @brief CC2650F128 linker configuration file for TI-RTOS with
//! Code Composer Studio.
//!
//! Revised $Date$
//! Revision $Revision$
//
// Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// Neither the name of Texas Instruments Incorporated nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//****************************************************************************/
/* Retain interrupt vector table variable */
--retain=g_pfnVectors
/* Override default entry point. */
/*--entry_point ResetISR */
/* Suppress warnings and errors: */
/* - 10063: Warning about entry point not being _c_int00 */
/* - 16011, 16012: 8-byte alignment errors. Observed when linking in object */
/* files compiled using Keil (ARM compiler) */
--diag_suppress=10063,16011,16012
/* The following command line options are set as part of the CCS project. */
/* If you are building using the command line, or for some reason want to */
/* define them here, you can uncomment and modify these lines as needed. */
/* If you are using CCS for building, it is probably better to make any such */
/* modifications in your CCS project and leave this file alone. */
/* */
/* --heap_size=0 */
/* --stack_size=256 */
/* --library=rtsv7M3_T_le_eabi.lib */
/* The starting address of the application. Normally the interrupt vectors */
/* must be located at the beginning of the application. */
#define FLASH_BASE 0x00000000
#define BIM_BASE 0x0001F000
#define PAGE_SIZE 0x1000
#define RAM_BASE 0x20000000
#define RAM_SIZE 0x5000
/* System memory map */
MEMORY
{
/* EDITOR'S NOTE:
* the FLASH and SRAM lengths can be changed by defining
* ICALL_STACK0_ADDR or ICALL_RAM0_ADDR in
* Properties->ARM Linker->Advanced Options->Command File Preprocessing.
*/
IVEC_FLASH (RX) : origin = FLASH_BASE, length = PAGE_SIZE
/* BIM stored in and executes from internal flash */
/* Flash Size 4 KB */
FLASH (RX) : origin = BIM_BASE, length = PAGE_SIZE
// CCFG Page, contains .ccfg code section and some application code.
//FLASH_LAST_PAGE (RX) : origin = FLASH_SIZE - 0x1000, length = 0x1000
/* Application uses internal RAM for data */
/* RAM Size 16 KB */
SRAM (RWX) : origin = RAM_BASE, length = 0x00002CFF
}
/* Section allocation in memory */
SECTIONS
{
.resetVecs : > IVEC_FLASH
.intvecs : > IVEC_FLASH
.text : > FLASH
.const : > FLASH
.constdata : > FLASH
.rodata : > FLASH
.cinit : > FLASH
.pinit : > FLASH
.init_array : > FLASH
.emb_text : > FLASH
.ccfg : > FLASH (HIGH)
.vtable : > SRAM
.vtable_ram : > SRAM
vtable_ram : > SRAM
.data : > SRAM
.bss : > SRAM
.sysmem : > SRAM
.stack : > SRAM (HIGH)
.nonretenvar : > SRAM
}
/* Create global constant that points to top of stack */
/* CCS: Change stack size under Project Properties */
__STACK_TOP = __stack + __STACK_SIZE;
/* Allow main() to take args */
/*--args 0x8*/

View File

@@ -0,0 +1,131 @@
//*****************************************************************************
//! @file cc26xx_ble_app.cmd
//! @brief CC2650F128 linker configuration file for TI-RTOS with
//! Code Composer Studio.
//!
//! Revised $Date$
//! Revision $Revision$
//
// Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// Neither the name of Texas Instruments Incorporated nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//****************************************************************************/
/* Retain interrupt vector table variable */
--retain=g_pfnVectors
/* Override default entry point. */
--entry_point ResetISR
/* Suppress warnings and errors: */
/* - 10063: Warning about entry point not being _c_int00 */
/* - 16011, 16012: 8-byte alignment errors. Observed when linking in object */
/* files compiled using Keil (ARM compiler) */
--diag_suppress=10063,16011,16012
/* The following command line options are set as part of the CCS project. */
/* If you are building using the command line, or for some reason want to */
/* define them here, you can uncomment and modify these lines as needed. */
/* If you are using CCS for building, it is probably better to make any such */
/* modifications in your CCS project and leave this file alone. */
/* */
/* --heap_size=0 */
/* --stack_size=256 */
/* --library=rtsv7M3_T_le_eabi.lib */
/* The starting address of the application. Normally the interrupt vectors */
/* must be located at the beginning of the application. */
#define APP_BASE 0x00000000
#define FLASH_SIZE 0x20000
#define PAGE_SIZE 0x1000
#define RAM_BASE 0x20000000
#define RAM_SIZE 0x5000
#ifdef RTOS_ROM
#define INTVEC_BASE 0x1500
#else
#define INTVEC_BASE 0x8000
#endif
/* System memory map */
MEMORY
{
/* EDITOR'S NOTE:
* the FLASH and SRAM lengths can be changed by defining
* ICALL_STACK0_ADDR or ICALL_RAM0_ADDR in
* Properties->ARM Linker->Advanced Options->Command File Preprocessing.
*/
/* Application stored in and executes from internal flash */
/* Flash Size 128 KB */
#ifdef RTOS_ROM // Image A
FLASH (RX) : origin = 0x1000, length = 0x6FFF
#else // Image B
FLASH (RX) : origin = 0x8000 , length = 0x00008FFF
#endif
/* Application uses internal RAM for data */
/* RAM Size 16 KB */
#ifdef ICALL_RAM0_ADDR
SRAM (RWX) : origin = RAM_BASE, length = ICALL_RAM0_ADDR - RAM_BASE
#else //default
SRAM (RWX) : origin = RAM_BASE, length = 0x000042FF
#endif
}
/* Section allocation in memory */
SECTIONS
{
.resetVecs : > INTVEC_BASE
//.intvecs : > INTVEC_BASE
.text : > FLASH
.const : > FLASH
.constdata : > FLASH
.rodata : > FLASH
.cinit : > FLASH
.pinit : > FLASH
.init_array : > FLASH
.emb_text : > FLASH
.vtable : > SRAM
.vtable_ram : > SRAM
vtable_ram : > SRAM
.data : > SRAM
.bss : > SRAM
.sysmem : > SRAM
.stack : > SRAM (HIGH)
.nonretenvar : > SRAM
}
/* Create global constant that points to top of stack */
/* CCS: Change stack size under Project Properties */
__STACK_TOP = __stack + __STACK_SIZE;
/* Allow main() to take args */
/*--args 0x8*/

View File

@@ -0,0 +1,122 @@
//*****************************************************************************
//! @file cc26xx_ble_app.cmd
//! @brief CC2650F128 linker configuration file for TI-RTOS with
//! Code Composer Studio.
//!
//! Revised $Date$
//! Revision $Revision$
//
// Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// Neither the name of Texas Instruments Incorporated nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//****************************************************************************/
/* Retain interrupt vector table variable */
--retain=g_pfnVectors
/* Override default entry point. */
/*--entry_point ResetISR */
/* Suppress warnings and errors: */
/* - 10063: Warning about entry point not being _c_int00 */
/* - 16011, 16012: 8-byte alignment errors. Observed when linking in object */
/* files compiled using Keil (ARM compiler) */
--diag_suppress=10063,16011,16012
/* The following command line options are set as part of the CCS project. */
/* If you are building using the command line, or for some reason want to */
/* define them here, you can uncomment and modify these lines as needed. */
/* If you are using CCS for building, it is probably better to make any such */
/* modifications in your CCS project and leave this file alone. */
/* */
/* --heap_size=0 */
/* --stack_size=256 */
/* --library=rtsv7M3_T_le_eabi.lib */
/* The starting address of the application. Normally the interrupt vectors */
/* must be located at the beginning of the application. */
#define FLASH_BASE 0x00000000
#define BIM_BASE 0x0001F000
#define PAGE_SIZE 0x1000
#define RAM_BASE 0x20000000
#define RAM_SIZE 0x5000
/* System memory map */
MEMORY
{
/* EDITOR'S NOTE:
* the FLASH and SRAM lengths can be changed by defining
* ICALL_STACK0_ADDR or ICALL_RAM0_ADDR in
* Properties->ARM Linker->Advanced Options->Command File Preprocessing.
*/
#if defined(KEEP_INTVECS)
IVEC_FLASH (RX) : origin = FLASH_BASE, length = PAGE_SIZE
#endif // KEEP_INTVECS
/* BIM stored in and executes from internal flash */
/* Flash Size 4 KB */
FLASH (RX) : origin = BIM_BASE, length = PAGE_SIZE
/* Application uses internal RAM for data */
/* RAM Size 16 KB */
SRAM (RWX) : origin = RAM_BASE, length = 0x00002CFF
}
/* Section allocation in memory */
SECTIONS
{
LoaderEntry : > BIM_BASE
.text : > FLASH
.const : > FLASH
.constdata : > FLASH
.rodata : > FLASH
.cinit : > FLASH
.pinit : > FLASH
.init_array : > FLASH
.emb_text : > FLASH
.ccfg : > FLASH (HIGH)
.vtable : > SRAM
.vtable_ram : > SRAM
vtable_ram : > SRAM
.data : > SRAM
.bss : > SRAM
.sysmem : > SRAM
.stack : > SRAM (HIGH)
.nonretenvar : > SRAM
}
/* Create global constant that points to top of stack */
/* CCS: Change stack size under Project Properties */
__STACK_TOP = __stack + __STACK_SIZE;
/* Allow main() to take args */
/*--args 0x8*/

View File

@@ -0,0 +1,128 @@
//*****************************************************************************
//! @file cc26xx_ble_app.cmd
//! @brief CC2650F128 linker configuration file for TI-RTOS with
//! Code Composer Studio.
//!
//! Revised $Date$
//! Revision $Revision$
//
// Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// Neither the name of Texas Instruments Incorporated nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//****************************************************************************/
/* Retain interrupt vector table variable */
--retain=g_pfnVectors
/* Override default entry point. */
--entry_point ResetISR
/* Suppress warnings and errors: */
/* - 10063: Warning about entry point not being _c_int00 */
/* - 16011, 16012: 8-byte alignment errors. Observed when linking in object */
/* files compiled using Keil (ARM compiler) */
--diag_suppress=10063,16011,16012
/* The following command line options are set as part of the CCS project. */
/* If you are building using the command line, or for some reason want to */
/* define them here, you can uncomment and modify these lines as needed. */
/* If you are using CCS for building, it is probably better to make any such */
/* modifications in your CCS project and leave this file alone. */
/* */
/* --heap_size=0 */
/* --stack_size=256 */
/* --library=rtsv7M3_T_le_eabi.lib */
/* The starting address of the application. Normally the interrupt vectors */
/* must be located at the beginning of the application. */
#define APP_BASE 0x00000000
#define FLASH_SIZE 0x20000
#define RAM_BASE 0x20000000
#define RAM_SIZE 0x5000
/* System memory map */
MEMORY
{
/* EDITOR'S NOTE:
* the FLASH and SRAM lengths can be changed by defining
* ICALL_STACK0_ADDR or ICALL_RAM0_ADDR in
* Properties->ARM Linker->Advanced Options->Command File Preprocessing.
*/
/* Application stored in and executes from internal flash */
/* Flash Size 128 KB */
#ifdef ICALL_STACK0_ADDR
FLASH (RX) : origin = APP_BASE, length = ICALL_STACK0_ADDR - APP_BASE - 1
#else // default
FLASH (RX) : origin = APP_BASE, length = 0x00008FFF
#endif
// CCFG Page, contains .ccfg code section and some application code.
FLASH_LAST_PAGE (RX) : origin = FLASH_SIZE - 0x1000, length = 0x1000
/* Application uses internal RAM for data */
/* RAM Size 16 KB */
#ifdef ICALL_RAM0_ADDR
SRAM (RWX) : origin = RAM_BASE, length = ICALL_RAM0_ADDR - RAM_BASE - 1
#else //default
SRAM (RWX) : origin = RAM_BASE, length = 0x00002CFF
#endif
}
/* Section allocation in memory */
SECTIONS
{
.intvecs : > APP_BASE
.text : >> FLASH | FLASH_LAST_PAGE
.const : >> FLASH | FLASH_LAST_PAGE
.constdata : >> FLASH | FLASH_LAST_PAGE
.rodata : >> FLASH | FLASH_LAST_PAGE
.cinit : > FLASH | FLASH_LAST_PAGE
.pinit : >> FLASH | FLASH_LAST_PAGE
.init_array : >> FLASH | FLASH_LAST_PAGE
.emb_text : >> FLASH | FLASH_LAST_PAGE
.ccfg : > FLASH_LAST_PAGE (HIGH)
.vtable : > SRAM
.vtable_ram : > SRAM
vtable_ram : > SRAM
.data : > SRAM
.bss : > SRAM
.sysmem : > SRAM
.stack : > SRAM (HIGH)
.nonretenvar : > SRAM
}
/* Create global constant that points to top of stack */
/* CCS: Change stack size under Project Properties */
__STACK_TOP = __stack + __STACK_SIZE;
/* Allow main() to take args */
--args 0x8

View File

@@ -0,0 +1,128 @@
//*****************************************************************************
//! @file cc26xx_ble_app.cmd
//! @brief CC2650F128 linker configuration file for TI-RTOS with
//! Code Composer Studio.
//!
//! Revised $Date$
//! Revision $Revision$
//
// Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// Neither the name of Texas Instruments Incorporated nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//****************************************************************************/
/* Retain interrupt vector table variable */
--retain=g_pfnVectors
/* Override default entry point. */
--entry_point ResetISR
/* Suppress warnings and errors: */
/* - 10063: Warning about entry point not being _c_int00 */
/* - 16011, 16012: 8-byte alignment errors. Observed when linking in object */
/* files compiled using Keil (ARM compiler) */
--diag_suppress=10063,16011,16012
/* The following command line options are set as part of the CCS project. */
/* If you are building using the command line, or for some reason want to */
/* define them here, you can uncomment and modify these lines as needed. */
/* If you are using CCS for building, it is probably better to make any such */
/* modifications in your CCS project and leave this file alone. */
/* */
/* --heap_size=0 */
/* --stack_size=256 */
/* --library=rtsv7M3_T_le_eabi.lib */
/* The starting address of the application. Normally the interrupt vectors */
/* must be located at the beginning of the application. */
#ifndef APP_BASE
#define APP_BASE 0x00001000
#endif //APP_BASE
#define FLASH_SIZE 0x20000
#define PAGE_SIZE 0x1000
#define RAM_BASE 0x20000000
#define RAM_SIZE 0x5000
/* System memory map */
MEMORY
{
/* EDITOR'S NOTE:
* the FLASH and SRAM lengths can be changed by defining
* ICALL_STACK0_ADDR or ICALL_RAM0_ADDR in
* Properties->ARM Linker->Advanced Options->Command File Preprocessing.
*/
/* Application stored in and executes from internal flash starting at 4KB offset from 0x0 */
/* Flash Size 128 KB */
#ifdef ICALL_STACK0_ADDR
FLASH (RX) : origin = APP_BASE, length = ICALL_STACK0_ADDR - (APP_BASE + PAGE_SIZE) - 1
#else // default
FLASH (RX) : origin = APP_BASE, length = 0x0000CFFF
#endif
/* Application uses internal RAM for data */
/* RAM Size 16 KB */
#ifdef ICALL_RAM0_ADDR
SRAM (RWX) : origin = RAM_BASE, length = ICALL_RAM0_ADDR - RAM_BASE - 1
#else //default
SRAM (RWX) : origin = RAM_BASE, length = 0x00002CFF
#endif
}
/* Section allocation in memory */
SECTIONS
{
.intvecs : > APP_BASE
.text : > FLASH
.const : > FLASH
.constdata : > FLASH
.rodata : > FLASH
.cinit : > FLASH
.pinit : > FLASH
.init_array : > FLASH
.emb_text : > FLASH
.vtable : > SRAM
.vtable_ram : > SRAM
vtable_ram : > SRAM
.data : > SRAM
.bss : > SRAM
.sysmem : > SRAM
.stack : > SRAM (HIGH)
.nonretenvar : > SRAM
}
/* Create global constant that points to top of stack */
/* CCS: Change stack size under Project Properties */
__STACK_TOP = __stack + __STACK_SIZE;
/* Allow main() to take args */
/*--args 0x8*/

View File

@@ -0,0 +1,121 @@
//*****************************************************************************
//! @file cc26xx_ble_stack.cmd
//! @brief CC2650F128 linker configuration file for TI-RTOS with
//! Code Composer Studio.
//!
//! Revised $Date$
//! Revision $Revision$
//
// Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// Neither the name of Texas Instruments Incorporated nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//****************************************************************************/
/* Retain interrupt vector table variable */
--retain=g_pfnVectors
/* Override default entry point. */
//--entry_point ResetISR
/* Suppress warnings and errors: */
/* - 10063: Warning about entry point not being _c_int00 */
/* - 16011, 16012: 8-byte alignment errors. Observed when linking in object */
/* files compiled using Keil (ARM compiler) */
--diag_suppress=10063,16011,16012
/* The following command line options are set as part of the CCS project. */
/* If you are building using the command line, or for some reason want to */
/* define them here, you can uncomment and modify these lines as needed. */
/* If you are using CCS for building, it is probably better to make any such */
/* modifications in your CCS project and leave this file alone. */
/* */
/* --heap_size=0 */
/* --stack_size=256 */
/* --library=rtsv7M3_T_le_eabi.lib */
/* The starting address of the application. Normally the interrupt vectors */
/* must be located at the beginning of the application. */
#define APP_BASE 0x0
#define FLASH_SIZE 0x20000
#define RAM_BASE 0x20000000
#define RAM_SIZE 0x5000
#define RAM_END 0x200048E7
#define PAGE_SIZE 0x1000
// Last page is reserved by Application for CCFG.
#define NUM_RESERVED_PAGES 1
#define RESERVED_SIZE (NUM_RESERVED_PAGES * PAGE_SIZE)
/* System memory map */
MEMORY
{
/* EDITOR'S NOTE:
* the FLASH and SRAM lengths can be changed by defining
* ICALL_STACK0_ADDR or ICALL_RAM0_ADDR in
* Properties->ARM Linker->Advanced Options->Command File Preprocessing.
*/
/* Application stored in and executes from internal flash */
/* Flash Size 128 KB */
#ifndef ICALL_STACK0_ADDR
#define ICALL_STACK0_ADDR 0x9000
#endif
FLASH (RX) : origin = ICALL_STACK0_ADDR, length = FLASH_SIZE - RESERVED_SIZE - ICALL_STACK0_ADDR
/* Application uses internal RAM for data */
/* RAM Size 20 KB */
#ifndef ICALL_RAM0_ADDR
#define ICALL_RAM0_ADDR 0x20002D00
#endif
//SRAM (RWX) : origin = ICALL_RAM0_ADDR, length = (RAM_BASE + RAM_SIZE) - ICALL_RAM0_ADDR
SRAM (RWX) : origin = ICALL_RAM0_ADDR, length = RAM_END - ICALL_RAM0_ADDR
}
/* Section allocation in memory */
SECTIONS
{
.text : > FLASH
.const : > FLASH
.constdata : > FLASH
.rodata : > FLASH
.cinit : > FLASH
.pinit : > FLASH
.init_array : > FLASH
.emb_text : > FLASH
EntrySection : > ICALL_STACK0_ADDR
.vtable : > SRAM
.vtable_ram : > SRAM
vtable_ram : > SRAM
.data : > SRAM
.bss : > SRAM
.sysmem : > SRAM
.nonretenvar : > SRAM
}

View File

@@ -0,0 +1,161 @@
/*******************************************************************************
Filename: cc26xx_ble_app.icf
Revised: $Date: 2014-03-25 14:18:47 -0700 (Tue, 25 Mar 2014) $
Revision: $Revision: 37873 $
Description: IAR ARM Linker Configuration File - BIM
Imported Symbols
Note: Linker defines are located in the IAR IDE project using --config_def
in Options->Linker->Extra Options.
CCxxxx: Device Name (e.g. CC1350)
Exported Symbols
Note: Can be used as externs in C code.
STACK_TOP: Location of the top of RAM.
Copyright 2013-2015 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
*******************************************************************************/
////////////////////////////////////////////////////////////////////////////////
// Memory Sizes
////////////////////////////////////////////////////////////////////////////////
define symbol RAM_SIZE = 0x00005000; // 20K
define symbol FLASH_SIZE = 0x00020000; // 128K
define symbol ROM_SIZE = 0x0001C000; // 115K
////////////////////////////////////////////////////////////////////////////////
// Memory Definitions
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// RAM
//
define symbol RAM_START = 0x20000000;
if ( isdefinedsymbol(ICALL_RAM0_ADDR) )
{
define symbol RAM_END = (ICALL_RAM0_ADDR-1);
}
else // Default
{
define symbol RAM_END = 0x200036FF;
}
////////////////////////////////////////////////////////////////////////////////
// Flash
//
// BIM is allocated Flash sector 0.
define symbol FLASH_START = 0x00000000;
define symbol FLASH_END = 0x0001FFFF;
// Start here to avoid the RTOS in ROM config area from 0x100 to 0x5FF
define symbol BIM_START = 0x0001F000;
// Ledger page
define symbol BIM_LEDGER_BEGIN = 0x11000;
define symbol BIM_LEDGER_END = 0x11FFF;
////////////////////////////////////////////////////////////////////////////////
// Stack
//
define symbol STACK_SIZE = 0x400;
define symbol STACK_START = RAM_END + 1;
define symbol STACK_END = STACK_START - STACK_SIZE;
define block CSTACK with alignment = 8, size = STACK_SIZE { section .stack };
//
define symbol STACK_TOP = RAM_END + 1;
export symbol STACK_TOP;
////////////////////////////////////////////////////////////////////////////////
// Flash Interrupt Vector Table
//
define symbol INTVEC_NUM_ENTRIES = 50 + 1; // first entry is stack location
define symbol INTVEC_SIZE = INTVEC_NUM_ENTRIES + 4;
////////////////////////////////////////////////////////////////////////////////
// Memory Regions
////////////////////////////////////////////////////////////////////////////////
define memory mem with size = 4G;
define region RAM = mem:[from RAM_START to RAM_END];
define region FLASH = mem:[from FLASH_START to FLASH_END];
define region BIM = mem:[from BIM_START to FLASH_END];
define region BIM_LEDGER = mem:[from BIM_LEDGER_BEGIN to BIM_LEDGER_END];
////////////////////////////////////////////////////////////////////////////////
// Memory Placement
////////////////////////////////////////////////////////////////////////////////
// Interrupt Vector Table
place at address mem:FLASH_START { readonly section .intvec };
keep { readonly section .intvec };
// RAM Vector Table
place at start of RAM { section .vtable_ram };
// Stack
place at end of RAM { block CSTACK };
place in BIM { readonly };
place in RAM { readwrite };
place in BIM_LEDGER { ro section .bimLedger };
// CCFG
place at end of FLASH { readonly section .ccfg };
keep { section .ccfg };
////////////////////////////////////////////////////////////////////////////////
// Initialization
////////////////////////////////////////////////////////////////////////////////
initialize manually { section oadSelect };
initialize by copy { readwrite };
do not initialize
{
section .noinit,
section .stack,
};
////////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,230 @@
/*******************************************************************************
Filename: cc26xx_ble_stack.icf
Revised: $Date: 2014-03-24 07:09:35 -0700 (Mon, 24 Mar 2014) $
Revision: $Revision: 37847 $
Description: IAR ARM Linker Configuration File - BLE Stack
Note: Code stack and heap are allocated by the Application/RTOS build.
Imported Symbols
Note: Linker defines are located in the IAR IDE project using --config_def
in Options->Linker->Extra Options, or placed in Options->Linker->
Config->Configuration file symbol definitions.
CCxxxx: Device Name (e.g. CC2650).
FLASH_ONLY_BUILD: Build full BLE stack in flash only memory.
FLASH_ROM_BUILD: Build Flash portion of BLE stack to work with ROM code.
ROM_BUILD: Build ROM portion of BLE stack.
COMMON_ROM_BUILD: Build of common ROM code.
TEST_ROM_IN_FLASH: Build ROM code in Flash memory to test.
ICALL_STACK0_ADDR: Start address of flash only and flash ROM builds.
Exported Symbols
Note: Can be used as externs in C code.
ROM_BASE_ADDR: Location of start of ROM (where RT Init is expected).
RAM_BASE_ADDR: Location of start of RAM (for ICall and JT pointers).
COMMON_RAM_BASE_ADDR: Location of start of RAM (for ICall and JT pointers).
PAGE_SIZE: Size of Flash sector, in bytes.
NUM_SNV_PAGES: Number of sectors used for Simple NV.
Copyright 2013-2015 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
*******************************************************************************/
////////////////////////////////////////////////////////////////////////////////
// Memory Sizes
////////////////////////////////////////////////////////////////////////////////
define symbol RAM_SIZE = 0x00005000; // 20K
define symbol FLASH_SIZE = 0x00020000; // 128K
define symbol ROM_SIZE = 0x0001C000; // 115K
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Memory Definitions
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// RAM
//
define symbol RAM_START = 0x20000000;
if ( isdefinedsymbol(ICALL_RAM0_ADDR) )
{
define symbol RAM_END = (ICALL_RAM0_ADDR-1);
}
else // default
{
define symbol RAM_END = 0x200042FF;
}
////////////////////////////////////////////////////////////////////////////////
// Flash
//
// WARNING: Do not overwrite page 17 (address 0x11000) as it contains BIM's
// ledger page. Doing so will cause unexpected errors without warning!
if ( isdefinedsymbol(APP_IMAGE_START) )
{
define symbol FLASH_START = APP_IMAGE_START;
// Custom OAD Image sizes.
if ( isdefinedsymbol(APP_IMAGE_SIZE) )
{
define symbol IMAGE_SIZE = APP_IMAGE_SIZE;
}
else
{
if ( isdefinedsymbol(RTOS_ROM) )
{
// Default for RTOS in ROM build. This assumes that the application is
// also using some space on page 31 (0x1F).
define symbol IMAGE_SIZE = 0x5000;
}
else
{
// Default RTOS in Flash build. This is the maximum size for the larger
// OAD image, assuming Stack image starts at address 0xF000.
define symbol IMAGE_SIZE = 0x9000;
}
}
define symbol FLASH_END = APP_IMAGE_START + IMAGE_SIZE - 1;
}
else
{
if ( isdefinedsymbol(RTOS_ROM) )
{
// Default for Image A region, RTOS in ROM size.
define symbol FLASH_START = 0x1000;
define symbol FLASH_END = 0x7FFF;
// For cc13xx, the start of the image is claimed by the RTOS vectors.
// This is the first available slot.
define symbol INT_VEC_START = 0x1500;
}
else
{
// Default for Image B region, RTOS in Flash size.
define symbol FLASH_START = 0x00009000;
define symbol FLASH_END = FLASH_START + 0x7FFF;
define symbol INT_VEC_START = FLASH_START;
}
}
define symbol INT_VEC_SIZE = 64;
define symbol INT_VEC_END = INT_VEC_START + INT_VEC_SIZE - 1;
define symbol OAD_FLASH_START = INT_VEC_START + INT_VEC_SIZE;
////////////////////////////////////////////////////////////////////////////////
// Stack
//
define symbol STACK_SIZE = 0x400;
define symbol STACK_START = RAM_END + 1;
define symbol STACK_END = STACK_START - STACK_SIZE;
define block CSTACK with alignment = 8, size = STACK_SIZE { section .stack };
//
define symbol STACK_TOP = RAM_END + 1;
export symbol STACK_TOP;
////////////////////////////////////////////////////////////////////////////////
// Heap
//
define symbol HEAP_SIZE = 0x1000;
define block HEAP with alignment = 8, size = HEAP_SIZE { };
////////////////////////////////////////////////////////////////////////////////
// Flash Interrupt Vector Table
//
define symbol INTVEC_NUM_ENTRIES = 50 + 1; // first entry is stack location
define symbol INTVEC_SIZE = INTVEC_NUM_ENTRIES + 4;
////////////////////////////////////////////////////////////////////////////////
// Memory Regions
////////////////////////////////////////////////////////////////////////////////
define memory mem with size = 4G;
define region INT_VEC = mem:[from INT_VEC_START to INT_VEC_END];
define region FLASH = mem:[from OAD_FLASH_START to FLASH_END];
define region RAM = mem:[from RAM_START to RAM_END];
////////////////////////////////////////////////////////////////////////////////
// Memory Placement
// For ROM: C Runtime, Checksum, ROM Revision Number, Flash JT, and FPB.
////////////////////////////////////////////////////////////////////////////////
// Interrupt Vector Table
place at start of INT_VEC { readonly section .intvec };
keep { readonly section .intvec };
// RAM Vector Table
place at start of RAM { section .vtable_ram };
// Stack
place at end of RAM { block CSTACK };
// Heap
place in RAM { block HEAP };
place in FLASH { readonly };
place in RAM { readwrite };
////////////////////////////////////////////////////////////////////////////////
// Initialization
////////////////////////////////////////////////////////////////////////////////
initialize by copy { readwrite };
do not initialize
{
section .noinit,
section .stack,
};
////////////////////////////////////////////////////////////////////////////////
// The USE_TIRTOS_ROM symbol is defined internally in the build flow (using
// --config_def USE_TIRTOS_ROM=1) for TI-RTOS applications whose appBLE.cfg file
// specifies to use the ROM.
//
if (isdefinedsymbol(USE_TIRTOS_ROM)) {
include "TIRTOS_ROM.icf";
}

View File

@@ -0,0 +1,162 @@
/*******************************************************************************
Filename: cc26xx_ble_app.icf
Revised: $Date: 2014-03-25 14:18:47 -0700 (Tue, 25 Mar 2014) $
Revision: $Revision: 37873 $
Description: IAR ARM Linker Configuration File - BLE Application
Imported Symbols
Note: Linker defines are located in the IAR IDE project using --config_def
in Options->Linker->Extra Options.
CCxxxx: Device Name (e.g. CC2650)
Exported Symbols
Note: Can be used as externs in C code.
STACK_TOP: Location of the top of RAM.
Copyright 2013-2015 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
*******************************************************************************/
////////////////////////////////////////////////////////////////////////////////
// Memory Sizes
////////////////////////////////////////////////////////////////////////////////
define symbol RAM_SIZE = 0x00005000; // 20K
define symbol FLASH_SIZE = 0x00020000; // 128K
define symbol ROM_SIZE = 0x0001C000; // 115K
////////////////////////////////////////////////////////////////////////////////
// Memory Definitions
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// RAM
//
define symbol RAM_START = 0x20000000;
if ( isdefinedsymbol(ICALL_RAM0_ADDR) )
{
define symbol RAM_END = (ICALL_RAM0_ADDR-1);
}
else // Default
{
define symbol RAM_END = 0x200036FF;
}
////////////////////////////////////////////////////////////////////////////////
// Flash
//
// BIM is allocated Flash sector 0.
define symbol FLASH_START = 0x00000000;
define symbol FLASH_END = 0x0001FFFF;
// Start here to avoid the RTOS in ROM config area from 0x100 to 0x5FF
define symbol BIM_START = 0x0001F000;
////////////////////////////////////////////////////////////////////////////////
// Stack
//
define symbol STACK_SIZE = 0x400;
define symbol STACK_START = RAM_END + 1;
define symbol STACK_END = STACK_START - STACK_SIZE;
define block CSTACK with alignment = 8, size = STACK_SIZE { section .stack };
//
define symbol STACK_TOP = RAM_END + 1;
export symbol STACK_TOP;
////////////////////////////////////////////////////////////////////////////////
// Flash Interrupt Vector Table
//
define symbol INTVEC_NUM_ENTRIES = 50 + 1; // first entry is stack location
define symbol INTVEC_SIZE = INTVEC_NUM_ENTRIES + 4;
////////////////////////////////////////////////////////////////////////////////
// Memory Regions
////////////////////////////////////////////////////////////////////////////////
define memory mem with size = 4G;
define region RAM = mem:[from RAM_START to RAM_END];
define region FLASH = mem:[from FLASH_START to FLASH_END];
define region BIM = mem:[from BIM_START to FLASH_END];
////////////////////////////////////////////////////////////////////////////////
// Memory Placement
////////////////////////////////////////////////////////////////////////////////
if ( isdefinedsymbol(KEEP_INTVECS) )
{
// Interrupt Vector Table
place at address mem:FLASH_START { readonly section .intvec };
keep { readonly section .intvec };
// RAM Vector Table
place at start of RAM { section .vtable_ram };
}
// CCFG
place at end of FLASH { readonly section .ccfg };
keep { section .ccfg };
// Stack
place at end of RAM { block CSTACK };
// Flash
place at start of BIM { readonly section LoaderEntry };
keep { readonly section LoaderEntry };
place in BIM { readonly };
place in RAM { readwrite };
////////////////////////////////////////////////////////////////////////////////
// Initialization
////////////////////////////////////////////////////////////////////////////////
initialize manually { section oadSelect };
initialize by copy { readwrite };
do not initialize
{
section .noinit,
section .stack,
};
////////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,169 @@
/*******************************************************************************
Filename: cc26xx_ble_app.icf
Revised: $Date: 2014-03-25 14:18:47 -0700 (Tue, 25 Mar 2014) $
Revision: $Revision: 37873 $
Description: IAR ARM Linker Configuration File - BLE Application
Imported Symbols
Note: Linker defines are located in the IAR IDE project using --config_def
in Options->Linker->Extra Options.
CCxxxx: Device Name (e.g. CC2650)
Exported Symbols
Note: Can be used as externs in C code.
STACK_TOP: Location of the top of RAM.
Copyright 2013-2014 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
*******************************************************************************/
////////////////////////////////////////////////////////////////////////////////
// Memory Sizes
////////////////////////////////////////////////////////////////////////////////
define symbol RAM_SIZE = 0x00005000; // 20K
define symbol FLASH_SIZE = 0x00020000; // 128K
define symbol ROM_SIZE = 0x0001C000; // 115K
////////////////////////////////////////////////////////////////////////////////
// Memory Definitions
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// RAM
//
define symbol RAM_START = 0x20000000;
if ( isdefinedsymbol(ICALL_RAM0_ADDR) )
{
define symbol RAM_END = (ICALL_RAM0_ADDR-1);
}
else // default
{
define symbol RAM_END = 0x200027FF;
}
////////////////////////////////////////////////////////////////////////////////
// Flash
//
define symbol FLASH_START = 0x00000000;
if ( isdefinedsymbol(ICALL_STACK0_ADDR) )
{
define symbol FLASH_END = (ICALL_STACK0_ADDR-1);
}
else // default
{
define symbol FLASH_END = 0x00007FFF;
}
////////////////////////////////////////////////////////////////////////////////
// Stack
//
define symbol STACK_SIZE = 0x400;
define symbol STACK_START = RAM_END + 1;
define symbol STACK_END = STACK_START - STACK_SIZE;
define block CSTACK with alignment = 8, size = STACK_SIZE { section .stack };
//
define symbol STACK_TOP = RAM_END + 1;
export symbol STACK_TOP;
////////////////////////////////////////////////////////////////////////////////
// Heap
//
define symbol HEAP_SIZE = 0x1000;
define block HEAP with alignment = 8, size = HEAP_SIZE { };
////////////////////////////////////////////////////////////////////////////////
// Flash Interrupt Vector Table
//
define symbol INTVEC_NUM_ENTRIES = 50 + 1; // first entry is stack location
define symbol INTVEC_SIZE = INTVEC_NUM_ENTRIES + 4;
////////////////////////////////////////////////////////////////////////////////
// Memory Regions
////////////////////////////////////////////////////////////////////////////////
define memory mem with size = 4G;
define region RAM = mem:[from RAM_START to RAM_END];
define region FLASH_LAST_PAGE = mem:[from(FLASH_SIZE) - 0x1000 to FLASH_SIZE-1];
define region FLASH = mem:[from FLASH_START to FLASH_END]
| FLASH_LAST_PAGE;
////////////////////////////////////////////////////////////////////////////////
// Memory Placement
////////////////////////////////////////////////////////////////////////////////
// CCFG
place at end of FLASH_LAST_PAGE { readonly section .ccfg };
keep { section .ccfg };
// Interrupt Vector Table
place at address mem:FLASH_START { readonly section .intvec };
keep { readonly section .intvec };
// RAM Vector Table
place at start of RAM { section .vtable_ram };
// Stack
place at end of RAM { block CSTACK };
// Heap
place in RAM { block HEAP };
place in FLASH { readonly };
place in RAM { readwrite };
////////////////////////////////////////////////////////////////////////////////
// Initialization
////////////////////////////////////////////////////////////////////////////////
initialize by copy { readwrite };
do not initialize
{
section .noinit,
section .stack,
};
////////////////////////////////////////////////////////////////////////////////
// The USE_TIRTOS_ROM symbol is defined internally in the build flow (using
// --config_def USE_TIRTOS_ROM=1) for TI-RTOS applications whose appBLE.cfg file
// specifies to use the ROM.
//
if (isdefinedsymbol(USE_TIRTOS_ROM)) {
include "TIRTOS_ROM.icf";
}

View File

@@ -0,0 +1,260 @@
/*******************************************************************************
Filename: cc26xx_ble_stack.icf
Revised: $Date: 2014-03-24 07:09:35 -0700 (Mon, 24 Mar 2014) $
Revision: $Revision: 37847 $
Description: IAR ARM Linker Configuration File - BLE Stack
Note: Code stack and heap are allocated by the Application/RTOS build.
Imported Symbols
Note: Linker defines are located in the IAR IDE project using --config_def
in Options->Linker->Extra Options, or placed in Options->Linker->
Config->Configuration file symbol definitions.
CCxxxx: Device Name (e.g. CC2650).
FLASH_ONLY_BUILD: Build full BLE stack in flash only memory.
FLASH_ROM_BUILD: Build Flash portion of BLE stack to work with ROM code.
ROM_BUILD: Build ROM portion of BLE stack.
COMMON_ROM_BUILD: Build of common ROM code.
TEST_ROM_IN_FLASH: Build ROM code in Flash memory to test.
ICALL_STACK0_ADDR: Start address of flash only and flash ROM builds.
Exported Symbols
Note: Can be used as externs in C code.
ROM_BASE_ADDR: Location of start of ROM (where RT Init is expected).
RAM_BASE_ADDR: Location of start of RAM (for ICall and JT pointers).
COMMON_RAM_BASE_ADDR: Location of start of RAM (for ICall and JT pointers).
PAGE_SIZE: Size of Flash sector, in bytes.
NUM_SNV_PAGES: Number of sectors used for Simple NV.
Copyright 2013-2015 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
*******************************************************************************/
////////////////////////////////////////////////////////////////////////////////
// Memory Sizes
////////////////////////////////////////////////////////////////////////////////
define symbol RAM_SIZE = 0x00005000; // 20K
define symbol FLASH_SIZE = 0x00020000; // 128K
define symbol ROM_SIZE = 0x0001C000; // 115K
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Memory Definitions
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// RAM
//
define symbol RAM_START = 0x20000000;
if ( isdefinedsymbol(ICALL_RAM0_ADDR) )
{
define symbol RAM_END = (ICALL_RAM0_ADDR-1);
}
else // default
{
define symbol RAM_END = 0x200042FF;
}
////////////////////////////////////////////////////////////////////////////////
// Flash
//
if ( isdefinedsymbol(APP_IMAGE_START) )
{
define symbol FLASH_START = APP_IMAGE_START;
// For the External Flash use case, ICALL_STACK0_ADDR may be used to determine
// the end of the application's flash region
if ( isdefinedsymbol(ICALL_STACK0_ADDR) )
{
define symbol IMAGE_SIZE = ICALL_STACK0_ADDR - (FLASH_START) - 1;
}
// Custom OAD Image sizes.
else if ( isdefinedsymbol(APP_IMAGE_SIZE) )
{
define symbol IMAGE_SIZE = APP_IMAGE_SIZE;
}
else
{
if ( isdefinedsymbol(RTOS_ROM) )
{
// Default for RTOS in ROM build. This assumes that the application is
// also using some space on page 31 (0x1F).
define symbol IMAGE_SIZE = 0x5000;
}
else
{
// Default RTOS in Flash build. This is the maximum size for the larger
// OAD image, assuming Stack image starts at address 0xF000.
define symbol IMAGE_SIZE = 0x9000;
}
}
define symbol FLASH_END = APP_IMAGE_START + IMAGE_SIZE - 1;
}
else
{
if ( isdefinedsymbol(RTOS_ROM) )
{
// Default for OAD Image A region, RTOS in ROM size.
define symbol FLASH_START = 0x0600;
define symbol FLASH_END = 0x5FFF;
}
else
{
// Default for OAD Image B region, RTOS in Flash size.
define symbol FLASH_START = 0x00006000;
define symbol FLASH_END = FLASH_START + 0x8FFF;
}
}
// OAD specific
define symbol OAD_HDR_SIZE = 12; // linker needs word alignment.
define symbol OAD_HDR_START = FLASH_START + 4;
define symbol OAD_HDR_END = OAD_HDR_START + OAD_HDR_SIZE - 1;
define symbol INT_VEC_SIZE = 64;
define symbol INT_VEC_START = OAD_HDR_START + OAD_HDR_SIZE;
define symbol INT_VEC_END = INT_VEC_START + INT_VEC_SIZE - 1;
define symbol OAD_FLASH_START = INT_VEC_START + INT_VEC_SIZE;
////////////////////////////////////////////////////////////////////////////////
// Stack
//
define symbol STACK_SIZE = 0x400;
define symbol STACK_START = RAM_END + 1;
define symbol STACK_END = STACK_START - STACK_SIZE;
define block CSTACK with alignment = 8, size = STACK_SIZE { section .stack };
//
define symbol STACK_TOP = RAM_END + 1;
export symbol STACK_TOP;
////////////////////////////////////////////////////////////////////////////////
// Heap
//
define symbol HEAP_SIZE = 0x1000;
define block HEAP with alignment = 8, size = HEAP_SIZE { };
////////////////////////////////////////////////////////////////////////////////
// Flash Interrupt Vector Table
//
define symbol INTVEC_NUM_ENTRIES = 50 + 1; // first entry is stack location
define symbol INTVEC_SIZE = INTVEC_NUM_ENTRIES + 4;
////////////////////////////////////////////////////////////////////////////////
// Memory Regions
////////////////////////////////////////////////////////////////////////////////
define memory mem with size = 4G;
define region CHECKSUM = mem:[from FLASH_START to FLASH_START + 3];
define region FLASH_IMG_HDR = mem:[from OAD_HDR_START to OAD_HDR_END];
define region INT_VEC = mem:[from INT_VEC_START to INT_VEC_END];
// RTOS in ROM OAD image is fixed and can therefore use the extra space
// on page 31 (0x1F).
if ( isdefinedsymbol(RTOS_ROM) )
{
define region FLASH_LAST_PAGE = mem:[from(FLASH_SIZE) - 0xA00 to FLASH_SIZE-1];
define region FLASH = mem:[from OAD_FLASH_START to FLASH_END]
| FLASH_LAST_PAGE;
}
else
{
define region FLASH = mem:[from OAD_FLASH_START to FLASH_END];
}
define region RAM = mem:[from RAM_START to RAM_END];
////////////////////////////////////////////////////////////////////////////////
// Memory Placement
// For ROM: C Runtime, Checksum, ROM Revision Number, Flash JT, and FPB.
////////////////////////////////////////////////////////////////////////////////
place at start of CHECKSUM { ro section .checksum };
keep { ro section .checksum };
// Flash OAD Image Header
place at start of FLASH_IMG_HDR { readonly section IMAGE_HEADER };
keep { readonly section IMAGE_HEADER };
// CCA
if ( isdefinedsymbol(RTOS_ROM) )
{
place at end of FLASH_LAST_PAGE { readonly section .ccfg };
keep { section .ccfg};
}
// Interrupt Vector Table
place at start of INT_VEC { readonly section .intvec };
keep { readonly section .intvec };
// RAM Vector Table
place at start of RAM { section .vtable_ram };
// Stack
place at end of RAM { block CSTACK };
// Heap
place in RAM { block HEAP };
place in FLASH { readonly };
place in RAM { readwrite };
////////////////////////////////////////////////////////////////////////////////
// Initialization
////////////////////////////////////////////////////////////////////////////////
initialize by copy { readwrite };
do not initialize
{
section .noinit,
section .stack,
};
////////////////////////////////////////////////////////////////////////////////
// The USE_TIRTOS_ROM symbol is defined internally in the build flow (using
// --config_def USE_TIRTOS_ROM=1) for TI-RTOS applications whose appBLE.cfg file
// specifies to use the ROM.
//
if (isdefinedsymbol(USE_TIRTOS_ROM)) {
include "TIRTOS_ROM.icf";
}

View File

@@ -0,0 +1,240 @@
/*******************************************************************************
Filename: cc26xx_ble_stack.icf
Revised: $Date: 2014-03-24 07:09:35 -0700 (Mon, 24 Mar 2014) $
Revision: $Revision: 37847 $
Description: IAR ARM Linker Configuration File - BLE Stack
Note: Code stack and heap are allocated by the Application/RTOS build.
Imported Symbols
Note: Linker defines are located in the IAR IDE project using --config_def
in Options->Linker->Extra Options, or placed in Options->Linker->
Config->Configuration file symbol definitions.
CCxxxx: Device Name (e.g. CC2650).
FLASH_ONLY_BUILD: Build full BLE stack in flash only memory.
FLASH_ROM_BUILD: Build Flash portion of BLE stack to work with ROM code.
ROM_BUILD: Build ROM portion of BLE stack.
COMMON_ROM_BUILD: Build of common ROM code.
TEST_ROM_IN_FLASH: Build ROM code in Flash memory to test.
ICALL_STACK0_ADDR: Start address of flash only and flash ROM builds.
ICALL_RAM0_ADDR: Start address of RAM.
Exported Symbols
Note: Can be used as externs in C code.
ROM_BASE_ADDR: Location of start of ROM (where RT Init is expected).
RAM_BASE_ADDR: Location of start of RAM (for ICall and JT pointers).
COMMON_RAM_BASE_ADDR: Location of start of RAM (for ICall and JT pointers).
PAGE_SIZE: Size of Flash sector, in bytes.
NUM_SNV_PAGES: Number of sectors used for Simple NV.
Copyright 2013-2014 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
*******************************************************************************/
////////////////////////////////////////////////////////////////////////////////
// Memory Sizes
////////////////////////////////////////////////////////////////////////////////
// isdefinedsymbol(CC2650) <- Do not delete used by the Boundary tool file parser
// isdefinedsymbol(CC2640) <- Do not delete used by the Boundary tool file parser
define symbol RAM_SIZE = 0x00005000; // 20K
define symbol FLASH_SIZE = 0x00020000; // 128K
////////////////////////////////////////////////////////////////////////////////
// Memory Definitions
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// RAM
//
if ( isdefinedsymbol(FLASH_ONLY_BUILD) )
{
if ( isdefinedsymbol(ICALL_RAM0_ADDR) )
{
define symbol RAM_START = ICALL_RAM0_ADDR;
}
else // default
{
define symbol RAM_START = 0x20002D00;
}
if ( isdefinedsymbol(CC2650) )
{
define symbol RAM_END = 0x20004FFF;
}
else // default
{
define symbol RAM_END = 0x20003FFF;
}
}
else if ( isdefinedsymbol(ROM_BUILD) )
{
if ( isdefinedsymbol(CC2650) )
{
define symbol RAM_START = 0x200048E8;
define symbol RAM_END = 0x20004F2B;
}
else
{
define symbol RAM_START = 0x20003300;
define symbol RAM_END = 0x20003FFF;
}
define symbol RAM_BASE_ADDR = RAM_START;
export symbol RAM_BASE_ADDR;
}
else if ( isdefinedsymbol(FLASH_ROM_BUILD) )
{
if ( isdefinedsymbol(CC2650) )
{
if ( isdefinedsymbol(ICALL_RAM0_ADDR) )
{
define symbol RAM_START = ICALL_RAM0_ADDR;
}
else
{
define symbol RAM_START = 0x20002800;
}
define symbol RAM_END = 0x200048E7;
}
else
{
if ( isdefinedsymbol(ICALL_RAM0_ADDR) )
{
define symbol RAM_START = ICALL_RAM0_ADDR;
}
else
{
define symbol RAM_START = 0x20002D00;
}
define symbol RAM_END = 0x200031FF;
}
}
else // unknown build
{
define symbol RAM_START = 0xFFFFFFFF;
define symbol RAM_END = 0xFFFFFFFF;
}
////////////////////////////////////////////////////////////////////////////////
// Flash
//
define symbol PAGE_SIZE = 0x1000;
export symbol PAGE_SIZE;
define symbol NUM_RESERVED_PAGES = 1;
define symbol RESERVED_SIZE = (NUM_RESERVED_PAGES * PAGE_SIZE);
if ( isdefinedsymbol(FLASH_ONLY_BUILD) )
{
if ( isdefinedsymbol(ICALL_STACK0_ADDR) )
{
define symbol FLASH_START = ICALL_STACK0_ADDR;
}
else // default
{
define symbol FLASH_START = 0x00008000;
}
define symbol FLASH_END = FLASH_SIZE - RESERVED_SIZE - 1;
}
else if ( isdefinedsymbol(FLASH_ROM_BUILD) )
{
if ( isdefinedsymbol(ICALL_STACK0_ADDR) )
{
define symbol FLASH_START = ICALL_STACK0_ADDR;
}
else // default
{
define symbol FLASH_START = 0x00008000;
}
if ( isdefinedsymbol(TEST_ROM_IN_FLASH) )
{
define symbol FLASH_END = (ROM_START-1);
}
else // ROM code is in ROM memory
{
define symbol FLASH_END = FLASH_SIZE - RESERVED_SIZE - 1;
}
}
else // unknown build
{
define symbol FLASH_START = 0xFFFFFFFF;
define symbol FLASH_END = 0xFFFFFFFF;
}
//Entry section is set to the sector before SNV.
define symbol ENTRY_SECTION_START = ((FLASH_END + 1) - PAGE_SIZE * 2);
define symbol ENTRY_SECTION_END = (FLASH_END - PAGE_SIZE);
////////////////////////////////////////////////////////////////////////////////
// Memory Regions
////////////////////////////////////////////////////////////////////////////////
define memory mem with size = 4G;
define region FLASH = mem:[from FLASH_START to FLASH_END];
define region RAM = mem:[from RAM_START to RAM_END];
define region ENTRY_SECTION = mem:[from ENTRY_SECTION_START to ENTRY_SECTION_END];
////////////////////////////////////////////////////////////////////////////////
// Memory Placement
////////////////////////////////////////////////////////////////////////////////
// Flash Software Entry Point
////////////////////////////////////////////////////////////////////////////////
if ( isdefinedsymbol(FLASH_ONLY_BUILD) || isdefinedsymbol(FLASH_ROM_BUILD) )
{
place at start of FLASH { readonly section EntrySection };
// place at start of ENTRY_SECTION { readonly section EntrySection };
}
place at end of FLASH { ro section .snvSectors };
place in FLASH { readonly };
place in RAM { readwrite };
////////////////////////////////////////////////////////////////////////////////
// Initialization
////////////////////////////////////////////////////////////////////////////////
initialize by copy with packing = packbits { readwrite };
do not initialize
{
section .noinit,
section .stack,
};
////////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,170 @@
//*****************************************************************************
//! @file cc2650f128.icf
//! @brief CC2650F128 PG1 linker configuration file for IAR EWARM.
//!
//! Revised $Date: 2014-03-24 13:27:14 +0100 (ma, 24 mar 2014) $
//! Revision $Revision: 12556 $
//
// Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// Neither the name of Texas Instruments Incorporated nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//****************************************************************************/
place at address mem:0x00000538 {readonly section .const_xdc_runtime_IModule_Interface__BASE__C};
place at address mem:0x0000058c {readonly section .const_xdc_runtime_Error_policy__C};
place at address mem:0x0000051c {readonly section .const_xdc_runtime_Startup_lastFxns__C};
place at address mem:0x00000310 {readonly section .const_ti_sysbios_gates_GateMutex_Object__DESC__C};
place at address mem:0x000005ac {readonly section .const_ti_sysbios_rom_ROM_ti_sysbios_family_arm_cc26xx_Timer_initDevice__I};
place at address mem:0x0000054c {readonly section .const_xdc_runtime_Startup_execImpl__C};
place at address mem:0x000005cc {readonly section .const_ti_sysbios_gates_GateMutex_Instance_State_sem__O};
place at address mem:0x000005a8 {readonly section .const_ti_sysbios_rom_ROM_ti_sysbios_family_arm_cc26xx_Timer_getMaxTicks__E};
place at address mem:0x000004dc {readonly section .const_ti_sysbios_knl_Swi_Object__count__C};
place at address mem:0x00000478 {readonly section .const_ti_sysbios_knl_Idle_funcList__C};
place at address mem:0x00000170 {readonly section .const_ti_sysbios_family_arm_m3_Hwi_Object__PARAMS__C};
place at address mem:0x0000058a {readonly section .const_xdc_runtime_Text_isLoaded__C};
place at address mem:0x00000370 {readonly section .const_ti_sysbios_knl_Clock_Object__DESC__C};
place at address mem:0x00000480 {readonly section .const_ti_sysbios_family_arm_cc26xx_Boot_alternateBackdoorIOID__C};
place at address mem:0x000005d4 {readonly section .const_ti_sysbios_knl_Mailbox_Instance_State_dataQue__O};
place at address mem:0x00000240 {readonly section .const_ti_sysbios_gates_GateMutex_Module__FXNS__C};
place at address mem:0x000005e8 {readonly section .const_ti_sysbios_knl_Task_Module_State_inactiveQ__O};
place at address mem:0x00000506 {readonly section .const_ti_sysbios_family_arm_m3_Hwi_Module__id__C};
place at address mem:0x00000502 {readonly section .const_ti_sysbios_family_arm_cc26xx_Timer_Module__id__C};
place at address mem:0x000004d0 {readonly section .const_ti_sysbios_knl_Mailbox_Object__table__C};
place at address mem:0x00000498 {readonly section .const_ti_sysbios_family_arm_m3_Hwi_Object__table__C};
place at address mem:0x000003f0 {readonly section .const_ti_sysbios_knl_Swi_Object__DESC__C};
place at address mem:0x00000588 {readonly section .const_xdc_runtime_Text_charCnt__C};
place at address mem:0x000005b8 {readonly section .const_ti_sysbios_rom_ROM_ti_sysbios_family_arm_cc26xx_Timer_start__E};
place at address mem:0x000004c0 {readonly section .const_ti_sysbios_heaps_HeapMem_Object__table__C};
place at address mem:0x0000052c {readonly section .const_xdc_runtime_Error_policyFxn__C};
place at address mem:0x000005a0 {readonly section .const_ti_sysbios_rom_ROM_ti_sysbios_family_arm_cc26xx_Timer_getCount64__E};
place at address mem:0x00000514 {readonly section .const_xdc_runtime_Startup_firstFxns__C};
place at address mem:0x000001f4 {readonly section .const_ti_sysbios_knl_Swi_Object__PARAMS__C};
place at address mem:0x000004c8 {readonly section .const_ti_sysbios_knl_Clock_serviceMargin__C};
place at address mem:0x00000574 {readonly section .const_xdc_runtime_Text_charTab__C};
place at address mem:0x00000598 {readonly section .const_ti_sysbios_rom_ROM_AONRTCCurrentCompareValueGet};
place at address mem:0x000005bc {readonly section .const_ti_sysbios_rom_ROM_ti_sysbios_family_arm_cc26xx_TimestampProvider_get32__E};
place at address mem:0x000005a4 {readonly section .const_ti_sysbios_rom_ROM_ti_sysbios_family_arm_cc26xx_Timer_getCurrentTick__E};
place at address mem:0x000004b0 {readonly section .const_ti_sysbios_family_arm_m3_TaskSupport_stackAlignment__C};
place at address mem:0x00000490 {readonly section .const_ti_sysbios_family_arm_m3_Hwi_NUM_INTERRUPTS__C};
place at address mem:0x00000544 {readonly section .const_xdc_runtime_Main_Module__diagsMask__C};
place at address mem:0x000004e0 {readonly section .const_ti_sysbios_knl_Swi_Object__table__C};
place at address mem:0x00000500 {readonly section .const_ti_sysbios_family_arm_cc26xx_Boot_overrideDefaultBackdoorIOID__C};
place at address mem:0x00000586 {readonly section .const_xdc_runtime_Memory_Module__id__C};
place at address mem:0x00000100 {readonly section .const_ti_sysbios_knl_Task_Object__PARAMS__C};
place at address mem:0x00000448 {readonly section .const_ti_sysbios_gates_GateMutex_Object__PARAMS__C};
place at address mem:0x000004b8 {readonly section .const_ti_sysbios_heaps_HeapMem_Module__gateObj__C};
place at address mem:0x00000484 {readonly section .const_ti_sysbios_family_arm_cc26xx_Timer_startupNeeded__C};
place at address mem:0x000003b0 {readonly section .const_ti_sysbios_knl_Queue_Object__DESC__C};
place at address mem:0x00000410 {readonly section .const_ti_sysbios_knl_Task_Object__DESC__C};
place at address mem:0x00000524 {readonly section .const_xdc_runtime_Assert_E_assertFailed__C};
place at address mem:0x00000264 {readonly section .const_ti_sysbios_heaps_HeapMem_Object__PARAMS__C};
place at address mem:0x00000508 {readonly section .const_ti_sysbios_gates_GateHwi_Module__id__C};
place at address mem:0x00000430 {readonly section .const_ti_sysbios_gates_GateHwi_Object__PARAMS__C};
place at address mem:0x00000534 {readonly section .const_xdc_runtime_IHeap_Interface__BASE__C};
place at address mem:0x00000564 {readonly section .const_xdc_runtime_SysCallback_exitFxn__C};
place at address mem:0x0000050c {readonly section .const_ti_sysbios_heaps_HeapMem_Module__id__C};
place at address mem:0x000004a0 {readonly section .const_ti_sysbios_family_arm_m3_Hwi_excHandlerFunc__C};
place at address mem:0x000001cc {readonly section .const_ti_sysbios_heaps_HeapMem_Module__FXNS__C};
place at address mem:0x00000570 {readonly section .const_xdc_runtime_System_maxAtexitHandlers__C};
place at address mem:0x000004d4 {readonly section .const_ti_sysbios_knl_Queue_Object__count__C};
place at address mem:0x000004ec {readonly section .const_ti_sysbios_knl_Task_Object__table__C};
place at address mem:0x00000390 {readonly section .const_ti_sysbios_knl_Mailbox_Object__DESC__C};
place at address mem:0x000004a4 {readonly section .const_ti_sysbios_family_arm_m3_Hwi_nullIsrFunc__C};
place at address mem:0x00000510 {readonly section .const_ti_sysbios_knl_Clock_tickMode__C};
place at address mem:0x0000050a {readonly section .const_ti_sysbios_gates_GateMutex_Module__id__C};
place at address mem:0x000004e4 {readonly section .const_ti_sysbios_knl_Swi_numPriorities__C};
place at address mem:0x000004fc {readonly section .const_ti_sysbios_knl_Task_numConstructedTasks__C};
place at address mem:0x00000550 {readonly section .const_xdc_runtime_Startup_maxPasses__C};
place at address mem:0x0000059c {readonly section .const_ti_sysbios_rom_ROM_AONRTCEventClear};
place at address mem:0x0000050e {readonly section .const_ti_sysbios_knl_Task_initStackFlag__C};
place at address mem:0x0000053c {readonly section .const_xdc_runtime_Main_Module__diagsEnabled__C};
place at address mem:0x00000540 {readonly section .const_xdc_runtime_Main_Module__diagsIncluded__C};
place at address mem:0x00000568 {readonly section .const_xdc_runtime_System_abortFxn__C};
place at address mem:0x000005d8 {readonly section .const_ti_sysbios_knl_Mailbox_Instance_State_dataSem__O};
place at address mem:0x0000021c {readonly section .const_ti_sysbios_gates_GateHwi_Module__FXNS__C};
place at address mem:0x00000330 {readonly section .const_ti_sysbios_hal_Hwi_Object__DESC__C};
place at address mem:0x000004ac {readonly section .const_ti_sysbios_family_arm_m3_Hwi_priGroup__C};
place at address mem:0x00000528 {readonly section .const_xdc_runtime_Error_E_memory__C};
place at address mem:0x00000488 {readonly section .const_ti_sysbios_family_arm_m3_Hwi_E_alreadyDefined__C};
place at address mem:0x000005e0 {readonly section .const_ti_sysbios_knl_Mailbox_Instance_State_freeSem__O};
place at address mem:0x000004d8 {readonly section .const_ti_sysbios_knl_Queue_Object__table__C};
place at address mem:0x000002ac {readonly section .const_ti_sysbios_knl_Semaphore_Object__PARAMS__C};
place at address mem:0x0000056c {readonly section .const_xdc_runtime_System_exitFxn__C};
place at address mem:0x00000288 {readonly section .const_ti_sysbios_knl_Clock_Object__PARAMS__C};
place at address mem:0x00000594 {readonly section .const_ti_sysbios_rom_ROM_AONRTCCompareValueSet};
place at address mem:0x000005b0 {readonly section .const_ti_sysbios_rom_ROM_ti_sysbios_family_arm_cc26xx_Timer_setNextTick__E};
place at address mem:0x000004c4 {readonly section .const_ti_sysbios_heaps_HeapMem_reqAlign__C};
place at address mem:0x00000584 {readonly section .const_xdc_runtime_Main_Module__id__C};
place at address mem:0x00000554 {readonly section .const_xdc_runtime_Startup_sfxnRts__C};
place at address mem:0x000003d0 {readonly section .const_ti_sysbios_knl_Semaphore_Object__DESC__C};
place at address mem:0x000002f0 {readonly section .const_ti_sysbios_gates_GateHwi_Object__DESC__C};
place at address mem:0x000004bc {readonly section .const_ti_sysbios_heaps_HeapMem_Object__count__C};
place at address mem:0x000004a8 {readonly section .const_ti_sysbios_family_arm_m3_Hwi_numSparseInterrupts__C};
place at address mem:0x00000504 {readonly section .const_ti_sysbios_family_arm_cc26xx_TimestampProvider_useClockTimer__C};
place at address mem:0x000005c8 {readonly section .const_ti_sysbios_rom_ROM_xdc_runtime_System_SupportProxy_exit__E};
place at address mem:0x00000460 {readonly section .const_ti_sysbios_knl_Queue_Object__PARAMS__C};
place at address mem:0x000004f0 {readonly section .const_ti_sysbios_knl_Task_allBlockedFunc__C};
place at address mem:0x000005c4 {readonly section .const_ti_sysbios_rom_ROM_xdc_runtime_System_SupportProxy_abort__E};
place at address mem:0x000004cc {readonly section .const_ti_sysbios_knl_Mailbox_Object__count__C};
place at address mem:0x0000057c {readonly section .const_xdc_runtime_Text_nameStatic__C};
place at address mem:0x000005c0 {readonly section .const_ti_sysbios_rom_ROM_xdc_runtime_Startup_getState__I};
place at address mem:0x000005d0 {readonly section .const_ti_sysbios_knl_Clock_Module_State_clockQ__O};
place at address mem:0x000004f8 {readonly section .const_ti_sysbios_knl_Task_defaultStackSize__C};
place at address mem:0x00000530 {readonly section .const_xdc_runtime_IGateProvider_Interface__BASE__C};
place at address mem:0x0000048c {readonly section .const_ti_sysbios_family_arm_m3_Hwi_E_hwiLimitExceeded__C};
place at address mem:0x0000055c {readonly section .const_xdc_runtime_Startup_startModsFxn__C};
place at address mem:0x000005e4 {readonly section .const_ti_sysbios_knl_Semaphore_Instance_State_pendQ__O};
place at address mem:0x000002d0 {readonly section .const_ti_sysbios_family_arm_m3_Hwi_Object__DESC__C};
place at address mem:0x00000578 {readonly section .const_xdc_runtime_Text_nameEmpty__C};
place at address mem:0x00000494 {readonly section .const_ti_sysbios_family_arm_m3_Hwi_Object__count__C};
place at address mem:0x00000560 {readonly section .const_xdc_runtime_SysCallback_abortFxn__C};
place at address mem:0x000004f4 {readonly section .const_ti_sysbios_knl_Task_defaultStackHeap__C};
place at address mem:0x0000049c {readonly section .const_ti_sysbios_family_arm_m3_Hwi_ccr__C};
place at address mem:0x0000013c {readonly section .const_ti_sysbios_knl_Mailbox_Object__PARAMS__C};
place at address mem:0x000001a0 {readonly section .const_ti_sysbios_hal_Hwi_Object__PARAMS__C};
place at address mem:0x000004b4 {readonly section .const_ti_sysbios_heaps_HeapMem_E_memory__C};
place at address mem:0x000004e8 {readonly section .const_ti_sysbios_knl_Task_Object__count__C};
place at address mem:0x00000590 {readonly section .const_ti_sysbios_rom_ROM_AONRTCChannelEnable};
place at address mem:0x00000350 {readonly section .const_ti_sysbios_heaps_HeapMem_Object__DESC__C};
place at address mem:0x00000580 {readonly section .const_xdc_runtime_Text_nameUnknown__C};
place at address mem:0x00000548 {readonly section .const_xdc_runtime_Memory_defaultHeapInstance__C};
place at address mem:0x000005dc {readonly section .const_ti_sysbios_knl_Mailbox_Instance_State_freeQue__O};
place at address mem:0x000005b4 {readonly section .const_ti_sysbios_rom_ROM_ti_sysbios_family_arm_cc26xx_Timer_setThreshold__I};
place at address mem:0x00000558 {readonly section .const_xdc_runtime_Startup_sfxnTab__C};
place at address mem:0x20000178 {readwrite section .data_ti_sysbios_knl_Clock_Module__state__V};
place at address mem:0x200001ec {readwrite section .data_ti_sysbios_family_arm_cc26xx_TimestampProvider_Module__state__V};
place at address mem:0x200001f0 {readwrite section .data_xdc_runtime_Startup_Module__state__V};
place at address mem:0x200001a4 {readwrite section .data_ti_sysbios_BIOS_Module__state__V};
place at address mem:0x200001c8 {readwrite section .data_ti_sysbios_knl_Swi_Module__state__V};
place at address mem:0x20000100 {readwrite section .data_ti_sysbios_knl_Task_Module__state__V};
place at address mem:0x20000200 {readwrite section .data_xdc_runtime_Memory_Module__state__V};
place at address mem:0x200001f8 {readwrite section .data_xdc_runtime_System_Module__state__V};
place at address mem:0x20000144 {readwrite section .data_ti_sysbios_family_arm_m3_Hwi_Module__state__V};
place at address mem:0x200001e4 {readwrite section .data_ti_sysbios_family_arm_cc26xx_Timer_Module__state__V};

View File

@@ -0,0 +1,229 @@
/*******************************************************************************
Filename: startup.c
Revised: $Date: 2014-02-13 12:53:30 -0800 (Thu, 13 Feb 2014) $
Revision: $Revision: 37225 $
Description: Startup code for CC2650 for use with IAR.
Copyright 2014 - 2015 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
*******************************************************************************/
// Check if compiler is IAR
#if !(defined(__IAR_SYSTEMS_ICC__) || defined(__TI_COMPILER_VERSION__))
#error "startup.c: Unsupported compiler!"
#endif
/*******************************************************************************
* INCLUDES
*/
#include "hal_types.h"
#include <ICall.h>
#include <ICallAddrs.h>
#if defined( FLASH_ROM_BUILD )
#include "ROM_Init.h"
#include "CommonROM_Init.h"
#endif // FLASH_ROM_BUILD
/*******************************************************************************
* EXTERNS
*/
/*******************************************************************************
* PROTOTYPES
*/
/*******************************************************************************
* MACROS
*/
/*******************************************************************************
* CONSTANTS
*/
#define CRC16_POLYNOMIAL 0x1021
/*******************************************************************************
* TYPEDEFS
*/
/*******************************************************************************
* LOCAL VARIABLES
*/
/*******************************************************************************
* GLOBAL VARIABLES
*/
ICall_Dispatcher ICall_dispatcher;
ICall_EnterCS ICall_enterCriticalSection;
ICall_LeaveCS ICall_leaveCriticalSection;
/*******************************************************************************
* @fn checkCRC16
*
* @brief A simple implementation of the crc-16 checksum algorithm,
* courtesy of IAR (circa 2007).
*
* Note: If you use this function, you need to call it with an
* extra number of zero bytes equal to the size of the
* checksum (in this case 2), to "rotate out the answer".
*
* input parameters
*
* @param crc - The CRC value to start with.
* @param pAddr - Pointer to an array of bytes to run the CRC over.
* @param len - The number of bytes to process.
*
* output parameters
*
* @param None.
*
* @return CRC-16 result.
*/
uint16 slow_crc16( uint16 crc, uint8 *pAddr, uint32 len )
{
while (len--)
{
uint8 i;
uint8 byte = *(pAddr++);
for (i=0; i<8; ++i)
{
uint32 temp = crc;
crc <<= 1;
if ( byte & 0x80 )
{
crc |= 1;
}
if ( temp & 0x8000 )
{
crc ^= CRC16_POLYNOMIAL;
}
byte <<= 1;
}
}
return crc;
}
/*******************************************************************************
* @fn validChecksum
*
* @brief Check if the ROM checksum is valid.
*
* Note: This routine assumes the CRC directly follows the end
* address!
*
* input parameters
*
* @param None.
*
* output parameters
*
* @param None.
*
* @return TRUE=Valid Checksum; FALSE=Invalid Checksum.
*/
uint8 validChecksum( const uint32 *beginAddr, const uint32 *endAddr )
{
uint16 crc = 0;
uint16 romCRC = *((uint16 *)(((uint8 *)endAddr)+1));
uint8 zeros[2] = {0, 0};
// calculate the ROM checksum
crc = slow_crc16( crc,
(uint8 *)beginAddr,
(uint32)endAddr - (uint32)beginAddr + 1 );
// needed to rotate out the answer
crc = slow_crc16( crc, zeros, 2 );
// Compare the calculated checksum with the stored
return( (crc==romCRC)? TRUE : FALSE );
}
/*******************************************************************************
* @fn startup_entry
*
* @brief This is the BLE stack entry point.
*
* input parameters
*
* @param arg0 argument containing remote dispatch function pointers
* @param arg1 custom initialization parameter
*
* output parameters
*
* @param None.
*
* @return None.
*/
#ifdef __TI_COMPILER_VERSION__
#pragma CODE_SECTION(startup_entry,"EntrySection")
#elif defined(__IAR_SYSTEMS_ICC__)
#pragma location="EntrySection"
#endif
void startup_entry( const ICall_RemoteTaskArg *arg0, void *arg1 )
{
extern int stack_main( void *arg );
#if defined(__IAR_SYSTEMS_ICC__)
extern void __iar_data_init3(void);
__iar_data_init3();
#elif defined(__TI_COMPILER_VERSION__)
extern void __TI_auto_init(void);
__TI_auto_init();
#else
#error "Error: Must specify a compiler!"
#endif
ICall_dispatcher = arg0->dispatch;
ICall_enterCriticalSection = arg0->entercs;
ICall_leaveCriticalSection = arg0->leavecs;
#if defined( FLASH_ROM_BUILD )
// initialize the Common ROM
CommonROM_Init();
// initialize the BLE Controller ROM
ROM_Init();
#endif // FLASH_ROM_BUILD
stack_main( arg1 );
}

View File

@@ -0,0 +1,314 @@
/**************************************************************************************************
Filename: OnBoard.c
Revised: $Date: 2008-03-14 11:04:28 -0700 (Fri, 14 Mar 2008) $
Revision: $Revision: 16589 $
Description: This file contains the UI and control for the
peripherals on the EVAL development board
Notes: This file targets the Chipcon MSP430xxx
Copyright 2005 - 2015 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
**************************************************************************************************/
/*********************************************************************
* INCLUDES
*/
#include "bcomdef.h"
#include "OnBoard.h"
#include "OSAL.h"
#include "hal_board_cfg.h"
#include "hal_key.h"
/*********************************************************************
* MACROS
*/
/*********************************************************************
* CONSTANTS
*/
// Task ID not initialized
#define NO_TASK_ID 0xFF
/*********************************************************************
* TYPEDEFS
*/
/*********************************************************************
* GLOBAL VARIABLES
*/
/* Initialize Key stuff */
uint8 OnboardKeyIntEnable = HAL_KEY_MODE;
/*********************************************************************
* LOCAL VARIABLES
*/
// Registered keys task ID, initialized to NOT USED.
static uint8 registeredKeysTaskID = NO_TASK_ID;
/*********************************************************************
* EXTERNAL VARIABLES
*/
/*********************************************************************
* EXTERNAL FUNCTIONS
*/
extern uint8 LL_PseudoRand( uint8 *, uint8 );
#if defined FEATURE_ABL
#include "..\..\util\ABL\app\sbl_app.c"
#elif defined FEATURE_SBL
#include "..\..\util\SBL\app\sbl_app.c"
#elif defined FEATURE_EBL
#include "..\..\util\EBL\app\sbl_app.c"
#elif defined FEATURE_UBL_MSD
#include "..\..\util\UBL\soc_8051\usb_msd\app\ubl_app.c"
#else
void appForceBoot(void);
#endif
/*********************************************************************
* @fn InitBoard
*
* @brief Initialize CC26xx board and HAL.
*
* @param None
*
* @return None
*
*********************************************************************/
void InitBoard()
{
// Enable or Disable HAL Key Interrupts.
OnboardKeyIntEnable = HAL_KEY_MODE;
// Configure HAL Keys
#if (defined HAL_KEY) && (HAL_KEY == TRUE)
HalKeyConfig( OnboardKeyIntEnable, OnBoard_KeyCallback);
#endif // (defined HAL_KEY) && (HAL_KEY == TRUE)
}
/*********************************************************************
* @fn Onboard_rand
*
* @brief Random number generator
*
* @param none
*
* @return uint16 - new random number
*
*********************************************************************/
uint16 Onboard_rand( void )
{
uint16 randNum;
LL_PseudoRand( (uint8 *)&randNum, 2 );
return ( randNum );
}
/*********************************************************************
* @fn _itoa
*
* @brief convert a 16bit number to ASCII
*
* @param num -
* buf -
* radix -
*
* @return void
*
*********************************************************************/
void _itoa(uint16 num, uint8 *buf, uint8 radix)
{
char c,i;
uint8 *p, rst[5];
p = rst;
for ( i=0; i<5; i++,p++ )
{
c = num % radix; // Isolate a digit
*p = c + (( c < 10 ) ? '0' : '7'); // Convert to Ascii
num /= radix;
if ( !num )
break;
}
for ( c=0 ; c<=i; c++ )
*buf++ = *p--; // Reverse character order
*buf = '\0';
}
/*********************************************************************
* @fn Onboard_soft_reset
*
* @brief Effect a soft reset.
*
* @param none
*
* @return none
*
*********************************************************************/
void Onboard_soft_reset( void )
{
}
/*********************************************************************
* @fn appForceBoot
*
* @brief Common force-boot function for the HCI library to invoke.
*
* @param none
*
* @return void
*********************************************************************/
void appForceBoot( void )
{
// Dummy function for HCI library that cannot depend on the SBL build defines.
}
/*********************************************************************
* "Keyboard" Support
*********************************************************************/
/*********************************************************************
* Keyboard Register function
*
* The keyboard handler is setup to send all keyboard changes to
* one task (if a task is registered).
*
* If a task registers, it will get all the keys. You can change this
* to register for individual keys.
*********************************************************************/
uint8 RegisterForKeys( uint8 task_id )
{
// Allow only the first task
if ( registeredKeysTaskID == NO_TASK_ID )
{
registeredKeysTaskID = task_id;
return ( true );
}
else
return ( false );
}
/*********************************************************************
* @fn OnBoard_KeyCallback
*
* @brief Callback service for keys
*
* @param keys - keys that were pressed
* state - shifted
*
* @return void
*********************************************************************/
void OnBoard_KeyCallback ( uint8 keys, uint8 state )
{
uint8 shift;
(void)state;
// shift key (S1) is used to generate key interrupt
// applications should not use S1 when key interrupt is enabled
shift = (OnboardKeyIntEnable == BSP_KEY_MODE_ISR) ? false : ((keys & HAL_KEY_SW_6) ? true : false);
//TODO is this necessary?
if ( OnBoard_SendKeys( keys, shift ) != SUCCESS )
{
// Process SW1 here
if ( keys & HAL_KEY_SW_1 ) // Switch 1
{
}
// Process SW2 here
if ( keys & HAL_KEY_SW_2 ) // Switch 2
{
}
// Process SW3 here
if ( keys & HAL_KEY_SW_3 ) // Switch 3
{
}
// Process SW4 here
if ( keys & HAL_KEY_SW_4 ) // Switch 4
{
}
// Process SW5 here
if ( keys & HAL_KEY_SW_5 ) // Switch 5
{
}
// Process SW6 here
if ( keys & HAL_KEY_SW_6 ) // Switch 6
{
}
}
}
/*********************************************************************
* @fn OnBoard_SendKeys
*
* @brief Send "Key Pressed" message to application.
*
* @param keys - keys that were pressed
* state - shifted
*
* @return status
*********************************************************************/
uint8 OnBoard_SendKeys( uint8 keys, uint8 state )
{
keyChange_t *msgPtr;
if ( registeredKeysTaskID != NO_TASK_ID )
{
// Send the address to the task
msgPtr = (keyChange_t *)osal_msg_allocate( sizeof(keyChange_t) );
if ( msgPtr )
{
msgPtr->hdr.event = KEY_CHANGE;
msgPtr->state = state;
msgPtr->keys = keys;
osal_msg_send( registeredKeysTaskID, (uint8 *)msgPtr );
}
return ( SUCCESS );
}
else
return ( FAILURE );
}
/*********************************************************************
*********************************************************************/

View File

@@ -0,0 +1,151 @@
/**************************************************************************************************
Filename: OnBoard.h
Revised: $Date: 2008-07-25 17:36:14 -0700 (Fri, 25 Jul 2008) $
Revision: $Revision: 17620 $
Description: Defines constants and prototypes for Evaluation boards
This file targets the Texas Instruments CC26xx Device Family.
Copyright 2006 - 2015 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
**************************************************************************************************/
#ifndef ONBOARD_H
#define ONBOARD_H
#include "hal_mcu.h"
#include "hal_sleep.h"
#include "osal.h"
/*********************************************************************
*/
// Internal (MCU) RAM addresses
//#define MCU_RAM_BEG 0x1100
//#define MCU_RAM_END 0x20FF
#define MCU_RAM_BEG 0x20000000
#define MCU_RAM_END 0x20004000
#define MCU_RAM_LEN (MCU_RAM_END - MCU_RAM_BEG + 1)
// Internal (MCU) heap size
#if !defined( INT_HEAP_LEN )
#define INT_HEAP_LEN 4096 //1024 // 1.00K
#endif
// Memory Allocation Heap
#define MAXMEMHEAP INT_HEAP_LEN // Typically, 0.70-1.50K
/* OSAL timer defines */
#define TICK_TIME 1000 // Timer per tick - in micro-sec
// Timer clock and power-saving definitions
#define TICK_COUNT 1 // TIMAC requires this number to be 1
#ifndef _WIN32
extern void _itoa(uint16 num, uint8 *buf, uint8 radix);
#endif
/* Tx and Rx buffer size defines used by SPIMgr.c */
#define MT_UART_THRESHOLD 5
#define MT_UART_TX_BUFF_MAX 170
#define MT_UART_RX_BUFF_MAX 120
#define MT_UART_IDLE_TIMEOUT 5
/* system restart and boot loader used from MTEL.c */
#define SystemReset() HAL_SYSTEM_RESET();
#define SystemResetSoft() Onboard_soft_reset();
#define BootLoader() // Not yet implemented for MSP430
/* Reset reason for reset indication */
#define ResetReason() (0)
/* port definition stuff used by MT */
#if defined (ZAPP_P1)
#define ZAPP_PORT HAL_UART_PORT_0 //SERIAL_PORT1
#elif defined (ZAPP_P2)
#define ZAPP_PORT HAL_UART_PORT_1 //SERIAL_PORT2
#else
#undef ZAPP_PORT
#endif
#if defined (ZTOOL_P1)
#define ZTOOL_PORT HAL_UART_PORT_0 //SERIAL_PORT1
#elif defined (ZTOOL_P2)
#define ZTOOL_PORT HAL_UART_PORT_1 //SERIAL_PORT2
#else
#undef ZTOOL_PORT
#endif
// Power conservation
#define OSAL_SET_CPU_INTO_SLEEP(timeout) halSleep(timeout); /* Called from OSAL_PwrMgr */
typedef struct
{
osal_event_hdr_t hdr;
uint8 state; // shift
uint8 keys; // keys
} keyChange_t;
/*
* Used to Initialize HAL setting in *_Main
*/
void InitBoard( void );
/* used by MTEL.c */
uint8 OnBoard_SendKeys( uint8 keys, uint8 state );
/*
* Board specific random number generator
*/
extern uint16 Onboard_rand( void );
/*
* Get elapsed timer clock counts
*/
extern uint32 TimerElapsed( void );
/*
* Perform a soft reset - jump to 0x0
*/
extern void Onboard_soft_reset( void );
/*
* Register for all key events
*/
extern uint8 RegisterForKeys( uint8 task_id );
/*
* Callback routine to handle keys
*/
extern void OnBoard_KeyCallback ( uint8 keys, uint8 state );
/*********************************************************************
*/
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,399 @@
/**************************************************************************************************
Filename: UTC_clock.c
Revised: $Date: 2015-07-22 10:45:09 -0700 (Wed, 22 Jul 2015) $
Revision: $Revision: 44392 $
Description: This file contains the UTC clock definitions for use by
Application threads.
Copyright 2011 - 2015 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
**************************************************************************************************/
/*********************************************************************
* INCLUDES
*/
#include "comdef.h"
#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <ti/sysbios/knl/Queue.h>
#include <ICall.h>
#include "util.h"
#include "UTC_clock.h"
/*********************************************************************
* MACROS
*/
#define YearLength(yr) (IsLeapYear(yr) ? 366 : 365)
/*********************************************************************
* CONSTANTS
*/
// Update every 1000ms
#define UTC_UPDATE_PERIOD 1000
#define IsLeapYear(yr) (!((yr) % 400) || (((yr) % 100) && !((yr) % 4)))
#define BEGYEAR 2000 // UTC started at 00:00:00 January 1, 2000
#define DAY 86400UL // 24 hours * 60 minutes * 60 seconds
/*********************************************************************
* TYPEDEFS
*/
/*********************************************************************
* GLOBAL VARIABLES
*/
/*********************************************************************
* EXTERNAL VARIABLES
*/
/*********************************************************************
* EXTERNAL FUNCTIONS
*/
/*********************************************************************
* LOCAL VARIABLES
*/
// Clock instance used to update UTC clock.
Clock_Struct UTC_clock;
// Time is the number of seconds since 0 hrs, 0 minutes, 0 seconds, on the
// 1st of January 2000 UTC.
UTCTime UTC_timeSeconds = 0;
/*********************************************************************
* LOCAL FUNCTION PROTOTYPES
*/
static uint8_t UTC_monthLength(uint8_t lpyr, uint8_t mon);
static void UTC_clockUpdate(uint32_t elapsedMSec);
static void UTC_timeUpdateHandler(UArg a0);
/*********************************************************************
* FUNCTIONS
*********************************************************************/
/*********************************************************************
* @fn UTC_init
*
* @brief Initialize the UTC clock module. Sets up and starts the
* clock instance.
*
* @param None.
*
* @return None.
*/
void UTC_init(void)
{
// Construct a periodic clock with a 1000ms duration and period to start
// immediately.
Util_constructClock(&UTC_clock, UTC_timeUpdateHandler, UTC_UPDATE_PERIOD,
UTC_UPDATE_PERIOD, true, 0);
}
/*********************************************************************
* @fn UTC_timeUpdateHandler
*
* @brief Expiration callback for UTC clock instance.
* Each time this is called the internal counter is updated
*
*
* @param None.
*
* @return None.
*/
void UTC_timeUpdateHandler(UArg a0)
{
static uint32_t prevClockTicks = 0;
static uint16_t remUsTicks = 0;
uint32_t clockTicks, elapsedClockTicks;
uint32_t elapsedMSec = 0;
// Get the running count of clock ticks.
clockTicks = Clock_getTicks();
// Check that time has passed.
if (clockTicks != prevClockTicks)
{
// To make sure time has passed and that a negative difference is not
// calculated, check if the tick count is greater than the previous
// measurement's.
if (clockTicks > prevClockTicks)
{
// Get the elapsed clock ticks.
elapsedClockTicks = clockTicks - prevClockTicks;
}
// Else tick count rolled over.
else
{
// Get the elapsed clock ticks, accounting for the roll over.
elapsedClockTicks = (0xFFFFFFFF - prevClockTicks) + clockTicks + 1;
}
// Convert to milliseconds.
elapsedMSec = (elapsedClockTicks * Clock_tickPeriod) / 1000;
// Find remainder.
remUsTicks += (elapsedClockTicks * Clock_tickPeriod) % 1000;
// If the running total of remaining microseconds is greater than or equal
// to one millisecond.
if (remUsTicks >= 1000)
{
// Add in the extra millisecond.
// Note: the remainder has an open upper limit of 2 milliseconds.
elapsedMSec += 1;
// Adjust the remainder.
remUsTicks %= 1000;
}
}
// If time has passed
if (elapsedMSec)
{
// Store the tick count for the next iteration through this function.
prevClockTicks = clockTicks;
// Update the UTC Clock.
UTC_clockUpdate(elapsedMSec);
}
}
/*********************************************************************
* @fn UTC_clockUpdate
*
* @brief Updates the UTC Clock time with elapsed milliseconds.
*
* @param elapsedMSec - elapsed milliseconds
*
* @return none
*/
static void UTC_clockUpdate(uint32_t elapsedMSec)
{
static uint32_t timeMSec = 0;
// Add elapsed milliseconds to the saved millisecond portion of time.
timeMSec += elapsedMSec;
// Roll up milliseconds to the number of seconds.
if (timeMSec >= 1000)
{
UTC_timeSeconds += timeMSec / 1000;
timeMSec = timeMSec % 1000;
}
}
/*********************************************************************
* @fn UTC_setClock
*
* @brief Set a new time. This will only set the seconds portion
* of time and doesn't change the factional second counter.
*
* @param newTime - Number of seconds since 0 hrs, 0 minutes,
* 0 seconds, on the 1st of January 2000 UTC.
*
* @return none
*/
void UTC_setClock(UTCTime newTime)
{
UTC_timeSeconds = newTime;
}
/*********************************************************************
* @fn UTC_getClock
*
* @brief Gets the current time. This will only return the seconds
* portion of time and doesn't include the factional second
* counter.
*
* @param none
*
* @return number of seconds since 0 hrs, 0 minutes, 0 seconds,
* on the 1st of January 2000 UTC
*/
UTCTime UTC_getClock(void)
{
return (UTC_timeSeconds);
}
/*********************************************************************
* @fn UTC_convertUTCTime
*
* @brief Converts UTCTime to UTCTimeStruct (from total seconds to exact
* date).
*
* @param tm - pointer to breakdown struct.
*
* @param secTime - number of seconds since 0 hrs, 0 minutes,
* 0 seconds, on the 1st of January 2000 UTC.
*
* @return none
*/
void UTC_convertUTCTime(UTCTimeStruct *tm, UTCTime secTime)
{
// Calculate the time less than a day - hours, minutes, seconds.
{
// The number of seconds that have occured so far stoday.
uint32_t day = secTime % DAY;
// Seconds that have passed in the current minute.
tm->seconds = day % 60UL;
// Minutes that have passed in the current hour.
// (seconds per day) / (seconds per minute) = (minutes on an hour boundary)
tm->minutes = (day % 3600UL) / 60UL;
// Hours that have passed in the current day.
tm->hour = day / 3600UL;
}
// Fill in the calendar - day, month, year
{
uint16_t numDays = secTime / DAY;
uint8_t monthLen;
tm->year = BEGYEAR;
while (numDays >= YearLength(tm->year))
{
numDays -= YearLength(tm->year);
tm->year++;
}
// January.
tm->month = 0;
monthLen = UTC_monthLength(IsLeapYear(tm->year), tm->month);
// Determine the number of months which have passed from remaining days.
while (numDays >= monthLen)
{
// Subtract number of days in month from remaining count of days.
numDays -= monthLen;
tm->month++;
// Recalculate month length.
monthLen = UTC_monthLength(IsLeapYear(tm->year), tm->month);
}
// Store the remaining days.
tm->day = numDays;
}
}
/*********************************************************************
* @fn UTC_monthLength
*
* @param lpyr - 1 for leap year, 0 if not
*
* @param mon - 0 - 11 (jan - dec)
*
* @return number of days in specified month
*/
static uint8_t UTC_monthLength(uint8_t lpyr, uint8_t mon)
{
uint8_t days = 31;
if (mon == 1) // feb
{
days = (28 + lpyr);
}
else
{
if (mon > 6) // aug-dec
{
mon--;
}
if (mon & 1)
{
days = 30;
}
}
return (days);
}
/*********************************************************************
* @fn UTC_convertUTCSecs
*
* @brief Converts a UTCTimeStruct to UTCTime (from exact date to total
* seconds).
*
* @param tm - pointer to provided struct.
*
* @return number of seconds since 00:00:00 on 01/01/2000 (UTC).
*/
UTCTime UTC_convertUTCSecs(UTCTimeStruct *tm)
{
uint32_t seconds;
// Seconds for the partial day.
seconds = (((tm->hour * 60UL) + tm->minutes) * 60UL) + tm->seconds;
// Account for previous complete days.
{
// Start with complete days in current month.
uint16_t days = tm->day;
// Next, complete months in current year.
{
int8 month = tm->month;
while (--month >= 0)
{
days += UTC_monthLength(IsLeapYear(tm->year), month);
}
}
// Next, complete years before current year.
{
uint16_t year = tm->year;
while (--year >= BEGYEAR)
{
days += YearLength(year);
}
}
// Add total seconds before partial day.
seconds += (days * DAY);
}
return (seconds);
}

View File

@@ -0,0 +1,138 @@
/******************************************************************************
Filename: UTC_Clock.h
Revised: $Date: 2015-07-22 10:45:09 -0700 (Wed, 22 Jul 2015) $
Revision: $Revision: 44392 $
Description: UTC Clock types and functions prototypes.
Copyright 2004 - 2015 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
******************************************************************************/
#ifndef UTC_CLOCK_H
#define UTC_CLOCK_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
* INCLUDES
*/
/*********************************************************************
* MACROS
*/
/*********************************************************************
* CONSTANTS
*/
/*********************************************************************
* TYPEDEFS
*/
// number of seconds since 0 hrs, 0 minutes, 0 seconds, on the
// 1st of January 2000 UTC
typedef uint32_t UTCTime;
// UTC time structs broken down until standard components.
typedef struct
{
uint8_t seconds; // 0-59
uint8_t minutes; // 0-59
uint8_t hour; // 0-23
uint8_t day; // 0-30
uint8_t month; // 0-11
uint16_t year; // 2000+
} UTCTimeStruct;
/*********************************************************************
* GLOBAL VARIABLES
*/
/*********************************************************************
* FUNCTIONS
*/
/*
* @fn UTC_init
*
* @brief Initialize the UTC clock module. Sets up and starts the
* clock instance.
*
* @param None.
*
* @return None.
*/
extern void UTC_init(void);
/*
* Set the new time. This will only set the seconds portion
* of time and doesn't change the factional second counter.
* newTime - number of seconds since 0 hrs, 0 minutes,
* 0 seconds, on the 1st of January 2000 UTC
*/
extern void UTC_setClock( UTCTime newTime );
/*
* Gets the current time. This will only return the seconds
* portion of time and doesn't include the factional second counter.
* returns: number of seconds since 0 hrs, 0 minutes,
* 0 seconds, on the 1st of January 2000 UTC
*/
extern UTCTime UTC_getClock( void );
/*
* Converts UTCTime to UTCTimeStruct
*
* secTime - number of seconds since 0 hrs, 0 minutes,
* 0 seconds, on the 1st of January 2000 UTC
* tm - pointer to breakdown struct
*/
extern void UTC_convertUTCTime( UTCTimeStruct *tm, UTCTime secTime );
/*
* Converts UTCTimeStruct to UTCTime (seconds since 00:00:00 01/01/2000)
*
* tm - pointer to UTC time struct
*/
extern UTCTime UTC_convertUTCSecs( UTCTimeStruct *tm );
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* UTC_CLOCK_H */

View File

@@ -0,0 +1,196 @@
/**************************************************************************************************
Filename: bletime.h
Revised: $Date: 2015-06-17 11:11:08 -0700 (Wed, 17 Jun 2015) $
Revision: $Revision: 44123 $
Description: This file contains GATT service discovery and
configuration definitions and prototypes for discovering
Time services.
Copyright 2014 - 2015 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
**************************************************************************************************/
#ifndef BLETIME_H
#define BLETIME_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
* INCLUDES
*/
/*********************************************************************
* CONSTANTS
*/
// Time discovery states
enum
{
DISC_IDLE = 0x00, // Idle state
DISC_CURR_TIME_START = 0x10, // Current time service
DISC_CURR_TIME_SVC, // Discover service
DISC_CURR_TIME_CHAR, // Discover all characteristics
DISC_CURR_TIME_CT_TIME_CCCD, // Discover CT time CCCD
DISC_DST_CHG_START = 0x20, // DST change service
DISC_DST_CHG_SVC, // Discover service
DISC_DST_CHG_CHAR, // Discover all characteristics
DISC_REF_TIME_START = 0x30, // Reference time service
DISC_REF_TIME_SVC, // Discover service
DISC_REF_TIME_CHAR, // Discover all characteristics
DISC_NWA_START = 0x40, // NwA service
DISC_NWA_SVC, // Discover service
DISC_NWA_CHAR, // Discover all characteristics
DISC_NWA_NWA_CCCD, // Discover NwA CCCD
DISC_ALERT_NTF_START = 0x50, // Alert notification service
DISC_ALERT_NTF_SVC, // Discover service
DISC_ALERT_NTF_CHAR, // Discover all characteristics
DISC_ALERT_NTF_NEW_CCCD, // Discover new alert CCCD
DISC_ALERT_NTF_UNREAD_CCCD, // Discover unread alert status CCCD
DISC_BATT_START = 0x60, // Battery service
DISC_BATT_SVC, // Discover service
DISC_BATT_CHAR, // Discover all characteristics
DISC_BATT_LVL_CCCD, // Discover battery level CCCD
DISC_PAS_START = 0x70, // Phone alert status service
DISC_PAS_SVC, // Discover service
DISC_PAS_CHAR, // Discover all characteristics
DISC_PAS_ALERT_CCCD, // Discover alert status CCCD
DISC_PAS_RINGER_CCCD, // Discover ringer setting CCCD
DISC_FAILED = 0xFF // Discovery failed
};
// Time handle cache indexes
enum
{
HDL_CURR_TIME_CT_TIME_START, // Current time start handle
HDL_CURR_TIME_CT_TIME_END, // Current time end handle
HDL_CURR_TIME_CT_TIME_CCCD, // Current time CCCD
HDL_CURR_TIME_LOC_INFO, // Local time info
HDL_CURR_TIME_REF_INFO, // Reference time info
HDL_DST_CHG_TIME_DST, // Time with DST
HDL_REF_TIME_UPD_CTRL, // Time update control point
HDL_REF_TIME_UPD_STATE, // Time update state
HDL_NWA_NWA_START, // NwA start handle
HDL_NWA_NWA_END, // NwA end handle
HDL_NWA_NWA_CCCD, // NwA CCCD
HDL_ALERT_NTF_NEW_START, // New alert start handle
HDL_ALERT_NTF_NEW_END, // New alert end handle
HDL_ALERT_NTF_UNREAD_START, // Unread alert status start handle
HDL_ALERT_NTF_UNREAD_END, // Unread alert status end handle
HDL_ALERT_NTF_CTRL, // Alert notification control point
HDL_ALERT_NTF_NEW_CAT, // Supported New Alert Category
HDL_ALERT_NTF_UNREAD_CAT, // Supported Unread Alert Category
HDL_ALERT_NTF_NEW_CCCD, // New alert CCCD
HDL_ALERT_NTF_UNREAD_CCCD, // Alert unread alert status CCCD
HDL_BATT_LEVEL_START, // Battery level start handle
HDL_BATT_LEVEL_END, // Battery level end handle
HDL_BATT_LEVEL_CCCD, // Battery level CCCD
HDL_PAS_ALERT_START, // Alert status start handle
HDL_PAS_ALERT_END, // Alert status end handle
HDL_PAS_RINGER_START, // Ringer setting start handle
HDL_PAS_RINGER_END, // Ringer setting end handle
HDL_PAS_CTRL, // Ringer control point
HDL_PAS_ALERT_CCCD, // Alert status CCCD
HDL_PAS_RINGER_CCCD, // Ringer setting CCCD
HDL_CACHE_LEN
};
// Configuration states
#define TIME_CONFIG_START 0x00
#define TIME_CONFIG_CMPL 0xFF
/*********************************************************************
* TYPEDEFS
*/
/*********************************************************************
* MACROS
*/
/*********************************************************************
* GLOBAL
*/
// Connection handle
extern uint16_t Time_connHandle;
// Handle cache
extern uint16_t Time_handleCache[HDL_CACHE_LEN];
// Task ID
extern uint8_t Time_configDone;
/*********************************************************************
* FUNCTIONS
*/
/*
* Time service discovery functions.
*/
extern uint8_t Time_discStart(void);
extern uint8_t Time_discGattMsg(uint8_t state, gattMsgEvent_t *pMsg);
/*
* Time characteristic configuration functions.
*/
extern uint8_t Time_configNext(uint8_t state);
extern uint8_t Time_configGattMsg(uint8_t state, gattMsgEvent_t *pMsg);
/*
* Time indication and notification handling functions.
*/
extern void Time_indGattMsg(gattMsgEvent_t *pMsg);
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* BLETIME_H */

View File

@@ -0,0 +1,234 @@
/**************************************************************************************************
Filename: time_clock.c
Revised: $Date: 2014-11-04 14:27:46 -0800 (Tue, 04 Nov 2014) $
Revision: $Revision: 40983 $
Description: Time clock display and timekeeping.
Copyright 2014 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
**************************************************************************************************/
/*********************************************************************
* INCLUDES
*/
#include <string.h>
#include "bcomdef.h"
#include "board_lcd.h"
#include "Board.h"
#include "UTC_Clock.h"
#include "time_clock.h"
#include <ti/drivers/lcd/LCDDogm1286.h>
/*********************************************************************
* MACROS
*/
/*********************************************************************
* CONSTANTS
*/
/*********************************************************************
* TYPEDEFS
*/
/*********************************************************************
* GLOBAL VARIABLES
*/
/*********************************************************************
* EXTERNAL VARIABLES
*/
/*********************************************************************
* EXTERNAL FUNCTIONS
*/
/*********************************************************************
* LOCAL VARIABLES
*/
// Month string
static const char timeMonthStr[12][3] =
{
{'J', 'a', 'n'},
{'F', 'e', 'b'},
{'M', 'a', 'r'},
{'A', 'p', 'r'},
{'M', 'a', 'y'},
{'J', 'u', 'n'},
{'J', 'u', 'l'},
{'A', 'u', 'g'},
{'S', 'e', 'p'},
{'O', 'c', 't'},
{'N', 'o', 'v'},
{'D', 'e', 'c'}
};
/*********************************************************************
* LOCAL FUNCTIONS
*/
static char *num2Str(char *pStr, uint8_t num);
static char *year2Str(char *pStr, uint16_t year);
/*********************************************************************
* @fn Time_clockInit()
*
* @brief Initialize the Time clock.
*
* @return none
*/
void Time_clockInit(void)
{
// Start the UTC clock.
UTC_init();
}
/*********************************************************************
* @fn Time_clockDisplay()
*
* @brief Write the clock time to the display.
*
* @return none
*/
void Time_clockDisplay(void)
{
char displayBuf[20];
char *p = displayBuf;
UTCTimeStruct time;
memset(displayBuf, 0x00, 20);
// Get time structure from UTC.
UTC_convertUTCTime(&time, UTC_getClock());
// Display is in the format:
// HH:MM MmmDD YYYY
p = num2Str(p, time.hour);
*p++ = ':';
p = num2Str(p, time.minutes);
*p++ = ' ';
*p++ = timeMonthStr[time.month][0];
*p++ = timeMonthStr[time.month][1];
*p++ = timeMonthStr[time.month][2];
p = num2Str(p, time.day + 1);
*p++ = ' ';
p = year2Str(p, time.year);
LCD_WRITE_STRING(displayBuf, LCD_PAGE2);
}
/*********************************************************************
* @fn Time_clockSet()
*
* @brief Set the clock.
*
* @param pData - Pointer to a Date Time characteristic structure
*
* @return none
*/
void Time_clockSet(uint8_t *pData)
{
UTCTimeStruct time;
// Parse time service structure to UTC time structure.
time.year = BUILD_UINT16(pData[0], pData[1]);
if (time.year == 0)
{
time.year = 2000;
}
pData += 2;
time.month = *pData++;
if (time.month > 0)
{
// time.month--;
}
time.day = *pData++;
if (time.day > 0)
{
// time.day--;
}
time.hour = *pData++;
time.minutes = *pData++;
time.seconds = *pData;
// Update UTC time.
UTC_setClock(UTC_convertUTCSecs(&time));
}
/*********************************************************************
* @fn num2Str()
*
* @brief Convert unsigned int 0-99 to decimal digit string.
*
* @return pointer to string
*/
static char *num2Str(char *pStr, uint8_t num)
{
*pStr++ = (num / 10) + '0';
*pStr++ = (num % 10) + '0';
return pStr;
}
/*********************************************************************
* @fn num2Str()
*
* @brief Convert a year [9999-0000] to decimal digit string.
* Note: this assumes the device's longevity will not surpass
* year 9999.
*
* @return pointer to string
*/
static char *year2Str(char *pStr, uint16_t year)
{
//thousands
*pStr++ = ((year / 1000) % 10) + '0';
//hundreds
*pStr++ = ((year / 100) % 10) + '0';
//tens
*pStr++ = ((year / 10) % 10) + '0';
//units
*pStr++ = (year & 10) + '0';
return pStr;
}
/*********************************************************************
*********************************************************************/

View File

@@ -0,0 +1,87 @@
/*******************************************************************************
Filename: time_clock.h
Revised: $Date: 2014-03-11 10:03:49 -0700 (Tue, 11 Mar 2014) $
Revision: $Revision: 37614 $
Description: This file contains the time clock definitions and prototypes.
Copyright 2014 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
*******************************************************************************/
#ifndef TIME_CLOCK_H
#define TIME_CLOCK_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
* INCLUDES
*/
/*********************************************************************
* CONSTANTS
*/
/*********************************************************************
* TYPEDEFS
*/
/*********************************************************************
* MACROS
*/
/*********************************************************************
* GLOBAL
*/
/*********************************************************************
* FUNCTIONS
*/
/*
* Time clock functions.
*/
extern void Time_clockInit( void );
extern void Time_clockDisplay( void );
extern void Time_clockSet(uint8_t *pData);
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* TIME_CLOCK_H */

View File

@@ -0,0 +1,220 @@
/**************************************************************************************************
Filename: time_config.c
Revised: $Date: 2015-07-06 17:12:12 -0700 (Mon, 06 Jul 2015) $
Revision: $Revision: 44317 $
Description: Time characteristic configuration routines.
Copyright 2011 - 2014 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
**************************************************************************************************/
/*********************************************************************
* INCLUDES
*/
#include "bcomdef.h"
#include "gatt.h"
#include "gatt_uuid.h"
#include "gattservapp.h"
#include "time_clock.h"
#include "bletime.h"
/*********************************************************************
* MACROS
*/
// Used to determine the end of Time_configList[]
#define TIME_CONFIG_MAX (sizeof(Time_configList) / sizeof(uint8_t))
/*********************************************************************
* CONSTANTS
*/
// Array of handle cache indexes. This list determines the
// characteristics that are read or written during configuration.
const uint8_t Time_configList[] =
{
HDL_CURR_TIME_CT_TIME_START, // Current time
HDL_CURR_TIME_CT_TIME_CCCD, // Current time CCCD
};
/*********************************************************************
* TYPEDEFS
*/
/*********************************************************************
* GLOBAL VARIABLES
*/
// Connection handle.
uint16_t Time_connHandle = 0;
/*********************************************************************
* EXTERNAL VARIABLES
*/
/*********************************************************************
* EXTERNAL FUNCTIONS
*/
/*********************************************************************
* LOCAL VARIABLES
*/
uint8_t Time_configDone = FALSE;
/*********************************************************************
* LOCAL FUNCTIONS
*/
/*********************************************************************
* @fn Time_configNext()
*
* @brief Perform the characteristic configuration read or
* write procedure.
*
* @param state - Configuration state.
*
* @return New configuration state.
*/
uint8_t Time_configNext(uint8_t state)
{
bool read;
// Find next non-zero cached handle of interest
while (state < TIME_CONFIG_MAX &&
Time_handleCache[Time_configList[state]] == 0)
{
state++;
}
// Return if reached end of list
if (state >= TIME_CONFIG_MAX)
{
return TIME_CONFIG_CMPL;
}
// Determine what to do with characteristic
switch (Time_configList[state])
{
// Read these characteristics
case HDL_CURR_TIME_CT_TIME_START:
read = TRUE;
break;
// Set notification for these characteristics
case HDL_CURR_TIME_CT_TIME_CCCD:
read = FALSE;
break;
default:
return state;
}
if(Time_configDone==TRUE)
{
return state;
}
// Do a GATT read or write
if (read)
{
attReadReq_t readReq;
readReq.handle = Time_handleCache[Time_configList[state]];
// Send the read request
GATT_ReadCharValue(Time_connHandle, &readReq, ICall_getEntityId());
// Only reading time right now
Time_configDone = TRUE;
}
else
{
attWriteReq_t writeReq;
writeReq.pValue = GATT_bm_alloc(Time_connHandle, ATT_WRITE_REQ, 2, NULL);
if (writeReq.pValue != NULL)
{
writeReq.len = 2;
writeReq.pValue[0] = LO_UINT16(GATT_CLIENT_CFG_NOTIFY);
writeReq.pValue[1] = HI_UINT16(GATT_CLIENT_CFG_NOTIFY);
writeReq.sig = 0;
writeReq.cmd = 0;
writeReq.handle = Time_handleCache[Time_configList[state]];
// Send the read request
if (GATT_WriteCharValue(Time_connHandle, &writeReq,
ICall_getEntityId()) != SUCCESS)
{
GATT_bm_free((gattMsg_t *)&writeReq, ATT_WRITE_REQ);
}
}
}
return state;
}
/*********************************************************************
* @fn Time_configGattMsg()
*
* @brief Handle GATT messages for characteristic configuration.
*
* @param state - Discovery state.
* @param pMsg - GATT message.
*
* @return New configuration state.
*/
uint8_t Time_configGattMsg(uint8_t state, gattMsgEvent_t *pMsg)
{
if ((pMsg->method == ATT_READ_RSP || pMsg->method == ATT_WRITE_RSP) &&
(pMsg->hdr.status == SUCCESS))
{
// Process response
switch (Time_configList[state])
{
case HDL_CURR_TIME_CT_TIME_START:
// Set clock to time read from time server
Time_clockSet(pMsg->msg.readRsp.pValue);
break;
default:
break;
}
}
return Time_configNext(state + 1);
}
/*********************************************************************
*********************************************************************/

View File

@@ -0,0 +1,340 @@
/*******************************************************************************
Filename: time_discovery.c
Revised: $Date: 2015-06-16 15:14:24 -0700 (Tue, 16 Jun 2015) $
Revision: $Revision: 44104 $
Description: Time service and characteristic discovery routines.
Copyright 2011 - 2014 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
*******************************************************************************/
/*********************************************************************
* INCLUDES
*/
#include <string.h>
#include "bcomdef.h"
#include "gatt.h"
#include "gatt_uuid.h"
#include "gatt_profile_uuid.h"
#include "bletime.h"
/*********************************************************************
* MACROS
*/
// Length of Characteristic declaration + handle with 16 bit UUID
#define CHAR_DESC_HDL_UUID16_LEN 7
/*********************************************************************
* CONSTANTS
*/
/*********************************************************************
* TYPEDEFS
*/
/*********************************************************************
* GLOBAL VARIABLES
*/
/*********************************************************************
* EXTERNAL VARIABLES
*/
// Attribute handle cache
uint16_t Time_handleCache[HDL_CACHE_LEN];
/*********************************************************************
* EXTERNAL FUNCTIONS
*/
/*********************************************************************
* LOCAL VARIABLES
*/
// Attribute handles used during discovery
static uint16_t Time_svcStartHdl;
static uint16_t Time_svcEndHdl;
static uint8_t Time_endHdlIdx;
/*********************************************************************
* LOCAL FUNCTIONS
*/
static uint8_t Time_discCurrTime(uint8_t state, gattMsgEvent_t *pMsg);
/*********************************************************************
* @fn Time_discStart()
*
* @brief Start service discovery.
*
* @return New discovery state.
*/
uint8_t Time_discStart(void)
{
// Clear handle cache
memset(Time_handleCache, 0, sizeof(Time_handleCache));
// Start discovery with first service
return Time_discGattMsg(DISC_CURR_TIME_START, NULL);
}
/*********************************************************************
* @fn Time_discGattMsg()
*
* @brief Handle GATT messages for characteristic discovery.
*
* @param state - Discovery state.
* @param pMsg - GATT message.
*
* @return New discovery state.
*/
uint8_t Time_discGattMsg(uint8_t state, gattMsgEvent_t *pMsg)
{
// Execute discovery function for service
do
{
switch (state & 0xF0)
{
// Current time service
case DISC_CURR_TIME_START:
state = Time_discCurrTime(state, pMsg);
if (state == DISC_FAILED)
{
state = DISC_FAILED;
}
else if (state == DISC_IDLE)
{
state = DISC_IDLE;
}
break;
default:
break;
}
} while ((state != 0) && ((state & 0x0F) == 0));
return state;
}
/*********************************************************************
* @fn Time_discCurrTime()
*
* @brief Current time service and characteristic discovery.
*
* @param state - Discovery state.
* @param pMsg - GATT message.
*
* @return New discovery state.
*/
static uint8_t Time_discCurrTime(uint8_t state, gattMsgEvent_t *pMsg)
{
uint8_t newState = state;
switch (state)
{
case DISC_CURR_TIME_START:
{
uint8_t uuid[ATT_BT_UUID_SIZE] = { LO_UINT16(CURRENT_TIME_SERV_UUID),
HI_UINT16(CURRENT_TIME_SERV_UUID) };
// Initialize service discovery variables
Time_svcStartHdl = Time_svcEndHdl = 0;
Time_endHdlIdx = 0;
// Discover service by UUID
GATT_DiscPrimaryServiceByUUID(Time_connHandle, uuid,
ATT_BT_UUID_SIZE, ICall_getEntityId());
newState = DISC_CURR_TIME_SVC;
}
break;
case DISC_CURR_TIME_SVC:
// Service found, store handles
if (pMsg->method == ATT_FIND_BY_TYPE_VALUE_RSP &&
pMsg->msg.findByTypeValueRsp.numInfo > 0)
{
Time_svcStartHdl =
ATT_ATTR_HANDLE(pMsg->msg.findByTypeValueRsp.pHandlesInfo, 0);
Time_svcEndHdl =
ATT_GRP_END_HANDLE(pMsg->msg.findByTypeValueRsp.pHandlesInfo, 0);
}
// If procedure complete
if ((pMsg->method == ATT_FIND_BY_TYPE_VALUE_RSP &&
pMsg->hdr.status == bleProcedureComplete) ||
(pMsg->method == ATT_ERROR_RSP))
{
// If service found
if (Time_svcStartHdl != 0)
{
// Discover all characteristics
GATT_DiscAllChars(Time_connHandle, Time_svcStartHdl,
Time_svcEndHdl, ICall_getEntityId());
newState = DISC_CURR_TIME_CHAR;
}
else
{
// Service not found
newState = DISC_FAILED;
}
}
break;
case DISC_CURR_TIME_CHAR:
{
// Characteristics found
if (pMsg->method == ATT_READ_BY_TYPE_RSP &&
pMsg->msg.readByTypeRsp.numPairs > 0 &&
pMsg->msg.readByTypeRsp.len == CHAR_DESC_HDL_UUID16_LEN)
{
uint8_t i;
uint8_t *p;
uint16_t handle;
uint16_t uuid;
// For each characteristic declaration
p = pMsg->msg.readByTypeRsp.pDataList;
for (i = pMsg->msg.readByTypeRsp.numPairs; i > 0; i--)
{
// Parse characteristic declaration
handle = BUILD_UINT16(p[3], p[4]);
uuid = BUILD_UINT16(p[5], p[6]);
// If looking for end handle
if (Time_endHdlIdx != 0)
{
// End handle is one less than handle of characteristic
// declaration.
Time_handleCache[Time_endHdlIdx] = BUILD_UINT16(p[0], p[1]) - 1;
Time_endHdlIdx = 0;
}
// If UUID is of interest, store handle
switch (uuid)
{
case CURRENT_TIME_UUID:
Time_handleCache[HDL_CURR_TIME_CT_TIME_START] = handle;
Time_endHdlIdx = HDL_CURR_TIME_CT_TIME_END;
break;
default:
break;
}
p += CHAR_DESC_HDL_UUID16_LEN;
}
}
// If procedure complete
if ((pMsg->method == ATT_READ_BY_TYPE_RSP &&
pMsg->hdr.status == bleProcedureComplete) ||
(pMsg->method == ATT_ERROR_RSP))
{
// Special case of end handle at end of service
if (Time_endHdlIdx != 0)
{
Time_handleCache[Time_endHdlIdx] = Time_svcEndHdl;
Time_endHdlIdx = 0;
}
// If didn't find time characteristic
if (Time_handleCache[HDL_CURR_TIME_CT_TIME_START] == 0)
{
newState = DISC_FAILED;
}
else if (Time_handleCache[HDL_CURR_TIME_CT_TIME_START] <
Time_handleCache[HDL_CURR_TIME_CT_TIME_END])
{
// Discover characteristic descriptors
GATT_DiscAllCharDescs(Time_connHandle,
Time_handleCache[HDL_CURR_TIME_CT_TIME_START] + 1,
Time_handleCache[HDL_CURR_TIME_CT_TIME_END],
ICall_getEntityId());
newState = DISC_CURR_TIME_CT_TIME_CCCD;
}
else
{
newState = DISC_IDLE;
}
}
}
break;
case DISC_CURR_TIME_CT_TIME_CCCD:
{
// Characteristic descriptors found
if (pMsg->method == ATT_FIND_INFO_RSP &&
pMsg->msg.findInfoRsp.numInfo > 0 &&
pMsg->msg.findInfoRsp.format == ATT_HANDLE_BT_UUID_TYPE)
{
uint8_t i;
// For each handle/uuid pair
for (i = 0; i < pMsg->msg.findInfoRsp.numInfo; i++)
{
// Look for CCCD
if (ATT_BT_PAIR_UUID(pMsg->msg.findInfoRsp.pInfo, i) ==
GATT_CLIENT_CHAR_CFG_UUID)
{
// CCCD found
Time_handleCache[HDL_CURR_TIME_CT_TIME_CCCD] =
ATT_BT_PAIR_HANDLE(pMsg->msg.findInfoRsp.pInfo, i);
break;
}
}
}
// If procedure complete
if ((pMsg->method == ATT_FIND_INFO_RSP &&
pMsg->hdr.status == bleProcedureComplete) ||
(pMsg->method == ATT_ERROR_RSP))
{
newState = DISC_IDLE;
}
}
break;
default:
break;
}
return newState;
}
/*********************************************************************
*********************************************************************/

View File

@@ -0,0 +1,135 @@
/*******************************************************************************
Filename: time_ind.c
Revised: $Date: 2015-06-16 15:14:24 -0700 (Tue, 16 Jun 2015) $
Revision: $Revision: 44104 $
Description: Time indication and notification handling routines.
Copyright 2011 - 2014 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
*******************************************************************************/
/*********************************************************************
* INCLUDES
*/
#include "string.h"
#include "bcomdef.h"
#include "gatt.h"
#include "gatt_uuid.h"
#include "gattservapp.h"
#include "time_clock.h"
#include "bletime.h"
/*********************************************************************
* MACROS
*/
// Maximum category ID value
#define ALERT_CAT_ID_MAX 9
// Parse major category
#define ALERT_MAJOR_CAT(x) ((x) >> 3)
// Parse subcategory
#define ALERT_SUBCAT(x) ((x) & 0x07)
/*********************************************************************
* CONSTANTS
*/
/*********************************************************************
* TYPEDEFS
*/
/*********************************************************************
* GLOBAL VARIABLES
*/
/*********************************************************************
* EXTERNAL VARIABLES
*/
/*********************************************************************
* EXTERNAL FUNCTIONS
*/
/*********************************************************************
* LOCAL VARIABLES
*/
/*********************************************************************
* LOCAL FUNCTIONS
*/
/*********************************************************************
* @fn Time_indGattMsg
*
* @brief Handle indications and notifications.
*
* @param pMsg - GATT message.
*
* @return none
*/
void Time_indGattMsg(gattMsgEvent_t *pMsg)
{
uint8_t i;
// Look up the handle in the handle cache
for (i = 0; i < HDL_CACHE_LEN; i++)
{
if (pMsg->msg.handleValueNoti.handle == Time_handleCache[i])
{
break;
}
}
// Perform processing for this handle
switch (i)
{
case HDL_CURR_TIME_CT_TIME_START:
// Set clock to time read from time server
Time_clockSet(pMsg->msg.handleValueNoti.pValue);
break;
default:
break;
}
// Send confirm for indication
if (pMsg->method == ATT_HANDLE_VALUE_IND)
{
ATT_HandleValueCfm(pMsg->connHandle);
}
}
/*********************************************************************
*********************************************************************/

View File

@@ -0,0 +1,205 @@
/*******************************************************************************
Filename: board_key.c
Revised: $Date: 2014-03-10 07:29:12 -0700 (Mon, 10 Mar 2014) $
Revision: $Revision: 37597 $
Description: This file contains the interface to the SRF06EB Key Service.
Copyright 2014 - 2015 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
*******************************************************************************/
/*********************************************************************
* INCLUDES
*/
#include <stdbool.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/family/arm/m3/Hwi.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <ti/sysbios/knl/Queue.h>
#include <ti/drivers/pin/PINCC26XX.h>
#ifdef USE_ICALL
#include <ICall.h>
#endif
#include <inc/hw_ints.h>
#include "bcomdef.h"
#include "util.h"
#include "board_key.h"
#include "Board.h"
/*********************************************************************
* TYPEDEFS
*/
/*********************************************************************
* LOCAL FUNCTIONS
*/
static void Board_keyChangeHandler(UArg a0);
static void Board_keyCallback(PIN_Handle hPin, PIN_Id pinId);
/*******************************************************************************
* EXTERNAL VARIABLES
*/
/*********************************************************************
* LOCAL VARIABLES
*/
// Value of keys Pressed
static uint8_t keysPressed;
// Key debounce clock
static Clock_Struct keyChangeClock;
// Pointer to application callback
keysPressedCB_t appKeyChangeHandler = NULL;
// Memory for the GPIO module to construct a Hwi
Hwi_Struct callbackHwiKeys;
// PIN configuration structure to set all KEY pins as inputs with pullups enabled
PIN_Config keyPinsCfg[] =
{
Board_KEY_SELECT | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
Board_KEY_UP | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
Board_KEY_DOWN | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
Board_KEY_LEFT | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
Board_KEY_RIGHT | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
PIN_TERMINATE
};
PIN_State keyPins;
PIN_Handle hKeyPins;
/*********************************************************************
* PUBLIC FUNCTIONS
*/
/*********************************************************************
* @fn Board_initKeys
*
* @brief Enable interrupts for keys on GPIOs.
*
* @param appKeyCB - application key pressed callback
*
* @return none
*/
void Board_initKeys(keysPressedCB_t appKeyCB)
{
// Initialize KEY pins. Enable int after callback registered
hKeyPins = PIN_open(&keyPins, keyPinsCfg);
PIN_registerIntCb(hKeyPins, Board_keyCallback);
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_KEY_SELECT | PIN_IRQ_NEGEDGE);
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_KEY_UP | PIN_IRQ_NEGEDGE);
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_KEY_DOWN | PIN_IRQ_NEGEDGE);
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_KEY_LEFT | PIN_IRQ_NEGEDGE);
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_KEY_RIGHT | PIN_IRQ_NEGEDGE);
#ifdef POWER_SAVING
//Enable wakeup
PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_KEY_SELECT | PINCC26XX_WAKEUP_NEGEDGE);
PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_KEY_UP | PINCC26XX_WAKEUP_NEGEDGE);
PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_KEY_DOWN | PINCC26XX_WAKEUP_NEGEDGE);
PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_KEY_LEFT | PINCC26XX_WAKEUP_NEGEDGE);
PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_KEY_RIGHT | PINCC26XX_WAKEUP_NEGEDGE);
#endif
// Setup keycallback for keys
Util_constructClock(&keyChangeClock, Board_keyChangeHandler,
KEY_DEBOUNCE_TIMEOUT, 0, false, 0);
// Set the application callback
appKeyChangeHandler = appKeyCB;
}
/*********************************************************************
* @fn Board_keyCallback
*
* @brief Interrupt handler for Keys
*
* @param none
*
* @return none
*/
static void Board_keyCallback(PIN_Handle hPin, PIN_Id pinId)
{
keysPressed = 0;
if ( PIN_getInputValue(Board_KEY_SELECT) == 0 )
{
keysPressed |= KEY_SELECT;
}
if ( PIN_getInputValue(Board_KEY_UP) == 0 )
{
keysPressed |= KEY_UP;
}
if ( PIN_getInputValue(Board_KEY_DOWN) == 0 )
{
keysPressed |= KEY_DOWN;
}
if ( PIN_getInputValue(Board_KEY_LEFT) == 0 )
{
keysPressed |= KEY_LEFT;
}
if ( PIN_getInputValue(Board_KEY_RIGHT) == 0 )
{
keysPressed |= KEY_RIGHT;
}
Util_startClock(&keyChangeClock);
}
/*********************************************************************
* @fn Board_keyChangeHandler
*
* @brief Handler for key change
*
* @param UArg a0 - ignored
*
* @return none
*/
static void Board_keyChangeHandler(UArg a0)
{
if (appKeyChangeHandler != NULL)
{
// Notify the application
(*appKeyChangeHandler)(keysPressed);
}
}
/*********************************************************************
*********************************************************************/

View File

@@ -0,0 +1,98 @@
/*******************************************************************************
Filename: board_key.h
Revised: $Date: 2014-02-28 14:18:14 -0800 (Fri, 28 Feb 2014) $
Revision: $Revision: 37461 $
Description: This file contains the SRF06EB Key Service definitions
and prototypes.
Copyright 2014 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
*******************************************************************************/
#ifndef BOARD_KEY_H
#define BOARD_KEY_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************************************************************
* INCLUDES
*/
/*********************************************************************
* EXTERNAL VARIABLES
*/
/*********************************************************************
* CONSTANTS
*/
#define KEY_SELECT 0x0001
#define KEY_UP 0x0002
#define KEY_DOWN 0x0004
#define KEY_LEFT 0x0008
#define KEY_RIGHT 0x0010
// Debounce timeout in milliseconds
#define KEY_DEBOUNCE_TIMEOUT 200
/*********************************************************************
* TYPEDEFS
*/
typedef void (*keysPressedCB_t)(uint8 keysPressed);
/*********************************************************************
* MACROS
*/
/*********************************************************************
* API FUNCTIONS
*/
/*********************************************************************
* @fn Board_initKeys
*
* @brief Enable interrupts for keys on GPIOs.
*
* @param appKeyCB - application key pressed callback
*
* @return none
*/
void Board_initKeys(keysPressedCB_t appKeyCB);
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* BOARD_KEY_H */

View File

@@ -0,0 +1,163 @@
/*******************************************************************************
Filename: board_lcd.c
Revised: $Date: 2014-03-10 07:29:12 -0700 (Mon, 10 Mar 2014) $
Revision: $Revision: 37597 $
Description: This file contains the interface to the SRF06EB LCD Service.
Copyright 2014 - 2015 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
*******************************************************************************/
/*********************************************************************
* INCLUDES
*/
#include <ti/drivers/lcd/LCDDogm1286.h>
#include "board_lcd.h"
#include "Board.h"
/*********************************************************************
* TYPEDEFS
*/
/*********************************************************************
* LOCAL FUNCTIONS
*/
/*******************************************************************************
* EXTERNAL VARIABLES
*/
/*********************************************************************
* LOCAL VARIABLES
*/
// LCD parameter
static LCD_Handle lcdHandle = NULL;
#ifdef TI_DRIVERS_LCD_INCLUDED
// LCD pin table
PIN_Config LCDPinTable[] = {
Board_3V3_EN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, // Enable 3V3 domain. Need to be high for LCD to work.
PIN_TERMINATE // Terminate list
};
// LCD pin state
PIN_State LCDPinState;
// LCD pin handle
PIN_Handle hLCDPins;
#endif //TI_DRIVERS_LCD_INCLUDED
Char lcdBuffer0[LCD_BYTES] = {0};
LCD_Buffer lcdBuffers[] = {
{lcdBuffer0, LCD_BYTES, NULL},
};
/*********************************************************************
* PUBLIC FUNCTIONS
*/
/*********************************************************************
* @fn Board_openLCD
*
* @brief Open LCD peripheral on SRF06EB.
*
* @param none
*
* @return void
*/
void Board_openLCD(void)
{
#ifdef TI_DRIVERS_LCD_INCLUDED
//Enable the 3V3 domain for the LCD
hLCDPins = PIN_open(&LCDPinState, LCDPinTable);
LCD_Params lcdParams;
LCD_Params_init(&lcdParams);
// Open LCD peripheral
lcdHandle = LCD_open(&lcdBuffers[0], 1, &lcdParams);
if ( lcdHandle )
{
LCD_bufferClear(lcdHandle, 0);
LCD_update(lcdHandle, 0);
}
#endif
}
/*********************************************************************
* @fn Board_writeString
*
* @brief Write a string on the LCD display.
*
* @param str - string to print
* @param line - line (page) to write (0-7)
*
* @return void
*/
void Board_writeString(char *str, uint8_t line)
{
if (lcdHandle != NULL)
{
LCD_bufferClearPage(lcdHandle, 0, (LCD_Page)line);
LCD_bufferPrintString(lcdHandle, 0, str, 0, (LCD_Page)line);
LCD_update(lcdHandle, 0);
}
}
/*********************************************************************
* @fn Board_writeStringValue
*
* @brief Write a string and value on the LCD display.
*
* @param str - string to print
* @param value - value to print
* @param format - base of the value to print (2,8,16 etc)
* @param line - line (page) to write (0-7)
*
* @return void
*/
void Board_writeStringValue(char *str, uint32_t value, uint8_t format,
uint8_t line)
{
if (lcdHandle != NULL)
{
// Write string and 32-bit number
LCD_writeLine(lcdHandle, 0, str, value, format, line);
}
}
/*********************************************************************
*********************************************************************/

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,128 @@
/*******************************************************************************
Filename: board_lcd.h
Revised: $Date: 2014-02-28 14:18:14 -0800 (Fri, 28 Feb 2014) $
Revision: $Revision: 37461 $
Description: This file contains the SRF06EB Key Service definitions
and prototypes.
Copyright 2014 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
*******************************************************************************/
#ifndef BOARD_LCD_H
#define BOARD_LCD_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************************************************************
* INCLUDES
*/
/*********************************************************************
* EXTERNAL VARIABLES
*/
/*********************************************************************
* CONSTANTS
*/
/*********************************************************************
* TYPEDEFS
*/
/*********************************************************************
* MACROS
*/
// LCD macros
#ifdef TI_DRIVERS_LCD_INCLUDED
#define LCD_WRITE_STRING(str, line) Board_writeString(str, line)
#define LCD_WRITE_STRING_VALUE(str, value, format, line) \
Board_writeStringValue(str, value, format, line)
#else
#define LCD_WRITE_STRING(str, line)
#define LCD_WRITE_STRING_VALUE(str, value, format, line)
#endif // TI_DRIVERS_LCD_INCLUDED
/*********************************************************************
* API FUNCTIONS
*/
/*********************************************************************
* @fn Board_openLCD
*
* @brief Open LCD peripheral on SRF06EB.
*
* @param none
*
* @return none
*/
extern void Board_openLCD(void);
/*********************************************************************
* @fn Board_writeString
*
* @brief Write a string on the LCD display.
*
* @param str - string to print
* @param line - line (page) to write (0-7)
*
* @return void
*/
extern void Board_writeString(char *str, uint8_t line);
/*********************************************************************
* @fn Board_writeStringValue
*
* @brief Write a string and value on the LCD display.
*
* @param str - string to print
* @param value - value to print
* @param format - base of the value to print (2,8,16 etc)
* @param line - line (page) to write (0-7)
*
* @return void
*/
extern void Board_writeStringValue(char *str, uint32_t value, uint8_t format,
uint8_t line);
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* BOARD_LCD_H */

View File

@@ -0,0 +1,237 @@
/*
* Copyright (c) 2014, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/** ============================================================================
* @file Board.h
*
* @brief CC2650SENSORTAG Board Specific header file.
*
* The CC2650 header file should be included in an application as follows:
* @code
* #include <Board.h>
* @endcode
*
* ============================================================================
*/
#ifndef __CC2650ST_H__
#define __CC2650ST_H__
#ifdef TI_DRIVERS_PIN_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif
/** ============================================================================
* Includes
* ==========================================================================*/
// TBD: #include <ti/drivers/GPIO.h>
#include <ti/drivers/I2C.h>
#include <ti/drivers/SPI.h>
#include <ti/drivers/UART.h>
#include <ti/drivers/Watchdog.h>
#include <ti/drivers/AES.h>
#include <ti/drivers/PIN.h>
#include <driverlib/ioc.h>
/** ============================================================================
* Externs
* ==========================================================================*/
extern PIN_Config BoardGpioInitTable[];
/** ============================================================================
* Defines
* ==========================================================================*/
/* Mapping of pins to board signals using general board aliases
* <board signal alias> <pin mapping>
*/
/* Discrete outputs */
#define Board_LED1 IOID_10
#define Board_LED2 IOID_15
#define Board_BUZZER IOID_21
#define Board_LED_ON 1
#define Board_LED_OFF 0
#define Board_BUZZER_ON 1
#define Board_BUZZER_OFF 0
/* Discrete inputs */
#define Board_KEY_LEFT IOID_0
#define Board_KEY_RIGHT IOID_4
#define Board_RELAY IOID_3
/* Sensor outputs */
#define Board_MPU_INT IOID_7
#define Board_TMP_RDY IOID_1
/* I2C */
#define Board_I2C0_SDA0 IOID_5
#define Board_I2C0_SCL0 IOID_6
#define Board_I2C0_SDA1 IOID_8
#define Board_I2C0_SCL1 IOID_9
/* SPI */
#define Board_SPI_FLASH_CS IOID_14
#define Board_SPI_DEVPK_CS IOID_20
#define Board_FLASH_CS_ON 0
#define Board_FLASH_CS_OFF 1
#define Board_SPI0_CLK IOID_11
#define Board_SPI0_MISO IOID_18
#define Board_SPI0_MOSI IOID_19
/* UART (need to strap on SmartRF06EB) */
#define Board_UART_TX IOID_16
#define Board_UART_RX IOID_17
/* DevPack */
#define Board_AUDIOFS_TDO IOID_16
#define Board_AUDIODO IOID_22
#define Board_DP2 IOID_23
#define Board_DP1 IOID_24
#define Board_DP0 IOID_25
#define Board_DP3 IOID_27
#define Board_DEVPK_ID IOID_30
/* Power control */
#define Board_MPU_POWER IOID_12
#define Board_MPU_POWER_ON 1
#define Board_MPU_POWER_OFF 0
#define Board_MIC_POWER IOID_13
#define Board_MIC_POWER_ON 1
#define Board_MIC_POWER_OFF 0
#define Board_I2S_AD0 IOID_2
/** ============================================================================
* Instance identifiers
* ==========================================================================*/
/* Generic I2C instance identifiers */
#define Board_I2C CC2650_I2C0
/* Generic SPI instance identifiers */
#define Board_SPI0 CC2650_SPI0
#define Board_SPI1 CC2650_SPI1
/* Generic UART instance identifiers */
#define Board_UART CC2650_UART0
/* Generic AES instance identifiers */
#define Board_AES CC2650_AES0
/* Generic Watchdog instance identifiers */
#define Board_WATCHDOG CC2650_WATCHDOG0
/** ============================================================================
* Number of peripherals and their names
* ==========================================================================*/
/*!
* @def CC2650_I2CName
* @brief Enum of I2C names on the CC2650 dev board
*/
typedef enum CC2650_I2CName {
CC2650_I2C0 = 0,
CC2650_I2CCOUNT
} CC2650_I2CName;
/*!
* @def CC2650_AESName
* @brief Enum of AES names on the CC2650 dev board
*/
typedef enum CC2650_AESName {
CC2650_AES0 = 0,
CC2650_AESCOUNT
} CC2650_AESName;
/*!
* @def CC2650_SPIName
* @brief Enum of SPI names on the CC2650 dev board
*/
typedef enum CC2650_SPIName {
CC2650_SPI0 = 0,
CC2650_SPICOUNT
} CC2650_SPIName;
/*!
* @def CC2650_UARTName
* @brief Enum of UARTs on the CC2650 dev board
*/
typedef enum CC2650_UARTName {
CC2650_UART0 = 0,
CC2650_UARTCOUNT
} CC2650_UARTName;
/*!
* @def CC2650_WatchdogName
* @brief Enum of Watchdogs on the CC2650 dev board
*/
typedef enum CC2650_WatchdogName {
CC2650_WATCHDOG0 = 0,
CC2650_WATCHDOGCOUNT
} CC2650_WatchdogName;
/*!
* @def CC2650_LcdBufferName
* @brief Enum of LCD buffers
*/
typedef enum CC2650_LcdBufferName {
CC2650_LCDBUFFER0 = 0,
CC2650_LCDBUFFER1,
CC2650_LCDBUFFERCOUNT
} CC2650_LcdBufferName;
/*!
* @def CC2650_UdmaName
* @brief Enum of DMA buffers
*/
typedef enum CC2650_UdmaName {
CC2650_UDMA0 = 0,
CC2650_UDMACOUNT
} CC2650_UdmaName;
/** ============================================================================
* Global pin handle
* ==========================================================================*/
extern PIN_State pinGpioState;
extern PIN_Handle hGpioPin;
#ifdef __cplusplus
}
#endif
#endif
#endif /* __CC2650EM_H__ */

View File

@@ -0,0 +1,520 @@
/*
* Copyright (c) 2014, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* ======== SENSORTAG_CC26xx.c ========
* This file is responsible for setting up the board specific items for the
* SRF06EB_CC2650 with (CC2650EM) board.
*
* The following defines are used to determine which TI-RTOS peripheral drivers
* to include:
* TI_DRIVERS_GPIO_INCLUDED
* TI_DRIVERS_I2C_INCLUDED
* TI_DRIVERS_SPI_INCLUDED
* TI_DRIVERS_SPI_INCLUDED
* TI_DRIVERS_UART_INCLUDED
* TI_DRIVERS_UART_DMA_INCLUDED
* TI_DRIVERS_WATCHDOG_INCLUDED
* TI_DRIVERS_LCD_INCLUDED
* These defines are created when a useModule is done on the driver in the
* application's .cfg file. The actual #define is in the application
* generated header file that is brought in via the xdc/cfg/global.h.
* For example the following in the .cfg file
* var GPIO = xdc.useModule('ti.drivers.GPIO');
* Generates the following
* #define TI_DRIVERS_GPIO_INCLUDED 1
* If there is no useModule of ti.drivers.GPIO, the constant is set to 0.
*
* Note: a useModule is generated in the .cfg file via the graphical
* configuration tool when the "Add xxx to my configuration" is checked
* or "Use xxx" is selected.
*/
#include <stdint.h>
#include <stdbool.h>
#include <inc/hw_memmap.h>
#include <inc/hw_types.h>
#include <inc/hw_ints.h>
#include <driverlib/udma.h>
#include <driverlib/osc.h>
#include <driverlib/cpu.h>
#include <driverlib/pwr_ctrl.h>
#include <driverlib/sys_ctrl.h>
#include <driverlib/aon_event.h>
#include <xdc/std.h>
#include <xdc/runtime/System.h>
#include <ti/sysbios/family/arm/m3/Hwi.h>
#include <ti/sysbios/family/arm/cc26xx/Power.h>
#include <ti/sysbios/family/arm/cc26xx/PowerCC2650.h>
#if !(defined(MODULE_CC26XX_7X7) || defined(MODULE_CC26XX_5X5) || defined(MODULE_CC26XX_4X4))
#error "Please specify project wide definition of package: MODULE_CC26XX_7X7 / MODULE_CC26XX_5X5 / MODULE_CC26XX_4X4..."
#endif
/* Make sure to include drivers for GPIO and SPI if LCD driver is included */
#if defined(TI_DRIVERS_LCD_INCLUDED)
#ifndef TI_DRIVERS_GPIO_INCLUDED
#define TI_DRIVERS_GPIO_INCLUDED
#endif
#ifndef TI_DRIVERS_SPI_INCLUDED
#define TI_DRIVERS_SPI_INCLUDED
#endif
#endif // TI_DRIVERS_LCD_INCLUDED
/* workaround to avoid macro expansion of ccs to 1 within a nested #include. Bug number: 320943 */
#ifdef ccs
#undef ccs
#include <xdc/cfg/global.h>
#define ccs 1
#else
#include <xdc/cfg/global.h>
#endif
#include "SENSORTAG_CC2650.h"
#if (TI_DRIVERS_UART_DMA_INCLUDED || TI_DRIVERS_SPI_INCLUDED)
#include <ti/drivers/UDMA.h>
/* Udma objects */
Udma_Object UdmaObjects[SENSORTAG_CC2650_UDMACOUNT];
/* UDMA configuration structure */
const Udma_HWAttrs UdmaHWAttrs[SENSORTAG_CC2650_UDMACOUNT] = {
{UDMA0_BASE, INT_UDMAERR, PERIPH_UDMA},
};
const Udma_Config Udma_config[] = {
{&UdmaObjects[0], &UdmaHWAttrs[0]},
{NULL, NULL},
};
#endif /* (TI_DRIVERS_UART_DMA_INCLUDED || TI_DRIVERS_SPI_INCLUDED) */
/*
* ======== SENSORTAG_CC2650_initGeneral ========
*/
Void SENSORTAG_CC2650_initGeneral(Void)
{
/* force power on AUX - this will be released when entering sleep mode */
AONWUCAuxWakeupEvent(AONWUC_AUX_WAKEUP);
/* enable the AUX oscillator clock */
AUXWUCClockEnable(AUX_WUC_OSCCTRL_CLOCK);
while(AUXWUCClockStatus(AUX_WUC_OSCCTRL_CLOCK) != AUX_WUC_CLOCK_READY)
{ }
/* This application will not be using the AUX domain out of boot
* and we will leave out clock for optimal power conservation */
AONWUCAuxPowerDownConfig(AONWUC_NO_CLOCK);
/*
* Source the LF clock from the low frequency XTAL_OSC.
* HF and MF are sourced from the high frequency RC_OSC.
*/
OSCClockSourceSet(OSC_SRC_CLK_LF, OSC_XOSC_LF);
OSCClockSourceSet(OSC_SRC_CLK_MF | OSC_SRC_CLK_HF, OSC_RCOSC_HF);
/*
* Check if already sourcing the HF clock from RC_OSC.
* If a switch of the clock source is not required, then the call to ROM
* will loop forever.
*/
if(OSCClockSourceGet(OSC_SRC_CLK_HF) != OSC_RCOSC_HF)
{
OSCHfSourceSwitch();
}
/* enable DCDC */
PowerCtrlSourceSet(PWRCTRL_PWRSRC_DCDC);
/* make sure AON accesses are in sync and enable powerdown on AUX */
SysCtrlAonSync();
AUXWUCPowerCtrl(AUX_WUC_POWER_DOWN);
}
#if TI_DRIVERS_GPIO_INCLUDED
#include <ti/drivers/GPIO.h>
/* Callback functions for the GPIO interrupt */
void gpioButton1Fxn(void);
void gpioButton2Fxn(void);
void gpioRelayFxn(void);
void gpioMpuFxn(void);
/* GPIO configuration structure */
const GPIO_HWAttrs gpioHWAttrs[SENSORTAG_CC2650_GPIOCOUNT] = {
{GPIO_PIN_10, GPIO_OUTPUT}, /* SENSORTAG_CC2650_LED1 */
{GPIO_PIN_15, GPIO_OUTPUT}, /* SENSORTAG_CC2650_LED2 */
{GPIO_PIN_0, GPIO_INPUT}, /* SENSORTAG_CC2650_BUTTON2 */
{GPIO_PIN_4, GPIO_INPUT}, /* SENSORTAG_CC2650_BUTTON1 */
{GPIO_PIN_3, GPIO_INPUT}, /* SENSORTAG_CC2650_RELAY */
{GPIO_PIN_21, GPIO_OUTPUT}, /* SENSORTAG_CC2650_BUZZER_EN */
{GPIO_PIN_17, GPIO_INPUT}, /* SENSORTAG_CC2650_UART_RX */
{GPIO_PIN_16, GPIO_OUTPUT}, /* SENSORTAG_CC2650_UART_TX */
{GPIO_PIN_12, GPIO_OUTPUT}, /* SENSORTAG_CC2650_MPU_POWER */
{GPIO_PIN_14, GPIO_OUTPUT}, /* SENSORTAG_CC2650_FLASH_CS */
{GPIO_PIN_7, GPIO_INPUT}, /* SENSORTAG_CC2650_MPU_INT */
{GPIO_PIN_1, GPIO_INPUT}, /* SENSORTAG_CC2650_TMP_RDY */
{GPIO_PIN_13, GPIO_OUTPUT}, /* SENSORTAG_CC2650_MIC_POWER */
};
/* Memory for the GPIO module to construct a Hwi */
Hwi_Struct callbackHwi;
/* GPIO callback structure to set callbacks for GPIO interrupts. NB! Indexed by GPIO pin number! */
const GPIO_Callbacks SENSORTAG_CC2650_gpioPortCallbacks = {
INT_EDGE_DETECT, &callbackHwi,
{
gpioButton2Fxn, NULL, NULL, gpioRelayFxn, gpioButton1Fxn, NULL, NULL, gpioMpuFxn,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
}
};
const GPIO_Config GPIO_config[SENSORTAG_CC2650_GPIOCOUNT+1] = {
{&gpioHWAttrs[0]},
{&gpioHWAttrs[1]},
{&gpioHWAttrs[2]},
{&gpioHWAttrs[3]},
{&gpioHWAttrs[4]},
{&gpioHWAttrs[5]},
{&gpioHWAttrs[6]},
{&gpioHWAttrs[7]},
{&gpioHWAttrs[8]},
{&gpioHWAttrs[9]},
{&gpioHWAttrs[10]},
{&gpioHWAttrs[11]},
{&gpioHWAttrs[11]},
{NULL},
};
/*
* ======== SENSORTAG_CC2650_initGPIO ========
*/
Void SENSORTAG_CC2650_initGPIO(Void)
{
Bits32 pin;
/* Power up the GPIO module. */
GPIO_open();
/* Setup the LED1 (red) GPIO pin. */
pin = gpioHWAttrs[SENSORTAG_CC2650_LED1].pin;
IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_OUTPUT);
GPIODirModeSet(pin, GPIO_DIR_MODE_OUT);
/* Setup the LED2 (green) GPIO pin. */
pin = gpioHWAttrs[SENSORTAG_CC2650_LED2].pin;
IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_OUTPUT);
GPIODirModeSet(pin, GPIO_DIR_MODE_OUT);
/* Setup the Button1 GPIO pin. */
pin = gpioHWAttrs[SENSORTAG_CC2650_BUTTON1].pin;
IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_INPUT);
GPIODirModeSet(pin, GPIO_DIR_MODE_IN);
IOCIOPortPullSet(PIN2IOID(pin), IOC_IOPULL_UP);
/* Setup the Button2 GPIO pin. */
pin = gpioHWAttrs[SENSORTAG_CC2650_BUTTON2].pin;
IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_INPUT);
GPIODirModeSet(pin, GPIO_DIR_MODE_IN);
IOCIOPortPullSet(PIN2IOID(pin), IOC_IOPULL_UP);
/* Setup the Reed relay GPIO pin. */
pin = gpioHWAttrs[SENSORTAG_CC2650_REED_INT].pin;
IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_INPUT);
GPIODirModeSet(pin, GPIO_DIR_MODE_IN);
IOCIOPortPullSet(PIN2IOID(pin), IOC_IOPULL_DOWN);
/* Setup the FLASH_CS pin. */
pin = gpioHWAttrs[SENSORTAG_CC2650_FLASH_CS].pin;
IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_OUTPUT);
GPIODirModeSet(pin, GPIO_DIR_MODE_OUT);
IOCIOPortPullSet(PIN2IOID(pin), IOC_NO_IOPULL);
/* Setup the BUZZER_EN pin. */
pin = gpioHWAttrs[SENSORTAG_CC2650_BUZZER_EN].pin;
IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_OUTPUT);
GPIODirModeSet(pin, GPIO_DIR_MODE_OUT);
/* Setup the MPU_POWER GPIO pin. */
pin = gpioHWAttrs[SENSORTAG_CC2650_MPU_POWER].pin;
IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_OUTPUT);
GPIODirModeSet(pin, GPIO_DIR_MODE_OUT);
/* Setup the MPU_INT GPIO pin. */
pin = gpioHWAttrs[SENSORTAG_CC2650_MPU_INT].pin;
IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_INPUT);
GPIODirModeSet(pin, GPIO_DIR_MODE_IN);
IOCIOPortPullSet(PIN2IOID(pin), IOC_IOPULL_DOWN);
/* Setup the TMP_RDY GPIO pin. */
pin = gpioHWAttrs[SENSORTAG_CC2650_TMP_RDY].pin;
IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_INPUT);
GPIODirModeSet(pin, GPIO_DIR_MODE_IN);
/* Once GPIO_init is called, GPIO_config cannot be changed */
GPIO_init();
/* Set some of the IO pins */
GPIO_write(SENSORTAG_CC2650_LED1, SENSORTAG_CC2650_LED_OFF);
GPIO_write(SENSORTAG_CC2650_LED2, SENSORTAG_CC2650_LED_OFF);
GPIO_write(SENSORTAG_CC2650_MPU_POWER, SENSORTAG_CC2650_MPU_POWER_ON);
GPIO_write(SENSORTAG_CC2650_MIC_POWER, SENSORTAG_CC2650_MIC_POWER_OFF);
GPIO_write(SENSORTAG_CC2650_FLASH_CS, SENSORTAG_CC2650_FLASH_CS_OFF);
}
#endif /* TI_DRIVERS_GPIO_INCLUDED */
#if TI_DRIVERS_I2C_INCLUDED
#include <ti/drivers/I2C.h>
#include "ti/drivers/i2c/I2CCC26XX.h"
#include <driverlib/prcm.h>
#include "bsp_i2c.h"
/* Init function of IOs for SPI */
void I2CCC26XX_ioInit(const I2C_Config* I2C_config, int i2cInterfaceID)
{
I2CCC26XX_Object* pI2CCC26XX;
/* Initialize the IOs for I2C0 */
pI2CCC26XX = (I2CCC26XX_Object*)I2C_config[0].object;
if (i2cInterfaceID == BSP_I2C_INTERFACE_0)
{
pI2CCC26XX->i2cScl = SENSORTAG_CC2650_I2C0_SCL;
pI2CCC26XX->i2cSda = SENSORTAG_CC2650_I2C0_SDA;
}
else if (i2cInterfaceID == BSP_I2C_INTERFACE_1)
{
pI2CCC26XX->i2cScl = SENSORTAG_CC2650_I2C1_SCL;
pI2CCC26XX->i2cSda = SENSORTAG_CC2650_I2C1_SDA;
}
}
/* I2C objects */
I2CCC26XX_Object i2cCC26XXObjects[SENSORTAG_CC2650_I2CCOUNT];
/* I2C configuration structure, describing which pins are to be used */
const I2CCC26XX_HWAttrs i2cCC26XXHWAttrs[SENSORTAG_CC2650_I2CCOUNT] = {
{I2C0_BASE, INT_I2C, PERIPH_I2C0},
};
const I2C_Config I2C_config[] = {
{&I2CCC26XX_fxnTable, &i2cCC26XXObjects[0], &i2cCC26XXHWAttrs[0]},
{NULL, NULL, NULL}
};
/*
* ======== SENSORTAG_CC2650_initI2C ========
*/
Void SENSORTAG_CC2650_initI2C(Void)
{
/* Initialize drivers */
I2C_init();
/* Initialize IOs */
I2CCC26XX_ioInit(I2C_config, BSP_I2C_INTERFACE_0);
}
#endif /* TI_DRIVERS_I2C_INCLUDED */
#if TI_DRIVERS_SPI_INCLUDED
#include <ti/drivers/SPI.h>
#include <ti/drivers/spi/SPICC26XX.h>
/* Init function of IOs for SPI */
static void SPICC26XX_ioInit(const SPI_Config* SPI_config)
{
/* Initialize the IOs for the SPI0 */
((SPICC26XX_Object*)SPI_config[0].object)->spiMiso = SENSORTAG_CC2650_SPI0_MISO;
((SPICC26XX_Object*)SPI_config[0].object)->spiMosi = SENSORTAG_CC2650_SPI0_MOSI;
((SPICC26XX_Object*)SPI_config[0].object)->spiClk = SENSORTAG_CC2650_SPI0_CLK;
((SPICC26XX_Object*)SPI_config[0].object)->spiCsn = IOID_UNUSED; // Let application control CSN
}
/* SPI objects */
SPICC26XX_Object spiCC26XXObjects[SENSORTAG_CC2650_SPICOUNT];
/* SPI configuration structure */
const SPICC26XX_HWAttrs spiCC26XXHWAttrs[SENSORTAG_CC2650_SPICOUNT] = {
{ SSI0_BASE, INT_SSI0, PERIPH_SSI0 }, /* SENSORTAG_CC2650_SPI0 */
};
const SPI_Config SPI_config[] = {
{ &SPICC26XX_fxnTable, &spiCC26XXObjects[0], &spiCC26XXHWAttrs[0] },
{ NULL, NULL, NULL }
};
/*
* ======== SENSORTAG_CC2650_initSPI ========
*/
Void SENSORTAG_CC2650_initSPI(Void)
{
/* Initialize driver */
SPI_init();
/* Initialize IOs */
SPICC26XX_ioInit(SPI_config);
}
#endif /* TI_DRIVERS_SPI_INCLUDED */
#if TI_DRIVERS_SPI_INCLUDED
#include <ti/drivers/UDMA.h>
#include <ti/drivers/SPI.h>
#include <ti/drivers/spi/SPICC26XXDMA.h>
/* Init function of IOs for SPI */
void SPICC26XXDma_ioInit(const SPI_Config* SPI_config)
{
/* Initialize the IOs for the SPI0 */
((SPICC26XXDMA_Object*)SPI_config[0].object)->spiMiso = SENSORTAG_CC2650_SPI0_MISO;
((SPICC26XXDMA_Object*)SPI_config[0].object)->spiMosi = SENSORTAG_CC2650_SPI0_MOSI;
((SPICC26XXDMA_Object*)SPI_config[0].object)->spiClk = SENSORTAG_CC2650_SPI0_CLK;
((SPICC26XXDMA_Object*)SPI_config[0].object)->spiCsn = IOID_UNUSED;
}
/* SPI objects */
SPICC26XXDMA_Object spiCC26XXDMAobjects[SENSORTAG_CC2650_SPICOUNT];
/* SPI configuration structure, describing which pins are to be used */
const SPICC26XXDMA_HWAttrs spiCC26XXDMAHWAttrs[SENSORTAG_CC2650_SPICOUNT] = {
{
SSI0_BASE, INT_SSI0, PERIPH_SSI0, UDMA0_BASE,
UDMA_CHAN_SSI0_RX, UDMA_CHAN_SSI0_TX,
},
{
SSI1_BASE, INT_SSI1, PERIPH_SSI1, UDMA0_BASE,
UDMA_CHAN_SSI1_RX, UDMA_CHAN_SSI1_TX,
}
};
const SPI_Config SPI_config[] = {
{&SPICC26XXDMA_fxnTable, &spiCC26XXDMAobjects[0], &spiCC26XXDMAHWAttrs[0]},
{&SPICC26XXDMA_fxnTable, &spiCC26XXDMAobjects[1], &spiCC26XXDMAHWAttrs[1]},
{NULL, NULL, NULL},
};
/*
* ======== SENSORTAG_CC2650_initSPI ========
*/
Void SENSORTAG_CC2650_initSPI(Void)
{
/* Initialize drivers */
UDMA_init();
SPI_init();
/* Initialize IOs */
SPICC26XXDma_ioInit(SPI_config);
}
#endif /* TI_DRIVERS_SPI_INCLUDED */
#if TI_DRIVERS_UART_INCLUDED
#include <ti/drivers/UART.h>
#include <ti/drivers/uart/UARTCC26XX.h>
/* Init function of IOs for SPI */
void UARTCC26XX_ioInit(const UART_Config* UART_config)
{
uint32_t pin;
/* Initialize the IOs for the UART0 */
pin = gpioHWAttrs[SENSORTAG_CC2650_UART_TX].pin;
((UARTCC26XX_Object*)UART_config[0].object)->uartTx = PIN2IOID(pin);
pin = gpioHWAttrs[SENSORTAG_CC2650_UART_RX].pin;
((UARTCC26XX_Object*)UART_config[0].object)->uartRx = PIN2IOID(pin);
((UARTCC26XX_Object*)UART_config[0].object)->uartCts = IOID_UNUSED;
((UARTCC26XX_Object*)UART_config[0].object)->uartRts = IOID_UNUSED;
}
/* UART objects */
UARTCC26XX_Object uartCC26XXObjects[SENSORTAG_CC2650_UARTCOUNT];
/* UART configuration structure */
const UARTCC26XX_HWAttrs uartCC26XXHWAttrs[SENSORTAG_CC2650_UARTCOUNT] = {
{UART0_BASE, INT_UART0, PERIPH_UART0}, /* SENSORTAG_CC2650_UART0 */
};
const UART_Config UART_config[] = {
{ &UARTCC26XX_fxnTable, &uartCC26XXObjects[0], &uartCC26XXHWAttrs[0] },
{ NULL, NULL, NULL }
};
/*
* ======== SENSORTAG_CC2650_initUART ========
*/
Void SENSORTAG_CC2650_initUART()
{
/* Initialize the UART driver */
UART_init();
/* Initialize the UART IOs */
UARTCC26XX_ioInit(UART_config);
}
#endif /* TI_DRIVERS_UART_INCLUDED */
#if TI_DRIVERS_WATCHDOG_INCLUDED
#include <ti/drivers/Watchdog.h>
#include <ti/drivers/watchdog/WatchdogCC26XX.h>
/* Watchdog objects */
WatchdogCC26XX_Object watchdogCC26XXObjects[SENSORTAG_CC2650_WATCHDOGCOUNT];
/* Watchdog configuration structure */
const WatchdogCC26XX_HWAttrs watchdogCC26XXHWAttrs[SENSORTAG_CC2650_WATCHDOGCOUNT] = {
/* SENSORTAG_CC2650_WATCHDOG0 with 1 sec period at default CPU clock freq */
{WDT_BASE, INT_WATCHDOG, 48000000/2},
};
const Watchdog_Config Watchdog_config[] = {
{&WatchdogCC26XX_fxnTable, &watchdogCC26XXObjects[0], &watchdogCC26XXHWAttrs[0]},
{NULL, NULL, NULL},
};
/*
* ======== SENSORTAG_CC2650_initWatchdog ========
*/
Void SENSORTAG_CC2650_initWatchdog()
{
/* Initialize the Watchdog driver */
Watchdog_init();
}
#endif /* TI_DRIVERS_WATCHDOG_INCLUDED */

View File

@@ -0,0 +1,277 @@
/*
* Copyright (c) 2014 - 2015, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/** ============================================================================
* @file SENSORTAG_CC2650.h
*
* @brief SENSORTAG_CC2650 Board Specific APIs (CC2650)
*
* The SENSORTAG_CC2650 header file should be included in an application as follows:
* @code
* #include <SENSORTAG_CC2650.h>
* @endcode
*
* ============================================================================
*/
#ifndef __SENSORTAG_CC2650_H
#define __SENSORTAG_CC2650_H
#ifdef __cplusplus
extern "C" {
#endif
#include <ti/drivers/GPIO.h>
#include <ti/drivers/I2C.h>
#include <ti/drivers/SPI.h>
#include <ti/drivers/UART.h>
#include <ti/drivers/Watchdog.h>
#include <driverlib/ioc.h>
#if defined(__IAR_SYSTEMS_ICC__)
#include <intrinsics.h>
#define PIN2IOID(pin) (31 - __CLZ(pin))
#endif
#if defined(__TI_COMPILER_VERSION__)
#define PIN2IOID(pin) (31 - __clz(pin))
#endif
/* LEDs on SENSORTAG_CC2650 are active high. */
#define SENSORTAG_CC2650_LED_OFF (0)
#define SENSORTAG_CC2650_LED_ON (~0)
/* MPU_POWER on SENSORTAG_CC2650 is active high. */
#define SENSORTAG_CC2650_MPU_POWER_OFF (0)
#define SENSORTAG_CC2650_MPU_POWER_ON (~0)
/* MIC_POWER on SENSORTAG_CC2650 is active high. */
#define SENSORTAG_CC2650_MIC_POWER_OFF (0)
#define SENSORTAG_CC2650_MIC_POWER_ON (~0)
/* BUZZER on SENSORTAG_CC2650 is active high. */
#define SENSORTAG_CC2650_BUZZER_OFF (0)
#define SENSORTAG_CC2650_BUZZER_ON (~0)
/* FLASH_CS on SENSORTAG_CC2650 is active low. */
#define SENSORTAG_CC2650_FLASH_CS_OFF (~0)
#define SENSORTAG_CC2650_FLASH_CS_ON (0)
/* IO pin definitions */
#define BSP_IOID_BUTTON2 IOID_0
#define BSP_IOID_TMP_RDY IOID_1
#define BSP_IOID_AUDIO_DI IOID_2
#define BSP_IOID_REED_INT IOID_3
#define BSP_IOID_BUTTON1 IOID_4
#define BSP_IOID_SDA IOID_5
#define BSP_IOID_SCL IOID_6
#define BSP_IOID_MPU_INT IOID_7
#define BSP_IOID_SDA_HP IOID_8
#define BSP_IOID_SCL_HP IOID_9
#define BSP_IOID_LED1 IOID_10
#define BSP_IOID_IO7_SCLK IOID_11 // Skin + Flash
#define BSP_IOID_MPU_POWER IOID_12
#define BSP_IOID_MIC_POWER IOID_13
#define BSP_IOID_FLASH_CS IOID_14 // Flash
#define BSP_IOID_LED2 IOID_15
#define BSP_IOID_IO12_TDO IOID_16 // Skin
#define BSP_IOID_IO8_TDI IOID_17 // Skin
#define BSP_IOID_IO9_UARTRX_MISO IOID_18 // Skin + Flash
#define BSP_IOID_IO10_UARTTX_MOSI IOID_19 // Skin + Flash
#define BSP_IOID_IO11_CSN IOID_20 // Skin + Flash
#define BSP_IOID_BUZZER_EN IOID_21
#define BSP_IOID_IO6_PWM IOID_22 // Skin
#define BSP_IOID_IO2 IOID_23 // Skin
#define BSP_IOID_IO1 IOID_24 // Skin
#define BSP_IOID_IO0 IOID_25 // Skin
#define BSP_IOID_VDD IOID_26
#define BSP_IOID_IO3 IOID_27 // Skin
#define BSP_IOID_IO4 IOID_28 // Skin
#define BSP_IOID_IO5 IOID_29 // Skin
#define BSP_IOID_SKIN_ID IOID_30 // Skin
/* SPI0 pin default pin mapping */
#define SENSORTAG_CC2650_SPI0_CSN BSP_IOID_FLASH_CS
#define SENSORTAG_CC2650_SPI0_CLK BSP_IOID_IO7_SCLK
#define SENSORTAG_CC2650_SPI0_MOSI BSP_IOID_IO10_UARTTX_MOSI
#define SENSORTAG_CC2650_SPI0_MISO BSP_IOID_IO9_UARTRX_MISO
/* I2C pin default pin mapping */
#define SENSORTAG_CC2650_I2C0_SCL BSP_IOID_SCL
#define SENSORTAG_CC2650_I2C0_SDA BSP_IOID_SDA
#define SENSORTAG_CC2650_I2C1_SCL BSP_IOID_SCL_HP
#define SENSORTAG_CC2650_I2C1_SDA BSP_IOID_SDA_HP
/* GPIO_Callbacks structure for GPIO interrupts */
extern const GPIO_Callbacks SENSORTAG_CC2650_gpioPortCallbacks;
/*!
* @def SENSORTAG_CC2650_GPIOName
* @brief Enum of GPIO names on the SENSORTAG_CC2650 dev board
*/
typedef enum SENSORTAG_CC2650_GPIOName {
SENSORTAG_CC2650_LED1 = 0,
SENSORTAG_CC2650_LED2,
SENSORTAG_CC2650_BUTTON2,
SENSORTAG_CC2650_BUTTON1,
SENSORTAG_CC2650_REED_INT,
SENSORTAG_CC2650_BUZZER_EN,
SENSORTAG_CC2650_UART_RX,
SENSORTAG_CC2650_UART_TX,
SENSORTAG_CC2650_MPU_POWER,
SENSORTAG_CC2650_FLASH_CS,
SENSORTAG_CC2650_MPU_INT,
SENSORTAG_CC2650_TMP_RDY,
SENSORTAG_CC2650_MIC_POWER,
SENSORTAG_CC2650_GPIOCOUNT
} SENSORTAG_CC2650_GPIOName;
/*!
* @def SENSORTAG_CC2650_I2CName
* @brief Enum of I2C names on the SENSORTAG_CC2650 dev board
*/
typedef enum SENSORTAG_CC2650_I2CName {
SENSORTAG_CC2650_I2C0 = 0,
SENSORTAG_CC2650_I2CCOUNT
} SENSORTAG_CC2650_I2CName;
/*!
* @def SENSORTAG_CC2650_SPIName
* @brief Enum of SPI names on the SENSORTAG_CC2650 dev board
*/
typedef enum SENSORTAG_CC2650_SPIName {
SENSORTAG_CC2650_SPI0 = 0,
SENSORTAG_CC2650_SPICOUNT
} SENSORTAG_CC2650_SPIName;
/*!
* @def SENSORTAG_CC2650_UARTName
* @brief Enum of UARTs on the SENSORTAG_CC2650 dev board
*/
typedef enum SENSORTAG_CC2650_UARTName {
SENSORTAG_CC2650_UART0 = 0,
SENSORTAG_CC2650_UARTCOUNT
} SENSORTAG_CC2650_UARTName;
/*!
* @def SENSORTAG_CC2650_WatchdogName
* @brief Enum of Watchdogs on the SENSORTAG_CC2650 dev board
*/
typedef enum SENSORTAG_CC2650_WatchdogName {
SENSORTAG_CC2650_WATCHDOG0 = 0,
SENSORTAG_CC2650_WATCHDOGCOUNT
} SENSORTAG_CC2650_WatchdogName;
/*!
* @brief Initialize board specific DMA settings
*
* This function creates a hwi in case the DMA controller creates an error
* interrupt, enables the DMA and supplies it with a uDMA control table.
*/
extern Void SENSORTAG_CC2650_initDMA(Void);
/*!
* @brief Initialize the general board specific settings
*
* This function initializes the general board specific settings. This include
* - Flash wait states based on the process
* - Disable clock source to watchdog module
* - Enable clock sources for peripherals
*/
extern Void SENSORTAG_CC2650_initGeneral(Void);
/*!
* @brief Initialize board specific GPIO settings
*
* This function initializes the board specific GPIO settings and
* then calls the GPIO_init API to initialize the GPIO module.
*
* The GPIOs controlled by the GPIO module are determined by the GPIO_config
* variable.
*/
extern Void SENSORTAG_CC2650_initGPIO(Void);
/*!
* @brief Initialize board specific I2C settings
*
* This function initializes the board specific I2C settings and then calls
* the I2C_init API to initialize the I2C module.
*
* The I2C peripherals controlled by the I2C module are determined by the
* I2C_config variable.
*/
extern Void SENSORTAG_CC2650_initI2C(Void);
/*!
* @brief Assigns pins to I2C controller
*/
extern Void I2CCC26XX_ioInit(const I2C_Config* I2C_config, int i2cInterfaceID);
/*!
* @brief Initialize board specific SPI settings
*
* This function initializes the board specific SPI settings and then calls
* the SPI_init API to initialize the SPI module.
*
* The SPI peripherals controlled by the SPI module are determined by the
* SPI_config variable.
*/
extern Void SENSORTAG_CC2650_initSPI(Void);
/*!
* @brief Initialize board specific UART settings
*
* This function initializes the board specific UART settings and then calls
* the UART_init API to initialize the UART module.
*
* The UART peripherals controlled by the UART module are determined by the
* UART_config variable.
*/
extern Void SENSORTAG_CC2650_initUART(Void);
/*!
* @brief Initialize board specific Watchdog settings
*
* This function initializes the board specific Watchdog settings and then
* calls the Watchdog_init API to initialize the Watchdog module.
*
* The Watchdog peripherals controlled by the Watchdog module are determined
* by the Watchdog_config variable.
*/
extern Void SENSORTAG_CC2650_initWatchdog(Void);
#ifdef __cplusplus
}
#endif
#endif /* __SENSORTAG_CC2650_H */

View File

@@ -0,0 +1,152 @@
//*****************************************************************************
//! @file bsp.h
//! @brief Board support package header file for CC26xx on SmartRF06EB.
//!
//! Revised $Date: 2014-03-07 10:33:11 +0100 (fr, 07 mar 2014) $
//! Revision $Revision: 12329 $
//
// Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// Neither the name of Texas Instruments Incorporated nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//****************************************************************************/
#ifndef __BSP_H__
#define __BSP_H__
/******************************************************************************
* If building with a C++ compiler, make all of the definitions in this header
* have a C binding.
******************************************************************************/
#ifdef __cplusplus
extern "C"
{
#endif
/******************************************************************************
* INCLUDES
*/
#include <stdint.h>
#include <inc/hw_types.h>
#include <inc/hw_memmap.h>
#include <inc/hw_sysctl.h> // Access to the GET_MCU_CLOCK define
#include <inc/hw_ioc.h>
#include <driverlib/ioc.h>
#include <driverlib/gpio.h>
/******************************************************************************
* DEFINES
*/
// Clock speed defines
#define BSP_CLK_SPD_48MHZ 48000000UL
#define BSP_CLK_SPD_24MHZ 24000000UL
#define BSP_CLK_SPD_12MHZ 12000000UL
#define BSP_CLK_SPD_6MHZ 6000000UL
#define BSP_CLK_SPD_3MHZ 3000000UL
#define BSP_CLK_SPD_1_5MHZ 1500000UL
#define BSP_CLK_SPD_750KHZ 750000UL
#define BSP_CLK_SPD_375KHZ 375000UL
#define BSP_CLK_SPD_187_5KHZ 187500UL
//! Default system clock speed
#define BSP_SYS_CLK_SPD BSP_CLK_SPD_48MHZ
// Board LED defines
#define BSP_IOID_LED_1 IOID_10
#define BSP_LED_1 (1 << BSP_IOID_LED_1)
#define BSP_IOID_LED_2 IOID_15
#define BSP_LED_2 (1 << BSP_IOID_LED_2)
#define BSP_LED_ALL (BSP_LED_1 | BSP_LED_2)
// Board buzzer defines
#define BSP_IOID_BUZZER IOID_21
#define BSP_BUZZER (1 << BSP_IOID_BUZZER)
// Board sensor power control defines
#define BSP_IOID_MPU_POWER IOID_12
#define BSP_MPU_POWER (1 << BSP_IOID_MPU_POWER)
#define BSP_IOID_MIC_POWER IOID_13
#define BSP_MIC_POWER (1 << BSP_IOID_MIC_POWER)
// Board key defines
#define BSP_IOID_KEY_LEFT IOID_0
#define BSP_IOID_KEY_RIGHT IOID_4
#define BSP_KEY_LEFT (1 << BSP_IOID_KEY_LEFT)
#define BSP_KEY_RIGHT (1 << BSP_IOID_KEY_RIGHT)
#define BSP_KEY_DIR_ALL (BSP_KEY_LEFT | BSP_KEY_RIGHT )
#define BSP_KEY_ALL (BSP_KEY_DIR_ALL) //!< Bitmask of all keys
// Board flash defines
#define BSP_IOID_FLASH_CS IOID_14
#define BSP_FLASH_CS (1 << BSP_IOID_FLASH_CS)
// Board reed relay defines
#define BSP_IOID_REED_RELAY_INT IOID_1
#define BSP_REED_RELAY_INT (1 << BSP_IOID_REED_RELAY_INT)
// Board sensor interface
#define BSP_IOID_MPU_INT IOID_7
#define BSP_MPU_INT (1 << BSP_IOID_MPU_INT)
#define BSP_IOD_SDA IOID_5
#define BSP_IOD_SCL IOID_6
#define BSP_IOD_SDA_HP IOID_8
#define BSP_IOD_SCL_HP IOID_9
// Board Light Skin interface
#define BSP_LIGHT_IOID_WHITE IOID_27
#define BSP_LIGHT_WHITE (1 << BSP_LIGHT_IOID_WHITE)
#define BSP_LIGHT_IOID_GREEN IOID_23
#define BSP_LIGHT_GREEN (1 << BSP_LIGHT_IOID_GREEN)
#define BSP_LIGHT_IOID_BLUE IOID_24
#define BSP_LIGHT_BLUE (1 << BSP_LIGHT_IOID_BLUE)
#define BSP_LIGHT_IOID_RED IOID_25
#define BSP_LIGHT_RED (1 << BSP_LIGHT_IOID_RED)
#define BSP_LIGHT_DIR_ALL ( BSP_LIGHT_WHITE | BSP_LIGHT_RED | BSP_LIGHT_BLUE | BSP_LIGHT_GREEN)
#define BSP_LIGHT_ALL ( BSP_LIGHT_DIR_ALL )
/******************************************************************************
* FUNCTION PROTOTYPES
*/
extern void bspInit(uint32_t ui32SysClockSpeed);
extern void bspSleep(void);
/******************************************************************************
* Mark the end of the C bindings section for C++ compilers.
******************************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* #ifndef __BSP_H__ */

View File

@@ -0,0 +1,70 @@
/*
* Copyright (c) 2014, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <inc/hw_types.h>
#include <inc/hw_memmap.h>
#include <driverlib/ioc.h>
#include <driverlib/timer.h>
#include "bsp.h"
#include "bsp_buzzer.h"
void bspBuzzerInit(void)
{
// Configure pin as PWM output
IOCPortConfigureSet(BSP_IOID_BUZZER, IOC_PORT_MCU_TIMER0, IOC_STD_OUTPUT);
// Use GPT0, Channel A (16 bit timer)
TimerConfigure(GPT0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PWM);
}
void bspBuzzerEnable(int freq)
{
// Stop timer
TimerDisable(GPT0_BASE, TIMER_A);
if (freq > 0)
{
uint32_t load;
load = (48000000 / freq );
// Timer A; freq 48 MHz / freq
TimerLoadSet(GPT0_BASE, TIMER_A, load);
TimerMatchSet(GPT0_BASE, TIMER_A, load / 2 ); // 50 per cent duty cycle
// Start timer
TimerEnable(GPT0_BASE, TIMER_A);
}
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright (c) 2014, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef BSP_BUZZER_H
#define BSP_BUZZER_H
extern void bspBuzzerInit(void);
extern void bspBuzzerEnable(int frequency);
#endif // BSP_BUZZER_H

View File

@@ -0,0 +1,228 @@
/******************************************************************************
* Filename: bsp_i2c.c
* Revised: $Date: $
* Revision: $Revision: $
*
* Description: Layer added on top of RTOS driver for backward
* compatibility with non RTOS I2C driver.
*
* Copyright (C) 2014 - 2015 Texas Instruments Incorporated - http://www.ti.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#ifdef TI_DRIVERS_I2C_INCLUDED
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/family/arm/cc26xx/Power.h>
#include <ti/drivers/i2c/I2CCC26XX.h>
#include <driverlib/prcm.h>
#include "Board.h"
#include "bsp_i2c.h"
//*****************************************************************************
// I2C setup
extern I2CCC26XX_HWAttrs i2cCC26xxHWAttrs[];
static uint8_t slaveAddr;
static uint8_t interface;
static I2C_Handle I2Chandle;
static I2C_Params I2CParams;
static Semaphore_Struct mutex;
static I2C_Transaction masterTransaction;
#ifdef POWER_SAVING
static bool checkI2cConstraint;
#endif
//
// Burst write to an I2C device
//
bool bspI2cWrite(uint8_t *data, uint8_t len)
{
masterTransaction.writeCount = len;
masterTransaction.writeBuf = data;
masterTransaction.readCount = 0;
masterTransaction.readBuf = NULL;
masterTransaction.slaveAddress = slaveAddr;
return I2C_transfer(I2Chandle, &masterTransaction) == TRUE;
}
//
// Single write to an I2C device
//
bool bspI2cWriteSingle(uint8_t data)
{
uint8_t d;
// This is not optimal but is an implementation
d = data;
return bspI2cWrite(&d, 1);
}
//
// Burst read from an I2C device
//
bool bspI2cRead(uint8_t *data, uint8_t len)
{
masterTransaction.writeCount = 0;
masterTransaction.writeBuf = NULL;
masterTransaction.readCount = len;
masterTransaction.readBuf = data;
masterTransaction.slaveAddress = slaveAddr;
return I2C_transfer(I2Chandle, &masterTransaction) == TRUE;
}
//
// Write and read in one operation
//
bool bspI2cWriteRead(uint8_t *wdata, uint8_t wlen, uint8_t *rdata, uint8_t rlen)
{
masterTransaction.writeCount = wlen;
masterTransaction.writeBuf = wdata;
masterTransaction.readCount = rlen;
masterTransaction.readBuf = rdata;
masterTransaction.slaveAddress = slaveAddr;
return I2C_transfer(I2Chandle, &masterTransaction) == TRUE;
}
void bspI2cSelect(uint8_t newInterface, uint8_t address)
{
/* Acquire I2C resource */
Semaphore_pend(Semaphore_handle(&mutex),BIOS_WAIT_FOREVER);
#ifdef POWER_SAVING
if (!checkI2cConstraint)
{
/* Prevent the system from entering standby while using I2C. */
Power_setConstraint(Power_SB_DISALLOW);
checkI2cConstraint = true;
}
#endif
slaveAddr = address;
if (newInterface != interface)
{
interface = newInterface;
I2C_close(I2Chandle);
if (interface == BSP_I2C_INTERFACE_0)
{
i2cCC26xxHWAttrs[CC2650_I2C0].sdaPin = Board_I2C0_SDA0;
i2cCC26xxHWAttrs[CC2650_I2C0].sclPin = Board_I2C0_SCL0;
// Secondary I2C as GPIO
IOCPinTypeGpioInput(Board_I2C0_SDA1);
IOCPinTypeGpioInput(Board_I2C0_SCL1);
IOCIOPortPullSet(Board_I2C0_SDA1, IOC_NO_IOPULL);
IOCIOPortPullSet(Board_I2C0_SCL1, IOC_NO_IOPULL);
}
else if (interface == BSP_I2C_INTERFACE_1)
{
i2cCC26xxHWAttrs[CC2650_I2C0].sdaPin = Board_I2C0_SDA1;
i2cCC26xxHWAttrs[CC2650_I2C0].sclPin = Board_I2C0_SCL1;
// Primary I2C as GPIO
IOCPinTypeGpioInput(Board_I2C0_SDA0);
IOCPinTypeGpioInput(Board_I2C0_SCL0);
IOCIOPortPullSet(Board_I2C0_SDA0, IOC_NO_IOPULL);
IOCIOPortPullSet(Board_I2C0_SCL0, IOC_NO_IOPULL);
}
I2Chandle = I2C_open(Board_I2C, &I2CParams);
}
}
void bspI2cDeselect(void)
{
#ifdef POWER_SAVING
/* Allow the system to enter standby */
if (checkI2cConstraint)
{
Power_releaseConstraint(Power_SB_DISALLOW);
checkI2cConstraint = false;
}
#endif
/* Release I2C resource */
Semaphore_post(Semaphore_handle(&mutex));
}
void bspI2cInit(void)
{
Semaphore_Params semParamsMutex;
// Create protection semaphore
Semaphore_Params_init(&semParamsMutex);
semParamsMutex.mode = Semaphore_Mode_BINARY;
Semaphore_construct(&mutex, 1, &semParamsMutex);
// Reset the I2C controller
HWREG(PRCM_BASE + PRCM_O_RESETI2C) = PRCM_RESETI2C_I2C;
I2C_init();
I2C_Params_init(&I2CParams);
I2CParams.bitRate = I2C_400kHz;
I2Chandle = I2C_open(Board_I2C, &I2CParams);
// Initialize local variables
slaveAddr = 0xFF;
interface = BSP_I2C_INTERFACE_0;
#ifdef POWER_SAVING
checkI2cConstraint = false;
#endif
/*
if (I2Chandle == NULL) {
while(1) {
// wait here for ever
}
}
*/
}
void bspI2cReset(void)
{
I2C_close(I2Chandle);
I2Chandle = I2C_open(Board_I2C, &I2CParams);
}
#endif

View File

@@ -0,0 +1,82 @@
/**************************************************************************************************
* Filename: bsp_i2c.h
* Revised: $Date: $
* Revision: $Revision: $
*
* Description: Layer added on top of RTOS driver for backward
* compatibility with non RTOS I2C driver.
*
* Copyright (C) 2014 - 2015 Texas Instruments Incorporated - http://www.ti.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef BSP_I2C_H
#define BSP_I2C_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
* INCLUDES
*/
#include "stdbool.h"
#include "stdint.h"
#include <inc/hw_memmap.h>
/*********************************************************************
* CONSTANTS
*/
#define BSP_I2C_INTERFACE_0 0
#define BSP_I2C_INTERFACE_1 1
#define BSP_I2C_INTERFACE_NONE -1
/*********************************************************************
* TYPEDEFS
*/
/*********************************************************************
* FUNCTIONS
*/
void bspI2cInit(void);
void bspI2cSelect(uint8_t interface, uint8_t slaveAddress);
bool bspI2cRead(uint8_t *data, uint8_t len);
bool bspI2cWrite(uint8_t *data, uint8_t len);
bool bspI2cWriteSingle(uint8_t data);
bool bspI2cWriteRead(uint8_t *wdata, uint8_t wlen, uint8_t *rdata, uint8_t rlen);
void bspI2cDeselect(void);
void bspI2cDisable(void);
void bspI2cReset(void);
/////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
}
#endif
#endif /* BSP_I2C_H */

View File

@@ -0,0 +1,183 @@
/******************************************************************************
* Filename: bsp_spi.c
* Revised: $Date$
* Revision: $Revision$
*
* Description: Layer added on top of RTOS driver for backward
* compatibility with non RTOS SPI driver.
*
* Copyright (C) 2014 - 2015 Texas Instruments Incorporated - http://www.ti.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#ifdef TI_DRIVERS_SPI_INCLUDED
#include <ti/sysbios/family/arm/cc26xx/Power.h>
#include <ti/drivers/spi/SPICC26XXDMA.h>
#include <ti/drivers/dma/UDMACC26XX.h>
#include <driverlib/ssi.h>
#include "Board.h"
#include "bsp_spi.h"
#include "string.h"
//*****************************************************************************
// SPI setup
static SPI_Handle spiHandle = NULL;
static SPI_Params spiParams;
//
// Write to an SPI device
//
int bspSpiWrite(const uint8_t *buf, size_t length)
{
SPI_Transaction masterTransaction;
bool success;
masterTransaction.count = length;
masterTransaction.txBuf = (void*)buf;
masterTransaction.arg = NULL;
masterTransaction.rxBuf = NULL;
success = SPI_transfer(spiHandle, &masterTransaction);
return success ? 0 : -1;
}
//
// Read from an SPI device
//
int bspSpiRead(uint8_t *buf, size_t length)
{
SPI_Transaction masterTransaction;
bool success;
masterTransaction.count = length;
masterTransaction.txBuf = NULL;
masterTransaction.arg = NULL;
masterTransaction.rxBuf = buf;
success = SPI_transfer(spiHandle, &masterTransaction);
return success ? 0 : -1;
}
//
// Write and read from an SPI device
//
int bspSpiWriteRead(uint8_t *buf, uint8_t wlen, uint8_t rlen)
{
SPI_Transaction masterTransaction;
bool success;
masterTransaction.count = wlen + rlen;
masterTransaction.txBuf = buf;
masterTransaction.arg = NULL;
masterTransaction.rxBuf = buf;
success = SPI_transfer(spiHandle, &masterTransaction);
if (success)
{
memcpy(buf,buf+wlen,rlen);
}
return success ? 0 : -1;
}
//
// Initialize the SPI communication
//
void bspSpiOpen(void)
{
if (spiHandle == NULL)
{
/* Configure SPI as master, 4 mHz bit rate*/
SPI_Params_init(&spiParams);
spiParams.bitRate = 4000000;
// spiParams.frameFormat = SPI_POL1_PHA1;
spiParams.mode = SPI_MASTER;
spiParams.transferMode = SPI_MODE_BLOCKING;
/* Attempt to open SPI. */
spiHandle = SPI_open(Board_SPI0, &spiParams);
if (spiHandle == NULL)
{
while(1) {
// wait here forever
}
}
}
}
/* See bsp_spi.h file for description */
void bspSpiFlush(void)
{
/* make sure SPI hardware module is done */
while(SSIBusy(((SPICC26XX_HWAttrs*)spiHandle->hwAttrs)->baseAddr))
{ };
}
void bspSpiFlashSelect(bool select)
{
if (select)
{
PIN_setOutputValue(hGpioPin, Board_SPI_FLASH_CS, 0);
}
else
{
PIN_setOutputValue(hGpioPin, Board_SPI_FLASH_CS, 1);
}
}
void bspSpiLcdSelect(bool select)
{
if (select)
{
PIN_setOutputValue(hGpioPin, Board_SPI_DEVPK_CS, 0);
}
else
{
PIN_setOutputValue(hGpioPin, Board_SPI_DEVPK_CS, 1);
}
}
/* See bsp_spi.h file for description */
void bspSpiClose(void)
{
if (spiHandle != NULL)
{
SPI_close(spiHandle);
spiHandle = NULL;
}
}
#endif

View File

@@ -0,0 +1,102 @@
/**
@file bsp_spi.h
@brief SPI-bus abstraction
<!--
Copyright 2014 - 2015 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
-->
*/
#ifndef BSP_SPI_H
#define BSP_SPI_H
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C"
{
#endif
/**
* Initialize SPI interface
*
* @return none
*/
extern void bspSpiOpen(void);
/**
* Close SPI interface
*
* @return True when successful.
*/
extern void bspSpiClose(void);
/**
* Clear data from SPI interface
*
* @return none
*/
extern void bspSpiFlush(void);
/**
* Read from an SPI device
*
* @return 0 when successful.
*/
extern int bspSpiRead(uint8_t *buf, size_t length);
/**
* Write to an SPI device
*
* @return 0 when successful.
*/
extern int bspSpiWrite(const uint8_t *buf, size_t length);
/**
* Write and read to/from an SPI device in the same transaction
*
* @return 0 when successful.
*/
extern int bspSpiWriteRead(uint8_t *buf, uint8_t wlen, uint8_t rlen);
/**
* Select the external flash device (chip select)
*
* @return 0 when successful.
*/
void bspSpiFlashSelect(bool select);
#ifdef __cplusplus
}
#endif
#endif /* BSP_SPI_H */

View File

@@ -0,0 +1,485 @@
/**
@file ext_flash.c
@brief Experimental base loader storage implementation for W25X20CL
<!--
Copyright 2014 - 2015 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
-->
*/
#ifndef TI_DRIVERS_SPI_INCLUDED
#include <driverlib/gpio.h>
#endif
#include "bsp.h"
#include "bsp_spi.h"
#include "ext_flash.h"
/*
* Implementation for WinBond W25X20CL Flash
*
*/
/* Instruction codes */
#define BLS_CODE_PROGRAM 0x02 /**< Page Program */
#define BLS_CODE_READ 0x03 /**< Read Data */
#define BLS_CODE_READ_STATUS 0x05 /**< Read Status Register */
#define BLS_CODE_WRITE_ENABLE 0x06 /**< Write Enable */
#define BLS_CODE_SECTOR_ERASE 0x20 /**< Sector Erase */
#define BLS_CODE_MDID 0x90 /**< Manufacturer Device ID */
#define BLS_CODE_DP 0xB9 /**< Power down */
#define BLS_CODE_RDP 0xAB /**< Power standby */
/* Erase instructions */
#define BLS_CODE_ERASE_4K 0x20 /**< Sector Erase */
#define BLS_CODE_ERASE_32K 0x52
#define BLS_CODE_ERASE_64K 0xD8
#define BLS_CODE_ERASE_ALL 0xC7 /**< Mass Erase */
/* Bitmasks of the status register */
#define BLS_STATUS_SRWD_BM 0x80
#define BLS_STATUS_BP_BM 0x0C
#define BLS_STATUS_WEL_BM 0x02
#define BLS_STATUS_WIP_BM 0x01
#define BLS_STATUS_BIT_BUSY 0x01 /**< Busy bit of the status register */
/* Part specific constants */
#define BLS_MANUFACTURER_ID 0xEF
#define BLS_DEVICE_ID 0x11
#define BLS_PROGRAM_PAGE_SIZE 256
#define BLS_ERASE_SECTOR_SIZE 4096
static int extFlashWaitReady(void);
static int extFlashWaitPowerDown(void);
/**
* Clear external flash CSN line
*/
static void extFlashSelect(void)
{
#ifndef TI_DRIVERS_SPI_INCLUDED
GPIOPinWrite(BSP_FLASH_CS, 0);
#else
bspSpiFlashSelect(true);
#endif
}
/**
* Set external flash CSN line
*/
static void extFlashDeselect(void)
{
#ifndef TI_DRIVERS_SPI_INCLUDED
GPIOPinWrite(BSP_FLASH_CS, 1);
#else
bspSpiFlashSelect(false);
#endif
}
/******************************************************************************
* @fn extFlashPowerDown
*
* @brief Put the device in power save mode. No access to data; only
* the status register is accessible.
*
* @param none
*
* @return Returns true SPI transactions succeed
******************************************************************************/
static bool bspFlashExtPowerDown(void)
{
uint8_t cmd;
bool success;
cmd = BLS_CODE_DP;
extFlashSelect();
success = bspSpiWrite(&cmd,sizeof(cmd)) == 0;
extFlashDeselect();
return success;
}
/******************************************************************************
* @fn extFlashPowerStandby
*
* @brief Take device out of power save mode and prepare it for normal operation
*
* @param none
*
* @return Returns true if command successfully written
******************************************************************************/
static bool extFlashPowerStandby(void)
{
uint8_t cmd;
bool success;
cmd = BLS_CODE_RDP;
extFlashSelect();
success = bspSpiWrite(&cmd,sizeof(cmd)) == 0;
extFlashDeselect();
if (success)
success = extFlashWaitReady() == 0;
return success;
}
/**
* Verify the flash part.
* @return True when successful.
*/
static bool extFlashVerifyPart(void)
{
const uint8_t wbuf[] = { BLS_CODE_MDID, 0xFF, 0xFF, 0x00 };
uint8_t rbuf[2];
extFlashSelect();
int ret = bspSpiWrite(wbuf, sizeof(wbuf));
if (ret)
{
extFlashDeselect();
return false;
}
ret = bspSpiRead(rbuf, sizeof(rbuf));
extFlashDeselect();
if (ret || rbuf[0] != BLS_MANUFACTURER_ID || rbuf[1] != BLS_DEVICE_ID)
{
return false;
}
return true;
}
/**
* Wait till previous erase/program operation completes.
* @return Zero when successful.
*/
static int extFlashWaitReady(void)
{
const uint8_t wbuf[1] = { BLS_CODE_READ_STATUS };
int ret;
/* Throw away all garbages */
extFlashSelect();
bspSpiFlush();
extFlashDeselect();
for (;;)
{
uint8_t buf;
/* Note that this temporary implementation is not
* energy efficient.
* Thread could have yielded while waiting for flash
* erase/program to complete.
*/
extFlashSelect();
bspSpiWrite(wbuf, sizeof(wbuf));
ret = bspSpiRead(&buf,sizeof(buf));
extFlashDeselect();
if (ret)
{
/* Error */
return -2;
}
if (!(buf & BLS_STATUS_BIT_BUSY))
{
/* Now ready */
break;
}
}
return 0;
}
/**
* Wait until the part has entered power down (status register is 0xFF)
* @return Zero when successful.
*/
static int extFlashWaitPowerDown(void)
{
const uint8_t wbuf[1] = { BLS_CODE_READ_STATUS };
int ret;
/* Throw away all garbages */
bspSpiFlush();
for (;;)
{
uint8_t buf;
/* Note that this temporary implementation is not
* energy efficient.
* Thread could have yielded while waiting for flash
* erase/program to complete.
*/
extFlashSelect();
bspSpiWrite(wbuf, sizeof(wbuf));
ret = bspSpiRead(&buf,sizeof(buf));
extFlashDeselect();
if (ret)
{
/* Error */
return -2;
}
if (buf == 0xFF)
{
/* Now ready */
break;
}
}
return 0;
}
/**
* Enable write.
* @return Zero when successful.
*/
static int extFlashWriteEnable(void)
{
const uint8_t wbuf[] = { BLS_CODE_WRITE_ENABLE };
extFlashSelect();
int ret = bspSpiWrite(wbuf,sizeof(wbuf));
extFlashDeselect();
if (ret)
{
return -3;
}
return 0;
}
/* See ext_flash.h file for description */
bool extFlashOpen(void)
{
#ifndef TI_DRIVERS_SPI_INCLUDED
bspSpiOpen();
/* GPIO pin configuration */
IOCPinTypeGpioOutput(BSP_IOID_FLASH_CS);
#endif
/* Default output to clear chip select */
extFlashDeselect();
/* Put the part is standby mode */
extFlashPowerStandby();
return extFlashVerifyPart();
}
/* See ext_flash.h file for description */
void extFlashClose(void)
{
// Put the part in low power mode
bspFlashExtPowerDown();
#ifndef TI_DRIVERS_SPI_INCLUDED
bspSpiClose();
#endif
}
/* See ext_flash.h file for description */
bool extFlashRead(size_t offset, size_t length, uint8_t *buf)
{
uint8_t wbuf[4];
/* Wait till previous erase/program operation completes */
int ret = extFlashWaitReady();
if (ret)
{
return false;
}
/* SPI is driven with very low frequency (1MHz < 33MHz fR spec)
* in this temporary implementation.
* and hence it is not necessary to use fast read. */
wbuf[0] = BLS_CODE_READ;
wbuf[1] = (offset >> 16) & 0xff;
wbuf[2] = (offset >> 8) & 0xff;
wbuf[3] = offset & 0xff;
extFlashSelect();
if (bspSpiWrite(wbuf, sizeof(wbuf)))
{
/* failure */
extFlashDeselect();
return false;
}
ret = bspSpiRead(buf, length);
extFlashDeselect();
return ret == 0;
}
/* See ext_flash.h file for description */
bool extFlashWrite(size_t offset, size_t length, const uint8_t *buf)
{
uint8_t wbuf[4];
while (length > 0)
{
/* Wait till previous erase/program operation completes */
int ret = extFlashWaitReady();
if (ret)
{
return false;
}
ret = extFlashWriteEnable();
if (ret)
{
return false;
}
size_t ilen; /* interim length per instruction */
ilen = BLS_PROGRAM_PAGE_SIZE - (offset % BLS_PROGRAM_PAGE_SIZE);
if (length < ilen)
{
ilen = length;
}
wbuf[0] = BLS_CODE_PROGRAM;
wbuf[1] = (offset >> 16) & 0xff;
wbuf[2] = (offset >> 8) & 0xff;
wbuf[3] = offset & 0xff;
offset += ilen;
length -= ilen;
/* Up to 100ns CS hold time (which is not clear
* whether it's application only in-between reads)
* is not imposed here since above instructions
* should be enough to delay
* as much. */
extFlashSelect();
if (bspSpiWrite(wbuf, sizeof(wbuf)))
{
/* failure */
extFlashDeselect();
return false;
}
if (bspSpiWrite(buf,ilen))
{
/* failure */
extFlashDeselect();
return false;
}
buf += ilen;
extFlashDeselect();
}
return true;
}
/* See ext_flash.h file for description */
bool extFlashErase(size_t offset, size_t length)
{
/* Note that Block erase might be more efficient when the floor map
* is well planned for OTA but to simplify for the temporary implementation,
* sector erase is used blindly. */
uint8_t wbuf[4];
size_t i, numsectors;
wbuf[0] = BLS_CODE_SECTOR_ERASE;
{
size_t endoffset = offset + length - 1;
offset = (offset / BLS_ERASE_SECTOR_SIZE) * BLS_ERASE_SECTOR_SIZE;
numsectors = (endoffset - offset + BLS_ERASE_SECTOR_SIZE - 1) / BLS_ERASE_SECTOR_SIZE;
}
for (i = 0; i < numsectors; i++)
{
/* Wait till previous erase/program operation completes */
int ret = extFlashWaitReady();
if (ret)
{
return false;
}
ret = extFlashWriteEnable();
if (ret)
{
return false;
}
wbuf[1] = (offset >> 16) & 0xff;
wbuf[2] = (offset >> 8) & 0xff;
wbuf[3] = offset & 0xff;
extFlashSelect();
if (bspSpiWrite(wbuf, sizeof(wbuf)))
{
/* failure */
extFlashDeselect();
return false;
}
extFlashDeselect();
offset += BLS_ERASE_SECTOR_SIZE;
}
return true;
}
/* See ext_flash.h file for description */
bool extFlashTest(void)
{
bool ret;
ret = extFlashOpen();
if (ret)
{
extFlashClose();
ret = extFlashWaitPowerDown() == 0;
}
return ret;
}

View File

@@ -0,0 +1,94 @@
/**
@file ext_flash.h
@brief External flash storage abstraction
<!--
Copyright 2014 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
-->
*/
#ifndef EXT_FLASH_H
#define EXT_FLASH_H
#include <stdlib.h>
#include <stdbool.h>
#define EXT_FLASH_PAGE_SIZE 4096
#ifdef __cplusplus
extern "C"
{
#endif
/**
* Initialize storage driver.
*
* @return True when successful.
*/
extern bool extFlashOpen(void);
/**
* Close the storage driver
*/
extern void extFlashClose(void);
/**
* Read storage content
*
* @return True when successful.
*/
extern bool extFlashRead(size_t offset, size_t length, uint8_t *buf);
/**
* Erase storage sectors corresponding to the range.
*
* @return True when successful.
*/
extern bool extFlashErase(size_t offset, size_t length);
/**
* Write to storage sectors.
*
* @return True when successful.
*/
extern bool extFlashWrite(size_t offset, size_t length, const uint8_t *buf);
/**
* Test the flash (power on self-test)
*
* @return True when successful.
*/
extern bool extFlashTest(void);
#ifdef __cplusplus
}
#endif
#endif /* BLS_H */

View File

@@ -0,0 +1,296 @@
/**************************************************************************************************
* Filename: sensor.c
* Revised: $Date: 2012-09-21 15:30:38 +0200 (fr, 21 sep 2012) $
* Revision: $Revision: 31581 $
*
* Description: Sensor driver shared code.
*
* Copyright (C) 2014 - 2015 Texas Instruments Incorporated - http://www.ti.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**************************************************************************************************/
/* ------------------------------------------------------------------------------------------------
* Includes
* ------------------------------------------------------------------------------------------------
*/
#include "sensor.h"
#include "bsp_i2c.h"
#include "ext_flash.h"
#include "sensor_tmp007.h"
#include "sensor_sht21.h"
#include "sensor_bmp280.h"
#include "sensor_opt3001.h"
#include "sensor_mpu9250.h"
/* ------------------------------------------------------------------------------------------------
* Macros and constants
* ------------------------------------------------------------------------------------------------
*/
/* ------------------------------------------------------------------------------------------------
* Local Variables
* ------------------------------------------------------------------------------------------------
*/
static uint8_t buffer[32];
static uint8_t selfTestResult;
/**************************************************************************************************
* @fn sensorReadReg
*
* @brief This function implements the I2C protocol to read from a sensor. The sensor must
* be selected before this routine is called.
*
* @param addr - which register to read
* @param pBuf - pointer to buffer to place data
* @param nBytes - number of bytes to read
*
* @return TRUE if the required number of bytes are received
**************************************************************************************************/
bool sensorReadReg(uint8_t addr, uint8_t *pBuf, uint8_t nBytes)
{
return bspI2cWriteRead(&addr,1,pBuf,nBytes);
}
/**************************************************************************************************
* @fn sensorWriteReg
* @brief This function implements the I2C protocol to write to a sensor. he sensor must
* be selected before this routine is called.
*
* @param addr - which register to write
* @param pBuf - pointer to buffer containing data to be written
* @param nBytes - number of bytes to write
*
* @return TRUE if successful write
*/
bool sensorWriteReg(uint8_t addr, uint8_t *pBuf, uint8_t nBytes)
{
uint8_t i;
uint8_t *p = buffer;
/* Copy address and data to local buffer for burst write */
*p++ = addr;
for (i = 0; i < nBytes; i++)
{
*p++ = *pBuf++;
}
nBytes++;
/* Send data */
return bspI2cWrite(buffer,nBytes);
}
/*********************************************************************
* @fn sensorTestExecute
*
* @brief Run a self-test on all the sensors
*
* @param none
*
* @return bitmask of passed flags, one bit set for each sensor
*/
uint8_t sensorTestExecute(void)
{
selfTestResult = 0;
// 1. Temp sensor test
if (sensorTmp007Test())
selfTestResult |= ST_IRTEMP;
// 2. Humidity sensor test
if (sensorSht21Test())
selfTestResult |= ST_HUMIDITY;
// 3. Barometer test
if (sensorBmp280Test())
selfTestResult |= ST_PRESSURE;
// 3. Optic sensor test
if (sensorOpt3001Test())
selfTestResult |= ST_LIGHT;
// 4. MPU test
if (sensorMpu9250Test())
selfTestResult |= ST_MPU;
// 5. Flash test
if (extFlashTest())
{
/*
uint8_t buf[16];
static uint8_t buf2[32];
extFlashOpen();
extFlashRead(0x28000, 16, buf);
for (int i=0; i<16; i++)
{
buf[i] = i;
}
extFlashWrite(0x28000, 16, buf);
extFlashRead(0x28000, 32, buf2);
extFlashClose();
*/
selfTestResult |= ST_FLASH;
}
return selfTestResult;
}
/*********************************************************************
* @fn sensorTestResult
*
* @brief Return the self-test result
*
* @param none
*
* @return bitmask of passed flags, one bit set for each sensor
*/
uint8_t sensorTestResult(void)
{
return selfTestResult;
}
/*********************************************************************
* @fn sensorSetErrorData
*
* @brief Fill a result buffer with dummy error data
*
* @param pBuf - pointer to buffer containing data to be written
* @param n - number of bytes to fill
*
* @return bitmask of error flags
*/
void sensorSetErrorData(uint8_t *pBuf, uint8_t n)
{
while (n > 0)
{
n--;
pBuf[n] = ST_ERROR_DATA;
}
}
//
// Various utilities
//
#include "math.h"
/*********************************************************************
* @fn convertToLe
*
* @brief Convert 16-bit words form big-endian to little-endian
*
* @param none
*
* @return none
*/
void convertToLe(uint8_t *data, uint8_t len)
{
for (int i=0; i<len; i+=2)
{
uint8_t tmp;
tmp = data[i];
data[i] = data[i+1];
data[i+1] = tmp;
}
}
#define PRECISION 100.0
#define IPRECISION 100
uint16_t floatToSfloat(float data)
{
double sgn = data > 0 ? +1 : -1;
double mantissa = fabs(data) * PRECISION;
int exponent = 0;
bool scaled = false;
// Scale if mantissa is too large
while (!scaled)
{
if (mantissa <= (float)0xFFF)
{
scaled = true;
}
else
{
exponent++;
mantissa /= 2.0;
}
}
uint16_t int_mantissa = (int) round(sgn * mantissa);
uint16_t sfloat = ((exponent & 0xF) << 12) | (int_mantissa & 0xFFF);
return sfloat;
}
float sfloatToFloat(uint16_t rawData)
{
uint16_t e, m;
m = rawData & 0x0FFF;
e = (rawData & 0xF000) >> 12;
return m * exp2(e) * (1.0/PRECISION);
}
uint16_t intToSfloat(int data)
{
int sgn = data > 0 ? +1 : -1;
int mantissa = data * IPRECISION;
int exponent = 0;
bool scaled = false;
// Scale if mantissa is too large
while (!scaled)
{
if (mantissa <= 0xFFF)
{
scaled = true;
}
else
{
exponent++;
mantissa /= 2;
}
}
uint16_t int_mantissa = sgn * mantissa;
uint16_t sfloat = ((exponent & 0xF) << 12) | (int_mantissa & 0xFFF);
return sfloat;
}
/*********************************************************************
*********************************************************************/

View File

@@ -0,0 +1,126 @@
/**************************************************************************************************
* Filename: sensor.h
* Revised: $Date: 2013-03-26 15:47:25 +0100 (ti, 26 mar 2013) $
* Revision: $Revision: 33597 $
*
* Description: Sensor driver shared code.
*
* Copyright (C) 2014 - 2015 Texas Instruments Incorporated - http://www.ti.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**************************************************************************************************/
#ifndef SENSOR_H
#define SENSOR_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
* INCLUDES
*/
#include "stdbool.h"
#include "stdint.h"
#ifdef TI_DRIVERS_I2C_INCLUDED
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Clock.h>
#endif
/*********************************************************************
* CONSTANTS and MACROS
*/
/* Sensor I2C addresses */
#define BMP280_I2C_ADDRESS 0x40 // Pressure
#define TMP007_I2C_ADDRESS 0x44 // IR temperature
#define OPT3001_I2C_ADDRESS 0x45 // Optical sensor
#define MPU9250_I2C_ADDRESS 0x68 // Gyro/Accelerometer
#define SHT21_I2C_ADDRESS 0x77 // Humidity sensor
#define MAG_I2C_ADDRESS 0x0C // Compass (packaged with MPU9250)
/* Bit values for power on self-test */
#define ST_IRTEMP 0x01
#define ST_HUMIDITY 0x02
#define ST_LIGHT 0x04
#define ST_PRESSURE 0x08
#define ST_MPU 0x10
#ifdef MAG_INCLUDED
#define ST_MAG 0x20
#else
#define ST_MAG 0x00
#endif
#define ST_FLASH 0x40
#define ST_DEVPACK 0x80
#define ST_TEST_MAP ( ST_IRTEMP | ST_HUMIDITY | ST_LIGHT | ST_PRESSURE | ST_MPU | ST_MAG | ST_FLASH)
/* Self test assertion; return FALSE (failed) if condition is not met */
#define ST_ASSERT(cond) st( if (!(cond)) {bspI2cDeselect(); return false;} )
/* Data to use when an error occurs */
#define ST_ERROR_DATA 0xCC
/* Loop enclosure for macros */
#define st(x) do { x } while (__LINE__ == -1)
/* Conversion macros */
#define HI_UINT16(a) (((a) >> 8) & 0xFF)
#define LO_UINT16(a) ((a) & 0xFF)
/* Delay */
#ifdef TI_DRIVERS_I2C_INCLUDED
#define delay_ms(i) Task_sleep( ((i) * 1000) / Clock_tickPeriod )
#define MS_2_TICKS(ms) ( ((ms) * 1000) / Clock_tickPeriod )
#else
#define delay_ms(i) // TBD
#endif
/*********************************************************************
* FUNCTIONS
*/
uint8_t sensorTestExecute(void);
uint8_t sensorTestResult(void);
bool sensorReadReg(uint8_t addr, uint8_t *pBuf, uint8_t nBytes);
bool sensorWriteReg(uint8_t addr, uint8_t *pBuf, uint8_t nBytes);
void sensorSetErrorData(uint8_t *pBuf, uint8_t nBytes);
void convertToLe(uint8_t *data, uint8_t len);
uint16_t floatToSfloat(float data);
float sfloatToFloat(uint16_t rawData);
uint16_t intToSfloat(int data);
/*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* SENSOR_H */

View File

@@ -0,0 +1,318 @@
/**************************************************************************************************
* Filename: sensor_bmp280.c
* Revised: $Date: 2014-02-05 10:47:02 +0100 (on, 05 feb 2014) $
* Revision: $Revision: 12066 $
*
* Description: Driver for the Bosch BMP280 Pressure Sensor
*
* Copyright (C) 2014 - 2015 Texas Instruments Incorporated - http://www.ti.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*************************************************************************************************/
/* -----------------------------------------------------------------------------------------------
* Includes
* ------------------------------------------------------------------------------------------------
*/
#include "sensor_bmp280.h"
#include "sensor.h"
#include "bsp_i2c.h"
#include "stddef.h"
/* ------------------------------------------------------------------------------------------------
* Constants and macros
* ------------------------------------------------------------------------------------------------
*/
// Sensor I2C address
#define SENSOR_I2C_ADDRESS 0x77
// Registers
#define ADDR_CALIB 0x88
#define ADDR_PROD_ID 0xD0
#define ADDR_RESET 0xE0
#define ADDR_STATUS 0xF3
#define ADDR_CTRL_MEAS 0xF4
#define ADDR_CONFIG 0xF5
#define ADDR_PRESS_MSB 0xF7
#define ADDR_PRESS_LSB 0xF8
#define ADDR_PRESS_XLSB 0xF9
#define ADDR_TEMP_MSB 0xFA
#define ADDR_TEMP_LSB 0xFB
#define ADDR_TEMP_XLSB 0xFC
// Reset values
#define VAL_PROD_ID 0x58
#define VAL_RESET 0x00
#define VAL_STATUS 0x00
#define VAL_CTRL_MEAS 0x00
#define VAL_CONFIG 0x00
#define VAL_PRESS_MSB 0x80
#define VAL_PRESS_LSB 0x00
#define VAL_TEMP_MSB 0x80
#define VAL_TEMP_LSB 0x00
// Test values
#define VAL_RESET_EXECUTE 0xB6
#define VAL_CTRL_MEAS_TEST 0x55
// Misc.
#define CALIB_DATA_SIZE 24
#define RES_OFF 0
#define RES_ULTRA_LOW_POWER 1
#define RES_LOW_POWER 2
#define RES_STANDARD 3
#define RES_HIGH 5
#define RES_ULTRA_HIGH 6
// Bit fields in CTRL_MEAS register
#define PM_OFF 0
#define PM_FORCED 1
#define PM_NORMAL 3
#define OSRST(v) ((v) << 5)
#define OSRSP(v) ((v) << 2)
// Sensor selection/deselection
#define SENSOR_SELECT() bspI2cSelect(BSP_I2C_INTERFACE_0,SENSOR_I2C_ADDRESS)
#define SENSOR_DESELECT() bspI2cDeselect()
/* ------------------------------------------------------------------------------------------------
* Type Definitions
* ------------------------------------------------------------------------------------------------
*/
typedef struct {
uint16_t dig_T1;
int16_t dig_T2;
int16_t dig_T3;
uint16_t dig_P1;
int16_t dig_P2;
int16_t dig_P3;
int16_t dig_P4;
int16_t dig_P5;
int16_t dig_P6;
int16_t dig_P7;
int16_t dig_P8;
int16_t dig_P9;
int32_t t_fine;
} Bmp280Calibration_t;
/* ------------------------------------------------------------------------------------------------
* Local Functions
* ------------------------------------------------------------------------------------------------
*/
/* ------------------------------------------------------------------------------------------------
* Local Variables
* ------------------------------------------------------------------------------------------------
*/
static uint8_t calData[CALIB_DATA_SIZE];
/**************************************************************************************************
* @fn sensorBmp280Init
*
* @brief Initialize the sensor
*
* @return true of success
*/
bool sensorBmp280Init(void)
{
bool ret;
uint8_t val;
SENSOR_SELECT();
// Read and store calibration data
ret = sensorReadReg( ADDR_CALIB, calData, CALIB_DATA_SIZE);
if (ret)
{
// Reset the sensor
val = VAL_RESET_EXECUTE;
sensorWriteReg(ADDR_RESET, &val, sizeof(val));
}
SENSOR_DESELECT();
return ret;
}
/**************************************************************************************************
* @fn sensorBmp280Enable
*
* @brief Enable/disable measurements
*
* @param enable - flag to turn the sensor on/off
*
* @return none
*/
void sensorBmp280Enable(bool enable)
{
uint8_t val;
if (enable)
{
// Enable forced mode
val = PM_NORMAL | OSRSP(1) | OSRST(1);
}
else
{
val = PM_OFF;
}
SENSOR_SELECT();
sensorWriteReg(ADDR_CTRL_MEAS, &val, sizeof(val));
SENSOR_DESELECT();
}
/**************************************************************************************************
* @fn sensorBmp280Read
*
* @brief Read temperature and pressure data
*
* @param data - buffer for temperature and pressure (6 bytes)
*
* @return TRUE if valid data
*/
bool sensorBmp280Read(uint8_t *data)
{
bool success;
SENSOR_SELECT();
success = sensorReadReg( ADDR_PRESS_MSB, data, BMP_DATA_SIZE);
SENSOR_DESELECT();
if (!success)
{
sensorSetErrorData(data,BMP_DATA_SIZE);
}
return success;
}
/**************************************************************************************************
* @fn sensorBmp280Convert
*
* @brief Convert raw data to object and ambience temperature
*
* @param data - raw data from sensor
*
* @param temp - converted temperature
*
* @param press - converted pressure
*
* @return none
**************************************************************************************************/
void sensorBmp280Convert(uint8_t *data, int32_t *temp, uint32_t *press)
{
int32_t utemp, upress;
Bmp280Calibration_t *p = (Bmp280Calibration_t *)calData;
int32_t v_x1_u32r;
int32_t v_x2_u32r;
int32_t t_fine;
uint32_t pressure;
// Pressure
upress = (int32_t)((((uint32_t)(data[0])) << 12) | (((uint32_t)(data[1])) << 4) | ((uint32_t)data[2] >> 4));
// Temperature
utemp = (int32_t)((( (uint32_t) (data[3])) << 12) | (((uint32_t)(data[4])) << 4) | ((uint32_t)data[5] >> 4));
// Compensate temperature
v_x1_u32r = ((((utemp >> 3) - ((int32_t)p->dig_T1 << 1))) * ((int32_t)p->dig_T2)) >> 11;
v_x2_u32r = (((((utemp >> 4) - ((int32_t)p->dig_T1)) * ((utemp >> 4) - ((int32_t)p->dig_T1))) >> 12) * ((int32_t)p->dig_T3)) >> 14;
t_fine = v_x1_u32r + v_x2_u32r;
*temp = (int32_t)((t_fine * 5 + 128) >> 8);
// Compensate pressure
v_x1_u32r = (((int32_t)t_fine) >> 1) - (int32_t)64000;
v_x2_u32r = (((v_x1_u32r >> 2) * (v_x1_u32r >> 2)) >> 11) * ((int32_t)p->dig_P6);
v_x2_u32r = v_x2_u32r + ((v_x1_u32r * ((int32_t)p->dig_P5)) << 1);
v_x2_u32r = (v_x2_u32r >> 2) + (((int32_t)p->dig_P4) << 16);
v_x1_u32r = (((p->dig_P3 * (((v_x1_u32r >> 2) * (v_x1_u32r >> 2)) >> 13)) >> 3) +
((((int32_t)p->dig_P2) * v_x1_u32r) >> 1)) >> 18;
v_x1_u32r = ((((32768+v_x1_u32r)) * ((int32_t)p->dig_P1)) >> 15);
if (v_x1_u32r == 0)
return; /* Avoid exception caused by division by zero */
pressure = (((uint32_t)(((int32_t)1048576) - upress) - (v_x2_u32r >> 12))) * 3125;
if (pressure < 0x80000000)
pressure = (pressure << 1) / ((uint32_t)v_x1_u32r);
else
pressure = (pressure / (uint32_t)v_x1_u32r) * 2;
v_x1_u32r = (((int32_t)p->dig_P9) * ((int32_t)(((pressure >> 3) * (pressure >> 3)) >> 13))) >> 12;
v_x2_u32r = (((int32_t)(pressure >> 2)) * ((int32_t)p->dig_P8)) >> 13;
pressure = (uint32_t)((int32_t)pressure + ((v_x1_u32r + v_x2_u32r + p->dig_P7) >> 4));
*press = pressure;
}
/**************************************************************************************************
* @fn sensorBmp280Test
*
* @brief Run a sensor self-test
*
* @return TRUE if passed, FALSE if failed
*/
bool sensorBmp280Test(void)
{
uint8_t val;
// Select this sensor on the I2C bus
SENSOR_SELECT();
// Check reset values
ST_ASSERT(sensorReadReg(ADDR_PROD_ID, &val, sizeof(val)));
ST_ASSERT(val == VAL_PROD_ID);
ST_ASSERT(sensorReadReg(ADDR_CONFIG, &val, sizeof(val)));
ST_ASSERT(val == VAL_CONFIG);
// Check that registers can be written
val = VAL_CTRL_MEAS_TEST;
ST_ASSERT(sensorWriteReg(ADDR_CTRL_MEAS, &val, sizeof(val)));
ST_ASSERT(sensorReadReg(ADDR_CTRL_MEAS, &val, sizeof(val)));
ST_ASSERT(val == VAL_CTRL_MEAS_TEST);
// Reset the sensor
val = VAL_RESET_EXECUTE;
ST_ASSERT(sensorWriteReg(ADDR_RESET, &val, sizeof(val)));
// Check that CTRL_MEAS register has reset value
ST_ASSERT(sensorReadReg(ADDR_CTRL_MEAS, &val, sizeof(val)));
ST_ASSERT(val == VAL_CTRL_MEAS);
SENSOR_DESELECT();
return true;
}

View File

@@ -0,0 +1,76 @@
/**************************************************************************************************
* Filename: sensor_bmp280.h
* Revised: $Date: 2014-02-05 10:47:02 +0100 (on, 05 feb 2014) $
* Revision: $Revision: 12066 $
*
* Description: Driver for the Bosch BMP280 Pressure Sensor
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*************************************************************************************************/
#ifndef SENSOR_BMP280_H
#define SENSOR_BMP280_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
* INCLUDES
*/
#include "stdint.h"
#include "stdbool.h"
/*********************************************************************
* CONSTANTS
*/
#define BMP_DATA_SIZE 6
/*********************************************************************
* TYPEDEFS
*/
/*********************************************************************
* FUNCTIONS
*/
bool sensorBmp280Init(void);
void sensorBmp280Enable(bool enable);
bool sensorBmp280Read(uint8_t *pBuf);
void sensorBmp280Convert(uint8_t *raw, int32_t *temp, uint32_t *press);
bool sensorBmp280Test(void);
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* SENSOR_BMP280_H */

View File

@@ -0,0 +1,681 @@
/**************************************************************************************************
* Filename: sensor_mpu6500.c
* Revised: $Date: 2014-02-05 10:47:02 +0100 (on, 05 feb 2014) $
* Revision: $Revision: 12066 $
*
* Description: Driver for the Invensys MPU6500 Motion Processing Unit
*
* Copyright (C) 2014 - 2015 Texas Instruments Incorporated - http://www.ti.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*************************************************************************************************/
/* ------------------------------------------------------------------------------------------------
* Includes
* ------------------------------------------------------------------------------------------------
*/
#include "sensor_mpu6500.h"
#include "sensor.h"
#include "bsp_i2c.h"
/* ------------------------------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------------------------------
*/
// Sensor I2C address
#define SENSOR_I2C_ADDRESS 0x68
// Registers
#define SELF_TEST_X_GYRO 0x00 // R/W
#define SELF_TEST_Y_GYRO 0x01 // R/W
#define SELF_TEST_Z_GYRO 0x02 // R/W
#define SELF_TEST_X_ACCEL 0x0D // R/W
#define SELF_TEST_Z_ACCEL 0x0E // R/W
#define SELF_TEST_Y_ACCEL 0x0F // R/W
#define XG_OFFSET_H 0x13 // R/W
#define XG_OFFSET_L 0x14 // R/W
#define YG_OFFSET_H 0x15 // R/W
#define YG_OFFSET_L 0x16 // R/W
#define ZG_OFFSET_H 0x17 // R/W
#define ZG_OFFSET_L 0x18 // R/W
#define SMPLRT_DIV 0x19 // R/W
#define CONFIG 0x1A // R/W
#define GYRO_CONFIG 0x1B // R/W
#define ACCEL_CONFIG 0x1C // R/W
#define ACCEL_CONFIG_2 0x1D // R/W
#define LP_ACCEL_ODR 0x1E // R/W
#define WOM_THR 0x1F // R/W
#define FIFO_EN 0x23 // R/W
// .. registers 0x24 - 0x36 are not applicable to the SensorTag HW configuration (IC2 Master)
#define INT_PIN_CFG 0x37 // R/W
#define INT_ENABLE 0x38 // R/W
#define INT_STATUS 0x3A // R
#define ACCEL_XOUT_H 0x3B // R
#define ACCEL_XOUT_L 0x3C // R
#define ACCEL_YOUT_H 0x3D // R
#define ACCEL_YOUT_L 0x3E // R
#define ACCEL_ZOUT_H 0x3F // R
#define ACCEL_ZOUT_L 0x40 // R
#define TEMP_OUT_H 0x41 // R
#define TEMP_OUT_L 0x42 // R
#define GYRO_XOUT_H 0x43 // R
#define GYRO_XOUT_L 0x44 // R
#define GYRO_YOUT_H 0x45 // R
#define GYRO_YOUT_L 0x46 // R
#define GYRO_ZOUT_H 0x47 // R
#define GYRO_ZOUT_L 0x48 // R
// .. registers 0x49 - 0x60 are not applicable to the SensorTag HW configuration (external sensor data)
// .. registers 0x63 - 0x67 are not applicable to the SensorTag HW configuration (I2C master)
#define SIGNAL_PATH_RESET 0x68 // R/W
#define ACCEL_INTEL_CTRL 0x69 // R/W
#define USER_CTRL 0x6A // R/W
#define PWR_MGMT_1 0x6B // R/W
#define PWR_MGMT_2 0x6C // R/W
#define FIFO_COUNT_H 0x72 // R/W
#define FIFO_COUNT_L 0x73 // R/W
#define FIFO_R_W 0x74 // R/W
#define WHO_AM_I 0x75 // R/W
// Acceleromter ranges
#define ACC_REG_CTRL_2G 0x00
#define ACC_REG_CTRL_4G 0x08
#define ACC_REG_CTRL_8G 0x10
#define ACC_REG_CTRL_16G 0x18
#define ACC_REG_CTRL_INVALID 0xFF
// Masks is mpuConfig valiable
#define ACC_CONFIG_MASK 0x38
#define GYRO_CONFIG_MASK 0x07
// Values PWR_MGMT_1
#define MPU_SLEEP 0x4F // Sleep + stop all clocks
#define MPU_WAKE_UP 0x09 // Disable temp. + intern osc
// Values PWR_MGMT_2
#define ALL_AXES 0x3F
#define GYRO_AXES 0x07
#define ACC_AXES 0x38
// Data sizes
#define DATA_SIZE 6
// Output data rates
#define INV_LPA_0_3125HZ 0
#define INV_LPA_0_625HZ 1
#define INV_LPA_1_25HZ 2
#define INV_LPA_2_5HZ 3
#define INV_LPA_5HZ 4
#define INV_LPA_10HZ 5
#define INV_LPA_20HZ 6
#define INV_LPA_40HZ 7
#define INV_LPA_80HZ 8
#define INV_LPA_160HZ 9
#define INV_LPA_320HZ 10
#define INV_LPA_640HZ 11
#define INV_LPA_STOPPED 255
// Bit values
#define BIT_ACTL 0x80
#define BIT_LATCH_EN 0x20
#define BIT_ANY_RD_CLR 0x10
#define BIT_RAW_RDY_EN 0x01
#define BIT_WOM_EN 0x40
#define BIT_LPA_CYCLE 0x20
#define BIT_STBY_XA 0x20
#define BIT_STBY_YA 0x10
#define BIT_STBY_ZA 0x08
#define BIT_STBY_XG 0x04
#define BIT_STBY_YG 0x02
#define BIT_STBY_ZG 0x01
#define BIT_STBY_XYZA (BIT_STBY_XA | BIT_STBY_YA | BIT_STBY_ZA)
#define BIT_STBY_XYZG (BIT_STBY_XG | BIT_STBY_YG | BIT_STBY_ZG)
// Sensor selection/deselection
#define SENSOR_SELECT() bspI2cSelect(BSP_I2C_INTERFACE_1,SENSOR_I2C_ADDRESS)
#define SENSOR_DESELECT() bspI2cDeselect()
/* ------------------------------------------------------------------------------------------------
* Typedefs
* ------------------------------------------------------------------------------------------------
*/
/* ------------------------------------------------------------------------------------------------
* Macros
* ------------------------------------------------------------------------------------------------
*/
/* ------------------------------------------------------------------------------------------------
* Local Functions
* ------------------------------------------------------------------------------------------------
*/
static void sensorMpuSleep(void);
static void sensorMpu6500WakeUp(void);
static void sensorMpu6500SelectAxes(void);
/* ------------------------------------------------------------------------------------------------
* Local Variables
* ------------------------------------------------------------------------------------------------
*/
static uint8_t mpuConfig;
static uint8_t accRange = ACC_RANGE_INVALID;
static uint8_t accRangeReg;
static uint8_t val;
static uint8_t intStatus;
static bool isWomEnabled;
/**************************************************************************************************
* @fn sensorMpu6500Init
*
* @brief This function initializes the HAL Accelerometer abstraction layer.
*
* @return True if success
*/
bool sensorMpu6500Init(void)
{
bool ret;
isWomEnabled = false;
// Select this sensor
SENSOR_SELECT();
// Device reset
val = 0x80;
ret = sensorWriteReg(PWR_MGMT_1, &val, 1);
if (ret)
{
delay_ms(100);
// Release reset
val = 0x00;
ret = sensorWriteReg(PWR_MGMT_1, &val, 1);
if (ret)
{
delay_ms(100);
// Initial configuration
mpuConfig = 0; // All axes off
sensorMpu6500AccSetRange(ACC_RANGE_8G);
// Power save
sensorMpuSleep();
}
}
SENSOR_DESELECT();
return ret;
}
/**************************************************************************************************
* @fn sensorMpu6500IntEnable
*
* @brief This function initializes the Accelerometer abstraction layer.
*
* @param enable - true if interrupt is to be generated
*
* @return True if success
*/
bool sensorMpu6500IntEnable(bool enable)
{
bool ret;
SENSOR_SELECT();
// Configure INT pin
val = enable ? BIT_RAW_RDY_EN : 0;
ret = sensorWriteReg(INT_ENABLE, &val, 1);
SENSOR_DESELECT();
return ret;
}
/**************************************************************************************************
* @fn sensorMpu6500WomEnable
*
* @brief Enable Wake On Motion functionality
*
* @return True if success
*/
bool sensorMpu6500WomEnable(void)
{
SENSOR_SELECT();
// Make sure accelerometer is running
val = 0x09;
ST_ASSERT(sensorWriteReg(PWR_MGMT_1, &val, 1));
// Enable accelerometer, disable gyro
val = 0x07;
ST_ASSERT(sensorWriteReg(PWR_MGMT_2, &val, 1));
// Set Accel LPF setting to 184 Hz Bandwidth
val = 0x01;
ST_ASSERT(sensorWriteReg(ACCEL_CONFIG_2, &val, 1));
// Enable Motion Interrupt
val = BIT_WOM_EN;
ST_ASSERT(sensorWriteReg(INT_ENABLE, &val, 1));
// Enable Accel Hardware Intelligence
val = 0xC0;
ST_ASSERT(sensorWriteReg(ACCEL_INTEL_CTRL, &val, 1));
// Set Motion Threshold
val = 3;
ST_ASSERT(sensorWriteReg(WOM_THR, &val, 1));
// Set Frequency of Wake-up
val = INV_LPA_5HZ;
ST_ASSERT(sensorWriteReg(LP_ACCEL_ODR, &val, 1));
// Enable Cycle Mode (Accel Low Power Mode)
val = 0x29;
ST_ASSERT(sensorWriteReg(PWR_MGMT_1, &val, 1));
// Select the current range
ST_ASSERT(sensorWriteReg(ACCEL_CONFIG, &accRangeReg, 1));
SENSOR_DESELECT();
isWomEnabled = true;
mpuConfig = BIT_STBY_XYZA;
return true;
}
/**************************************************************************************************
* @fn sensorMpu6500IntStatus
*
* @brief Check whether a data or wake on motion interrupt has occurred
*
* @return Return interrupt status
*/
uint8_t sensorMpu6500IntStatus(void)
{
SENSOR_SELECT();
sensorReadReg(INT_STATUS,&intStatus,1);
SENSOR_DESELECT();
return intStatus;
}
/**************************************************************************************************
* @fn sensorMpu6500AccEnable
*
* @brief Enable acceleromter readout
*
* @param Axes: bitmap [0..2], X = 1, Y = 2, Z = 4. 0 = accelerometer off
*
* @return None
*/
void sensorMpu6500AccEnable(uint8_t axes)
{
// Select this sensor
SENSOR_SELECT();
if (mpuConfig == 0 && axes != 0)
{
// Wake up the sensor if it was off
sensorMpu6500WakeUp();
}
mpuConfig &= ~ACC_CONFIG_MASK;
mpuConfig |= (axes << 3);
if (mpuConfig != 0)
{
// Enable accelerometer readout
sensorMpu6500SelectAxes();
delay_ms(10);
}
else if (mpuConfig == 0)
{
sensorMpuSleep();
}
SENSOR_DESELECT();
}
/**************************************************************************************************
* @fn sensorMpu6500GyroEnable
*
* @brief Enable gyroscope readout
*
* @param Axes: bitmap [0..2], X = 1, Y = 2, Z = 4. 0 = gyroscope off
*
* @return None
*/
void sensorMpu6500GyroEnable(uint8_t axes)
{
// Select this sensor
SENSOR_SELECT();
if (mpuConfig == 0 && axes != 0 && !isWomEnabled)
{
// Wake up the sensor if it was off
sensorMpu6500WakeUp();
}
mpuConfig &= ~GYRO_CONFIG_MASK;
mpuConfig |= axes;
if (mpuConfig != 0)
{
// Enable gyro readout
sensorMpu6500SelectAxes();
// Gyro seems to cause false interrupts during startup, so delay processing slightly
delay_ms(10);
}
else if (mpuConfig == 0 && !isWomEnabled)
{
sensorMpuSleep();
}
SENSOR_DESELECT();
}
/**************************************************************************************************
* @fn sensorMpu6500AccSetRange
*
* @brief Set the range of the accelerometer
*
* @param newRange: ACC_RANGE_2G, ACC_RANGE_4G, ACC_RANGE_8G, ACC_RANGE_16G
*
* @return true if write succeeded
*/
bool sensorMpu6500AccSetRange(uint8_t newRange)
{
bool success;
if (newRange == accRange)
return true;
success = false;
switch (newRange)
{
case ACC_RANGE_2G:
accRangeReg = ACC_REG_CTRL_2G;
break;
case ACC_RANGE_4G:
accRangeReg = ACC_REG_CTRL_4G;
break;
case ACC_RANGE_8G:
accRangeReg = ACC_REG_CTRL_8G;
break;
case ACC_RANGE_16G:
accRangeReg = ACC_REG_CTRL_16G;
break;
default:
accRangeReg = ACC_REG_CTRL_INVALID;
// Should not get here
break;
}
if (accRangeReg != ACC_REG_CTRL_INVALID)
{
// Apply the range
success = sensorWriteReg(ACCEL_CONFIG, &accRangeReg, 1);
if (success)
accRange = newRange;
}
return success;
}
/**************************************************************************************************
* @fn sensorMpu6500AccRead
*
* @brief Read data from the accelerometer - X, Y, Z - 3 words
*
* @return TRUE if valid data, FALSE if not
*/
bool sensorMpu6500AccRead(uint16_t *data )
{
bool success;
// Select this sensor
SENSOR_SELECT();
if (intStatus & BIT_RAW_RDY_EN)
{
// Burst read of all accelerometer values
success = sensorReadReg(ACCEL_XOUT_H, (uint8_t*)data, DATA_SIZE);
if (!success)
{
sensorSetErrorData((uint8_t*)data,DATA_SIZE);
}
}
else
{
success = false; // Data not ready
}
SENSOR_DESELECT();
return success;
}
/**************************************************************************************************
* @fn sensorMpu6500GyroRead
*
* @brief Read data from the gyroscope - X, Y, Z - 3 words
*
* @return TRUE if valid data, FALSE if not
*/
bool sensorMpu6500GyroRead(uint16_t *data )
{
bool success;
// Select this sensor
SENSOR_SELECT();
if (intStatus & BIT_RAW_RDY_EN)
{
// Burst read of all gyroscope values
success = sensorReadReg(GYRO_XOUT_H, (uint8_t*)data, DATA_SIZE);
if (!success)
{
sensorSetErrorData((uint8_t*)data,DATA_SIZE);
}
}
else
{
success = false;
}
SENSOR_DESELECT();
return success;
}
/**************************************************************************************************
* @fn sensorMpu6500Test
*
* @brief Run a sensor self-test
*
* @return TRUE if passed, FALSE if failed
*/
bool sensorMpu6500Test(void)
{
// Select this sensor on the I2C bus
SENSOR_SELECT();
// Check the WHO AM I register
ST_ASSERT(sensorReadReg(WHO_AM_I, &val, 1));
ST_ASSERT(val == 0x70);
SENSOR_DESELECT();
return true;
}
/**************************************************************************************************
* @fn sensorMpu6500AccelConvert
*
* @brief Convert raw data to G units
*
* @param rawData - raw data from sensor
*
* @return Converted value
**************************************************************************************************/
float sensorMpu6500AccelConvert(int16_t rawData)
{
float v;
switch (accRange)
{
case ACC_RANGE_2G:
//-- calculate acceleration, unit G, range -2, +2
v = (rawData * 1.0) / (32768/2);
break;
case ACC_RANGE_4G:
//-- calculate acceleration, unit G, range -4, +4
v = (rawData * 1.0) / (32768/4);
break;
case ACC_RANGE_8G:
//-- calculate acceleration, unit G, range -8, +8
v = (rawData * 1.0) / (32768/8);
break;
case ACC_RANGE_16G:
//-- calculate acceleration, unit G, range -16, +16
v = (rawData * 1.0) / (32768/16);
break;
}
return v;
}
/**************************************************************************************************
* @fn sensorMpu6500GyroConvert
*
* @brief Convert raw data to deg/sec units
*
* @param data - raw data from sensor
*
* @return none
**************************************************************************************************/
float sensorMpu6500GyroConvert(int16_t data)
{
//-- calculate rotation, unit deg/s, range -250, +250
return (data * 1.0) / (65536 / 500);
}
/* ------------------------------------------------------------------------------------------------
* Private functions
* -------------------------------------------------------------------------------------------------
*/
/**************************************************************************************************
* @fn sensorMpuSleep
*
* @brief Place the MPU in low power mode
*
* @return
*/
static void sensorMpuSleep(void)
{
val = ALL_AXES;
sensorWriteReg(PWR_MGMT_2, &val, 1);
val = MPU_SLEEP;
sensorWriteReg(PWR_MGMT_1, &val, 1);
}
/**************************************************************************************************
* @fn sensorMpu6500WakeUp
*
* @brief Exit low power mode
*
* @return none
*/
static void sensorMpu6500WakeUp(void)
{
val = MPU_WAKE_UP;
sensorWriteReg(PWR_MGMT_1, &val, 1);
// All axis initially disabled
val = ALL_AXES;
sensorWriteReg(PWR_MGMT_2, &val, 1);
mpuConfig = 0;
// Restore the range
sensorWriteReg(ACCEL_CONFIG, &accRangeReg, 1);
// Clear interrupts
sensorReadReg(INT_STATUS,&val,1);
}
/**************************************************************************************************
* @fn sensorMpu6500SelectAxes
*
* @brief MPU in sleep
*
* @return none
*/
static void sensorMpu6500SelectAxes(void)
{
val = ~mpuConfig;
sensorWriteReg(PWR_MGMT_2, &val, 1);
}
// Temporary test function to read all registers
uint8_t sensorMpu6500ReadRegs(uint8_t *data, uint8_t start, uint8_t nRegs)
{
uint8_t reg;
SENSOR_SELECT();
for (reg = start; reg < nRegs; reg++)
{
if (sensorReadReg(reg, data+reg, 1) == FALSE)
break;
}
SENSOR_DESELECT();
return reg;
}
/*********************************************************************
*********************************************************************/

View File

@@ -0,0 +1,105 @@
/**************************************************************************************************
* Filename: sensor_mpu6500.h
* Revised: $Date: 2014-02-05 10:47:02 +0100 (on, 05 feb 2014) $
* Revision: $Revision: 12066 $
*
* Description: Driver for the Invensys MPU6500 Motion Processing Unit
*
* Copyright (C) 2014 - 2015 Texas Instruments Incorporated - http://www.ti.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*************************************************************************************************/
#ifndef SENSOR_MPU6500_H
#define SENSOR_MPU6500_H
#ifdef __cplusplus
extern "C" {
#endif
/* ------------------------------------------------------------------------------------------------
* Includes
* ------------------------------------------------------------------------------------------------
*/
#include "stdint.h"
#include "stdbool.h"
/* ------------------------------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------------------------------
*/
#define ACC_RANGE_2G 1
#define ACC_RANGE_4G 2
#define ACC_RANGE_8G 3
#define ACC_RANGE_16G 4
#define ACC_RANGE_INVALID 255
#define MPU_NO_AXIS 0x00
#define MPU_ALL_AXIS 0x07
#define MPU_DATA_READY 0x01
#define MPU_MOVEMENT 0x40
/* ------------------------------------------------------------------------------------------------
* Typedefs
* ------------------------------------------------------------------------------------------------
*/
/* ------------------------------------------------------------------------------------------------
* Functions
* ------------------------------------------------------------------------------------------------
*/
bool sensorMpu6500Init(void);
bool sensorMpu6500IntEnable(bool enable);
bool sensorMpu6500WomEnable(void);
uint8_t sensorMpu6500IntStatus(void);
bool sensorMpu6500Test(void);
void sensorMpu6500AccEnable(uint8_t config);
bool sensorMpu6500AccSetRange(uint8_t range);
bool sensorMpu6500AccRead(uint16_t *rawData);
float sensorMpu6500AccelConvert(int16_t rawValue);
void sensorMpu6500GyroEnable(uint8_t config);
bool sensorMpu6500GyroRead(uint16_t *rawData);
float sensorMpu6500GyroConvert(int16_t rawValue);
// For test
uint8_t sensorMpu6500ReadRegs(uint8_t *data, uint8_t start, uint8_t nRegs);
/**************************************************************************************************
*/
#ifdef __cplusplus
};
#endif
#endif
/**************************************************************************************************
*/

View File

@@ -0,0 +1,905 @@
/**************************************************************************************************
* Filename: sensor_mpu9250.c
* Revised: $Date: 2014-02-05 10:47:02 +0100 (on, 05 feb 2014) $
* Revision: $Revision: 12066 $
*
* Description: Driver for the Invensys MPU9250 Motion Processing Unit
*
* Copyright (C) 2014 - 2015 Texas Instruments Incorporated - http://www.ti.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*************************************************************************************************/
/* ------------------------------------------------------------------------------------------------
* Includes
* ------------------------------------------------------------------------------------------------
*/
#include "Board.h"
#include "sensor_mpu9250.h"
#include "sensor.h"
#include "bsp_i2c.h"
/* ------------------------------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------------------------------
*/
// Sensor I2C address
#define SENSOR_I2C_ADDRESS 0x68
#define SENSOR_MAG_I2_ADDRESS 0x0C
// Registers
#define SELF_TEST_X_GYRO 0x00 // R/W
#define SELF_TEST_Y_GYRO 0x01 // R/W
#define SELF_TEST_Z_GYRO 0x02 // R/W
#define SELF_TEST_X_ACCEL 0x0D // R/W
#define SELF_TEST_Z_ACCEL 0x0E // R/W
#define SELF_TEST_Y_ACCEL 0x0F // R/W
#define XG_OFFSET_H 0x13 // R/W
#define XG_OFFSET_L 0x14 // R/W
#define YG_OFFSET_H 0x15 // R/W
#define YG_OFFSET_L 0x16 // R/W
#define ZG_OFFSET_H 0x17 // R/W
#define ZG_OFFSET_L 0x18 // R/W
#define SMPLRT_DIV 0x19 // R/W
#define CONFIG 0x1A // R/W
#define GYRO_CONFIG 0x1B // R/W
#define ACCEL_CONFIG 0x1C // R/W
#define ACCEL_CONFIG_2 0x1D // R/W
#define LP_ACCEL_ODR 0x1E // R/W
#define WOM_THR 0x1F // R/W
#define FIFO_EN 0x23 // R/W
// .. registers 0x24 - 0x36 are not applicable to the SensorTag HW configuration (IC2 Master)
#define INT_PIN_CFG 0x37 // R/W
#define INT_ENABLE 0x38 // R/W
#define INT_STATUS 0x3A // R
#define ACCEL_XOUT_H 0x3B // R
#define ACCEL_XOUT_L 0x3C // R
#define ACCEL_YOUT_H 0x3D // R
#define ACCEL_YOUT_L 0x3E // R
#define ACCEL_ZOUT_H 0x3F // R
#define ACCEL_ZOUT_L 0x40 // R
#define TEMP_OUT_H 0x41 // R
#define TEMP_OUT_L 0x42 // R
#define GYRO_XOUT_H 0x43 // R
#define GYRO_XOUT_L 0x44 // R
#define GYRO_YOUT_H 0x45 // R
#define GYRO_YOUT_L 0x46 // R
#define GYRO_ZOUT_H 0x47 // R
#define GYRO_ZOUT_L 0x48 // R
// .. registers 0x49 - 0x60 are not applicable to the SensorTag HW configuration (external sensor data)
// .. registers 0x63 - 0x67 are not applicable to the SensorTag HW configuration (I2C master)
#define SIGNAL_PATH_RESET 0x68 // R/W
#define ACCEL_INTEL_CTRL 0x69 // R/W
#define USER_CTRL 0x6A // R/W
#define PWR_MGMT_1 0x6B // R/W
#define PWR_MGMT_2 0x6C // R/W
#define FIFO_COUNT_H 0x72 // R/W
#define FIFO_COUNT_L 0x73 // R/W
#define FIFO_R_W 0x74 // R/W
#define WHO_AM_I 0x75 // R/W
// Masks is mpuConfig valiable
#define ACC_CONFIG_MASK 0x38
#define GYRO_CONFIG_MASK 0x07
// Values PWR_MGMT_1
#define MPU_SLEEP 0x4F // Sleep + stop all clocks
#define MPU_WAKE_UP 0x09 // Disable temp. + intern osc
// Values PWR_MGMT_2
#define ALL_AXES 0x3F
#define GYRO_AXES 0x07
#define ACC_AXES 0x38
// Data sizes
#define DATA_SIZE 6
// Output data rates
#define INV_LPA_0_3125HZ 0
#define INV_LPA_0_625HZ 1
#define INV_LPA_1_25HZ 2
#define INV_LPA_2_5HZ 3
#define INV_LPA_5HZ 4
#define INV_LPA_10HZ 5
#define INV_LPA_20HZ 6
#define INV_LPA_40HZ 7
#define INV_LPA_80HZ 8
#define INV_LPA_160HZ 9
#define INV_LPA_320HZ 10
#define INV_LPA_640HZ 11
#define INV_LPA_STOPPED 255
// Bit values
#define BIT_ANY_RD_CLR 0x10
#define BIT_RAW_RDY_EN 0x01
#define BIT_WOM_EN 0x40
#define BIT_LPA_CYCLE 0x20
#define BIT_STBY_XA 0x20
#define BIT_STBY_YA 0x10
#define BIT_STBY_ZA 0x08
#define BIT_STBY_XG 0x04
#define BIT_STBY_YG 0x02
#define BIT_STBY_ZG 0x01
#define BIT_STBY_XYZA (BIT_STBY_XA | BIT_STBY_YA | BIT_STBY_ZA)
#define BIT_STBY_XYZG (BIT_STBY_XG | BIT_STBY_YG | BIT_STBY_ZG)
// User control register
#define BIT_ACTL 0x80
#define BIT_LATCH_EN 0x20
// INT Pin / Bypass Enable Configuration
#define BIT_AUX_IF_EN 0x20 // I2C_MST_EN
#define BIT_BYPASS_EN 0x02
// Magnetometer registers
#define MAG_WHO_AM_I 0x00 // should return 0x48
#define MAG_INFO 0x01
#define MAG_ST1 0x02 // data ready status bit 0
#define MAG_XOUT_L 0x03 // data
#define MAG_XOUT_H 0x04
#define MAG_YOUT_L 0x05
#define MAG_YOUT_H 0x06
#define MAG_ZOUT_L 0x07
#define MAG_ZOUT_H 0x08
#define MAG_ST2 0x09 // Data overflow bit 3 and data read error status bit 2
#define MAG_CNTL 0x0A // Power down (0000), single-measurement (0001), self-test (1000) and Fuse ROM (1111) modes on bits 3:0
#define MAG_ASTC 0x0C // Self test control
#define MAG_I2CDIS 0x0F // I2C disable
#define MAG_ASAX 0x10 // Fuse ROM x-axis sensitivity adjustment value
#define MAG_ASAY 0x11 // Fuse ROM y-axis sensitivity adjustment value
#define MAG_ASAZ 0x12 // Fuse ROM z-axis sensitivity adjustment value
// Sensor selection/deselection
#define SENSOR_SELECT() bspI2cSelect(BSP_I2C_INTERFACE_1,SENSOR_I2C_ADDRESS)
#define SENSOR_SELECT_MAG() bspI2cSelect(BSP_I2C_INTERFACE_1,SENSOR_MAG_I2_ADDRESS)
#define SENSOR_DESELECT() bspI2cDeselect()
/* ------------------------------------------------------------------------------------------------
* Typedefs
* ------------------------------------------------------------------------------------------------
*/
/* ------------------------------------------------------------------------------------------------
* Macros
* ------------------------------------------------------------------------------------------------
*/
/* ------------------------------------------------------------------------------------------------
* Local Functions
* ------------------------------------------------------------------------------------------------
*/
static void sensorMpuSleep(void);
static void sensorMpu9250WakeUp(void);
static void sensorMpu9250SelectAxes(void);
#ifdef MAG_INCLUDED
static bool sensorMpu9250SetBypass(void);
static bool sensorMagInit(void);
#endif
/* ------------------------------------------------------------------------------------------------
* Local Variables
* ------------------------------------------------------------------------------------------------
*/
static uint8_t mpuConfig;
static uint8_t accRange;
static uint8_t accRangeReg;
static uint8_t val;
static uint8_t intStatus;
#ifdef WOM_ENABLE
static bool isWomEnabled;
#endif
#if CC2650_SENSORTAG >= 0060
/**************************************************************************************************
* @fn sensorMpu9250PowerOn
*
* @brief This function turns on the power supply to MPU9250
*
* @return none
*/
void sensorMpu9250PowerOn(void)
{
// Make sure I2C interface is in a known state
bspI2cSelect(BSP_I2C_INTERFACE_0,0);
bspI2cDeselect();
PIN_setOutputValue(hGpioPin,Board_MPU_POWER, Board_MPU_POWER_ON);
delay_ms(100);
sensorMpu9250Init();
}
/**************************************************************************************************
* @fn sensorMpu9250PowerOff
*
* @brief This function turns off the power supply to MPU9250
*
* @return none
*/
void sensorMpu9250PowerOff(void)
{
// Make sure I2C interface is in a known state
bspI2cSelect(BSP_I2C_INTERFACE_0,0);
bspI2cDeselect();
IOCIOPortPullSet(Board_I2C0_SDA1, IOC_IOPULL_DOWN);
IOCIOPortPullSet(Board_I2C0_SDA1, IOC_IOPULL_DOWN);
// Turn off power supply
PIN_setOutputValue(hGpioPin,Board_MPU_POWER, Board_MPU_POWER_OFF);
}
/**************************************************************************************************
* @fn sensorMpu9250PowerIsOn
*
* @brief Return true if MPU power is on
*
* @return none
*/
bool sensorMpu9250PowerIsOn(void)
{
return PIN_getOutputValue(Board_MPU_POWER) == Board_MPU_POWER_ON;
}
#endif
/**************************************************************************************************
* @fn sensorMpu9250Init
*
* @brief This function initializes the MPU abstraction layer.
*
* @return True if success
*/
bool sensorMpu9250Init(void)
{
bool ret;
#ifdef WOM_ENABLE
isWomEnabled = false;
#endif
intStatus = false;
accRange = ACC_RANGE_INVALID;
mpuConfig = 0; // All axes off
// Device reset
val = 0x80;
SENSOR_SELECT();
ret = sensorWriteReg(PWR_MGMT_1, &val, 1);
SENSOR_DESELECT();
if (ret)
{
delay_ms(200);
// Initial configuration
sensorMpu9250AccSetRange(ACC_RANGE_8G);
#ifdef MAG_INCLUDED
sensorMagInit();
#endif
// Power save
sensorMpuSleep();
}
return ret;
}
/**************************************************************************************************
* @fn sensorMpu9250IntEnable
*
* @brief This function enables interrupt output
*
* @param enable - true if interrupt is to be generated
*
* @return True if success
*/
bool sensorMpu9250IntEnable(bool enable)
{
bool ret;
SENSOR_SELECT();
// Configure INT pin
val = enable ? BIT_RAW_RDY_EN : 0;
ret = sensorWriteReg(INT_ENABLE, &val, 1);
SENSOR_DESELECT();
return ret;
}
#ifdef WOM_ENABLE
/**************************************************************************************************
* @fn sensorMpu9250WomEnable
*
* @brief Enable Wake On Motion functionality
*
* @return True if success
*/
bool sensorMpu9250WomEnable(void)
{
SENSOR_SELECT();
// Make sure accelerometer is running
val = 0x09;
ST_ASSERT(sensorWriteReg(PWR_MGMT_1, &val, 1));
// Enable accelerometer, disable gyro
val = 0x07;
ST_ASSERT(sensorWriteReg(PWR_MGMT_2, &val, 1));
// Set Accel LPF setting to 184 Hz Bandwidth
val = 0x01;
ST_ASSERT(sensorWriteReg(ACCEL_CONFIG_2, &val, 1));
// Enable Motion Interrupt
val = BIT_WOM_EN;
ST_ASSERT(sensorWriteReg(INT_ENABLE, &val, 1));
// Enable Accel Hardware Intelligence
val = 0xC0;
ST_ASSERT(sensorWriteReg(ACCEL_INTEL_CTRL, &val, 1));
// Set Motion Threshold
val = 3;
ST_ASSERT(sensorWriteReg(WOM_THR, &val, 1));
// Set Frequency of Wake-up
val = INV_LPA_5HZ;
ST_ASSERT(sensorWriteReg(LP_ACCEL_ODR, &val, 1));
// Enable Cycle Mode (Accel Low Power Mode)
val = 0x29;
ST_ASSERT(sensorWriteReg(PWR_MGMT_1, &val, 1));
// Select the current range
ST_ASSERT(sensorWriteReg(ACCEL_CONFIG, &accRangeReg, 1));
SENSOR_DESELECT();
isWomEnabled = true;
mpuConfig = BIT_STBY_XYZA;
return true;
}
#endif
/**************************************************************************************************
* @fn sensorMpu9250IntStatus
*
* @brief Check whether a data or wake on motion interrupt has occurred
*
* @return Return interrupt status
*/
uint8_t sensorMpu9250IntStatus(void)
{
SENSOR_SELECT();
sensorReadReg(INT_STATUS,&intStatus,1);
SENSOR_DESELECT();
return intStatus;
}
/**************************************************************************************************
* @fn sensorMpu9250nable
*
* @brief Enable acceleromter readout
*
* @param Axes: Gyro bitmap [0..2], X = 1, Y = 2, Z = 4. 0 = gyro off
* @ Acc bitmap [3..5], X = 8, Y = 16, Z = 32. 0 = accelerometer off
*
* @return None
*/
void sensorMpu9250Enable(uint16_t axes)
{
if (mpuConfig == 0 && axes != 0)
{
// Wake up the sensor if it was off
sensorMpu9250WakeUp();
}
mpuConfig = axes;
if (mpuConfig != 0)
{
// Enable gyro + accelerometer readout
sensorMpu9250SelectAxes();
delay_ms(10);
}
else if (mpuConfig == 0)
{
sensorMpuSleep();
}
}
/**************************************************************************************************
* @fn sensorMpu9250AccSetRange
*
* @brief Set the range of the accelerometer
*
* @param newRange: ACC_RANGE_2G, ACC_RANGE_4G, ACC_RANGE_8G, ACC_RANGE_16G
*
* @return true if write succeeded
*/
bool sensorMpu9250AccSetRange(uint8_t newRange)
{
bool success;
if (newRange == accRange)
return true;
success = false;
accRangeReg = (newRange << 3);
// Apply the range
SENSOR_SELECT();
success = sensorWriteReg(ACCEL_CONFIG, &accRangeReg, 1);
SENSOR_DESELECT();
if (success)
accRange = newRange;
return success;
}
/**************************************************************************************************
* @fn sensorMpu9250AccReadRange
*
* @brief Set the range of the accelerometer
*
* @param none
*
* @return range: ACC_RANGE_2G, ACC_RANGE_4G, ACC_RANGE_8G, ACC_RANGE_16G
*/
uint8_t sensorMpu9250AccReadRange(void)
{
// Apply the range
SENSOR_SELECT();
sensorReadReg(ACCEL_CONFIG, &accRangeReg, 1);
SENSOR_DESELECT();
accRange = (accRangeReg>>3) & 3;
return accRange;
}
/**************************************************************************************************
* @fn sensorMpu9250AccRead
*
* @brief Read data from the accelerometer - X, Y, Z - 3 words
*
* @return TRUE if valid data, FALSE if not
*/
bool sensorMpu9250AccRead(uint16_t *data )
{
bool success;
// Select this sensor
if (intStatus & BIT_RAW_RDY_EN)
{
// Burst read of all accelerometer values
SENSOR_SELECT();
success = sensorReadReg(ACCEL_XOUT_H, (uint8_t*)data, DATA_SIZE);
SENSOR_DESELECT();
if (success)
{
convertToLe((uint8_t*)data,DATA_SIZE);
}
else
{
sensorSetErrorData((uint8_t*)data,DATA_SIZE);
}
}
else
{
success = false; // Data not ready
}
return success;
}
/**************************************************************************************************
* @fn sensorMpu9250GyroRead
*
* @brief Read data from the gyroscope - X, Y, Z - 3 words
*
* @return TRUE if valid data, FALSE if not
*/
bool sensorMpu9250GyroRead(uint16_t *data )
{
bool success;
if (intStatus & BIT_RAW_RDY_EN)
{
// Select this sensor
SENSOR_SELECT();
// Burst read of all gyroscope values
success = sensorReadReg(GYRO_XOUT_H, (uint8_t*)data, DATA_SIZE);
SENSOR_DESELECT();
if (success)
{
convertToLe((uint8_t*)data,DATA_SIZE);
}
else
{
sensorSetErrorData((uint8_t*)data,DATA_SIZE);
}
}
else
{
success = false;
}
return success;
}
#ifdef MAG_INCLUDED
/**************************************************************************************************
* @fn sensorMpu9250MagRead
*
* @brief Read data from the gyroscope - X, Y, Z - 3 words
*
* @return TRUE if valid data, FALSE if not
*/
bool sensorMpu9250MagRead(uint16_t *data )
{
bool success;
// Select this sensor
SENSOR_SELECT_MAG();
uint8_t rawData[7]; // x/y/z compass register data, ST2 register stored here, must read ST2 at end of data acquisition
success = sensorReadReg(MAG_ST1,&val,1);
if (success)
{
// Check magnetometer data ready bit
if (val & 0x01)
{
// Burst read of all compass values
sensorReadReg(MAG_XOUT_L, &rawData[0],7); // Read the six raw data and ST2 registers sequentially into data array
val = rawData[6]; // End data read by reading ST2 register
// Check if magnetic sensor overflow set, if not then report data
if(!(val & 0x08))
{
data[0] = ((int16_t)rawData[1] << 8) | rawData[0] ; // Turn the MSB and LSB into a signed 16-bit value
data[1] = ((int16_t)rawData[3] << 8) | rawData[2] ; // Data stored as little Endian
data[2] = ((int16_t)rawData[5] << 8) | rawData[4] ;
}
}
}
if (!success)
{
sensorSetErrorData((uint8_t*)data,DATA_SIZE);
}
SENSOR_DESELECT();
return success;
}
#endif
/**************************************************************************************************
* @fn sensorMpu9250Test
*
* @brief Run a sensor self-test
*
* @return TRUE if passed, FALSE if failed
*/
bool sensorMpu9250Test(void)
{
// Select Gyro/Accelerometer
SENSOR_SELECT();
// Check the WHO AM I register
ST_ASSERT(sensorReadReg(WHO_AM_I, &val, 1));
ST_ASSERT(val == 0x71);
SENSOR_DESELECT();
return true;
}
#ifdef MAG_INCLUDED
/**************************************************************************************************
* @fn sensorMpu9250MagTest
*
* @brief Run a magnetometer self test
*
* @return TRUE if passed, FALSE if failed
*/
bool sensorMpu9250MagTest(void)
{
sensorMagInit();
// Select magnetometer
SENSOR_SELECT_MAG();
// Check the WHO AM I register
val = 0xFF;
ST_ASSERT(sensorReadReg(MAG_WHO_AM_I, &val, 1));
ST_ASSERT(val == 0x48);
SENSOR_DESELECT();
return true;
}
#endif
/**************************************************************************************************
* @fn sensorMpu9250AccelConvert
*
* @brief Convert raw data to G units
*
* @param rawData - raw data from sensor
*
* @return Converted value
**************************************************************************************************/
float sensorMpu9250AccelConvert(int16_t rawData)
{
float v;
switch (accRange)
{
case ACC_RANGE_2G:
//-- calculate acceleration, unit G, range -2, +2
v = (rawData * 1.0) / (32768/2);
break;
case ACC_RANGE_4G:
//-- calculate acceleration, unit G, range -4, +4
v = (rawData * 1.0) / (32768/4);
break;
case ACC_RANGE_8G:
//-- calculate acceleration, unit G, range -8, +8
v = (rawData * 1.0) / (32768/8);
break;
case ACC_RANGE_16G:
//-- calculate acceleration, unit G, range -16, +16
v = (rawData * 1.0) / (32768/16);
break;
}
return v;
}
/**************************************************************************************************
* @fn sensorMpu9250GyroConvert
*
* @brief Convert raw data to deg/sec units
*
* @param data - raw data from sensor
*
* @return none
**************************************************************************************************/
float sensorMpu9250GyroConvert(int16_t data)
{
//-- calculate rotation, unit deg/s, range -250, +250
return (data * 1.0) / (65536 / 500);
}
/* ------------------------------------------------------------------------------------------------
* Private functions
* -------------------------------------------------------------------------------------------------
*/
/**************************************************************************************************
* @fn sensorMpuSleep
*
* @brief Place the MPU in low power mode
*
* @return
*/
static void sensorMpuSleep(void)
{
SENSOR_SELECT();
val = ALL_AXES;
sensorWriteReg(PWR_MGMT_2, &val, 1);
val = MPU_SLEEP;
sensorWriteReg(PWR_MGMT_1, &val, 1);
SENSOR_DESELECT();
}
/**************************************************************************************************
* @fn sensorMpu9250WakeUp
*
* @brief Exit low power mode
*
* @return none
*/
static void sensorMpu9250WakeUp(void)
{
SENSOR_SELECT();
val = MPU_WAKE_UP;
sensorWriteReg(PWR_MGMT_1, &val, 1);
// All axis initially disabled
val = ALL_AXES;
sensorWriteReg(PWR_MGMT_2, &val, 1);
mpuConfig = 0;
// Restore the range
sensorWriteReg(ACCEL_CONFIG, &accRangeReg, 1);
// Clear interrupts
sensorReadReg(INT_STATUS,&val,1);
SENSOR_DESELECT();
}
/**************************************************************************************************
* @fn sensorMpu9250SelectAxes
*
* @brief Select gyro and accelromter axes
*
* @return none
*/
static void sensorMpu9250SelectAxes(void)
{
val = ~mpuConfig;
sensorWriteReg(PWR_MGMT_2, &val, 1);
}
#ifdef MAG_INCLUDED
/**************************************************************************************************
* @fn sensorMpu9250SetBypass
*
* @brief Allow the I2C bus to control the compass
*
* @return none
*/
static bool sensorMpu9250SetBypass(void)
{
SENSOR_SELECT();
val = 0x22;
sensorWriteReg(INT_PIN_CFG, &val, 1);
val = 0x01;
sensorWriteReg(INT_ENABLE, &val, 1); // Enable data ready (bit 0) interrupt
delay_ms(100);
SENSOR_DESELECT();
return true;
}
/**************************************************************************************************
* @fn sensorMagInit
*
* @brief Initialize the compass
*
* @return none
*/
static bool sensorMagInit(void)
{
bool found;
uint8_t addr;
enum Mscale {
MFS_14BITS = 0, // 0.6 mG per LSB
MFS_16BITS // 0.15 mG per LSB
};
sensorMpu9250SetBypass();
// Find compass. Possible addresses range from 0x0C to 0x0F. *
found = false;
for (addr = 0x0C; addr <= 0x0F; addr++)
{
bool success;
bspI2cSelect(BSP_I2C_INTERFACE_1,addr);
success = sensorReadReg(MAG_WHO_AM_I,&val,1);
SENSOR_DESELECT();
if (success && (val == 0x48))
{
found = true;
break;
}
}
SENSOR_SELECT_MAG();
uint8_t Mscale = MFS_16BITS; // Choose either 14-bit or 16-bit magnetometer resolution
uint8_t Mmode = 0x02; // 2 for 8 Hz, 6 for 100 Hz continuous magnetometer data read
sensorReadReg(MAG_WHO_AM_I, &val, 1);
// First extract the factory calibration for each magnetometer axis
// uint8_t rawData[3]; // x/y/z gyro calibration data stored here
val = 0x00;
sensorWriteReg(MAG_CNTL, &val, 1); // Power down magnetometer
delay_ms(10);
val = 0x0F;
sensorWriteReg(MAG_CNTL, &val, 1); // Enter Fuse ROM access mode
delay_ms(10);
/*
sensorReadReg(AK8963_ADDRESS, AK8963_ASAX, 3, &rawData[0]); // Read the x-, y-, and z-axis calibration values
destination[0] = (float)(rawData[0] - 128)/256. + 1.; // Return x-axis sensitivity adjustment values, etc.
destination[1] = (float)(rawData[1] - 128)/256. + 1.;
destination[2] = (float)(rawData[2] - 128)/256. + 1.;
*/
val = 0x00;
sensorWriteReg(MAG_CNTL, &val, 1); // Power down magnetometer
delay_ms(10);
// Configure the magnetometer for continuous read and highest resolution
// set Mscale bit 4 to 1 (0) to enable 16 (14) bit resolution in CNTL register,
// and enable continuous mode data acquisition Mmode (bits [3:0]), 0010 for 8 Hz and 0110 for 100 Hz sample rates
val = Mscale << 4 | Mmode;
sensorWriteReg(MAG_CNTL, &val, 1); // Set magnetometer data resolution and sample ODR
delay_ms(10);
sensorReadReg(MAG_WHO_AM_I, &val, 1);
SENSOR_DESELECT();
return found;
}
#endif
//
// Temporary test function to read all registers
//
uint8_t sensorMpu9250ReadRegs(uint8_t *data, uint8_t start, uint8_t nRegs)
{
uint8_t reg;
SENSOR_SELECT();
for (reg = start; reg < nRegs; reg++)
{
if (sensorReadReg(reg, data+reg, 1) == FALSE)
break;
}
SENSOR_DESELECT();
return reg;
}
/*********************************************************************
*********************************************************************/

View File

@@ -0,0 +1,131 @@
/******************************************************************************
* Filename: sensor_mpu9250.h
* Revised: $Date: 2014-03-07 10:33:11 +0100 (fr, 07 mar 2014) $
* Revision: $Revision: 12329 $
*
* Description: This file contains the declaration to the HAL Invensense
* MPU9250 abstraction layer.
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#ifndef SENSOR_MPU9250_H
#define SENSOR_MPU9250_H
#ifdef __cplusplus
extern "C" {
#endif
/* ------------------------------------------------------------------------------------------------
* Includes
* ------------------------------------------------------------------------------------------------
*/
#include "stdint.h"
#include "stdbool.h"
/* ------------------------------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------------------------------
*/
#define ACC_RANGE_INVALID -1
#define ACC_RANGE_2G 0
#define ACC_RANGE_4G 1
#define ACC_RANGE_8G 2
#define ACC_RANGE_16G 3
#define MPU_AX_GYR_X 2
#define MPU_AX_GYR_Y 1
#define MPU_AX_GYR_Z 0
#define MPU_AX_GYR 0x07
#define MPU_AX_ACC_X 5
#define MPU_AX_ACC_Y 4
#define MPU_AX_ACC_Z 3
#define MPU_AX_ACC 0x38
#define MPU_AX_MAG 6
#define MPU_DATA_READY 0x01
#define MPU_MOVEMENT 0x40
/* ------------------------------------------------------------------------------------------------
* Typedefs
* ------------------------------------------------------------------------------------------------
*/
/* ------------------------------------------------------------------------------------------------
* Functions
* ------------------------------------------------------------------------------------------------
*/
#if CC2650_SENSORTAG >= 0060
void sensorMpu9250PowerOn(void);
void sensorMpu9250PowerOff(void);
bool sensorMpu9250PowerIsOn(void);
#endif
bool sensorMpu9250Init(void);
bool sensorMpu9250Test(void);
void sensorMpu9250Enable(uint16_t config);
bool sensorMpu9250IntEnable(bool enable);
bool sensorMpu9250AccSetRange(uint8_t range);
uint8_t sensorMpu9250AccReadRange(void);
bool sensorMpu9250AccRead(uint16_t *rawData);
float sensorMpu9250AccelConvert(int16_t rawValue);
bool sensorMpu9250GyroRead(uint16_t *rawData);
float sensorMpu9250GyroConvert(int16_t rawValue);
uint8_t sensorMpu9250IntStatus(void);
#ifdef MAG_INCLUDED
bool sensorMpu9250MagTest(void);
bool sensorMpu9250MagRead(uint16_t *rawData);
float sensorMpu9250MagConvert(int16_t rawValue);
#endif
#ifdef WOM_ENABLE
bool sensorMpu9250WomEnable(void);
#endif
/**************************************************************************************************
*/
#ifdef __cplusplus
};
#endif
#endif
/**************************************************************************************************
*/

View File

@@ -0,0 +1,229 @@
/**************************************************************************************************
* Filename: sensor_opt3001.c
* Revised: $Date: 2014-02-05 10:47:02 +0100 (on, 05 feb 2014) $
* Revision: $Revision: 12066 $
*
* Description: Driver for the Texas Instruments OP3001 Optical Sensor
*
* Copyright (C) 2014 - 2015 Texas Instruments Incorporated - http://www.ti.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*************************************************************************************************/
/* ------------------------------------------------------------------------------------------------
* Includes
* ------------------------------------------------------------------------------------------------
*/
#include "bsp_i2c.h"
#include "sensor.h"
#include "sensor_opt3001.h"
#include "math.h"
/* ------------------------------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------------------------------
*/
/* Slave address */
#define SENSOR_I2C_ADDRESS 0x45
/* Register addresses */
#define REG_RESULT 0x00
#define REG_CONFIGURATION 0x01
#define REG_LOW_LIMIT 0x02
#define REG_HIGH_LIMIT 0x03
#define REG_MANUFACTURER_ID 0x7E
#define REG_DEVICE_ID 0x7F
/* Register values */
#define MANUFACTURER_ID 0x5449 // TI
#define DEVICE_ID 0x3001 // Opt 3001
#define CONFIG_RESET 0xC810
#define CONFIG_TEST 0xCC10
#define CONFIG_ENABLE 0x10C4 // 0xC410 - 100 ms, continuous
#define CONFIG_DISABLE 0x10C0 // 0xC010 - 100 ms, shutdown
/* Bit values */
#define DATA_RDY_BIT 0x0080 // Data ready
/* Register length */
#define REGISTER_LENGTH 2
/* Sensor data size */
#define DATA_LENGTH 2
// Sensor selection/deselection
#define SENSOR_SELECT() bspI2cSelect(BSP_I2C_INTERFACE_0,SENSOR_I2C_ADDRESS)
#define SENSOR_DESELECT() bspI2cDeselect()
/* ------------------------------------------------------------------------------------------------
* Local Functions
* ------------------------------------------------------------------------------------------------
*/
/* ------------------------------------------------------------------------------------------------
* Local Variables
* ------------------------------------------------------------------------------------------------
*/
/* ------------------------------------------------------------------------------------------------
* Public functions
* -------------------------------------------------------------------------------------------------
*/
/**************************************************************************************************
* @fn sensorOpt3001Init
*
* @brief Initialize the temperature sensor driver
*
* @return none
**************************************************************************************************/
bool sensorOpt3001Init(void)
{
sensorOpt3001Enable(false);
return true;
}
/**************************************************************************************************
* @fn sensorOpt3001Enable
*
* @brief Turn the sensor on/off
*
* @return none
**************************************************************************************************/
void sensorOpt3001Enable(bool enable)
{
uint16_t val;
SENSOR_SELECT();
if (enable)
val = CONFIG_ENABLE;
else
val = CONFIG_DISABLE;
sensorWriteReg(REG_CONFIGURATION, (uint8_t *)&val, REGISTER_LENGTH);
SENSOR_DESELECT();
}
/**************************************************************************************************
* @fn sensorOpt3001Read
*
* @brief Read the result register
*
* @param Buffer to store data in
*
* @return TRUE if valid data
**************************************************************************************************/
bool sensorOpt3001Read(uint16_t *rawData)
{
bool success;
uint16_t val;
SENSOR_SELECT();
success = sensorReadReg(REG_CONFIGURATION, (uint8_t *)&val, REGISTER_LENGTH);
if (success)
success = (val & DATA_RDY_BIT) == DATA_RDY_BIT;
if (success)
success = sensorReadReg(REG_RESULT, (uint8_t*)&val, DATA_LENGTH);
if (success)
{
// Swap bytes
*rawData = (val << 8) | (val>>8 &0xFF);
}
else
{
sensorSetErrorData((uint8_t*)rawData, DATA_LENGTH);
}
SENSOR_DESELECT();
return success;
}
/**************************************************************************************************
* @fn sensorOpt3001Test
*
* @brief Run a sensor self-test
*
* @return TRUE if passed, FALSE if failed
**************************************************************************************************/
bool sensorOpt3001Test(void)
{
uint16_t val;
// Select this sensor on the I2C bus
SENSOR_SELECT();
// Check manufacturer ID
ST_ASSERT(sensorReadReg(REG_MANUFACTURER_ID, (uint8_t *)&val, REGISTER_LENGTH));
val = (LO_UINT16(val) << 8) | HI_UINT16(val);
ST_ASSERT(val == MANUFACTURER_ID);
// Check device ID
ST_ASSERT(sensorReadReg(REG_DEVICE_ID, (uint8_t *)&val, REGISTER_LENGTH));
val = (LO_UINT16(val) << 8) | HI_UINT16(val);
ST_ASSERT(val == DEVICE_ID);
SENSOR_DESELECT();
return true;
}
/**************************************************************************************************
* @fn sensorOpt3001Convert
*
* @brief Convert raw data to object and ambience temperature
*
* @param data - raw data from sensor
*
* @param lux - converted value (lux)
*
* @return none
**************************************************************************************************/
float sensorOpt3001Convert(uint16_t rawData)
{
uint16_t e, m;
m = rawData & 0x0FFF;
e = (rawData & 0xF000) >> 12;
return m * (0.01 * exp2(e));
}
/*********************************************************************
*********************************************************************/

View File

@@ -0,0 +1,73 @@
/**************************************************************************************************
* Filename: sensor_opt3001.h
* Revised: $Date: 2014-02-05 10:47:02 +0100 (on, 05 feb 2014) $
* Revision: $Revision: 12066 $
*
* Description: Driver for the Texas Instruments OP3001 Optical Sensor
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*************************************************************************************************/
#ifndef SENSOR_OPT3001_H
#define SENSOR_OPT3001_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
* INCLUDES
*/
#include "stdint.h"
/*********************************************************************
* CONSTANTS
*/
/*********************************************************************
* TYPEDEFS
*/
/*********************************************************************
* FUNCTIONS
*/
bool sensorOpt3001Init(void);
void sensorOpt3001Enable(bool enable);
bool sensorOpt3001Read(uint16_t *rawData);
float sensorOpt3001Convert(uint16_t rawData);
bool sensorOpt3001Test(void);
#ifdef __cplusplus
}
#endif
#endif /* SENSOR_OPT3001_H */

View File

@@ -0,0 +1,314 @@
/**************************************************************************************************
* Filename: sensor_sht21.c
* Revised: $Date: 2014-02-05 10:47:02 +0100 (on, 05 feb 2014) $
* Revision: $Revision: 12066 $
*
* Description: Driver for the Sensirion SHT21 Humidity Sensors
*
* Copyright (C) 2014 - 2015 Texas Instruments Incorporated - http://www.ti.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*************************************************************************************************/
/* ------------------------------------------------------------------------------------------------
* Includes
* ------------------------------------------------------------------------------------------------
*/
#include "sensor_sht21.h"
#include "sensor.h"
#include "bsp_i2c.h"
/* ------------------------------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------------------------------
*/
// Sensor I2C address
#define SENSOR_I2C_ADDRESS 0x40
#define S_REG_LEN 2
#define DATA_LEN 3
// Internal commands
#define SHT21_CMD_TEMP_T_NH 0xF3 // command trig. temp meas. no hold master
#define SHT21_CMD_HUMI_T_NH 0xF5 // command trig. humidity meas. no hold master
#define SHT21_CMD_WRITE_U_R 0xE6 // command write user register
#define SHT21_CMD_READ_U_R 0xE7 // command read user register
#define SHT21_CMD_SOFT_RST 0xFE // command soft reset
#define HUMIDITY 0x00
#define TEMPERATURE 0x01
#define USR_REG_MASK 0x38 // Mask off reserved bits (3,4,5)
#define USR_REG_DEFAULT 0x02 // Disable OTP reload
#define USR_REG_RES_MASK 0x7E // Only change bits 0 and 7 (meas. res.)
#define USR_REG_11BITRES 0x81 // 11-bit resolution
#define USR_REG_TEST_VAL 0x83
#define DATA_SIZE 6
// Sensor selection/deselection
#define SENSOR_SELECT() bspI2cSelect(BSP_I2C_INTERFACE_0,SENSOR_I2C_ADDRESS)
#define SENSOR_DESELECT() bspI2cDeselect()
/* ------------------------------------------------------------------------------------------------
* Type Definitions
* ------------------------------------------------------------------------------------------------
*/
/* ------------------------------------------------------------------------------------------------
* Local Functions
* ------------------------------------------------------------------------------------------------
*/
static bool sensorSht21ReadData(uint8_t *pBuf,uint8_t nBytes);
static bool sensorSht21WriteCmd(uint8_t cmd);
/* ------------------------------------------------------------------------------------------------
* Local Variables
* ------------------------------------------------------------------------------------------------
*/
static uint8_t usr; // Keeps user register value
static uint8_t buf[DATA_SIZE]; // Data buffer
static bool success;
/**************************************************************************************************
* @fn sensorSht21Init
*
* @brief Initialize the humidity sensor driver
*
* @return True if successful
**************************************************************************************************/
bool sensorSht21Init(void)
{
SENSOR_SELECT();
// Set 11 bit resolution
success = sensorReadReg(SHT21_CMD_READ_U_R,&usr,1);
if (success)
{
usr &= USR_REG_RES_MASK;
usr |= USR_REG_11BITRES;
success = sensorWriteReg(SHT21_CMD_WRITE_U_R,&usr,1);
}
SENSOR_DESELECT();
return success;
}
/**************************************************************************************************
* @fn sensorSht21StartTempMeasure
*
* @brief Execute measurement step
*
* @return none
*/
void sensorSht21StartTempMeasure(void)
{
if (success)
{
SENSOR_SELECT();
success = sensorSht21WriteCmd(SHT21_CMD_TEMP_T_NH);
SENSOR_DESELECT();
}
}
/**************************************************************************************************
* @fn sensorSht21LatchTempMeasure
*
* @brief Execute measurement step
*
* @return none
*/
void sensorSht21LatchTempMeasure(void)
{
if (success)
{
SENSOR_SELECT();
success = sensorSht21ReadData(buf, DATA_LEN);
SENSOR_DESELECT();
}
}
/**************************************************************************************************
* @fn sensorSht21StartHumMeasure
*
* @brief Execute measurement step
*
* @return none
*/
void sensorSht21StartHumMeasure(void)
{
if (success)
{
SENSOR_SELECT();
success = sensorSht21WriteCmd(SHT21_CMD_HUMI_T_NH);
SENSOR_DESELECT();
}
}
/**************************************************************************************************
* @fn sensorSht21LatchHumMeasure
*
* @brief Latch humidity measurement
*
* @return none
*/
void sensorSht21LatchHumMeasure(void)
{
if (success)
{
SENSOR_SELECT();
success = sensorSht21ReadData(buf+DATA_LEN, DATA_LEN);
SENSOR_DESELECT();
}
}
/**************************************************************************************************
* @fn sensorSht21Read
*
* @brief Get humidity sensor data
*
* @return none
*/
bool sensorSht21Read(uint16_t *rawTemp, uint16_t *rawHum)
{
bool valid;
valid = success;
if (!success)
{
sensorSetErrorData(buf,DATA_SIZE);
}
// Store temperature
*rawTemp = buf[0]<<8 | buf[1];
// [2] ignore CRC
// Store humidity
*rawHum = buf[3]<<8 | buf[4];
// [5] ignore CRC
success = true; // Ready for next cycle
return valid;
}
/**************************************************************************************************
* @fn sensorSht21Convert
*
* @brief Convert raw data to temperature and humidity
*
* @param data - raw data from sensor (little endian)
*
* @param temp - converted temperature
*
* @param hum - converted humidity
*
* @return none
**************************************************************************************************/
void sensorSht21Convert(uint16_t rawTemp, uint16_t rawHum, float *temp, float *hum)
{
//-- calculate temperature [°C] --
rawTemp &= ~0x0003; // clear bits [1..0] (status bits)
*temp = -46.85 + 175.72/65536 *(double)(int16_t)rawTemp;
rawHum &= ~0x0003; // clear bits [1..0] (status bits)
//-- calculate relative humidity [%RH] --
*hum = -6.0 + 125.0/65536 * (double)rawHum; // RH= -6 + 125 * SRH/2^16
}
/**************************************************************************************************
* @fn sensorSht21Test
*
* @brief Humidity sensor self test
*
* @return none
**************************************************************************************************/
bool sensorSht21Test(void)
{
uint8_t val;
SENSOR_SELECT();
// Verify write and read
val = USR_REG_TEST_VAL;
ST_ASSERT(sensorWriteReg(SHT21_CMD_WRITE_U_R,&val,1));
ST_ASSERT(sensorReadReg(SHT21_CMD_READ_U_R,&val,1));
ST_ASSERT(val == USR_REG_TEST_VAL);
SENSOR_DESELECT();
return true;
}
/* ------------------------------------------------------------------------------------------------
* Private functions
* -------------------------------------------------------------------------------------------------
*/
/**************************************************************************************************
* @fn halHumiWriteCmd
*
* @brief Write a command to the humidity sensor
*
* @param cmd - command to write
*
* @return TRUE if the command has been transmitted successfully
**************************************************************************************************/
static bool sensorSht21WriteCmd(uint8_t cmd)
{
/* Send command */
return bspI2cWriteSingle(cmd);
}
/**************************************************************************************************
* @fn sensorSht21ReadData
*
* @brief This function implements the I2C protocol to read from the SHT21.
*
* @param pBuf - pointer to buffer to place data
*
* @param nBytes - number of bytes to read
*
* @return TRUE if the required number of bytes are received
**************************************************************************************************/
static bool sensorSht21ReadData(uint8_t *pBuf, uint8_t nBytes)
{
/* Read data */
return bspI2cRead(pBuf,nBytes);
}
/*********************************************************************
*********************************************************************/

View File

@@ -0,0 +1,73 @@
/**************************************************************************************************
* Filename: sensor_sht21.h
* Revised: $Date: 2014-02-05 10:47:02 +0100 (on, 05 feb 2014) $
* Revision: $Revision: 12066 $
*
* Description: Driver for the Sensirion SHT21 Humidity Sensors
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*************************************************************************************************/
#ifndef SENSOR_SHT21_H
#define SENSOR_SHT21_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
* INCLUDES
*/
#include "stdbool.h"
#include "stdint.h"
/*********************************************************************
* CONSTANTS
*/
/*********************************************************************
* FUNCTIONS
*/
bool sensorSht21Init(void);
void sensorSht21StartTempMeasure(void);
void sensorSht21LatchTempMeasure(void);
void sensorSht21StartHumMeasure(void);
void sensorSht21LatchHumMeasure(void);
bool sensorSht21Read(uint16_t *rawHum, uint16_t *rawTemp);
void sensorSht21Convert(uint16_t rawHum, uint16_t rawTemp, float *temp, float *hum);
bool sensorSht21Test(void);
/*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* SENSOR_SHT21_H */

View File

@@ -0,0 +1,274 @@
/**************************************************************************************************
* Filename: sensor_tmp006.c
* Revised: $Date: 2014-02-05 10:47:02 +0100 (on, 05 feb 2014) $
* Revision: $Revision: 12066 $
*
* Description: Driver for the Texas Instruments TMP006 IR temperature sensor
*
* Copyright (C) 2014 - 2015 Texas Instruments Incorporated - http://www.ti.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*************************************************************************************************/
/* ------------------------------------------------------------------------------------------------
* Includes
* ------------------------------------------------------------------------------------------------
*/
#include "bsp_i2c.h"
#include "sensor.h"
#include "sensor_tmp006.h"
#include "math.h"
/* ------------------------------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------------------------------
*/
/* Slave address */
#define SENSOR_I2C_ADDRESS 0x44
/* TMP006 register addresses */
#define TMP006_REG_ADDR_VOLTAGE 0x00
#define TMP006_REG_ADDR_TEMPERATURE 0x01
#define TMP006_REG_ADDR_CONFIG 0x02
#define TMP006_REG_MANF_ID 0xFE
#define TMP006_REG_PROD_ID 0xFF
/* TMP006 register values */
#define TMP006_VAL_CONFIG_RESET 0x7400 // Sensor reset state
#define TMP006_VAL_CONFIG_ON 0x7000 // Sensor on state
#define TMP006_VAL_CONFIG_OFF 0x0000 // Sensor off state
#define TMP006_VAL_MANF_ID 0x5449 // Manufacturer ID
#define TMP006_VAL_PROD_ID 0x0067 // Product ID
/* Bit values */
#define DATA_RDY_BIT 0x8000 // Data ready
/* Register length */
#define REGISTER_LENGTH 2
/* Sensor data size */
#define DATA_SIZE 4
// Sensor selection/deselection
#define SENSOR_SELECT() bspI2cSelect(BSP_I2C_INTERFACE_0,SENSOR_I2C_ADDRESS)
#define SENSOR_DESELECT() bspI2cDeselect()
/* ------------------------------------------------------------------------------------------------
* Local Variables
* ------------------------------------------------------------------------------------------------
*/
static uint8_t configSensorReset[2] = {0x80, 0x00}; // Sensor reset
static uint8_t configSensorOff[2] = {0x00, 0x80}; // Sensor standby
static uint8_t configSensorOn[2] = {0x70, 0x00}; // Conversion time 0.25 sec
static uint8_t buf[DATA_SIZE];
/* ------------------------------------------------------------------------------------------------
* Public functions
* -------------------------------------------------------------------------------------------------
*/
/**************************************************************************************************
* @fn sensorTmp006Init
*
* @brief Initialize the temperature sensor driver
*
* @return none
**************************************************************************************************/
bool sensorTmp006Init(void)
{
return sensorTmp006Enable(false);
}
/**************************************************************************************************
* @fn sensorTmp006Enable
*
* @brief Turn the sensor on/off
*
* @return none
**************************************************************************************************/
bool sensorTmp006Enable(bool enable)
{
bool ret;
SENSOR_SELECT();
if (enable)
ret = sensorWriteReg(TMP006_REG_ADDR_CONFIG, configSensorOn, REGISTER_LENGTH);
else
ret = sensorWriteReg(TMP006_REG_ADDR_CONFIG, configSensorOff, REGISTER_LENGTH);
SENSOR_DESELECT();
return ret;
}
/**************************************************************************************************
* @fn sensorTmp006Read
*
* @brief Read the sensor voltage and sensor temperature registers
*
* @param rawVolt - voltage in 16 bit format
*
* @param rawtEMP - temperature in 16 bit format
*
* @return TRUE if valid data
**************************************************************************************************/
bool sensorTmp006Read(uint16_t *rawVolt, uint16_t *rawTemp)
{
bool success;
uint16_t v;
SENSOR_SELECT();
success = sensorReadReg(TMP006_REG_ADDR_CONFIG, (uint8_t *)&v,REGISTER_LENGTH );
if (success)
success = v & DATA_RDY_BIT;
if (success)
{
// Read the sensor registers
success = sensorReadReg(TMP006_REG_ADDR_VOLTAGE, &buf[0], REGISTER_LENGTH );
if (success)
{
success = sensorReadReg(TMP006_REG_ADDR_TEMPERATURE, &buf[2], REGISTER_LENGTH );
}
}
if (!success)
{
sensorSetErrorData(buf,4);
}
*rawVolt = buf[0]<<8 | buf[1];
*rawTemp = buf[2]<<8 | buf[3];
SENSOR_DESELECT();
return success;
}
/**************************************************************************************************
* @fn sensorTmp006Test
*
* @brief Run a sensor self-test
*
* @return TRUE if passed, FALSE if failed
**************************************************************************************************/
bool sensorTmp006Test(void)
{
uint16_t val;
// Select this sensor on the I2C bus
SENSOR_SELECT();
// Check manufacturer ID
ST_ASSERT(sensorReadReg(TMP006_REG_MANF_ID, (uint8_t *)&val, REGISTER_LENGTH));
val = (LO_UINT16(val) << 8) | HI_UINT16(val);
ST_ASSERT(val == TMP006_VAL_MANF_ID);
// Reset sensor
ST_ASSERT(sensorWriteReg(TMP006_REG_ADDR_CONFIG, configSensorReset, REGISTER_LENGTH));
// Check config register (reset)
ST_ASSERT(sensorReadReg(TMP006_REG_ADDR_CONFIG, (uint8_t *)&val, REGISTER_LENGTH));
val = ((LO_UINT16(val) << 8) | HI_UINT16(val));
ST_ASSERT(val == TMP006_VAL_CONFIG_RESET);
// Turn sensor off
ST_ASSERT(sensorWriteReg(TMP006_REG_ADDR_CONFIG, configSensorOff,REGISTER_LENGTH));
// Check config register (off)
ST_ASSERT(sensorReadReg(TMP006_REG_ADDR_CONFIG, (uint8_t *)&val, REGISTER_LENGTH));
val = ((LO_UINT16(val) << 8) | HI_UINT16(val));
// ST_ASSERT(val == TMP006_VAL_CONFIG_OFF);
// Turn sensor on
ST_ASSERT(sensorWriteReg(TMP006_REG_ADDR_CONFIG, configSensorOn, REGISTER_LENGTH));
// Check config register (on)
ST_ASSERT(sensorReadReg(TMP006_REG_ADDR_CONFIG, (uint8_t *)&val, REGISTER_LENGTH));
val = ((LO_UINT16(val) << 8) | HI_UINT16(val));
ST_ASSERT(val == TMP006_VAL_CONFIG_ON);
// Turn sensor off
ST_ASSERT(sensorWriteReg(TMP006_REG_ADDR_CONFIG, configSensorOff, REGISTER_LENGTH));
SENSOR_DESELECT();
return true;
}
/**************************************************************************************************
* @fn sensorTmp006Convert
*
* @brief Convert raw data to object and ambience temperature
*
* @param rawVolt - raw voltage from sensor
*
* @param rawTemp - raw temperature from sensor
*
* @param tObj - converted object temperature
*
* @param tAmb - converted ambience temperature
*
* @return none
**************************************************************************************************/
void sensorTmp006Convert(uint16_t rawVolt, uint16_t rawTemp, float *tObj, float *tAmb)
{
//-- calculate die temperature [°C] --
*tAmb = (double)((int16_t)rawTemp)/128.0;
//-- calculate target temperature [°C] -
double Vobj2 = (double)(int16_t)rawVolt;
Vobj2 *= 0.00000015625;
double Tdie2 = *tAmb + 273.15;
const double S0 = 6.4E-14; // Calibration factor
const double a1 = 1.75E-3;
const double a2 = -1.678E-5;
const double b0 = -2.94E-5;
const double b1 = -5.7E-7;
const double b2 = 4.63E-9;
const double c2 = 13.4;
const double Tref = 298.15;
double S = S0*(1+a1*(Tdie2 - Tref)+a2*pow((Tdie2 - Tref),2));
double Vos = b0 + b1*(Tdie2 - Tref) + b2*pow((Tdie2 - Tref),2);
double fObj = (Vobj2 - Vos) + c2*pow((Vobj2 - Vos),2);
double t = pow(pow(Tdie2,4) + (fObj/S),.25);
*tObj = (t - 273.15);
}
/*********************************************************************
*********************************************************************/

View File

@@ -0,0 +1,73 @@
**************************************************************************************************
* Filename: sensor_tmp006.h
* Revised: $Date: 2014-02-05 10:47:02 +0100 (on, 05 feb 2014) $
* Revision: $Revision: 12066 $
*
* Description: Driver for the Texas Instruments TMP006 IR temperature sensor
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*************************************************************************************************/
#ifndef SENSOR_TMP006_H
#define SENSOR_TMP006_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
* INCLUDES
*/
#include "stdint.h"
/*********************************************************************
* CONSTANTS
*/
/*********************************************************************
* TYPEDEFS
*/
/*********************************************************************
* FUNCTIONS
*/
bool sensorTmp006Init(void);
bool sensorTmp006Enable(bool enable);
bool sensorTmp006Read(uint16_t *rawVolt, uint16_t *rawTemp);
void sensorTmp006Convert(uint16_t rawVolt, uint16_t rawTemp, float *tObj, float *tTgt);
bool sensorTmp006Test(void);
#ifdef __cplusplus
}
#endif
#endif /* SENSOR_TMP006_H */

View File

@@ -0,0 +1,275 @@
/******************************************************************************
* Filename: sensor_tmp007.c
* Revised: $Date: 2014-03-07 10:33:11 +0100 (fr, 07 mar 2014) $
* Revision: $Revision: 12329 $
*
* Description: Driver for the TI TMP06 infrared thermophile sensor.
*
* Copyright (C) 2014 - 2015 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
/* -----------------------------------------------------------------------------
* Includes
* ------------------------------------------------------------------------------
*/
#include "bsp_i2c.h"
#include "sensor.h"
#include "sensor_tmp007.h"
#include "math.h"
/* -----------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------------
*/
/* Slave address */
#define SENSOR_I2C_ADDRESS 0x44
/* TMP006 register addresses */
#define TMP007_REG_ADDR_VOLTAGE 0x00
#define TMP007_REG_ADDR_LOCAL_TEMP 0x01
#define TMP007_REG_ADDR_CONFIG 0x02
#define TMP007_REG_ADDR_OBJ_TEMP 0x03
#define TMP007_REG_ADDR_STATUS 0x04
#define TMP007_REG_PROD_ID 0x1F
/* TMP006 register values */
#define TMP007_VAL_CONFIG_ON 0x1000 // Sensor on state
#define TMP007_VAL_CONFIG_OFF 0x0000 // Sensor off state
#define TMP007_VAL_CONFIG_RESET 0x8000
#define TMP007_VAL_PROD_ID 0x0078 // Product ID
/* Bit values */
#define CONV_RDY_BIT 0x4000 // Conversion ready
/* Register length */
#define REGISTER_LENGTH 2
/* Sensor data size */
#define DATA_SIZE 4
/* Byte swap of 16-bit register value */
#define SWAP(v) ( (LO_UINT16(v) << 8) | HI_UINT16(v) )
// Sensor selection/deselection
#define SENSOR_SELECT() bspI2cSelect(BSP_I2C_INTERFACE_0,SENSOR_I2C_ADDRESS)
#define SENSOR_DESELECT() bspI2cDeselect()
/* -----------------------------------------------------------------------------
* Local Functions
* ------------------------------------------------------------------------------
*/
/* -----------------------------------------------------------------------------
* Local Variables
* ------------------------------------------------------------------------------
*/
static uint8_t buf[DATA_SIZE];
static uint16_t val;
/* -----------------------------------------------------------------------------
* Public functions
* ------------------------------------------------------------------------------
*/
/*******************************************************************************
* @fn sensorTmp007Init
*
* @brief Initialize the temperature sensor driver
*
* @return none
******************************************************************************/
bool sensorTmp007Init(void)
{
// Configure sensor
return sensorTmp007Enable(false);
}
/*******************************************************************************
* @fn sensorTmp007Enable
*
* @brief Turn the sensor on/off
*
* @return none
******************************************************************************/
bool sensorTmp007Enable(bool enable)
{
bool success;
SENSOR_SELECT();
if (enable)
val = TMP007_VAL_CONFIG_ON;
else
val = TMP007_VAL_CONFIG_OFF;
val = SWAP(val);
success = sensorWriteReg(TMP007_REG_ADDR_CONFIG, (uint8_t*)&val,
REGISTER_LENGTH);
SENSOR_DESELECT();
return success;
}
/*******************************************************************************
* @fn sensorTmp007Read
*
* @brief Read the sensor voltage and sensor temperature registers
*
* @param rawtTemp - temperature in 16 bit format
*
* @param rawtObjTemp - object temperature in 16 bit format
*
* @return TRUE if valid data
******************************************************************************/
bool sensorTmp007Read(uint16_t *rawTemp, uint16_t *rawObjTemp)
{
bool success;
SENSOR_SELECT();
success = sensorReadReg(TMP007_REG_ADDR_STATUS, (uint8_t *)&val,
REGISTER_LENGTH);
if (success)
{
val = SWAP(val);
success = val & CONV_RDY_BIT;
}
if (success)
{
// Read the sensor registers
success = sensorReadReg(TMP007_REG_ADDR_LOCAL_TEMP, &buf[0],
REGISTER_LENGTH);
if (success)
{
success = sensorReadReg(TMP007_REG_ADDR_OBJ_TEMP, &buf[2],
REGISTER_LENGTH);
}
}
if (!success)
{
sensorSetErrorData(buf,4);
}
// Swap bytes
*rawTemp = buf[0]<<8 | buf[1];
*rawObjTemp = buf[2]<<8 | buf[3];
SENSOR_DESELECT();
return success;
}
/*******************************************************************************
* @fn sensorTmp007Test
*
* @brief Run a sensor self-test
*
* @return TRUE if passed, FALSE if failed
******************************************************************************/
bool sensorTmp007Test(void)
{
// Select this sensor on the I2C bus
SENSOR_SELECT();
// Check product ID
ST_ASSERT(sensorReadReg(TMP007_REG_PROD_ID, (uint8_t *)&val, REGISTER_LENGTH));
val = SWAP(val);
ST_ASSERT(val == TMP007_VAL_PROD_ID);
// Turn sensor on
val = SWAP(TMP007_VAL_CONFIG_ON);
ST_ASSERT(sensorWriteReg(TMP007_REG_ADDR_CONFIG, (uint8_t *)&val,
REGISTER_LENGTH));
// Check config register (on)
ST_ASSERT(sensorReadReg(TMP007_REG_ADDR_CONFIG, (uint8_t *)&val,
REGISTER_LENGTH));
val = SWAP(val);
ST_ASSERT(val == TMP007_VAL_CONFIG_ON);
// Turn sensor off
val = SWAP(TMP007_VAL_CONFIG_OFF);
ST_ASSERT(sensorWriteReg(TMP007_REG_ADDR_CONFIG, (uint8_t *)&val,
REGISTER_LENGTH));
// Check config register (off)
ST_ASSERT(sensorReadReg(TMP007_REG_ADDR_CONFIG, (uint8_t *)&val,
REGISTER_LENGTH));
val = SWAP(val);
ST_ASSERT(val == TMP007_VAL_CONFIG_OFF);
SENSOR_DESELECT();
return true;
}
/*******************************************************************************
* @fn sensorTmp007Convert
*
* @brief Convert raw data to object and ambience temperature
*
* @param rawTemp - raw temperature from sensor
*
* @param rawObjTemp - raw temperature from sensor
*
* @param tObj - converted object temperature
*
* @param tAmb - converted ambience temperature
*
* @return none
******************************************************************************/
void sensorTmp007Convert(uint16_t rawTemp, uint16_t rawObjTemp, float *tObj,
float *tTgt)
{
const float SCALE_LSB = 0.03125;
float t;
int it;
it = (int)((rawObjTemp) >> 2);
t = ((float)(it)) * SCALE_LSB;
*tObj = t;
it = (int)((rawTemp) >> 2);
t = (float)it;
*tTgt = t * SCALE_LSB;
}
/*******************************************************************************
*******************************************************************************/

View File

@@ -0,0 +1,79 @@
/******************************************************************************
* Filename: sensor_tmp007.h
* Revised: $Date: 2014-07-30 15:20:17 +0200 (on, 30 jul 2014) $
* Revision: $Revision: 13441 $
*
* Description: Interface to the IR temperature sensor driver TI TMP007.
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#ifndef SENSOR_TMP007_H
#define SENSOR_TMP007_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
* INCLUDES
*/
#include "stdint.h"
/*********************************************************************
* CONSTANTS
*/
/*********************************************************************
* TYPEDEFS
*/
/*********************************************************************
* FUNCTIONS
*/
bool sensorTmp007Init(void);
bool sensorTmp007Enable(bool enable);
bool sensorTmp007Test(void);
bool sensorTmp006Read(uint16_t *rawVolt, uint16_t *rawTemp);
void sensorTmp006Convert(uint16_t rawVolt, uint16_t rawTemp, float *tObj, float *tTgt);
bool sensorTmp007Read(uint16_t *rawTemp, uint16_t *rawObjTemp);
void sensorTmp007Convert(uint16_t rawTemp, uint16_t rawObjTemp, float *tObj, float *tTgt);
#ifdef __cplusplus
}
#endif
#endif /* SENSOR_TMP007_H */

View File

@@ -0,0 +1,380 @@
/*******************************************************************************
Filename: util.c
Revised: $Date: 2015-06-02 11:18:40 -0700 (Tue, 02 Jun 2015) $
Revision: $Revision: 43957 $
Description: This file contains utility functions commonly used by
BLE applications for CC26xx with TIRTOS.
Copyright 2014 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
*******************************************************************************/
/*********************************************************************
* INCLUDES
*/
#include <stdbool.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <ti/sysbios/knl/Queue.h>
#ifdef USE_ICALL
#include <ICall.h>
#else
#include <stdlib.h>
#endif
#include "bcomdef.h"
#include "util.h"
/*********************************************************************
* TYPEDEFS
*/
// RTOS queue for profile/app messages.
typedef struct _queueRec_
{
Queue_Elem _elem; // queue element
uint8_t *pData; // pointer to app data
} queueRec_t;
/*********************************************************************
* LOCAL FUNCTIONS
*/
/*******************************************************************************
* EXTERNAL VARIABLES
*/
/*********************************************************************
* LOCAL VARIABLES
*/
/*********************************************************************
* PUBLIC FUNCTIONS
*/
/*********************************************************************
* @fn Util_constructClock
*
* @brief Initialize a TIRTOS Clock instance.
*
* @param pClock - pointer to clock instance structure.
* @param clockCB - callback function upon clock expiration.
* @param clockDuration - longevity of clock timer in milliseconds
* @param clockPeriod - if set to a value other than 0, the first
* expiry is determined by clockDuration. All
* subsequent expiries use the clockPeriod value.
* @param startFlag - TRUE to start immediately, FALSE to wait.
* @param arg - argument passed to callback function.
*
* @return Clock_Handle - a handle to the clock instance.
*/
Clock_Handle Util_constructClock(Clock_Struct *pClock,
Clock_FuncPtr clockCB,
uint32_t clockDuration,
uint32_t clockPeriod,
uint8_t startFlag,
UArg arg)
{
Clock_Params clockParams;
// Convert clockDuration in milliseconds to ticks.
uint32_t clockTicks = clockDuration * (1000 / Clock_tickPeriod);
// Setup parameters.
Clock_Params_init(&clockParams);
// Setup argument.
clockParams.arg = arg;
// If period is 0, this is a one-shot timer.
clockParams.period = clockPeriod * (1000 / Clock_tickPeriod);
// Starts immediately after construction if true, otherwise wait for a call
// to start.
clockParams.startFlag = startFlag;
// Initialize clock instance.
Clock_construct(pClock, clockCB, clockTicks, &clockParams);
return Clock_handle(pClock);
}
/*********************************************************************
* @fn Util_startClock
*
* @brief Start a clock.
*
* @param pClock - pointer to clock struct
*
* @return none
*/
void Util_startClock(Clock_Struct *pClock)
{
Clock_Handle handle = Clock_handle(pClock);
// Start clock instance
Clock_start(handle);
}
/*********************************************************************
* @fn Util_restartClock
*
* @brief Restart a clock by changing the timeout.
*
* @param pClock - pointer to clock struct
* @param clockTimeout - longevity of clock timer in milliseconds
*
* @return none
*/
void Util_restartClock(Clock_Struct *pClock, uint32_t clockTimeout)
{
uint32_t clockTicks;
Clock_Handle handle;
handle = Clock_handle(pClock);
if (Clock_isActive(handle))
{
// Stop clock first
Clock_stop(handle);
}
// Convert timeout in milliseconds to ticks.
clockTicks = clockTimeout * (1000 / Clock_tickPeriod);
// Set the initial timeout
Clock_setTimeout(handle, clockTicks);
// Start clock instance
Clock_start(handle);
}
/*********************************************************************
* @fn Util_isActive
*
* @brief Determine if a clock is currently active.
*
* @param pClock - pointer to clock struct
*
* @return TRUE or FALSE
*/
bool Util_isActive(Clock_Struct *pClock)
{
Clock_Handle handle = Clock_handle(pClock);
// Start clock instance
return Clock_isActive(handle);
}
/*********************************************************************
* @fn Util_stopClock
*
* @brief Stop a clock.
*
* @param pClock - pointer to clock struct
*
* @return none
*/
void Util_stopClock(Clock_Struct *pClock)
{
Clock_Handle handle = Clock_handle(pClock);
// Stop clock instance
Clock_stop(handle);
}
/*********************************************************************
* @fn Util_rescheduleClock
*
* @brief Reschedule a clock by changing the timeout and period values.
*
* @param pClock - pointer to clock struct
* @param clockPeriod - longevity of clock timer in milliseconds
* @return none
*/
void Util_rescheduleClock(Clock_Struct *pClock, uint32_t clockPeriod)
{
bool running;
uint32_t clockTicks;
Clock_Handle handle;
handle = Clock_handle(pClock);
running = Clock_isActive(handle);
if (running)
{
Clock_stop(handle);
}
// Convert period in milliseconds to ticks.
clockTicks = clockPeriod * (1000 / Clock_tickPeriod);
Clock_setTimeout(handle, clockTicks);
Clock_setPeriod(handle, clockTicks);
if (running)
{
Clock_start(handle);
}
}
/*********************************************************************
* @fn Util_constructQueue
*
* @brief Initialize an RTOS queue to hold messages to be processed.
*
* @param pQueue - pointer to queue instance structure.
*
* @return A queue handle.
*/
Queue_Handle Util_constructQueue(Queue_Struct *pQueue)
{
// Construct a Queue instance.
Queue_construct(pQueue, NULL);
return Queue_handle(pQueue);
}
/*********************************************************************
* @fn Util_enqueueMsg
*
* @brief Creates a queue node and puts the node in RTOS queue.
*
* @param msgQueue - queue handle.
* @param sem - thread's event processing semaphore that queue is
* associated with.
* @param pMsg - pointer to message to be queued
*
* @return TRUE if message was queued, FALSE otherwise.
*/
uint8_t Util_enqueueMsg(Queue_Handle msgQueue, Semaphore_Handle sem,
uint8_t *pMsg)
{
queueRec_t *pRec;
// Allocated space for queue node.
#ifdef USE_ICALL
if (pRec = ICall_malloc(sizeof(queueRec_t)))
#else
if (pRec = (queueRec_t *)malloc(sizeof(queueRec_t)))
#endif
{
pRec->pData = pMsg;
Queue_enqueue(msgQueue, &pRec->_elem);
// Wake up the application thread event handler.
if (sem)
{
Semaphore_post(sem);
}
return TRUE;
}
// Free the message.
#ifdef USE_ICALL
ICall_free(pMsg);
#else
free(pMsg);
#endif
return FALSE;
}
/*********************************************************************
* @fn Util_dequeueMsg
*
* @brief Dequeues the message from the RTOS queue.
*
* @param msgQueue - queue handle.
*
* @return pointer to dequeued message, NULL otherwise.
*/
uint8_t *Util_dequeueMsg(Queue_Handle msgQueue)
{
if (!Queue_empty(msgQueue))
{
queueRec_t *pRec = Queue_dequeue(msgQueue);
uint8_t *pData = pRec->pData;
// Free the queue node
// Note: this does not free space allocated by data within the node.
#ifdef USE_ICALL
ICall_free(pRec);
#else
free(pRec);
#endif
return pData;
}
return NULL;
}
/*********************************************************************
* @fn Util_convertBdAddr2Str
*
* @brief Convert Bluetooth address to string. Only needed when
* LCD display is used.
*
* @param pAddr - BD address
*
* @return BD address as a string
*/
char *Util_convertBdAddr2Str(uint8_t *pAddr)
{
uint8_t charCnt;
char hex[] = "0123456789ABCDEF";
static char str[(2*B_ADDR_LEN)+3];
char *pStr = str;
*pStr++ = '0';
*pStr++ = 'x';
// Start from end of addr
pAddr += B_ADDR_LEN;
for (charCnt = B_ADDR_LEN; charCnt > 0; charCnt--)
{
*pStr++ = hex[*--pAddr >> 4];
*pStr++ = hex[*pAddr & 0x0F];
}
pStr = NULL;
return str;
}
/*********************************************************************
*********************************************************************/

View File

@@ -0,0 +1,217 @@
/*******************************************************************************
Filename: util.h
Revised: $Date: 2015-07-07 13:30:52 -0700 (Tue, 07 Jul 2015) $
Revision: $Revision: 44319 $
Description: This file contains function declarations common to CC26xx
TIRTOS Applications.
Copyright 2014 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
*******************************************************************************/
#ifndef UTIL_H
#define UTIL_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************************************************************
* INCLUDES
*/
#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/knl/Queue.h>
#include <ti/sysbios/knl/Semaphore.h>
/*********************************************************************
* EXTERNAL VARIABLES
*/
/*********************************************************************
* CONSTANTS
*/
/*********************************************************************
* TYPEDEFS
*/
typedef struct
{
uint16_t event; // Event type.
uint8_t state; // Event state;
}appEvtHdr_t;
/*********************************************************************
* MACROS
*/
/*********************************************************************
* API FUNCTIONS
*/
/*********************************************************************
* @fn Util_constructClock
*
* @brief Initialize a TIRTOS Clock instance.
*
* @param pClock - pointer to clock instance structure.
* @param clockCB - callback function upon clock expiration.
* @param clockDuration - longevity of clock timer in milliseconds
* @param clockPeriod - duration of a periodic clock, used continuously
* after clockDuration expires.
* @param startFlag - TRUE to start immediately, FALSE to wait.
* @param arg - argument passed to callback function.
*
* @return Clock_Handle - a handle to the clock instance.
*/
extern Clock_Handle Util_constructClock(Clock_Struct *pClock,
Clock_FuncPtr clockCB,
uint32_t clockDuration,
uint32_t clockPeriod,
uint8_t startFlag,
UArg arg);
/*********************************************************************
* @fn Util_startClock
*
* @brief Start a clock.
*
* @param pClock - pointer to clock struct
*
* @return none
*/
extern void Util_startClock(Clock_Struct *pClock);
/*********************************************************************
* @fn Util_setClockTimeout
*
* @brief Restart a clock by changing the timeout.
*
* @param pClock - pointer to clock struct
* @param clockTimeout - longevity of clock timer in milliseconds
*
* @return none
*/
extern void Util_restartClock(Clock_Struct *pClock, uint32_t clockTimeout);
/*********************************************************************
* @fn Util_isActive
*
* @brief Determine if a clock is currently active.
*
* @param pClock - pointer to clock struct
*
* @return TRUE or FALSE
*/
extern bool Util_isActive(Clock_Struct *pClock);
/*********************************************************************
* @fn Util_stopClock
*
* @brief Stop a clock.
*
* @param pClock - pointer to clock struct
*
* @return none
*/
extern void Util_stopClock(Clock_Struct *pClock);
/*********************************************************************
* @fn Util_rescheduleClock
*
* @brief Reschedule a clock by changing the timeout and period values.
*
* @param pClock - pointer to clock struct
* @param clockPeriod - longevity of clock timer in milliseconds
* @return none
*/
extern void Util_rescheduleClock(Clock_Struct *pClock, uint32_t clockPeriod);
/*********************************************************************
* @fn Util_constructQueue
*
* @brief Initialize an RTOS queue to hold messages from profile to be
* processed.
*
* @param pQueue - pointer to queue instance structure.
*
* @return A queue handle.
*/
extern Queue_Handle Util_constructQueue(Queue_Struct *pQueue);
/*********************************************************************
* @fn Util_enqueueMsg
*
* @brief Creates a queue node and puts the node in RTOS queue.
*
* @param msgQueue - queue handle.
*
* @param sem - the thread's event processing semaphore that this queue is
* associated with.
*
* @param pMsg - pointer to message to be queued
*
* @return TRUE if message was queued, FALSE otherwise.
*/
extern uint8_t Util_enqueueMsg(Queue_Handle msgQueue, Semaphore_Handle sem,
uint8_t *pMsg);
/*********************************************************************
* @fn Util_dequeueMsg
*
* @brief Dequeues the message from the RTOS queue.
*
* @param msgQueue - queue handle.
*
* @return pointer to dequeued message, NULL otherwise.
*/
extern uint8_t *Util_dequeueMsg(Queue_Handle msgQueue);
/*********************************************************************
* @fn Util_convertBdAddr2Str
*
* @brief Convert Bluetooth address to string. Only needed when
* LCD display is used.
*
* @param pAddr - BD address
*
* @return BD address as a string
*/
extern char *Util_convertBdAddr2Str(uint8_t *pAddr);
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* UTIL_H */

View File

@@ -0,0 +1,254 @@
/*******************************************************************************
Filename: npi.c
Revised: $Date: 2008-06-11 14:30:47 -0700 (Wed, 11 Jun 2008) $
Revision: $Revision: 17210 $
Description: This file contains the Network Processor Interface (NPI),
which abstracts the physical link between the Application
Processor (AP) and the Network Processor (NP). The NPI
serves as the HAL's client for the SPI and UART drivers, and
provides API and callback services for its client.
Copyright 2006-2015 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
*******************************************************************************/
/*******************************************************************************
* INCLUDES
*/
#include "hal_types.h"
#include "inc/npi_ble.h"
#include "npi.h"
#include "OSAL.h"
#include "bcomdef.h"
/*******************************************************************************
* MACROS
*/
/*******************************************************************************
* CONSTANTS
*/
/*******************************************************************************
* TYPEDEFS
*/
/*******************************************************************************
* LOCAL VARIABLES
*/
static uint8_t uartAppTaskId = INVALID_TASK_ID;
/*******************************************************************************
* GLOBAL VARIABLES
*/
/*******************************************************************************
* PROTOTYPES
*/
/*******************************************************************************
* FUNCTIONS
*/
/*******************************************************************************
* @fn NPI_InitTransport
*
* @brief This routine initializes the transport layer.
*
* input parameters
*
* @param npiCallback - pointer to callback
*
* output parameters
*
* @param None.
*
* @return Returns the number of bytes written to transport.
*/
void NPI_InitTransport(npiCBack_t npiCallback)
{
//Do something
}
/*******************************************************************************
* @fn NPI_RxBufLen
*
* @brief This routine returns the number of bytes in the receive buffer.
*
* input parameters
*
* @param None.
*
* output parameters
*
* @param None.
*
* @return Returns the number of bytes in the receive buffer.
*/
uint16 NPI_RxBufLen( void )
{
return 0;
}
/*******************************************************************************
* @fn NPI_ReadTransport
*
* @brief This routine reads data from the transport layer based on len,
* and places it into the buffer.
*
* input parameters
*
* @param buf - Pointer to buffer to place read data.
* @param len - Number of bytes to read.
*
* output parameters
*
* @param None.
*
* @return Returns the number of bytes read from transport.
*/
uint16 NPI_ReadTransport( uint8 *buf, uint16 len )
{
return 0;
}
/*******************************************************************************
* @fn NPI_WriteTransport
*
* @brief This routine writes data from the buffer to the transport layer.
*
* input parameters
*
* @param buf - Pointer to buffer to write data from.
* @param len - Number of bytes to write.
*
* output parameters
*
* @param None.
*
* @return Returns the number of bytes written to transport.
*/
uint16 NPI_WriteTransport( uint8 *buf, uint16 len )
{
npiPkt_t *pMsg;
// check if the Task Id is valid
if ( uartAppTaskId != INVALID_TASK_ID )
{
//Create an OSAL message to copy the buf
pMsg = (npiPkt_t *)osal_msg_allocate(sizeof(npiPkt_t) + len);
if (pMsg)
{
pMsg->hdr.event = *buf; //Has the event status code in first byte of payload
pMsg->hdr.status = 0xFF;
pMsg->pktLen = len;
pMsg->pData = (uint8 *)(pMsg + 1);
osal_memcpy(pMsg->pData, buf, len);
// Send message using uartAppTaskId
osal_msg_send(uartAppTaskId, (uint8 *)pMsg); //If there is no space, app has to queue it
return len;
}
}
return 0;
}
/*******************************************************************************
* @fn NPI_GetMaxRxBufSize
*
* @brief This routine returns the max size receive buffer.
*
* input parameters
*
* @param None.
*
* output parameters
*
* @param None.
*
* @return Returns the max size of the receive buffer.
*/
uint16 NPI_GetMaxRxBufSize( void )
{
return( NPI_UART_RX_BUF_SIZE );
}
/*******************************************************************************
* @fn NPI_GetMaxTxBufSize
*
* @brief This routine returns the max size transmit buffer.
*
* input parameters
*
* @param None.
*
* output parameters
*
* @param None.
*
* @return Returns the max size of the transmit buffer.
*/
uint16 NPI_GetMaxTxBufSize( void )
{
return( NPI_UART_TX_BUF_SIZE );
}
/*******************************************************************************
* @fn NPI_RegisterTask
*
* @brief This routine sends the taskID for the UART task to NPI
*
* input parameters
*
* @param taskID - for the UART app task
*
* output parameters
*
* @param None.
*
* @return None.
*/
void NPI_RegisterTask( uint8_t taskId )
{
uartAppTaskId = taskId;
return;
}
/*******************************************************************************
******************************************************************************/

View File

@@ -0,0 +1,100 @@
/*******************************************************************************
Filename: npi.h
Revised: $Date: 2007-10-28 09:35:41 -0700 (Sun, 28 Oct 2007) $
Revision: $Revision: 15796 $
Description: This file contains the Network Processor Interface (NPI),
which abstracts the physical link between the Application
Processor (AP) and the Network Processor (NP). The NPI
serves as the HAL's client for the SPI and UART drivers, and
provides API and callback services for its client.
Copyright 2008-2012 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
*******************************************************************************/
#ifndef NPI_H
#define NPI_H
#ifdef __cplusplus
extern "C"
{
#endif
/*******************************************************************************
* INCLUDES
*/
#include "hal_types.h"
#include "inc/npi_ble.h"
#include "OSAL.h"
/*******************************************************************************
* CONSTANTS
*/
#define NPI_UART_RX_BUF_SIZE 270// This should be common to app/stack
#define NPI_UART_TX_BUF_SIZE 270// This should be common to app/stack
/*******************************************************************************
* TYPEDEFS
*/
/*******************************************************************************
* LOCAL VARIABLES
*/
/*******************************************************************************
* GLOBAL VARIABLES
*/
/*******************************************************************************
* FUNCTIONS
*/
//
// Network Processor Interface APIs
//
extern void NPI_InitTransport(npiCBack_t npiCallback);
extern uint16 NPI_ReadTransport(uint8 *buf, uint16 len);
extern uint16 NPI_WriteTransport(uint8 *, uint16);
extern uint16 NPI_RxBufLen(void);
extern uint16 NPI_GetMaxRxBufSize(void);
extern uint16 NPI_GetMaxTxBufSize(void);
extern void NPI_RegisterTask(uint8_t taskId);
/*******************************************************************************
*/
#ifdef __cplusplus
}
#endif
#endif /* NPI_H */

View File

@@ -0,0 +1,228 @@
/*******************************************************************************
Filename: npi.c
Revised: $Date: 2008-06-11 14:30:47 -0700 (Wed, 11 Jun 2008) $
Revision: $Revision: 17210 $
Description: This file contains the Network Processor Interface (NPI),
which abstracts the physical link between the Application
Processor (AP) and the Network Processor (NP). The NPI
serves as the HAL's client for the SPI and UART drivers, and
provides API and callback services for its client.
Copyright 2006-2012 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
*******************************************************************************/
/*******************************************************************************
* INCLUDES
*/
#include "hal_types.h"
#include "hal_board.h"
#include "npi.h"
/*******************************************************************************
* MACROS
*/
/*******************************************************************************
* CONSTANTS
*/
/*******************************************************************************
* TYPEDEFS
*/
/*******************************************************************************
* LOCAL VARIABLES
*/
/*******************************************************************************
* GLOBAL VARIABLES
*/
/*******************************************************************************
* PROTOTYPES
*/
/*******************************************************************************
* FUNCTIONS
*/
/*******************************************************************************
* @fn NPI_InitTransport
*
* @brief This routine initializes the transport layer and opens the port
* of the device. Note that based on project defines, either the
* UART, USB (CDC), or SPI driver can be used.
*
* input parameters
*
* @param npiCback - User callback function when data is available.
*
* output parameters
*
* @param None.
*
* @return None.
*/
void NPI_InitTransport( npiCBack_t npiCBack )
{
halUARTCfg_t uartConfig;
// configure UART
uartConfig.configured = TRUE;
uartConfig.baudRate = NPI_UART_BR;
uartConfig.flowControl = NPI_UART_FC;
uartConfig.flowControlThreshold = NPI_UART_FC_THRESHOLD;
uartConfig.rx.maxBufSize = NPI_UART_RX_BUF_SIZE;
uartConfig.tx.maxBufSize = NPI_UART_TX_BUF_SIZE;
uartConfig.idleTimeout = NPI_UART_IDLE_TIMEOUT;
uartConfig.intEnable = NPI_UART_INT_ENABLE;
uartConfig.callBackFunc = (halUARTCBack_t)npiCBack;
// start UART
// Note: Assumes no issue opening UART port.
(void)HalUARTOpen( NPI_UART_PORT, &uartConfig );
return;
}
/*******************************************************************************
* @fn NPI_ReadTransport
*
* @brief This routine reads data from the transport layer based on len,
* and places it into the buffer.
*
* input parameters
*
* @param buf - Pointer to buffer to place read data.
* @param len - Number of bytes to read.
*
* output parameters
*
* @param None.
*
* @return Returns the number of bytes read from transport.
*/
uint16 NPI_ReadTransport( uint8 *buf, uint16 len )
{
return( HalUARTRead( NPI_UART_PORT, buf, len ) );
}
/*******************************************************************************
* @fn NPI_WriteTransport
*
* @brief This routine writes data from the buffer to the transport layer.
*
* input parameters
*
* @param buf - Pointer to buffer to write data from.
* @param len - Number of bytes to write.
*
* output parameters
*
* @param None.
*
* @return Returns the number of bytes written to transport.
*/
uint16 NPI_WriteTransport( uint8 *buf, uint16 len )
{
return( HalUARTWrite( NPI_UART_PORT, buf, len ) );
}
/*******************************************************************************
* @fn NPI_RxBufLen
*
* @brief This routine returns the number of bytes in the receive buffer.
*
* input parameters
*
* @param None.
*
* output parameters
*
* @param None.
*
* @return Returns the number of bytes in the receive buffer.
*/
uint16 NPI_RxBufLen( void )
{
return( Hal_UART_RxBufLen( NPI_UART_PORT ) );
}
/*******************************************************************************
* @fn NPI_GetMaxRxBufSize
*
* @brief This routine returns the max size receive buffer.
*
* input parameters
*
* @param None.
*
* output parameters
*
* @param None.
*
* @return Returns the max size of the receive buffer.
*/
uint16 NPI_GetMaxRxBufSize( void )
{
return( NPI_UART_RX_BUF_SIZE );
}
/*******************************************************************************
* @fn NPI_GetMaxTxBufSize
*
* @brief This routine returns the max size transmit buffer.
*
* input parameters
*
* @param None.
*
* output parameters
*
* @param None.
*
* @return Returns the max size of the transmit buffer.
*/
uint16 NPI_GetMaxTxBufSize( void )
{
return( NPI_UART_TX_BUF_SIZE );
}
/*******************************************************************************
******************************************************************************/

View File

@@ -0,0 +1,137 @@
/*******************************************************************************
Filename: npi.h
Revised: $Date: 2007-10-28 09:35:41 -0700 (Sun, 28 Oct 2007) $
Revision: $Revision: 15796 $
Description: This file contains the Network Processor Interface (NPI),
which abstracts the physical link between the Application
Processor (AP) and the Network Processor (NP). The NPI
serves as the HAL's client for the SPI and UART drivers, and
provides API and callback services for its client.
Copyright 2008-2012 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
*******************************************************************************/
#ifndef NPI_H
#define NPI_H
#ifdef __cplusplus
extern "C"
{
#endif
/*******************************************************************************
* INCLUDES
*/
#include "hal_types.h"
#include "hal_board.h"
#include "hal_uart.h"
/*******************************************************************************
* MACROS
*/
/*******************************************************************************
* CONSTANTS
*/
/* UART port */
#if !defined NPI_UART_PORT
#if ((defined HAL_UART_SPI) && (HAL_UART_SPI != 0)) // FOR SPI
#if (HAL_UART_SPI == 2)
#define NPI_UART_PORT HAL_UART_PORT_1
#else
#define NPI_UART_PORT HAL_UART_PORT_0
#endif
#else // FOR UART
#if ((defined HAL_UART_DMA) && (HAL_UART_DMA == 1))
#define NPI_UART_PORT HAL_UART_PORT_0
#elif ((defined HAL_UART_DMA) && (HAL_UART_DMA == 2))
#define NPI_UART_PORT HAL_UART_PORT_1
#else
#define NPI_UART_PORT HAL_UART_PORT_0
#endif
#endif // Endif for HAL_UART_SPI/DMA
#endif //Endif for NPI_UART_PORT
#if !defined( NPI_UART_FC )
#define NPI_UART_FC TRUE
#endif // !NPI_UART_FC
#define NPI_UART_FC_THRESHOLD 48
#define NPI_UART_RX_BUF_SIZE 128
#define NPI_UART_TX_BUF_SIZE 128
#define NPI_UART_IDLE_TIMEOUT 6
#define NPI_UART_INT_ENABLE TRUE
#if !defined( NPI_UART_BR )
#define NPI_UART_BR HAL_UART_BR_115200
#endif // !NPI_UART_BR
/*******************************************************************************
* TYPEDEFS
*/
typedef void (*npiCBack_t) ( uint8 port, uint8 event );
/*******************************************************************************
* LOCAL VARIABLES
*/
/*******************************************************************************
* GLOBAL VARIABLES
*/
/*******************************************************************************
* FUNCTIONS
*/
//
// Network Processor Interface APIs
//
extern void NPI_InitTransport( npiCBack_t npiCBack );
extern uint16 NPI_ReadTransport( uint8 *buf, uint16 len );
extern uint16 NPI_WriteTransport( uint8 *, uint16 );
extern uint16 NPI_RxBufLen( void );
extern uint16 NPI_GetMaxRxBufSize( void );
extern uint16 NPI_GetMaxTxBufSize( void );
/*******************************************************************************
*/
#ifdef __cplusplus
}
#endif
#endif /* NPI_H */