From shallow to deep, Bluetooth 4.0/BLE protocol stack development strategy (2)

From shallow to deep, Bluetooth 4.0/BLE protocol stack development strategy

This series of tutorials will be combined with TI's CC254x SoC series to explain the development process of Bluetooth 4.0 from the construction of the environment to the development of the Bluetooth 4.0 protocol stack. The tutorial is divided into six parts, this article is the second part:
      

The second part of the knowledge points:

Click to browse the next page The sixth section of the independent button query method

Click to browse the next page Section 7 Interrupt Mode of Independent Buttons

Click to browse the next page Section VIII CC254x internal temperature sensor temperature acquisition

Click to browse the next page Section IX five-way button

Click to browse the next page Section 10 Buzzer

For an introduction to TI's CC254x chip, you can click on the link below to view:

Mainstream Bluetooth BLE control chip detailed (1): TI CC2540

Recommended in the same series:

From shallow to deep, Bluetooth 4.0/BLE protocol stack development strategy (1)

For the download of the tool for this article, you can go to the following address:

Zhu Zhaoyu ForARM

The sixth section of the independent button query method

There is a separate button KEY1 on the MT254xboard, as shown in the figure, the independent button and the reset button are in the upper left corner of the entire team. The button is connected to the CPU through the P0.0 port. It is high when there is no button and low when pressed. Below we use the LCD to display the status of the individual buttons.

Display the status of the individual buttons through the LCD

The corresponding schematic diagram is as follows:

Independent button query method

We first read the state of the button by query. Because the button is connected to the P0.0 port, we can know the state of the button by reading the level of the P0.0 port.

Uint8 KeyValue(void) // Read button status

{

If((P0&0X01) == 0X00 ) // Press low

{

Return KEY_DOWN;

}

Else

{

Return KEY_UP;

}

}

Here we constantly read the state of the button in the while loop, and judge whether it changes, if it changes, change the display of the LCD.

Int main(void)

{

Uint8 OldKeyValue = 0;

Uint8 NewKeyValue = 0;

SysStartXOSC();

LCD12864_Init();

LCD12864_DisStr(1, “Key Test”);

// button initialization

P0SEL &= ~0X01; // Set to IO function

P0DIR &= ~0X01; // Set as input function

While(1)

{

NewKeyValue = KeyValue(); // Read button status

If(OldKeyValue != NewKeyValue) // Button state change

{

OldKeyValue = NewKeyValue; // save the current button state

If(OldKeyValue == KEY_DOWN)

{

LCD12864_DisStr(3, “Key Down ”);

}

Else

{

LCD12864_DisStr(3, “Key Up ”);

}

}

}

Return 0;

}

Run the program, the effect is as shown:

Copy code

Adopting KN95 grade anti-particulate matter filtering technology and antibacterial environmental protection fabnc, effectively filtering and protecting from PM2.5 air particulate matter and bacteria. without breathing valve.


Adopting KN95 grade anti-particulate matter filtering technology and antibacterial environmental protection fabnc, effectively filtering and protecting from PM2.5 air particulate matter and bacteria. without breathing valve.
(Details
NIOSH Approved: KN95
FDA Cleared 
Helps protect against certain airborne biological particles
Fluid resistant and disposable
Features include:
NIOSH approved KN95
Meets CDC guidelines for Mycobacterium tuberculosis exposure control
99% BFE (Bacterial Filtration Efficiency)
Fluid resistant 
Collapse resistant cup shape design
Braided headbands, cushioning nose foam, and light weight construction for comfortable wear)

Medical Mask

N95 Mask,Surgical Mask,Earloop Face Mask,Disposable Protective Mask

Guangzhou HangDeng Tech Co. Ltd , https://www.hangdengtech.com