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
timer.cpp
- Committer:
- rmaalmeida
- Date:
- 2017-10-03
- Revision:
- 6:3fb450ba1e95
File content as of revision 6:3fb450ba1e95:
//#include "derivative.h" #include "timer.h" #include "mbed.h" Timer t; int interval; void timerStart(unsigned int count_val){ // desliga timer para mudar a configura��o de tempo e resetar contador //LPTMR0_CSR=0; // Configura o tempo de contagem, como o timer usa um clock de 1KHz, cada unidade equivale 1ms // Subtrai duas unidades, descontando o overflow e a reinicializa��o //LPTMR0_CMR = count_val-2; //Liga o timer //LPTMR0_CSR |= 1; interval = count_val; t.start(); t.reset(); return; } unsigned int timerRead(void){ return t.read_us(); } void timerWait(void){ //Aguarda final da contagem while (t.read_us()<=interval); t.stop(); //Desliga o contador // LPTMR0_CSR &= ~LPTMR_CSR_TEN_MASK; } int timerFinished(void){ //Verifica se terminou de contar //if (LPTMR0_CSR & LPTMR_CSR_TCF_MASK){ if(t.read_us()>=interval){ //Se terminou desliga o contador //LPTMR0_CSR &= ~LPTMR_CSR_TEN_MASK; return 1; }else{ return 0; } } //gera um atraso de (time) milissegundos void timerDelay(unsigned int time){ timerStart(time); timerWait(); } void timerInit(void){ interval = 0; //Liga sistema de clock do timer //SIM_SCGC5 |= SIM_SCGC5_LPTMR_MASK; //Utiliza oscilador de 1kHz sem prescaller //LPTMR0_PSR = LPTMR_PSR_PCS(1)|LPTMR_PSR_PBYP_MASK; }