你好,经测试UART_read(uart, read, sizeof(read)) 这个串口最多一次可接受256个字节,能不能接受512个了,怎么设置?谢谢使用评估板SmartRF06的例子
user4988634:
你可以设置为单次读取一个字节,然后存储,这样就可以接受无数多了。
void Uart_ReadCallback(UART_Handle handle, void *rxBuf, size_t size) {Receive_dat = ((uint8_t *)rxBuf)[0];UART_read(handle, Uart_RxTempBuf, 1); }
fang wang6:
回复 user4988634:
麻烦你详细说明一下那个函数怎么用?谢谢
user1013622:
我使用时发现数据多了以后串口直接就死掉了,也没有解决手段
Yue TANG:
回复 user1013622:
两个方面去尝试:
1. 修改ringbuff的大小,这个在CC1310_LAUNCHXL.c里, 把ringbuff size改大.
在CC1310_LAUNCHXL.c里搜索"UARTCC26XX_HWAttrsV2",看下面红色的地方,把ringbuff改大
#include <ti/drivers/UART.h>#include <ti/drivers/uart/UARTCC26XX.h>
UARTCC26XX_Object uartCC26XXObjects[CC1310_LAUNCHXL_UARTCOUNT];
uint8_t uartCC26XXRingBuffer[CC1310_LAUNCHXL_UARTCOUNT][32]; //改大
const UARTCC26XX_HWAttrsV2 uartCC26XXHWAttrs[CC1310_LAUNCHXL_UARTCOUNT] = { { .baseAddr = UART0_BASE, .powerMngrId = PowerCC26XX_PERIPH_UART0, .intNum = INT_UART0_COMB, .intPriority = ~0, .swiPriority = 0, .txPin = CC1310_LAUNCHXL_UART_TX, .rxPin = CC1310_LAUNCHXL_UART_RX, .ctsPin = PIN_UNASSIGNED, .rtsPin = PIN_UNASSIGNED, .ringBufPtr = uartCC26XXRingBuffer[CC1310_LAUNCHXL_UART0], .ringBufSize = sizeof(uartCC26XXRingBuffer[CC1310_LAUNCHXL_UART0]) }};
const UART_Config UART_config[CC1310_LAUNCHXL_UARTCOUNT] = { { .fxnTablePtr = &UARTCC26XX_fxnTable, .object = &uartCC26XXObjects[CC1310_LAUNCHXL_UART0], .hwAttrs = &uartCC26XXHWAttrs[CC1310_LAUNCHXL_UART0] },};
const uint_least8_t UART_count = CC1310_LAUNCHXL_UARTCOUNT;
Yue TANG:
其实,底下的代码都可以看到,有兴趣可以研究下. 在SDK的如下link里, UART_read已经包含了TI-RTOS,
C:\ti\simplelink_cc13x0_sdk_1_50_00_08\source\ti\drivers\uart
如下是open函数, 创建使用的是
/* Create circular buffer object to be used for read buffering */ RingBuf_construct(&object->ringBuffer, hwAttrs->ringBufPtr, hwAttrs->ringBufSize);
/*! * @brief Function to initialize the CC26XX UART peripheral specified by the * particular handle. The parameter specifies which mode the UART * will operate. * * The function will set a dependency on it power domain, i.e. power up the * module and enable the clock. The IOs are allocated. Neither the RX nor TX * will be enabled, and none of the interrupts are enabled. * * @pre UART controller has been initialized * Calling context: Task * * @param handle A UART_Handle * * @param params Pointer to a parameter block, if NULL it will use * default values * * @return A UART_Handle on success or a NULL on an error or if it has been * already opened * * @sa UARTCC26XX_close() */UART_Handle UARTCC26XX_open(UART_Handle handle, UART_Params *params){ unsigned int key; /* Use union to save on stack allocation */ union { HwiP_Params hwiParams; SwiP_Params swiParams; ClockP_Params clkParams; } paramsUnion; UARTCC26XX_Object *object; UARTCC26XX_HWAttrsV2 const *hwAttrs;
/* Get the pointer to the object and hwAttrs */ object = handle->object; hwAttrs = handle->hwAttrs;
/* Disable preemption while checking if the UART is open. */ key = HwiP_disable();
/* Check if the UART is open already with the base addr. */ if (object->opened == true) { HwiP_restore(key);
DebugP_log1("UART:(%p) already in use.", hwAttrs->baseAddr);
return (NULL); } object->opened = true; HwiP_restore(key);
/* Check that a callback is set */ DebugP_assert(params->readMode != UART_MODE_CALLBACK || params->readCallback != NULL); DebugP_assert(params->writeMode != UART_MODE_CALLBACK || params->writeCallback != NULL);
/* Initialize the UART object */ object->readMode = params->readMode; object->writeMode = params->writeMode; object->readTimeout = params->readTimeout; object->writeTimeout = params->writeTimeout; object->readCallback = params->readCallback; object->writeCallback = params->writeCallback; object->readReturnMode = params->readReturnMode; object->readDataMode = params->readDataMode; object->writeDataMode = params->writeDataMode; object->baudRate = params->baudRate; object->dataLength = params->dataLength; object->stopBits = params->stopBits; object->parityType = params->parityType;
/* Set UART transaction variables to defaults. */ object->writeBuf = NULL; object->readBuf = NULL; object->writeCount = 0; object->readCount = 0; object->writeSize = 0; object->readSize = 0; object->writeCR = false; object->readRetPartial = false; object->readFifoThreshold = UART_TH_FIFO_4_8; object->writeFifoThreshold = UART_FIFO_TX1_8;
/* Register power dependency – i.e. power up and enable clock for UART. */ Power_setDependency(hwAttrs->powerMngrId);
/* Initialize the UART hardware module */ UARTCC26XX_initHw(handle);
/* Configure IOs, make sure it was successful */ if(!UARTCC26XX_initIO(handle)) { /* Trying to use UART driver when some other driver or application * has already allocated these pins, error! */ DebugP_log0("Could not allocate pins, already in use."); /* Disable UART */ UARTDisable(hwAttrs->baseAddr); /* Release power dependency – i.e. potentially power down serial domain. */ Power_releaseDependency(hwAttrs->powerMngrId); /* Mark the module as available */ key = HwiP_disable(); object->opened = false; HwiP_restore(key); /* Signal back to application that UART driver was not succesfully opened */ return (NULL); }
/* Create Hwi object for this UART peripheral. */ HwiP_Params_init(&(paramsUnion.hwiParams)); paramsUnion.hwiParams.arg = (uintptr_t)handle; paramsUnion.hwiParams.priority = hwAttrs->intPriority; HwiP_construct(&(object->hwi), hwAttrs->intNum, UARTCC26XX_hwiIntFxn, &(paramsUnion.hwiParams));
/* Create Swi object for this UART peripheral */ SwiP_Params_init(&(paramsUnion.swiParams)); paramsUnion.swiParams.arg0 = (uintptr_t)handle; paramsUnion.swiParams.priority = hwAttrs->swiPriority; SwiP_construct(&(object->swi), UARTCC26XX_swiIntFxn, &(paramsUnion.swiParams));
/* Initialize semaphore */
/* If write mode is blocking create a semaphore and set callback. */ if (object->writeMode == UART_MODE_BLOCKING) { SemaphoreP_constructBinary(&(object->writeSem), 0); object->writeCallback = &writeSemCallback; }
/* If read mode is blocking create a semaphore and set callback. */ if (object->readMode == UART_MODE_BLOCKING) { SemaphoreP_constructBinary(&(object->readSem), 0); object->readCallback = &readSemCallback; }
/* Create clock object to be used for write FIFO empty callback */ ClockP_Params_init(¶msUnion.clkParams); paramsUnion.clkParams.period = 0; paramsUnion.clkParams.startFlag = false; paramsUnion.clkParams.arg = (uintptr_t) handle; ClockP_construct(&(object->txFifoEmptyClk), (ClockP_Fxn) &writeFinishedDoCallback, 10, &(paramsUnion.clkParams));
/* Create circular buffer object to be used for read buffering */ RingBuf_construct(&object->ringBuffer, hwAttrs->ringBufPtr, hwAttrs->ringBufSize);
/* Register notification function */ Power_registerNotify(&object->uartPostObj, PowerCC26XX_AWAKE_STANDBY, (Power_NotifyFxn)uartPostNotify, (uint32_t)handle);
/* UART opened successfully */ DebugP_log1("UART:(%p) opened", hwAttrs->baseAddr);
/* Return the handle */ return (handle);}