powermux2  2.0.0.0
powermux2.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2020 MikroElektronika d.o.o.
3 ** Contact: https://www.mikroe.com/contact
4 **
5 ** Permission is hereby granted, free of charge, to any person obtaining a copy
6 ** of this software and associated documentation files (the "Software"), to deal
7 ** in the Software without restriction, including without limitation the rights
8 ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 ** copies of the Software, and to permit persons to whom the Software is
10 ** furnished to do so, subject to the following conditions:
11 ** The above copyright notice and this permission notice shall be
12 ** included in all copies or substantial portions of the Software.
13 **
14 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16 ** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19 ** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 ** USE OR OTHER DEALINGS IN THE SOFTWARE.
21 ****************************************************************************/
22 
28 #ifndef POWERMUX2_H
29 #define POWERMUX2_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_spi_master.h"
38 
39 
54 #define POWERMUX2_MAP_MIKROBUS( cfg, mikrobus ) \
55  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
56  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
57  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
58  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS )
59  // powermux2_map // powermux2
61 
66 typedef struct
67 {
68  // Modules
69 
70  spi_master_t spi;
72  pin_name_t chip_select;
74 } powermux2_t;
75 
80 typedef struct
81 {
82  // Communication gpio pins
83 
84  pin_name_t miso;
85  pin_name_t mosi;
86  pin_name_t sck;
87  pin_name_t cs;
89  // static variable
90 
91  uint32_t spi_speed;
92  spi_master_mode_t spi_mode;
93  spi_master_chip_select_polarity_t cs_polarity;
96 
101 typedef enum
102 {
104  POWERMUX2_ERROR = -1
105 
107 
124 
139 err_t powermux2_init ( powermux2_t *ctx, powermux2_cfg_t *cfg );
140 
154 err_t powermux2_generic_write ( powermux2_t *ctx, uint8_t data_in );
155 
170 err_t powermux2_set_resistance ( powermux2_t *ctx, float resistance );
171 
172 #ifdef __cplusplus
173 }
174 #endif
175 #endif // POWERMUX2_H
176  // powermux2
178 
179 // ------------------------------------------------------------------------ END
powermux2_set_resistance
err_t powermux2_set_resistance(powermux2_t *ctx, float resistance)
Power MUX 2 set resistance function.
POWERMUX2_OK
Definition: powermux2.h:102
powermux2_return_value_t
powermux2_return_value_t
Power MUX 2 Click return value data.
Definition: powermux2.h:100
POWERMUX2_ERROR
Definition: powermux2.h:103
powermux2_generic_write
err_t powermux2_generic_write(powermux2_t *ctx, uint8_t data_in)
Power MUX 2 data writing function.
powermux2_t
Power MUX 2 Click context object.
Definition: powermux2.h:65
powermux2_cfg_setup
void powermux2_cfg_setup(powermux2_cfg_t *cfg)
Power MUX 2 configuration object setup function.
powermux2_cfg_t
Power MUX 2 Click configuration object.
Definition: powermux2.h:79
powermux2_init
err_t powermux2_init(powermux2_t *ctx, powermux2_cfg_t *cfg)
Power MUX 2 initialization function.