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:
Sat Sep 30 17:20:23 2017 +0000
Revision:
0:32fded6e1775
Child:
1:083267bc0a0e
P?o de Queijo Development Board v1

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