Pão de Queijo Development Board. This repo has all libraries from pqdb shield.

Dependents:   pqdb_demo

Pão de Queijo development board is a shield for add-on on any arduino compatible board.

/media/uploads/rmaalmeida/compatibilidade_branco.png

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

/media/uploads/rmaalmeida/pqdb_perifericos.png

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.

/media/uploads/rmaalmeida/pqdb_fenolite_-_cortada.png

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

Committer:
rmaalmeida
Date:
Tue Oct 03 01:27:24 2017 +0000
Revision:
6:3fb450ba1e95
Parent:
1:083267bc0a0e
timer driver added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rmaalmeida 0:32fded6e1775 1 #include "keypad.h"
rmaalmeida 0:32fded6e1775 2 #include "so.h"
rmaalmeida 0:32fded6e1775 3 //#include "io.h"
rmaalmeida 0:32fded6e1775 4 #include "mbed.h"
rmaalmeida 1:083267bc0a0e 5 #include "ssd.h"
rmaalmeida 0:32fded6e1775 6
rmaalmeida 0:32fded6e1775 7 #define bitSet(arg,bit) ((arg) |= (1<<bit))
rmaalmeida 0:32fded6e1775 8 #define bitClr(arg,bit) ((arg) &= ~(1<<bit))
rmaalmeida 0:32fded6e1775 9 #define bitFlp(arg,bit) ((arg) ^= (1<<bit))
rmaalmeida 0:32fded6e1775 10 #define bitTst(arg,bit) ((arg) & (1<<bit))
rmaalmeida 0:32fded6e1775 11
rmaalmeida 0:32fded6e1775 12 DigitalIn KEY_1(D12);
rmaalmeida 0:32fded6e1775 13 DigitalIn KEY_2(D13);
rmaalmeida 0:32fded6e1775 14
rmaalmeida 0:32fded6e1775 15 static unsigned int keys;
rmaalmeida 0:32fded6e1775 16
rmaalmeida 0:32fded6e1775 17 //vetor com o "nome" dos bot�es
rmaalmeida 0:32fded6e1775 18 //U -> up, L -> left, D -> down, R -> right
rmaalmeida 0:32fded6e1775 19 //S -> start, s -> select
rmaalmeida 0:32fded6e1775 20 //a ordem � referente a posi��o dos bot�es
rmaalmeida 1:083267bc0a0e 21 static const char charKey[] = {'U','L','D','R','S','X','Y','A','B','s'};
rmaalmeida 0:32fded6e1775 22
rmaalmeida 0:32fded6e1775 23 unsigned int kpRead(void) {
rmaalmeida 0:32fded6e1775 24 return keys;
rmaalmeida 0:32fded6e1775 25 }
rmaalmeida 0:32fded6e1775 26 char kpReadKey(void){
rmaalmeida 0:32fded6e1775 27 int i;
rmaalmeida 0:32fded6e1775 28 for(i=0;i<10;i++){
rmaalmeida 0:32fded6e1775 29 if (keys&(1<<i)){
rmaalmeida 0:32fded6e1775 30 return charKey[i];
rmaalmeida 0:32fded6e1775 31 }
rmaalmeida 0:32fded6e1775 32 }
rmaalmeida 0:32fded6e1775 33 //nenhuma tecla pressionada
rmaalmeida 0:32fded6e1775 34 return 0;
rmaalmeida 0:32fded6e1775 35 }
rmaalmeida 0:32fded6e1775 36 void kpDebounce(void) {
rmaalmeida 0:32fded6e1775 37 int i;
rmaalmeida 0:32fded6e1775 38 static unsigned char tempo;
rmaalmeida 0:32fded6e1775 39 static unsigned int newRead;
rmaalmeida 0:32fded6e1775 40 static unsigned int oldRead;
rmaalmeida 0:32fded6e1775 41 newRead = 0;
rmaalmeida 1:083267bc0a0e 42 ssdOff();
rmaalmeida 0:32fded6e1775 43 for(i = 0; i<5; i++){
rmaalmeida 0:32fded6e1775 44 soWrite(1<<(i+3));
rmaalmeida 0:32fded6e1775 45 if(KEY_1){
rmaalmeida 0:32fded6e1775 46 bitSet(newRead,i);
rmaalmeida 0:32fded6e1775 47 }
rmaalmeida 0:32fded6e1775 48 if(KEY_2){
rmaalmeida 0:32fded6e1775 49 bitSet(newRead,(i+5));
rmaalmeida 0:32fded6e1775 50 }
rmaalmeida 0:32fded6e1775 51 }
rmaalmeida 0:32fded6e1775 52 if (oldRead == newRead) {
rmaalmeida 0:32fded6e1775 53 tempo--;
rmaalmeida 0:32fded6e1775 54 } else {
rmaalmeida 0:32fded6e1775 55 tempo = 4;
rmaalmeida 0:32fded6e1775 56 oldRead = newRead;
rmaalmeida 0:32fded6e1775 57 }
rmaalmeida 0:32fded6e1775 58 if (tempo == 0) {
rmaalmeida 0:32fded6e1775 59 keys = oldRead;
rmaalmeida 0:32fded6e1775 60 }
rmaalmeida 0:32fded6e1775 61 }
rmaalmeida 0:32fded6e1775 62 void kpInit(void) {
rmaalmeida 0:32fded6e1775 63 soInit();
rmaalmeida 0:32fded6e1775 64 //pinMode(12, INPUT);
rmaalmeida 0:32fded6e1775 65 //pinMode(13, INPUT);
rmaalmeida 0:32fded6e1775 66 }