Microprocessor and peripheral 2 assignments for AUTH
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

98 lines
2.1 KiB

  1. /*!
  2. * \file hal.h
  3. *
  4. * Author: Christos Choutouridis AEM: 8997
  5. * email : <cchoutou@ece.auth.gr>
  6. *
  7. */
  8. #ifndef DRIVERS_HAL_H_
  9. #define DRIVERS_HAL_H_
  10. #include <thermostat_shield.h>
  11. #include <alcd.h>
  12. #include <jiffies.h>
  13. #include <onewire_uart.h>
  14. #include <deque08.h>
  15. #include <thermostat.h>
  16. #include <stdio.h>
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. int hal_hw_init (void);
  21. /*
  22. * ========== LCD ===========
  23. */
  24. void lcd_init (void);
  25. void lcd_enable (uint8_t en) ;
  26. int lcd_putchar (char c);
  27. int lcd_puts (const char *s);
  28. /*
  29. * ========== Led interface ==========
  30. */
  31. void led_red (uint8_t en);
  32. void led_green (uint8_t en);
  33. /*
  34. * ========= Relay ===========
  35. */
  36. void relay(uint8_t on);
  37. /*
  38. * ========= Temperature ===========
  39. */
  40. // OneWire commands
  41. #define SKIPROM 0xCC // Skip ROM matching transition
  42. #define STARTCONV 0x44 // Tells device to take a temperature reading and put it on the scratchpad
  43. #define COPYSCRATCH 0x48 // Copy EEPROM
  44. #define READSCRATCH 0xBE // Read EEPROM
  45. #define WRITESCRATCH 0x4E // Write to EEPROM
  46. #define RECALLSCRATCH 0xB8 // Reload from last known
  47. #define READPOWERSUPPLY 0xB4 // Determine if device needs parasite power
  48. #define ALARMSEARCH 0xEC // Query bus for devices with an alarm condition
  49. // Device resolution
  50. #define TEMP_9_BIT 0x1F // 9 bit
  51. #define TEMP_10_BIT 0x3F // 10 bit
  52. #define TEMP_11_BIT 0x5F // 11 bit
  53. #define TEMP_12_BIT 0x7F // 12 bit
  54. #define IS_TEMP_RESOLUTION(x) \
  55. ((x == TEMP_9_BIT) || (x == TEMP_10_BIT) || (x == TEMP_11_BIT) || (x == TEMP_12_BIT))
  56. int temp_init (uint8_t resolution);
  57. float temp_read (void);
  58. /*
  59. * ========= Proximity ===========
  60. */
  61. #define PROX_TIME_MAX 25 // [msec]
  62. #define PROX_READINGS 7 // How many readings for averaging
  63. #define PROX_MAX_DISTANSE 450 // [cm]
  64. typedef struct {
  65. float_t readings[7];
  66. int iter;
  67. } proximity_t;
  68. void proximity_init (proximity_t* p);
  69. float_t proximity (proximity_t* p);
  70. /*
  71. * Public data types / classes
  72. */
  73. extern alcd_t alcd;
  74. extern ow_uart_t ow;
  75. extern proximity_t prox;
  76. #ifdef __cplusplus
  77. }
  78. #endif
  79. #endif /* DRIVERS_HAL_H_ */