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
ad.cpp
- Committer:
- rmaalmeida
- Date:
- 2017-10-03
- Revision:
- 6:3fb450ba1e95
- Parent:
- 0:32fded6e1775
File content as of revision 6:3fb450ba1e95:
//#include "io.h" #include "ad.h" //#include "derivative.h" #include "mbed.h" AnalogIn POT(A2); AnalogIn LDR(A1); AnalogIn TEMP(A0); void adInit(void) { /* // Habilita o clock para o conversor SIM_SCGC6 |= SIM_SCGC6_ADC0_MASK; //configura o sistema de convers�o: velocidade e modo de disparo ADC0_CFG1 = ADC_CFG1_ADIV(2) | ADC_CFG1_MODE(1) | ADC_CFG1_ADLSMP_MASK | ADC_CFG1_ADICLK(1); //Configura terminal 8 da porta B como entrada anal�gica canal 11 PORTB_BASE_PTR ->PCR[8] = (PORT_PCR_MUX(0) | PORT_PCR_DSE_MASK); bitSet(PTB_BASE_PTR ->PDDR, 8); //Configura terminal 9 da porta B como entrada anal�gica canal 10 PORTB_BASE_PTR ->PCR[9] = (PORT_PCR_MUX(0) | PORT_PCR_DSE_MASK); bitSet(PTB_BASE_PTR ->PDDR, 9); //Configura terminal 8 da porta A como entrada anal�gica canal 3 PORTA_BASE_PTR ->PCR[8] = (PORT_PCR_MUX(0) | PORT_PCR_DSE_MASK); bitSet(PTA_BASE_PTR ->PDDR, 8); */ } int adRead(int channel) { //Primeiro configura o canal correto //isso j� inicializa a convers�o. if (channel == 2) { return POT.read_u16(); //ADC0_SC1A = 11; } if (channel == 1) { //ADC0_SC1A = 10; return LDR.read_u16(); } if (channel == 0) { //ADC0_SC1A = 3; return TEMP.read_u16(); } //aguarda a convers�o //while ((ADC0_SC1A & ADC_SC1_COCO_MASK) == 0); //retorna o valor convertido // return ADC0_RA; return -1; }