2428 views|1 replies

74

Posts

0

Resources
The OP
 

[LAUNCHXL-CC2650] simple_peripheral routine analysis [Copy link]

CC2650 is a dual-core system. The Bluetooth protocol stack runs in the Cortex-M0 core, and the application runs in the Cortex-M3 core. simple_peripheral_cc2650lp_stack is the protocol stack, which runs in the Cortex-M0 core. simple_peripheral_cc2650lp_app is the application, which runs in the Cortex-M3 core. Here we mainly introduce the application running in the Cortex-M3 core.

1. Main program

The contents of the main() function in the application are as follows:

/* Register Application callback to trap asserts raised in the Stack */
RegisterAssertCback(AssertHandler);

PIN_init(BoardGpioInitTable);
// Enable iCache prefetching
VIMSConfigure(VIMS_BASE, TRUE, TRUE);

// Enable cache
VIMSModeSet(VIMS_BASE, VIMS_MODE_ENABLED);
/* Initialize ICall module */
ICall_init();

/* Start tasks of external images - Priority 5 */
ICall_createRemoteTasks();

/* Kick off profile - Priority 3 */
GAPRole_createTask();

SimpleBLEPeripheral_createTask();

/* enable interrupts and start SYS/BIOS */
BIOS_start();

RegisterAssertCback(AssertHandler); is used to register the assertion handler of the application.

PIN_init(BoardGpioInitTable); initializes the GPIO ports used on the board, including the LED pins, button pins, UART pins and SPI pins. The specific BoardGpioInitTable is in CC2650_LAUNCHXL.

VIMSConfigure(VIMS_BASE, TRUE, TRUE); Enable iCache.

VIMSModeSet(VIMS_BASE, VIMS_MODE_ENABLED); enables cache.

Since the application and protocol stack run in different kernels, the application and protocol stack communicate through the ICall module and perform some primitive services of RTOS (such as thread synchronization). ICall allows the application and protocol stack to run efficiently and share resources in a unified RTOS environment. Therefore, before starting the SYS/BIOS kernel scheduler, the application must instantiate and initialize the ICall service.

ICall_init(); Initializes ICall primary services and framework. Calls ICall_createRemoteTasks() to create but not enable Bluetooth protocol stack tasks. Before using ICall protocol services, the server and client must register ICall. Use ICall services in the osal_icall_ble.c file of the protocol stack program and register the call of the protocol stack service (server).

ICall_createRemoteTasks(); creates a task for each external image using its own entry function with a known address.

GAPRole_createTask(); Creates a task function for the GAP peripheral role. Calls gapRole_init() to initialize and handle GAP events.

SimpleBLEPeripheral_createTask(); creates a task function for the application. Initializes the application and handles application events.

BIOS_start(); Enable interrupts and start SYS/BIOS scheduling.

2. Equipment Information

Device information includes model, firmware version, hardware version, software version, manufacturer name, etc.

The device information is in the devinfoservice.c file and can be modified according to the device.

The specific code is as follows:

// System ID characteristic
static uint8 devInfoSystemIdProps = GATT_PROP_READ;
static uint8 devInfoSystemId[DEVINFO_SYSTEM_ID_LEN] = {0, 0, 0, 0, 0, 0, 0, 0};

// Model Number String characteristic
static uint8 devInfoModelNumberProps = GATT_PROP_READ;
static uint8 devInfoModelNumber[DEVINFO_STR_ATTR_LEN+1] = "Model Number";

// Serial Number String characteristic
static uint8 devInfoSerialNumberProps = GATT_PROP_READ;
static uint8 devInfoSerialNumber[DEVINFO_STR_ATTR_LEN+1] = "Serial Number";

// Firmware Revision String characteristic
static uint8 devInfoFirmwareRevProps = GATT_PROP_READ;
static uint8 devInfoFirmwareRev[DEVINFO_STR_ATTR_LEN+1] = "Firmware Revision";

// Hardware Revision String characteristic
static uint8 devInfoHardwareRevProps = GATT_PROP_READ;
static uint8 devInfoHardwareRev[DEVINFO_STR_ATTR_LEN+1] = "Hardware Revision";

// Software Revision String characteristic
static uint8 devInfoSoftwareRevProps = GATT_PROP_READ;
static uint8 devInfoSoftwareRev[DEVINFO_STR_ATTR_LEN+1] = "Software Revision";

// Manufacturer Name String characteristic
static uint8 devInfoMfrNameProps = GATT_PROP_READ;
static uint8 devInfoMfrName[DEVINFO_STR_ATTR_LEN+1] = "Manufacturer Name";

// IEEE 11073-20601 Regulatory Certification Data List characteristic
static uint8 devInfo11073CertProps = GATT_PROP_READ;
static uint8 defaultDevInfo11073Cert[] =
{
DEVINFO_11073_BODY_EXP, // authoritative body type
0x00, // authoritative body structure type
// authoritative body data follows below:
'e' , 'x', 'p', 'e', 'r', 'i', 'm', 'e', 'n', 't', 'a', 'l'
};

// The length of this characteristic is not fixed
static uint8 *devInfo11073Cert = defaultDevInfo11073Cert;
static uint8 devInfo11073CertLen = sizeof(defaultDevInfo11073Cert);

// PnP ID characteristic
static uint8 devInfoPnpIdProps = GATT_PROP_READ;
static uint8 devInfoPnpId[DEVINFO_PNP_ID_LEN] =
{
1, // Vendor ID source (1=Bluetooth SIG)
LO_UINT16(0x000D), HI_UINT16(0x000D), // Vendor ID (Texas Instruments)
LO_UINT16(0x0000), HI_UINT16(0x0000), // Product ID (vendor-specific)
LO_UINT16(0x0110), HI_UINT16(0x0110) // Product version (JJ.MN)
};

The System ID is redefined in the simple_peripheral.c file. If you want to modify it, you need to modify it in this file. The redefinition source code is as follows.

// use 6 bytes of device address for 8 bytes of system ID value
systemId[0] = ownAddress[0];
systemId[1] = ownAddress[1];
systemId[2] = ownAddress[2];

// set middle bytes to zero
systemId[4] = 0x00;
systemId[3] = 0x00;

// shift three bytes up
systemId[7] = ownAddress[5];
systemId[6] = ownAddress[4];
systemId[5] = ownAddress[3];

Use nRF Connect to connect to the development board and read the corresponding device information.

In addition, you can find that there is no device name here. The device name is defined in the simple_peripheral.c file.

3. Features

Five characteristics are defined in this example. In the simple_gatt_profile file, the five characteristics are defined, including the characteristic name, UUID, etc.

In simple_peripheral.c, use the SimpleProfile_SetParameter function to assign values to the five features respectively.

At the same time, when Feature 4 notification is turned on, Feature 4 will read the value of Feature 3 every 5 seconds and assign the value of Feature 3 to Feature 4.

After nRF Connect is connected, the corresponding feature information can be obtained.

This post is from RF/Wirelessly

Latest reply

The routine analysis is very detailed   Details Published on 2021-5-21 07:38
 

1668

Posts

0

Resources
2
 

The routine analysis is very detailed

This post is from RF/Wirelessly
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

快速回复 返回顶部 Return list