Other Parts Discussed in Thread: CC1310
Tool/software:
int main(void)
{
// Initialize the board
Board_init();
// Initialize task parameters
Task_Params taskParams;
#ifdef ONE_TASK_CREATE
Task_Params testTaskParams;
#endif
#ifndef USE_DEFAULT_USER_CFG
// Use custom user configuration for board settings
macUser0Cfg[0].pAssertFP = macHalAssertHandler;
#endif
#if ((CONFIG_RANGE_EXT_MODE == APIMAC_HIGH_GAIN_MODE) && \
defined(DeviceFamily_CC13X0) && !defined(FREQ_2_4G))
// Initialize PALNA if range extension mode is enabled for specific device family and frequency
macUser0Cfg[0].pSetRE = Board_Palna_initialize;
#endif
// Initialize board-related tasks such as LEDs following TI-RTOS convention
PIN_init(BoardGpioInitTable);
#ifdef FEATURE_BLE_OAD
// Check for left button press on reset if FEATURE_BLE_OAD is enabled
if (!PIN_getInputValue(Board_PIN_BUTTON0))
{
OAD_markSwitch();
}
#endif /* FEATURE_BLE_OAD */
#if defined(POWER_MEAS)
// Disable external flash for power measurements
Board_shutDownExtFlash();
#endif
#if defined(FEATURE_BLE_OAD) || defined(FEATURE_NATIVE_OAD)
// Initialize SPI if BLE OAD or Native OAD is enabled
SPI_init();
#endif
#if 1
// Set up input variable and initial welcome message
char input;
const char echoPrompt[] = "AXM500 Device Starting \r\n";
UART_Handle uart;
#endif
// Enable UART output for System_printf(..)
UART_init();
UART_Params_init(&uartParams);
#ifdef TASK_COMMAND
// Configure UART parameters
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.baudRate = 115200;
// Open UART and handle error
hUart = UART_open(Board_UART0, &uartParams);
if (hUart == NULL)
{
System_abort("Error opening the UART");
}
#else
// Configure and initialize UART parameters
uartParams.readMode = UART_MODE_CALLBACK;
uartParams.readCallback = Uart_ReadCallback;
uartParams.writeMode = UART_MODE_CALLBACK;
uartParams.writeCallback = Uart_WriteCallback;
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.baudRate = 115200;
UartPrintf_init(UART_open(Board_UART0, &uartParams));
UART_write(hUart, echoPrompt, sizeof(echoPrompt));
#endif
// Print system output and version/release information
System_printf(" \r\n");
System_printf(" ===========================================\r\n");
System_printf(" AXM500 Device Starting \r\n");
System_printf(" SW Version : %d.%d \r\n", VER_MAJOR, VER_PATCH);
System_printf(" Release Date : %s /%s \r\n", __DATE__, __TIME__);
System_printf(" ===========================================\r\n");
#ifdef OSAL_PORT2TIRTOS
// Initialize MAC task by converting OSAL to SYS/BIOS
_macTaskId = macTaskInit(macUser0Cfg);
#endif
/* Configure task. */
Task_Params_init(&taskParams);
taskParams.stack = appTaskStack;
taskParams.stackSize = APP_TASK_STACK_SIZE;
taskParams.priority = APP_TASK_PRIORITY;
Task_construct(&appTask, appTaskFxn, &taskParams, NULL);
#ifdef DEBUG_SW_TRACE
// Configure debug SW trace settings
IOCPortConfigureSet(IOID_8, IOC_PORT_RFC_TRC, IOC_STD_OUTPUT
| IOC_CURRENT_4MA | IOC_SLEW_ENABLE);
#endif /* DEBUG_SW_TRACE */
#ifdef ONE_TASK_CREATE
/* Configure task. */
Task_Params_init(&taskParams);
taskParams.stack = appTasktestStack;
taskParams.stackSize = APP_TASK_STACK_SIZE;
taskParams.priority = APP_TASK_PRIORITY;
Task_construct(&appTasktest, appTasktestFxn, &taskParams, NULL);
#endif
// Set up and create main thread
pthread_t thread;
pthread_attr_t attrs;
struct sched_param priParam;
int retc;
pthread_attr_init(&attrs);
priParam.sched_priority = 2;
retc = pthread_attr_setschedparam(&attrs, &priParam);
retc |= pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED);
retc |= pthread_attr_setstacksize(&attrs, THREADSTACKSIZE);
// Continue even if attribute setting fails
if (retc != 0)
{
System_printf("fail thread\r\n: ");
while (1)
;
}
/* Create the thread for the main application logic */
retc = pthread_create(&thread, &attrs, mainThread, NULL);
/* failed to create thread */
if (retc != 0)
{
System_printf("Failed to create thread\r\n: ");
while (1)
;
}
// Enable interrupts and start SYS/BIOS
BIOS_start();
return (0);
}
---------------------------------------------------------------------------------------------
Thanks for the reply.
Currently, when I use “Power_sleep(PowerCC26XX_STANDBY)” to enter sleep mode, 0.25mA is output. I think there are some devices alive in standby mode, so I'm looking for them. When I use UART_close() function to enter sleep mode, the value of sleep current drops to 0.22mA when I close the UART. I'm wondering if there are more things I can shut down in the main loop? Also, when shutting down the uart, the pin of the uart used in the cc1310 is also pulldown, is that the setting I need to do to enter sleep mode?
And I was wondering, is it a problem to use threads or tasks to turn off other devices after entering sleep mode?