powerEngined.h
84 lines
| 2.0 KiB
| text/x-c
|
CLexer
|
r193 | /* | ||
* powerEngined.h | ||||
* | ||||
* Created on: Jan 26, 2015 | ||||
* Author: aras | ||||
*/ | ||||
#ifndef POWERENGINED_POWERENGINED_H_ | ||||
#define POWERENGINED_POWERENGINED_H_ | ||||
|
r216 | #include <avr/io.h> | ||
|
r193 | |||
/* primitivas 1-wire transaction ds2438 . toda data/comandos es leida y escrita | ||||
* primero el bit menos significativo */ | ||||
|
r216 | /* Hardware definitions */ | ||
#define I2C_SLAVE_ADDR 0x26 | ||||
|
r193 | |||
|
r216 | #define DQ_BIT PB3 | ||
#define DQ_PORT PORTB | ||||
#define DQ_PIN PINB | ||||
#define DQ_DDR DDRB | ||||
/* DS2438Z definitions */ | ||||
#define READ_ROM 0X33 | ||||
#define MATCH_ROM 0x55 | ||||
#define SEARCH_ROM 0xF0 | ||||
#define SKIP_ROM 0xCC | ||||
#define WRITE_SP 0x4E | ||||
#define READ_SP 0xBE | ||||
#define COPY_SP 0x48 | ||||
#define CONV_T 0x44 | ||||
#define CONV_V 0xB4 | ||||
#define RCALL_MEM 0xB8 | ||||
/* DS2438Z Memory Pages (ver datasheet) */ | ||||
#define PAGE_0 0x00 | ||||
#define PAGE_1 0x01 | ||||
#define PAGE_2 0x02 | ||||
#define PAGE_3 0x03 | ||||
#define PAGE_4 0x04 | ||||
#define PAGE_5 0x05 | ||||
#define PAGE_6 0x06 | ||||
#define PAGE_7 0x07 | ||||
/* Funciones de escritura */ | ||||
void write_0_signal();//pull-low, wait 15us, remain low 45us (min), release (high),wait 1us | ||||
void write_1_signal();//pull-low, wait 10us, release (high) 50us (min), remain high,wait 1us | ||||
void write_byte(uint8_t byte); | ||||
|
r193 | void write_bytes(uint8_t* pbytes,uint8_t len); | ||
|
r216 | /* Funciones de lectura */ | ||
uint8_t read_signal();//pull-low, wait 1us, release, pin I , wait 9us, read line, | ||||
|
r193 | //wait 50us(min), pin O, wait 1us | ||
|
r216 | uint8_t read_byte(); | ||
|
r193 | void read_bytes(uint8_t* pbytes, uint8_t len); | ||
// 1 reset pulse trasmition (maestro) | ||||
// low signal for a minimum of 480us. luego del flanco de subida, | ||||
// espera de 15-60us y recibe el pulso de presencia del ds2438 | ||||
// (low 60-240us) | ||||
// 2 presence pulse (respuesta del esclavo) | ||||
void initialization(); | ||||
|
r216 | void memory_read(uint8_t* pbytes, uint8_t page_addr); | ||
|
r193 | |||
|
r216 | |||
|
r193 | // 5 CONVERT_T (0x44) inicia conversion A/D de temperatura | ||
// 6 CONVERT_V (0xB4) inicia conversion A/D de voltaje | ||||
void convert(uint8_t cmd); | ||||
|
r216 | void send_data(uint8_t* pbytes, uint8_t len); | ||
|
r193 | |||
#endif /* POWERENGINED_POWERENGINED_H_ */ | ||||