Blame view

RIOT/drivers/include/io1_xplained.h 3.71 KB
a752c7ab   elopes   add first test an...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
  /*
   * Copyright (C) 2016 Inria
   *
   * This file is subject to the terms and conditions of the GNU Lesser
   * General Public License v2.1. See the file LICENSE in the top level
   * directory for more details.
   */
  
  /**
   * @defgroup    drivers_io1_xplained Atmel IO1 Xplained Extension board
   * @ingroup     drivers_sensors
   * @brief       Device driver interface for the Atmel IO1 Xplained extension.
   *
   * This board contains several sensors and actuators:
   * * @ref drivers_at30tse75x
   * * TEMT6000 Light sensor (not yet supported by this driver)
   * * microSD card connector (not yet supported by this driver)
   * * one yellow LED
   * * 2 GPIO pins
   *
   * This board can be used with the following Atmel evaluation boards:
   * * @ref boards_samr21-xpro
   * * @ref boards_samd21-xpro
   * * @ref boards_saml21-xpro
   *
   * See the [datasheet]
   * (http://www.atmel.com/images/atmel-42078-io1-xplained-pro_user-guide.pdf)
   * for more information
   *
   * @{
   *
   * @file
   * @brief       Device driver interface for the Atmel IO1 Xplained extention.
   *
   * @author      Alexandre Abadie <alexandre.abadie@inria.fr>
   */
  
  #ifndef IO1_XPLAINED_H
  #define IO1_XPLAINED_H
  
  #include "saul.h"
  #include "at30tse75x.h"
  
  #ifdef __cplusplus
  extern "C" {
  #endif
  
  /**
   * @brief   IO1 Xplained driver return codes
   */
  enum {
      IO1_XPLAINED_OK = 0,           /**< Initialization successful */
      IO1_XPLAINED_NOTEMP,           /**< Error during temperature sensor initialization */
      IO1_XPLAINED_NOLED,            /**< Error during extension LED initialization */
      IO1_XPLAINED_NOGPIO1,          /**< Error during extension GPIO1 initialization */
      IO1_XPLAINED_NOGPIO2,          /**< Error during extension GPIO2 initialization */
      IO1_XPLAINED_READ_OK,          /**< Temperature read successful */
      IO1_XPLAINED_READ_ERR          /**< Error when reading temperature sensor */
  };
  
  /**
   * @brief   Device initialization parameters
   */
  typedef struct {
      uint8_t addr;                  /**< extension custom address */
  } io1_xplained_params_t;
  
  /**
   * @brief   Device descriptor for the IO1 Xplained extension.
   */
  typedef struct {
      io1_xplained_params_t params;  /**< Initialization parameters */
      at30tse75x_t temp;             /**< On-board temperature sensor */
  } io1_xplained_t;
  
  /**
   * @brief   Initialize the given IO1 Xplained extension
   *
   * @param[out] dev          Initialized device descriptor of IO1 Xplained extension
   * @param[in]  params       Device initialization parameters
   *
   * @return                  IO1_XPLAINED_OK on success
   * @return                  -IO1_XPLAINED_NOTEMP if temperature sensor initialization failed
   * @return                  -IO1_XPLAINED_NOLED if LED initialization failed
   * @return                  -IO1_XPLAINED_NOGPIO1 if GPIO1 initialization failed
   * @return                  -IO1_XPLAINED_NOGPIO2 if GPIO2 initialization failed
   */
  int io1_xplained_init(io1_xplained_t *dev, const io1_xplained_params_t *params);
  
  /**
   * @brief   Read temperature value from the given IO1 Xplained extension, returned in °C
   *
   * @param[in] dev           Device descriptor of IO1 Xplained to read from
   * @param[out] temperature  Temperature in °C
   *
   * @return                  IO1_XPLAINED_READ_OK on success
   * @return                  -IO1_XPLAINED_READ_ERR if temperature sensor read failed
   */
  int io1_xplained_read_temperature(const io1_xplained_t *dev, float *temperature);
  
  /**
   * @brief   Set the on-board led of the IO1 Xplained extension
   */
  void io1_xplained_set_led(void);
  
  /**
   * @brief   Clear the on-board led of the IO1 Xplained extension
   */
  void io1_xplained_clear_led(void);
  
  /**
   * @brief   Toggle the on-board led of the IO1 Xplained extension
   */
  void io1_xplained_toggle_led(void);
  
  #ifdef __cplusplus
  }
  #endif
  
  #endif /* IO1_XPLAINED_H */
  /** @} */