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
mcp7940n.cpp
- Committer:
- rmaalmeida
- Date:
- 2017-10-02
- Revision:
- 3:6ca4d7dd8bea
- Parent:
- 2:4b7f5a060c22
File content as of revision 3:6ca4d7dd8bea:
#include "i2c.h" #include "mcp7940n.h" //endere�o do dispositivo, deslocado por causa do bit de RW //1101000 (0x6f<<1) #define MCP7940N_CTRL_ID (0xde) #define I2C_WRITE 0 #define I2C_READ 1 int dec2bcd(int value) { return ((value / 10 * 16) + (value % 10)); } int bcd2dec(int value) { return ((value / 16 * 10) + (value % 16)); } void mcpInit(void) { i2cInit(); } void mcpStartClock(void) { int seconds; seconds = mcpReadData(SEC); mcpWriteData(0x80 | seconds,SEC); return; } void mcpWriteData(unsigned char value, int address) { i2cWriteByte(1,0, MCP7940N_CTRL_ID |I2C_WRITE); i2cWriteByte(0,0,address); i2cWriteByte(0,1,value); } int mcpReadData(int address) { int result; i2cWriteByte(1,0,MCP7940N_CTRL_ID | I2C_WRITE); i2cWriteByte(0,0,address); i2cWriteByte(1,0, MCP7940N_CTRL_ID | I2C_READ); result = i2cReadByte(1,1 ); return result; }