Advertisement
miszczo

Untitled

Jan 9th, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.14 KB | None | 0 0
  1. /*
  2.  * ds18b20.h
  3.  *
  4.  *  Created on: 8 sty 2015
  5.  *      Author: miszczo
  6.  */
  7.  
  8. #ifndef DS18B20_DS18B20_H_
  9. #define DS18B20_DS18B20_H_
  10.  
  11.  
  12. // connection to ds18b20
  13. #define ONE_WIRE_PORT B
  14. #define ONE_WIRE_PIN  4
  15.  
  16. //DDR
  17. #define WIRE_DDR_S(s)   GLUE(DDR,s)
  18. #define WIRE_DDR        WIRE_DDR_S(ONE_WIRE_PORT)       // DDRX
  19. //PORT
  20. #define WIRE_PORT_S(s)  GLUE(PORT,s)
  21. #define WIRE_PORT       WIRE_PORT_S(ONE_WIRE_PORT)  // PORTX
  22. //PIN
  23. #define WIRE_PIN_S(s)       GLUE(PIN,s)
  24. #define WIRE_PIN        WIRE_PIN_S(ONE_WIRE_PORT)   // PINX
  25. //direction
  26. #define WIRE_OUT WIRE_DDR|=(1<<ONE_WIRE_PIN)            // out
  27. #define WIRE_IN WIRE_DDR&=~(1<<ONE_WIRE_PIN)            // in
  28. // state
  29. #define WIRE_HI WIRE_PORT|=(1<<ONE_WIRE_PIN)        // hi
  30. #define WIRE_LO WIRE_PORT&=~(1<<ONE_WIRE_PIN)   // lo
  31. // get state
  32. #define WIRE_STATE (WIRE_PIN &(1<<ONE_WIRE_PIN))
  33.  
  34. void ds18b20_get_meas( uint8_t *decimal ,uint8_t  *fractal );
  35.  
  36.  
  37.  
  38. #endif /* DS18B20_DS18B20_H_ */
  39.  
  40.  
  41. /*
  42.  * ds18b20.c
  43.  *
  44.  *  Created on: 8 sty 2015
  45.  *      Author: miszczo
  46.  */
  47.  
  48. #include <avr/io.h>
  49.  
  50. #include "ds18b20.h"
  51.  
  52.  
  53. void ds18b20_get_meas( uint8_t *decimal ,uint8_t  *fractal ){
  54.     WIRE_HI;
  55.  
  56.  
  57.     //reset pulse
  58.     //ONE_WIRE_LO;
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement