Pão de Queijo Development Board. This repo has all libraries from pqdb shield.
Pão de Queijo development board is a shield for add-on on any arduino compatible board.
This project presents the libraries to control the board peripherals using mbed framework. The libraries works as interfaces to keep the main code compatible with the examples from the book "Programação de sistemas embarcados". The peripherals on the board are presented on the folowing picture
The main objective of the project is to develop a low cost, easy to assemble board with a group of peripheral that allows one to start learning embedded systems. The board was routed on one side copper PCB to make easier to buid it yourself.
The source code for Arduino boards (wiring) can be found on: https://github.com/projetopqdb/PQDB-Arduino
The source code for freedom frdm KL05 board (using direct register access) can be found on: https://github.com/projetopqdb/PQDB-KL05Z
The source code from the board schematics and layout can be found on: https://github.com/projetopqdb/PQDB-Hardware
Diff: keypad.cpp
- Revision:
- 0:32fded6e1775
- Child:
- 1:083267bc0a0e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/keypad.cpp Sat Sep 30 17:20:23 2017 +0000 @@ -0,0 +1,64 @@ +#include "keypad.h" +#include "so.h" +//#include "io.h" +#include "mbed.h" + +#define bitSet(arg,bit) ((arg) |= (1<<bit)) +#define bitClr(arg,bit) ((arg) &= ~(1<<bit)) +#define bitFlp(arg,bit) ((arg) ^= (1<<bit)) +#define bitTst(arg,bit) ((arg) & (1<<bit)) + +DigitalIn KEY_1(D12); +DigitalIn KEY_2(D13); + +static unsigned int keys; + +//vetor com o "nome" dos bot�es +//U -> up, L -> left, D -> down, R -> right +//S -> start, s -> select +//a ordem � referente a posi��o dos bot�es +static const char charKey[] = {'U','L','D','R','S','X','Y','B','A','s'}; + +unsigned int kpRead(void) { + return keys; +} +char kpReadKey(void){ + int i; + for(i=0;i<10;i++){ + if (keys&(1<<i)){ + return charKey[i]; + } + } + //nenhuma tecla pressionada + return 0; +} +void kpDebounce(void) { + int i; + static unsigned char tempo; + static unsigned int newRead; + static unsigned int oldRead; + newRead = 0; + for(i = 0; i<5; i++){ + soWrite(1<<(i+3)); + if(KEY_1){ + bitSet(newRead,i); + } + if(KEY_2){ + bitSet(newRead,(i+5)); + } + } + if (oldRead == newRead) { + tempo--; + } else { + tempo = 4; + oldRead = newRead; + } + if (tempo == 0) { + keys = oldRead; + } +} +void kpInit(void) { + soInit(); + //pinMode(12, INPUT); + //pinMode(13, INPUT); +}