Ti CC2540 Bluetooth Module Learning notes Finishing

Source: Internet
Author: User

Contact CC2540 A few days, finally have a preliminary understanding, now will take notes collated as follows, just fur, if there is a mistake, please correct me, there are a lot of no trouble to understand the place, should also continue to the inside update ~

First, the whole

1.TI Bluetooth platform supports 2 protocol stacks/Application configurations: Single device configuration, network processor configuration

2. Top 2 General profile of the protocol stack:

GAP Universal Access profile layer Generic access profiles

GATT General Properties Profile Layer Generic Attribute profiles

3. GAP: Processing equipment access mode and access process: ① Device Discovery ② link establish ③ link termination ④ start security function ⑤ device configuration (mainly connection parameter configuration)

GATT: Completing related sub-procedures for communication between server and client

The 4.BLE supports a 40-channel frequency hopping mechanism, where 3 channels are used for advertise and the remainder for data communication

5.OS Abstraction Layer: Question How to configure a new task, task priority, event trigger mechanism, message delivery

6. The main implementation is 2 code files:

OSAL_SIMPLEBLEPERIPHERAL.C Task callback function data definition and task initialization function definition as an external global variable of osal

SIMPLEBLEPERIPHERAL.C ble application Implementation code, the source file calls a series of BLE API functions, complete the complex Bluetooth protocol

To store the function to be called through the const PTASKEVENTHANDLEFN tasksarr[] Array

SimpleBLEPeripheral.h defines some constants, and Bluetooth application task initialization and task callback function declarations.

7.LL task functions have the highest priority, and application functions have the lowest priority

8.OSAL assigns a 16-bit event to each task, each one representing an incident, the highest bit representing Sys_event_msg, and the event being reserved by the osal system.

In the 9.main () function, the last entry of void Osal_run_system (void), this function is to see whether the corresponding task is not an event occurred, there is time to jump to the corresponding function

10. Inter-mission communication, typically through events and messages, whenever there is a message passing between tasks, will trigger the Sys_event_msg event, and each time the event is processed, the flag bit will be emptied.

Osal_set_event () OSAL.h the function dispatches an event directly

Osal_start_timerex () Osal_timers.h need to disguise the triggered event, call this function

11.Heap Manager (Stack management), function Osal_mem_alloc, allocates the required number of bytes to the function, and Osal_mem_free () is used to free memory.

Second, osal (OS abstraction Layer Operate System Abstraction layer)

Messages in 1.OSAL:

Before sending a message, use the Osal_msg_allocate () function to allocate the memory space, populate the data, and call Osal_msg_send () to send the message to the specified function. Then set the sys_event_msg of the function, then the receiver uses osal_mem_receive () to receive the message, and after the reception is complete, use the Osal_mem_deallocate () function to reclaim the memory occupied by the current message. Osal recommends using a separate message-receiving function in the task to process the message, for example: the Simplebleperipheral_processosalmsg () function.

2.GAP (Universal access profile layer Generic access profiles)

Connection process: ① Device Discovery ② link establishes ③ link termination ④ start security function ⑤ device configuration (mostly connection parameter configuration)

The gap layer is always working in 1 of the following roles:

Broadcaster announcer, show me in, but you can only see me, can't connect me

Observer Observer, look who's in, I'm only observing, not connected

Peripheral peripherals, I exist, imagine even me, I even who

Centeral Center, to see who is working in a single-layer or multilayer connection

3. Connection process: Peripheral outgoing->centeral receive a "Scan" command to the slave->peripheral respond->centeral send connection request with "SCANRESP" command

4.Connect Interval communication Gap Each interval 1.25ms is the basic unit, the minimum 6 units 7.5mS, the maximum 3200 units 4.0S.

5.Slave Latency Slave delay means that the number of connections peripheral can be ignored continuously, maximum no more than 499, the longest can not exceed 32S.

6.Supervision timeout The maximum interval between 2 successful connection events.

7.Profile A specification, service one services, characteristic eigenvalue, UUID uniform identifier (required by service,characteristic), centeral communication with peripheral, are implemented through characteristic

8. Send data

Main---from client call Gatt_writecharvalue () function sent;

The Gatt_notification () function is implemented from the main service called.

9. Receiving data

1 Gatt_profile_callback calls are generated after receiving from the <-master-slave machine;

Third, BLE

Four, low-power parts

1. How to always be in PM1

Osal_pwrmgr_device (pwrmgr_always_on);

2. How to enter PM2

Osal_pwrmgr_device (Pwrmgr_battery), which enters PM2 mode when it is idle

3. How to enter PM3

A connection is disconnected, there is a broadcast to stop the broadcast, and confirm that all the scheduled tasks that you created are closed, the system should enter PM3 mode, only external interrupt wake

4.cc2540 the PIN setting problem in low power consumption

The unused pins should not be connected to the outside, and the pins should be configured as a universal pull-up input state (except for p1.0,p1.1), and these pins should not be connected directly to the VDD,GND.

* For p1.0,p1.1, the "User Guide" gives the explanation that "except P1.0 and P1.1, which do not has pullup/pulldown capability" literally means no pull-up capability, but I don't understand, What do you mean by this pull-down?

V. Common commands, functions, and methods of implementation

1. Toggle Power Mode

Osal_pwrmgr_device (pwrmgr_always_on);

Osal_pwrmgr_device (Pwrmgr_battery);

2.Peripheral How to actively disconnect from the Centeral

bstatus_t gaprole_terminateconnection (); In the file Peripheralbroadcaster.c file

3. How to set the timeout period for peripheral broadcast

First of all ensure that the limit type of broadcast is Devdisc_mode_limit (permanent broadcast is devdisc_mode_general), in simplebleperipheral.c file static uint8 advertdata[] Set in the array.

When the mode is in limit mode, the broadcast timeout setting can be set by setting macro Tgap_lim_adv_time_out, if not set, the default time-out is 180S.

4. How to turn the broadcast on and off

Uint8 initial_advertising_enable = True/false TRUE: Turn broadcast FALSE: Turn off broadcast

Gaprole_setparameter (gaprole_advert_enabled, sizeof (uint8), &initial_advertising_enable);

Ti CC2540 Bluetooth Module Learning notes Finishing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.