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:
The sixth section of the independent button query method
Section 7 Interrupt Mode of Independent Buttons
Section VIII CC254x internal temperature sensor temperature acquisition
Section IX five-way button
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 ForARMThe 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.
The corresponding schematic diagram is as follows:
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:
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)
N95 Mask,Surgical Mask,Earloop Face Mask,Disposable Protective Mask
Guangzhou HangDeng Tech Co. Ltd , https://www.hangdengtech.com