##// END OF EJS Templates
Versión inicial de los bloques de comunicación para el módulo de procesamiento.
Versión inicial de los bloques de comunicación para el módulo de procesamiento.

File last commit:

r216:217
r219:220
Show More
powerEngined.h
84 lines | 2.0 KiB | text/x-c | CLexer
/*
* powerEngined.h
*
* Created on: Jan 26, 2015
* Author: aras
*/
#ifndef POWERENGINED_POWERENGINED_H_
#define POWERENGINED_POWERENGINED_H_
#include <avr/io.h>
/* primitivas 1-wire transaction ds2438 . toda data/comandos es leida y escrita
* primero el bit menos significativo */
/* Hardware definitions */
#define I2C_SLAVE_ADDR 0x26
#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);
void write_bytes(uint8_t* pbytes,uint8_t len);
/* Funciones de lectura */
uint8_t read_signal();//pull-low, wait 1us, release, pin I , wait 9us, read line,
//wait 50us(min), pin O, wait 1us
uint8_t read_byte();
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();
void memory_read(uint8_t* pbytes, uint8_t page_addr);
// 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);
void send_data(uint8_t* pbytes, uint8_t len);
#endif /* POWERENGINED_POWERENGINED_H_ */