sketchbook
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Classes | Macros | Enumerations | Functions | Variables
onewire_internal.h File Reference
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/wdt.h>
#include "dev_data.h"
#include "debug.h"
#include "uart.h"
#include "features.h"
#include "onewire.h"
#include "moat.h"

Go to the source code of this file.

Classes

union  ow_addr_t
 

Macros

#define NO_DEBUG
 
#define EICRA   MCUCR
 
#define PRESCALE   64
 
#define _ADD_T   0
 
#define T_(c)   ((F_CPU/PRESCALE)/(1000000/c)-_ADD_T)
 
#define OWT_MIN_RESET   T_(410)
 
#define OWT_RESET_PRESENCE   (T_(40)-1)
 
#define OWT_PRESENCE   (T_(160)-1)
 
#define OWT_READLINE   (T_(30)-2)
 
#define OWT_LOWTIME   (T_(40)-2)
 
#define PSRSYNC   PSR0
 
#define EN_TIMER()   do {TIMSK0 |= (1<<TOIE0); TIFR0|=(1<<TOV0);}while(0)
 
#define DIS_TIMER()   do {TIMSK0 &= ~(1<<TOIE0);} while(0)
 
#define SET_TIMER(x)   do { GTCCR = (1<<PSRSYNC); TCNT0=(uint8_t)~(x); } while(0)
 
#define TIMER_INT   ISR(TIMER0_OVF_vect)
 
#define TIMER0_OVF_vect   TIM0_OVF_vect
 
#define SET_LOW()   do { ONEWIRE_DDR|=ONEWIRE_PBIT;} while(0)
 
#define CLEAR_LOW()   do {ONEWIRE_DDR&=~ONEWIRE_PBIT;} while(0)
 
#define START_READING(bits)
 
#define wait_complete(c)   _wait_complete()
 

Enumerations

enum  mode_t {
  OWM_SLEEP, OWM_IN_RESET, OWM_AFTER_RESET, OWM_PRESENCE,
  OWM_SEARCH_ZERO, OWM_SEARCH_ONE, OWM_SEARCH_READ, OWM_IDLE,
  OWM_READ, OWM_WRITE
}
 
enum  xmode_t { OWX_IDLE, OWX_SELECT, OWX_COMMAND, OWX_RUNNING }
 
enum  wmode_t { OWW_WRITE_0, OWW_WRITE_1, OWW_NO_WRITE }
 

Functions

void onewire_init (void)
 
void _wait_complete (void)
 
void next_command (void) __attribute__((noreturn))
 
void xmit_byte (uint8_t val)
 
uint16_t xmit_byte_crc (uint16_t crc, uint8_t val)
 
uint16_t xmit_bytes_crc (uint16_t crc, uint8_t *buf, uint8_t len)
 
uint8_t recv_any_in (void)
 
void recv_byte (void)
 
uint16_t recv_bytes_crc (uint16_t crc, uint8_t *buf, uint8_t len)
 
uint16_t crc16 (uint16_t r, uint8_t x)
 
void onewire_poll (void)
 
void set_idle (void)
 

Variables

ow_addr_t ow_addr
 
volatile uint8_t bitp
 
volatile uint8_t bytep
 
volatile uint8_t cbuf
 
volatile mode_t mode
 
volatile xmode_t xmode
 
volatile wmode_t wmode
 
volatile uint8_t actbit
 

Macro Definition Documentation

#define _ADD_T   0
#define CLEAR_LOW ( )    do {ONEWIRE_DDR&=~ONEWIRE_PBIT;} while(0)
#define DIS_TIMER ( )    do {TIMSK0 &= ~(1<<TOIE0);} while(0)
#define EICRA   MCUCR
#define EN_TIMER ( )    do {TIMSK0 |= (1<<TOIE0); TIFR0|=(1<<TOV0);}while(0)
#define NO_DEBUG
#define OWT_LOWTIME   (T_(40)-2)
#define OWT_MIN_RESET   T_(410)
#define OWT_PRESENCE   (T_(160)-1)
#define OWT_READLINE   (T_(30)-2)
#define OWT_RESET_PRESENCE   (T_(40)-1)
#define PRESCALE   64
#define PSRSYNC   PSR0
#define SET_LOW ( )    do { ONEWIRE_DDR|=ONEWIRE_PBIT;} while(0)
#define SET_TIMER (   x)    do { GTCCR = (1<<PSRSYNC); TCNT0=(uint8_t)~(x); } while(0)
#define START_READING (   bits)
Value:
do { \
cbuf=0; \
lbitp=1<<(8-bits); \
} while(0)
volatile uint8_t cbuf
Definition: onewire.c:26
mode_t lmode
Definition: onewire.c:409
uint8_t lbitp
Definition: onewire.c:411
Definition: onewire_internal.h:146
#define T_ (   c)    ((F_CPU/PRESCALE)/(1000000/c)-_ADD_T)
#define TIMER0_OVF_vect   TIM0_OVF_vect
#define TIMER_INT   ISR(TIMER0_OVF_vect)
#define wait_complete (   c)    _wait_complete()

Enumeration Type Documentation

enum mode_t
Enumerator
OWM_SLEEP 
OWM_IN_RESET 
OWM_AFTER_RESET 
OWM_PRESENCE 
OWM_SEARCH_ZERO 
OWM_SEARCH_ONE 
OWM_SEARCH_READ 
OWM_IDLE 
OWM_READ 
OWM_WRITE 
enum wmode_t
Enumerator
OWW_WRITE_0 
OWW_WRITE_1 
OWW_NO_WRITE 
enum xmode_t
Enumerator
OWX_IDLE 
OWX_SELECT 
OWX_COMMAND 
OWX_RUNNING 

Function Documentation

void _wait_complete ( void  )
uint16_t crc16 ( uint16_t  r,
uint8_t  x 
)
void next_command ( void  )
void onewire_init ( void  )
void onewire_poll ( void  )
uint8_t recv_any_in ( void  )
void recv_byte ( void  )
uint16_t recv_bytes_crc ( uint16_t  crc,
uint8_t *  buf,
uint8_t  len 
)
void set_idle ( void  )
void xmit_byte ( uint8_t  val)
uint16_t xmit_byte_crc ( uint16_t  crc,
uint8_t  val 
)
uint16_t xmit_bytes_crc ( uint16_t  crc,
uint8_t *  buf,
uint8_t  len 
)

Variable Documentation

volatile uint8_t actbit
volatile uint8_t bitp
volatile uint8_t bytep
volatile uint8_t cbuf
volatile mode_t mode
ow_addr_t ow_addr
volatile wmode_t wmode
volatile xmode_t xmode