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

Files at this revision

API Documentation at this revision

Comitter:
rmaalmeida
Date:
Tue Oct 03 01:27:24 2017 +0000
Parent:
5:90824f533655
Commit message:
timer driver added

Changed in this revision

console.cpp Show annotated file Show diff for this revision Revisions of this file
console.h Show annotated file Show diff for this revision Revisions of this file
timer.cpp Show annotated file Show diff for this revision Revisions of this file
timer.h Show annotated file Show diff for this revision Revisions of this file
diff -r 90824f533655 -r 3fb450ba1e95 console.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/console.cpp	Tue Oct 03 01:27:24 2017 +0000
@@ -0,0 +1,96 @@
+#include "lcd.h"
+
+#define LCD_COLS 16
+#define LCD_LINES 2
+#define BUFF_LINES 4
+
+//mais um pra guardar o '\0' no fim de cada linha
+#define BUFF_COLS (LCD_COLS+1)
+
+char buffer[BUFF_LINES][BUFF_COLS];
+int line;
+int col;
+
+void consoleInit() {
+	int i, j;
+	lcdInit();
+	for (i = 0; i < BUFF_LINES; i++) {
+		for (j = 0; j < BUFF_COLS; j++) {
+			buffer[i][j] = '\0';
+		}
+	}
+	line = (BUFF_LINES - LCD_LINES);
+	col = 0;
+}
+
+void newLine(void) {
+	int l;
+	int c ;
+	//sobe cada linha do buffer em uma posição
+	for (l = 1; l < BUFF_LINES; l++) {
+		for (c = 0; c < BUFF_COLS; c++) {
+			buffer[l - 1][c] = buffer[l][c];
+		}
+	}
+	//limpa a última linha
+	for (l = 0; l < BUFF_COLS; l++) {
+		buffer[BUFF_LINES - 1][l] = '\0';
+	}
+}
+
+void consoleUpdate(void) {
+	int i, j;
+	lcdCommand(0x01);
+	for (i = 0; i < LCD_LINES; i++) {
+		lcdPosition(i,0);
+		for (j = 0; j < BUFF_COLS; j++) {
+			if ((buffer[line + i][j] == '\0')) {
+				break;
+			} else {
+				lcdChar(buffer[line + i][j]);
+			}
+		}
+	}
+}
+
+void consolePrint(char* vet) {
+	char i, j;
+	int currentPos = 0;
+	//enquanto a string não terminar continua processando
+	while (vet[currentPos] != '\0') {
+		//se chegou uma nova linha termina a atual e passa pra próxima
+		if (vet[currentPos] == '\n') {
+			buffer[BUFF_LINES - 1][col] = '\0';
+			col = 0;
+			newLine();
+		} else {
+			//se chegou uma letra normal armazena no buffer
+			buffer[BUFF_LINES - 1][col] = vet[currentPos];
+			col++;
+			//se encheu a linha, passa para próxima
+			//(-1 por causa do espaço para o '\0')
+			if (col >= (BUFF_COLS - 1)) {
+				buffer[BUFF_LINES - 1][BUFF_COLS - 1] = '\0';
+				col = 0;
+				newLine();
+			}
+		}
+		currentPos++;
+	}
+	//armazena '\0' na última posição
+	buffer[BUFF_LINES - 1][col] = vet[currentPos];
+}
+
+//muda a posição da linha que deve ser exibida
+void consoleMoveLine(int relativeMove) {
+	if (relativeMove < 0) {
+		if (line > 0) {
+			line--;
+		}
+	}
+	if (relativeMove > 0) {
+		if (line < BUFF_LINES - LCD_LINES) {
+			line++;
+		}
+	}
+}
diff -r 90824f533655 -r 3fb450ba1e95 console.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/console.h	Tue Oct 03 01:27:24 2017 +0000
@@ -0,0 +1,7 @@
+#ifndef CONSOLE_H
+#define CONSOLE_H
+	void consoleInit();
+	void consolePrint(char* vet);
+	void consoleUpdate(void);
+	void consoleMoveLine(int relativeMove);
+#endif
diff -r 90824f533655 -r 3fb450ba1e95 timer.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/timer.cpp	Tue Oct 03 01:27:24 2017 +0000
@@ -0,0 +1,54 @@
+//#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;
+}
diff -r 90824f533655 -r 3fb450ba1e95 timer.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/timer.h	Tue Oct 03 01:27:24 2017 +0000
@@ -0,0 +1,9 @@
+#ifndef TIMER_H
+#define TIMER_H
+	void timerStart(unsigned int count_val);
+	unsigned int timerRead(void);
+	void timerWait(void);
+	int  timerFinished(void);
+	void timerDelay(unsigned int time);
+	void timerInit(void);
+#endif