TI OSAL资料 整理

本文提供了Z-Stack 3.0.x与BLE-CC254x-1.4.2.2的下载链接及配置说明,详细介绍了使用IAR Workbench进行开发的过程,包括IAR工具版本推荐与破解教程,以及Z-Stack中UART串口通信的实现代码示例。

1 下载地址

http://www.ti.com.cn/tool/cn/z-stack
Z-Stack 3.0.x is TI’s Zigbee 3.0 compliant protocol suite for the CC2530, CC2531, and CC2538 Wireless MCU.
IAR Workbench:

Z-Stack is developed and tested using compilers from IAR. IAR versions used in Z-Stack are available to TI customers for 30 days evaluation at the following link: http://www.iar.com/Products/Wireless-solutions/Tools-for-TI-wireless/.

Application, library, and hex files were built/tested with the following versions of IAR tools. We recommend using the same IAR tool version

EWARM 8.11.1 (8.11.1.13272) for CC2538 Wireless MCU
EW8051 10.10.1 (10.10.1) for CC2530 and CC2531 Wireless MCU
Please contact your local IAR office for further details on license purchasing.

Z-STACK-3.0.1

C:\Texas Instruments\Z-Stack 3.0.1\Components\osal\common
在这里插入图片描述

2 BLE-CC254x-1.4.2.2

下载地址:
http://www.ti.com.cn/tool/cn/ble-stack

C:\Texas Instruments\BLE-CC254x-1.4.2.2\Components\osal\common
在这里插入图片描述

IAR (10.10.1) 安装与破解教程
https://blog.csdn.net/P_xiaojia/article/details/79119058

IAR Embedded Workbench for 8051 10.10下载链接与ZStack-cc2530-2.5.1a下载链接
https://blog.csdn.net/liangtao_1996/article/details/79253191

3 比较好的串口解析例程

C:\Texas Instruments\Z-Stack 3.0.1\Projects\zstack\Utilities\BootLoad\CC2538_UART

/**************************************************************************************************
  Filename:       sb_uart.c
  Revised:        $Date: 2013-06-27 15:44:38 -0700 (Thu, 27 Jun 2013) $
  Revision:       $Revision: 34663 $

  Description:    This file contains the implementation of a special SBL UART driver.


  Copyright 2012-2013 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 揂S 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_board.h"
#include "hal_types.h"
#include "sb_exec.h"
#include "sb_main.h"
#include "hw_ioc.h"

/* ------------------------------------------------------------------------------------------------
 *                                           Constants
 * ------------------------------------------------------------------------------------------------
 */

#define HAL_UART_PORT                      UART0_BASE

#define HAL_UART_SYS_CTRL                  SYS_CTRL_PERIPH_UART0
#define HAL_UART_GPIO_BASE                 GPIO_A_BASE
#define HAL_UART_GPIO_PINS                (GPIO_PIN_0 | GPIO_PIN_1)
#define HAL_UART_INT_CTRL                  INT_UART0

#define HalUartISR                         interrupt_uart0

/* ------------------------------------------------------------------------------------------------
 *                                           Local Variables
 * ------------------------------------------------------------------------------------------------
 */

static uint8 txBuf[SB_BUF_SIZE];
static uint32 txHead, txTail;

/* ------------------------------------------------------------------------------------------------
 *                                           Local Functions
 * ------------------------------------------------------------------------------------------------
 */

static void procTx(void);

/*************************************************************************************************
 * @fn      sbUartInit()
 *
 * @brief   Initialize the UART.
 *
 * @param   none
 *
 * @return  none
 */
void sbUartInit(void)
{
  //
  // Set IO clock to the same as system clock
  //
  SysCtrlIOClockSet(SYS_CTRL_SYSDIV_32MHZ);
   
  //
  // Enable UART peripheral module
  //
  SysCtrlPeripheralEnable(SYS_CTRL_PERIPH_UART0);

  //
  // Disable UART function
  //
  UARTDisable(UART0_BASE);

  //
  // Disable all UART module interrupts
  //
  UARTIntDisable(UART0_BASE, 0x1FFF);

  //
  // Set IO clock as UART clock source
  //
  UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);

  //
  // Map UART signals to the correct GPIO pins and configure them as
  // hardware controlled.
  //
  IOCPinConfigPeriphOutput(GPIO_A_BASE, GPIO_PIN_1, IOC_MUX_OUT_SEL_UART0_TXD);
  GPIOPinTypeUARTOutput(GPIO_A_BASE, GPIO_PIN_1); 
  IOCPinConfigPeriphInput(GPIO_A_BASE, GPIO_PIN_0, IOC_UARTRXD_UART0);
  GPIOPinTypeUARTInput(GPIO_A_BASE, GPIO_PIN_0);
     
  //
  // Configure the UART for 115,200, 8-N-1 operation.
  // This function uses SysCtrlClockGet() to get the system clock
  // frequency.  This could be also be a variable or hard coded value
  // instead of a function call.
  //
  UARTConfigSetExpClk(UART0_BASE, SysCtrlClockGet(), 115200,
                     (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
  UARTEnable(UART0_BASE);
}

/*************************************************************************************************
 * @fn      sbUartPoll
 *
 * @brief   This routine simulate polling and has to be called by the main loop.
 *
 * @param   void
 *
 * @return  void
 */
void sbUartPoll(void)
{
  procTx();
}

/*************************************************************************************************
 * @fn      sbUartWrite()
 *
 * @brief   Write a buffer to the UART.
 *
 * @param   pBuf - pointer to the buffer that will be written.
 *          len  - length of buffer to write.
 *
 * @return  length of the buffer that was sent.
 */
uint32 sbUartWrite(uint8 *pBuf, uint32 len)
{
  uint32 idx = txHead;
  uint32 cnt = txTail;

  if (cnt == idx)
  {
    cnt = SB_BUF_SIZE;
  }
  else if (cnt > idx)
  {
    cnt = SB_BUF_SIZE - cnt + idx;
  }
  else // (cnt < idx)
  {
    cnt = idx - cnt;
  }

  // Accept "all-or-none" on write request.
  if (cnt < len)
  {
    return 0;
  }

  idx = txTail;

  for (cnt = 0; cnt < len; cnt++)
  {
    txBuf[idx++] = pBuf[cnt];

    if (idx >= SB_BUF_SIZE)
    {
      // txBuf is a circular buffer. When reaching the end - go back to the start.
      idx = 0;
    }
  }

  txTail = idx;
  procTx();

  return len;  // Return the number of bytes actually put into the buffer.
}


bool sbUartCharAvail(void)
{
  return UARTCharsAvail(HAL_UART_PORT);
}


/*************************************************************************************************
 * @fn      sbUartGetChar
 *
 * @brief   Attempt to get an Rx byte.
 *
 * @param   pCh - Pointer to the character buffer into which to read an Rx byte.
 *
 * @return  Zero or One.
 */
uint32 sbUartGetChar(uint8 *pCh)
{
  if (UARTCharsAvail(HAL_UART_PORT))
  {
    *pCh = UARTCharGetNonBlocking(HAL_UART_PORT);
    return 1;
  }

  return 0;
}

/*************************************************************************************************
 * @fn      procTx
 *
 * @brief   Process Tx bytes.
 *
 * @param   void
 *
 * @return  void
 */
static void procTx(void)
{
  while ((txHead != txTail) && (UARTCharPutNonBlocking(HAL_UART_PORT, txBuf[txHead])))
  {
    if (++txHead >= SB_BUF_SIZE)
    {
      txHead = 0;
    }
  }
}

/**************************************************************************************************
*/

4 无锡谷雨电子 BLE CC2540 有一个 OSAL 的教程

在这里插入图片描述

在这里插入图片描述

(稍后补充)

本课程《华为物联网操作系统LiteOS》是朱老师物联网大讲堂推出的一套物联网理论和实践相结合的视频课程。本课程以渐次递进的方式讲了以下4个主题。主题1:物联网,这是整个课程第1部分。主要讲了物联网的概念、发展历程、物联网的典型案例和应用场景,从技术角度深度阐述了物联网的4层架构、分析了各层次的核心技术和实现原理。本部分的主要目的是让大家对物联网有一定深度和专业性的理解。很多人一直对物联网有兴趣,也找了不少资料看了不少书,但是越看越糊涂,尤其很多物联网专业的大学生,经过几年的大学学习仍然不知道究竟什么是物联网,更不知该如何去学习物联网,本部分就是为解决这个疑问而生。主题2:操作系统,这是整个课程第2部分。主要讲了操作系统的基本原理,操作系统的作用和组成部分,让我们明白裸机开发和基于操作系统的开发有什么差异。这部分是比较偏理论的,是为了解决很多同学对操作系统的认知基础的。很多同学甚至是开发者,尤其是单片机的开发者习惯了裸机开发,直接基于寄存器或者官方库函数(譬如stm32的HAL库、标准库)的开发,心里很疑惑到底什么是操作系统,为什么裸机开发也能做项目还需要操作系统?用不用操作系统的差异在哪里?为什么要去学习操作系统?应该如何学习操作系统?本部分就是为了回答这些问题。主题3:物联网操作系统,这是整个课程的的3部分。物联网操作系统是专为物联网而研发和设计的操作系统,是物联网设备的核心技术。物联网操作系统也是一种操作系统,他具有操作系统的普遍特性(以前前面我们才先学习泛性的普遍的操作系统),但是物联网操作系统有它很多独特的特性,华为的LiteOS就是一款非常典型的优秀的物联网操作系统,除此之外国内还有诸如RT-Thread、AliOSThings等其他优秀物联网操作系统,国外还有Amazon的Freertos等物联网操作系统。那究竟物联网操作系统有什么特别之处?物联网产品如何选择操作系统?如何基于操作系统来开发物联网产品?本部分课程将回答这些问题。主题4:华为物联网操作系统LiteOS,这是整个课程的第4部分。本部分聚焦LiteOS,基于前3部分的铺垫,向大家详细讲解LiteOS的设计思路,专门安排了2大章节来详细分析LiteOS的kernel源码和周边组件源码,还介绍了我们专为学习物联网而设计的NB476开发板,且基于该开发板和LiteOS设计了一个温湿度和断电检测报警器的典型的物联网产品试验,在试验实战中让大家体会基于LiteOS的物联网项目的开发方式。本部分是整个课程中最重头戏的部分,篇幅占据整个课程的一半左右。因此实际上我们整个课程的内容还是比较偏技术性的,可谓低走高开。从基础概念起步,最终带大家能够去做产品。课程特色*完全零基础,降低学习门槛。*深入浅出,通俗易懂。不怕学不会,就怕你不学习。*思路清晰、语言风趣,对着视频看也不会想睡觉······*视频 + 文档 + 练习题 + 答疑,全方位保证学习质量。*基础知识 + 思路引导的教学方式,授之以鱼更授之以渔。*系列课程。本教程只是入门篇,后续还有更多更精彩视频更新中。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值