完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
|
相关推荐
2 个讨论
|
|
/*
* Copyright (c) 2015-2016, 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. */ /* * ======== rfEasyLinkTx.c ======== */ /* XDCtools Header files */ #include #include #include #include /* BIOS Header files */ #include #include #include #include /* TI-RTOS Header files */ #include /* Board Header files */ #include "Board.h" /* EasyLink API Header files */ #include "easylink/EasyLink.h" /* Undefine to not use async mode */ #define RFEASYLINKTX_ASYNC #define RFEASYLINKTX_TASK_STACK_SIZE 1024 #define RFEASYLINKTX_TASK_PRIORITY 2 #define RFEASYLINKTX_BURST_SIZE 10 #define RFEASYLINKTXPAYLOAD_LENGTH 30 Task_Struct txTask; /* not static so you can see in ROV */ static Task_Params txTaskParams; static uint8_t txTaskStack[RFEASYLINKTX_TASK_STACK_SIZE]; /* Pin driver handle */ static PIN_Handle pinHandle; static PIN_State pinState; /* * Application LED pin configuration table: * - All LEDs board LEDs are off. */ PIN_Config pinTable[] = [ Board_PIN_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, Board_PIN_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, PIN_TERMINATE ]; static uint16_t seqNumber; #ifdef RFEASYLINKTX_ASYNC static Semaphore_Handle txDoneSem; #endif //RFEASYLINKTX_ASYNC #ifdef RFEASYLINKTX_ASYNC void txDoneCb(EasyLink_Status status) [ if (status == EasyLink_Status_Success) [ /* Toggle LED1 to indicate TX */ PIN_setOutputValue(pinHandle, Board_PIN_LED1,!PIN_getOutputValue(Board_PIN_LED1)); ] else if(status == EasyLink_Status_Aborted) [ /* Toggle LED2 to indicate command aborted */ PIN_setOutputValue(pinHandle, Board_PIN_LED2,!PIN_getOutputValue(Board_PIN_LED2)); ] else [ /* Toggle LED1 and LED2 to indicate error */ PIN_setOutputValue(pinHandle, Board_PIN_LED1,!PIN_getOutputValue(Board_PIN_LED1)); PIN_setOutputValue(pinHandle, Board_PIN_LED2,!PIN_getOutputValue(Board_PIN_LED2)); ] Semaphore_post(txDoneSem); ] #endif //RFEASYLINKTX_ASYNC static void rfEasyLinkTxFnx(UArg arg0, UArg arg1) [ uint8_t txBurstSize = 0; #ifdef RFEASYLINKTX_ASYNC /* Create a semaphore for Async */ Semaphore_Params params; Error_Block eb; /* Init params */ Semaphore_Params_init(¶ms); Error_init(&eb); /* Create semaphore instance */ txDoneSem = Semaphore_create(0, ¶ms, &eb); #endif //TX_ASYNC EasyLink_init(EasyLink_Phy_Custom); /* * If you wish to use a frequency other than the default, use * the following API: * EasyLink_setFrequency(868000000); */ /* Set output power to 12dBm */ EasyLink_setRfPwr(12); while(1) [ EasyLink_TxPacket txPacket = [ [0], 0, 0, [0] ]; /* Create packet with incrementing sequence number and random payload */ txPacket.payload[0] = (uint8_t)(seqNumber >> 8); txPacket.payload[1] = (uint8_t)(seqNumber++); uint8_t i; for (i = 2; i < RFEASYLINKTXPAYLOAD_LENGTH; i++) [ txPacket.payload = rand(); ] txPacket.len = RFEASYLINKTXPAYLOAD_LENGTH; txPacket.dstAddr[0] = 0xaa; /* Add a Tx delay for > 500ms, so that the abort kicks in and brakes the burst */ if(txBurstSize++ >= RFEASYLINKTX_BURST_SIZE) [ /* Set Tx absolute time to current time + 1s */ txPacket.absTime = EasyLink_getAbsTime() + EasyLink_ms_To_RadioTime(1000); txBurstSize = 0; ] /* Else set the next packet in burst to Tx in 100ms */ else [ /* Set Tx absolute time to current time + 100ms */ txPacket.absTime = EasyLink_getAbsTime() + EasyLink_ms_To_RadioTime(100); ] #ifdef RFEASYLINKTX_ASYNC EasyLink_transmitAsync(&txPacket, txDoneCb); /* Wait 300ms for Tx to complete */ if(Semaphore_pend(txDoneSem, (300000 / Clock_tickPeriod)) == FALSE) [ /* TX timed out, abort */ if(EasyLink_abort() == EasyLink_Status_Success) [ /* * Abort will cause the txDoneCb to be called and the txDoneSem * to be released, so we must consume the txDoneSem */ Semaphore_pend(txDoneSem, BIOS_WAIT_FOREVER); ] ] #else EasyLink_Status result = EasyLink_transmit(&txPacket); if (result == EasyLink_Status_Success) [ /* Toggle LED1 to indicate TX */ PIN_setOutputValue(pinHandle, Board_PIN_LED1,!PIN_getOutputValue(Board_PIN_LED1)); ] else [ /* Toggle LED1 and LED2 to indicate error */ PIN_setOutputValue(pinHandle, Board_PIN_LED1,!PIN_getOutputValue(Board_PIN_LED1)); PIN_setOutputValue(pinHandle, Board_PIN_LED2,!PIN_getOutputValue(Board_PIN_LED2)); ] #endif //RFEASYLINKTX_ASYNC ] ] void txTask_init(PIN_Handle inPinHandle) [ pinHandle = inPinHandle; Task_Params_init(&txTaskParams); txTaskParams.stackSize = RFEASYLINKTX_TASK_STACK_SIZE; txTaskParams.priority = RFEASYLINKTX_TASK_PRIORITY; txTaskParams.stack = &txTaskStack; txTaskParams.arg0 = (UInt)1000000; Task_construct(&txTask, rfEasyLinkTxFnx, &txTaskParams, NULL); ] /* * ======== main ======== */ int main(void) [ /* Call driver init functions. */ Board_initGeneral(); /* Open LED pins */ pinHandle = PIN_open(&pinState, pinTable); if(!pinHandle) [ System_abort("Error initializing board LED pinsn"); ] /* Clear LED pins */ PIN_setOutputValue(pinHandle, Board_PIN_LED1, 0); PIN_setOutputValue(pinHandle, Board_PIN_LED2, 0); txTask_init(pinHandle); /* Start BIOS */ BIOS_start(); return (0); ] |
|
|
|
|
|
只有小组成员才能发言,加入小组>>
NA555DR VCC最低电压需要在5V供电,为什么用3.3V供电搭了个单稳态触发器也使用正常?
642 浏览 3 评论
MSP430F249TPMR出现高温存储后失效了的情况,怎么解决?
585 浏览 1 评论
对于多级放大电路板,在PCB布局中,电源摆放的位置应该注意什么?
1039 浏览 1 评论
710 浏览 0 评论
普中科技F28335开发板每次上电复位后数码管都会显示,如何熄灭它?
509 浏览 1 评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
147浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
113浏览 14评论
在使用3254进行录音的时候出现一个奇怪的现象,右声道有吱吱声,请教一下,是否是什么寄存器设置存在问题?
118浏览 13评论
TLV320芯片内部自带数字滤波功能,请问linein进来的模拟信号是否是先经过ADC的超采样?
114浏览 12评论
TPA6304-Q1: TPA6304 两片公用一组I2C的话,其中一片配置不成功怎么办
157浏览 10评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-17 07:19 , Processed in 0.881732 second(s), Total 50, Slave 41 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号