radiostation  2.0.0.0
radiostation.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright© 2020 MikroElektronika d.o.o.
4  *
5  * Permission is hereby granted, free of charge, to any person
6  * obtaining a copy of this software and associated documentation
7  * files (the "Software"), to deal in the Software without restriction,
8  * including without limitation the rights to use, copy, modify, merge,
9  * publish, distribute, sublicense, and/or sell copies of the Software,
10  * and to permit persons to whom the Software is furnished to do so,
11  * subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22  * OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef RADIOSTATION_H
36 #define RADIOSTATION_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_i2c_master.h"
41 
42 // -------------------------------------------------------------- PUBLIC MACROS
52 #define RADIOSTATION_MAP_MIKROBUS( cfg, mikrobus ) \
53  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
54  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
55  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
56  cfg.sen = MIKROBUS( mikrobus, MIKROBUS_CS ); \
57  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
58 
64 #define RADIOSTATION_RETVAL uint8_t
65 
66 #define RADIOSTATION_OK 0x00
67 #define RADIOSTATION_INIT_ERROR 0xFF
68 
74 #define RADIOSTATION_SLAVE_ADDR0 0x11 // If SEN = 0
75 #define RADIOSTATION_SLAVE_ADDR1 0x63 // If SEN = 1
76 
82 #define RADIOSTATION_CTS 0x80
83 #define RADIOSTATION_ERR 0x40
84 #define RADIOSTATION_RDSINT 0x04
85 #define RADIOSTATION_ASQINT 0x02
86 #define RADIOSTATION_STCINT 0x01
87 
94 // Power Up Settings
95 #define RADIOSTATION_CTS_INTERRUPT_ENABLE 0x04
96 #define RADIOSTATION_GPO2_OUTPUT_ENABLE 0x02
97 #define RADIOSTATION_PATCH_ENABLE 0x01
98 
99 // Set Tune Frequency Possible Arguments
100 #define RADIOSTATION_MIN_TUNE_FREQ 7600
101 #define RADIOSTATION_MAX_TUNE_FREQ 10800
102 #define RADIOSTATION_MIN_STEP 5
103 
109 #define RADIOSTATION_PROP_GPO_IEN 0x0001
110 #define RADIOSTATION_GPO_IEN_ASQREP 0x0200
111 #define RADIOSTATION_GPO_IEN_STCREP 0x0100
112 #define RADIOSTATION_GPO_IEN_CTSIEN 0x0080
113 #define RADIOSTATION_GPO_IEN_ERRIEN 0x0040
114 #define RADIOSTATION_GPO_IEN_RDSIEN 0x0004
115 #define RADIOSTATION_GPO_IEN_ASQIEN 0x0002
116 #define RADIOSTATION_GPO_IEN_STCIENP 0x0001
117 
118 #define RADIOSTATION_PROP_REFCLK_FREQ 0x0201 // Value Range: 31130 to 34406
119 
120 #define RADIOSTATION_PROP_REFCLK_PRESCALE 0x0202 // Value Range: 1 to 4095
121 #define RADIOSTATION_REFCLK_PRESCALE_RCLK 0x0000 & 0x1000
122 #define RADIOSTATION_REFCLK_PRESCALE_DCLK 0x1000 & 0x1000
123 
124 #define RADIOSTATION_PROP_TX_COMPONENT_ENABLE 0x2100
125 #define RADIOSTATION_TX_COMPONENT_ENABLE_RDS 0x0004
126 #define RADIOSTATION_TX_COMPONENT_ENABLE_LEFT_MINUS_RIGHT 0x0002
127 #define RADIOSTATION_TX_COMPONENT_ENABLE_PILOT_TONE 0x0001
128 
129 #define RADIOSTATION_PROP_TX_AUDIO_DEVIATION 0x2101 // Value Range: 0 to 9000
130 
131 #define RADIOSTATION_PROP_TX_PILOT_DEVIATION 0x2102 // Value Range: 0 to 9000
132 
133 #define RADIOSTATION_PROP_TX_LINE_INPUT_LEVEL 0x2104
134 #define RADIOSTATION_TX_LINE_INPUT_LEVEL_LIATTEN_1 0x0000 & 0x3000
135 #define RADIOSTATION_TX_LINE_INPUT_LEVEL_LIATTEN_2 0x1000 & 0x3000
136 #define RADIOSTATION_TX_LINE_INPUT_LEVEL_LIATTEN_3 0x2000 & 0x3000
137 #define RADIOSTATION_TX_LINE_INPUT_LEVEL_LIATTEN_4 0x3000 & 0x3000
138 #define RADIOSTATION_TX_LINE_INPUT_LEVEL_MAX_LILEVEL 636 & 0x03FF
139 
140 #define RADIOSTATION_PROP_TX_LINE_INPUT_MUTE 0x2105
141 #define RADIOSTATION_TX_LINE_INPUT_MUTE_R 0x0001
142 #define RADIOSTATION_TX_LINE_INPUT_MUTE_L 0x0002
143 
144 #define RADIOSTATION_PROP_TX_PREEMPHASIS 0x2106
145 #define RADIOSTATION_TX_PREEMPHASIS_75 0x0000
146 #define RADIOSTATION_TX_PREEMPHASIS_50 0x0001
147 #define RADIOSTATION_TX_PREEMPHASIS_DISABLED 0x0002
148 
149 #define RADIOSTATION_PROP_TX_PILOT_FREQUENCY 0x2107 // Value Range: 0 to 19000
150 
151 #define RADIOSTATION_PROP_TX_ACOMP_ENABLE 0x2200
152 #define RADIOSTATION_TX_ACOMP_ENABLE_LIMITEN 0x0002
153 #define RADIOSTATION_TX_ACOMP_ENABLE_ACEN 0x0001
154 
155 #define RADIOSTATION_PROP_TX_ACOMP_THRESHOLD 0x2201 // Value Range: �40 to 0
156 
157 #define RADIOSTATION_PROP_TX_ACOMP_ATTACK_TIME 0x2202
158 #define RADIOSTATION_TX_ACOMP_ATTACK_TIME_0_5_MS 0x0000
159 #define RADIOSTATION_TX_ACOMP_ATTACK_TIME_1_0_MS 0x0001
160 #define RADIOSTATION_TX_ACOMP_ATTACK_TIME_1_5_MS 0x0002
161 #define RADIOSTATION_TX_ACOMP_ATTACK_TIME_2_0_MS 0x0003
162 #define RADIOSTATION_TX_ACOMP_ATTACK_TIME_2_5_MS 0x0004
163 #define RADIOSTATION_TX_ACOMP_ATTACK_TIME_3_0_MS 0x0005
164 #define RADIOSTATION_TX_ACOMP_ATTACK_TIME_3_5_MS 0x0006
165 #define RADIOSTATION_TX_ACOMP_ATTACK_TIME_4_0_MS 0x0007
166 #define RADIOSTATION_TX_ACOMP_ATTACK_TIME_4_5_MS 0x0008
167 #define RADIOSTATION_TX_ACOMP_ATTACK_TIME_5_0_MS 0x0009
168 
169 #define RADIOSTATION_PROP_TX_ACOMP_RELEASE_TIME 0x2203
170 #define RADIOSTATION_TX_ACOMP_RELEASE_TIME_100_MS 0x0000
171 #define RADIOSTATION_TX_ACOMP_RELEASE_TIME_200_MS 0x0001
172 #define RADIOSTATION_TX_ACOMP_RELEASE_TIME_350_MS 0x0002
173 #define RADIOSTATION_TX_ACOMP_RELEASE_TIME_525_MS 0x0003
174 #define RADIOSTATION_TX_ACOMP_RELEASE_TIME_1000_MS 0x0004
175 
176 #define RADIOSTATION_PROP_TX_ACOMP_GAIN 0x2204 // Value Range: 0 to 20
177 
178 #define RADIOSTATION_PROP_TX_LIMITER_RELEASE_TIME 0x2205 // Value Range: 5 to 2000
179 
180 #define RADIOSTATION_PROP_TX_ASQ_INTERRUPT_SELECT 0x2300
181 #define RADIOSTATION_TX_ASQ_INTERRUPT_OVERMODIEN 0x0004
182 #define RADIOSTATION_TX_ASQ_INTERRUPT_IALHIEN 0x0002
183 #define RADIOSTATION_TX_ASQ_INTERRUPT_IALLIEN 0x0001
184 
185 #define RADIOSTATION_PROP_TX_ASQ_LEVEL_LOW 0x2301 // Value Range: -70 to 0
186 
187 #define RADIOSTATION_PROP_TX_ASQ_LEVEL_HIGH 0x2303 // Value Range: -70 to 0
188 
189 #define RADIOSTATION_PROP_TX_ASQ_DURATION_LOW 0x2302
190 
191 #define RADIOSTATION_PROP_TX_ASQ_DURATION_HIGH 0x2304
192  // End group macro
195 // --------------------------------------------------------------- PUBLIC TYPES
204 typedef struct
205 {
206  // Output pins
207 
208  digital_out_t rst;
209  digital_out_t sen;
210 
211  // Input pins
212 
213  digital_in_t int_pin;
214 
215  // Modules
216 
217  i2c_master_t i2c;
218 
219  // ctx variable
220 
221  uint8_t slave_address;
222 
223  uint16_t transmit_frequency; // Frequency is represented in following way xxx.yy MHz
224  uint8_t status;
225 
227 
231 typedef struct
232 {
233  // Static variable
234 
235  uint8_t *params;
236  uint8_t params_count;
237  uint8_t *ret_vals;
238  uint8_t ret_vals_count;
239 
241 
245 typedef struct
246 {
247  // Communication gpio pins
248 
249  pin_name_t scl;
250  pin_name_t sda;
251 
252  // Additional gpio pins
253 
254  pin_name_t rst;
255  pin_name_t sen;
256  pin_name_t int_pin;
257 
258  // static variable
259 
260  uint32_t i2c_speed;
262 
264  // End types group
266 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
267 
273 #ifdef __cplusplus
274 extern "C"{
275 #endif
276 
285 void radiostation_cfg_setup ( radiostation_cfg_t *cfg, bool slave_select );
286 
296 
306 
316 void radiostation_write ( radiostation_t *ctx, uint8_t *data_buf, uint8_t len );
317 
327 void radiostation_read ( radiostation_t *ctx, uint8_t *data_buf, uint8_t len );
328 
339 uint8_t radiostation_power_up_advanced ( radiostation_t *ctx, radiostation_cmd_t *cmd, uint8_t config );
340 
351 
361 
372 uint8_t radiostation_get_revision ( radiostation_t *ctx, radiostation_cmd_t *cmd, uint8_t *ret_vals );
373 
385 uint8_t radiostation_get_revision1 ( radiostation_t *ctx, uint8_t *ret_vals );
386 
398 uint8_t radiostation_set_tune_frequency ( radiostation_t *ctx, radiostation_cmd_t *cmd, uint16_t freq );
399 
411 uint8_t radiostation_set_tune_power ( radiostation_t *ctx, radiostation_cmd_t *cmd, uint8_t voltage, uint8_t capacitance );
412 
423 uint8_t radiostation_get_tune_measure ( radiostation_t *ctx, radiostation_cmd_t *cmd, uint16_t freq, uint8_t capacitance );
424 
434 
445 
456 
467 
480 uint8_t radiostation_get_tune_status ( radiostation_t *ctx, radiostation_cmd_t *cmd, uint8_t clear_stc_status_bit, uint8_t *ret_vals );
481 
492 uint8_t radiostation_get_asq_status ( radiostation_t *ctx, radiostation_cmd_t *cmd, uint8_t *ret_vals ) ;
493 
504 uint8_t radiostation_set_property ( radiostation_t *ctx, radiostation_cmd_t *cmd, uint16_t property_id, uint16_t property_value );
505 
515 uint16_t radiostation_get_property ( radiostation_t *ctx, radiostation_cmd_t *cmd, uint16_t property_id );
516 
517 
518 #ifdef __cplusplus
519 }
520 #endif
521 #endif // _RADIOSTATION_H_
522  // End public_function group
525 
526 // ------------------------------------------------------------------------- END
radiostation_t::slave_address
uint8_t slave_address
Definition: radiostation.h:221
radiostation_cmd_t::params
uint8_t * params
Definition: radiostation.h:235
radiostation_t
Click ctx object definition.
Definition: radiostation.h:204
radiostation_t::status
uint8_t status
Definition: radiostation.h:224
radiostation_busy_wait_for_stcint
void radiostation_busy_wait_for_stcint(radiostation_t *ctx, radiostation_cmd_t *cmd)
Radio Station Click Busy Wait for STCINT.
radiostation_cfg_t::slave_select
bool slave_select
Definition: radiostation.h:261
radiostation_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: radiostation.h:260
radiostation_cfg_t
Click configuration structure definition.
Definition: radiostation.h:245
radiostation_get_int_status
uint8_t radiostation_get_int_status(radiostation_t *ctx, radiostation_cmd_t *cmd)
Getting int pin status.
radiostation_cfg_t::int_pin
pin_name_t int_pin
Definition: radiostation.h:256
radiostation_write
void radiostation_write(radiostation_t *ctx, uint8_t *data_buf, uint8_t len)
Generic write function.
radiostation_power_down
uint8_t radiostation_power_down(radiostation_t *ctx, radiostation_cmd_t *cmd)
Radio Station Click Power Down.
radiostation_cmd_t::params_count
uint8_t params_count
Definition: radiostation.h:236
radiostation_get_asq_status
uint8_t radiostation_get_asq_status(radiostation_t *ctx, radiostation_cmd_t *cmd, uint8_t *ret_vals)
Radio Station Click ASQ Status.
radiostation_t::rst
digital_out_t rst
Definition: radiostation.h:208
radiostation_busy_wait_for_asqint
void radiostation_busy_wait_for_asqint(radiostation_t *ctx, radiostation_cmd_t *cmd)
Radio Station Click Busy Wait for ASQINT.
radiostation_get_revision
uint8_t radiostation_get_revision(radiostation_t *ctx, radiostation_cmd_t *cmd, uint8_t *ret_vals)
Radio Station Click Get Revision.
radiostation_cmd_t
Click send command object definition.
Definition: radiostation.h:231
radiostation_t::transmit_frequency
uint16_t transmit_frequency
Definition: radiostation.h:223
radiostation_get_tune_measure
uint8_t radiostation_get_tune_measure(radiostation_t *ctx, radiostation_cmd_t *cmd, uint16_t freq, uint8_t capacitance)
Radio Station Click Get Tuning Measurements.
radiostation_get_property
uint16_t radiostation_get_property(radiostation_t *ctx, radiostation_cmd_t *cmd, uint16_t property_id)
Radio Station Click Get Property.
radiostation_t::sen
digital_out_t sen
Definition: radiostation.h:209
radiostation_t::int_pin
digital_in_t int_pin
Definition: radiostation.h:213
radiostation_cfg_t::rst
pin_name_t rst
Definition: radiostation.h:254
radiostation_init
RADIOSTATION_RETVAL radiostation_init(radiostation_t *ctx, radiostation_cfg_t *cfg)
Initialization function.
radiostation_cmd_t::ret_vals
uint8_t * ret_vals
Definition: radiostation.h:237
radiostation_set_tune_power
uint8_t radiostation_set_tune_power(radiostation_t *ctx, radiostation_cmd_t *cmd, uint8_t voltage, uint8_t capacitance)
Radio Station Click Get Revision.
radiostation_cfg_t::sda
pin_name_t sda
Definition: radiostation.h:250
radiostation_set_tune_frequency
uint8_t radiostation_set_tune_frequency(radiostation_t *ctx, radiostation_cmd_t *cmd, uint16_t freq)
Radio Station Click Set Tune Frequency.
radiostation_cmd_t::ret_vals_count
uint8_t ret_vals_count
Definition: radiostation.h:238
RADIOSTATION_RETVAL
#define RADIOSTATION_RETVAL
Definition: radiostation.h:64
radiostation_power_up_advanced
uint8_t radiostation_power_up_advanced(radiostation_t *ctx, radiostation_cmd_t *cmd, uint8_t config)
Radio Station Click Power Up Advanced.
radiostation_cfg_setup
void radiostation_cfg_setup(radiostation_cfg_t *cfg, bool slave_select)
Config Object Initialization function.
radiostation_t::i2c
i2c_master_t i2c
Definition: radiostation.h:217
radiostation_set_property
uint8_t radiostation_set_property(radiostation_t *ctx, radiostation_cmd_t *cmd, uint16_t property_id, uint16_t property_value)
Radio Station Click Set Property.
radiostation_read
void radiostation_read(radiostation_t *ctx, uint8_t *data_buf, uint8_t len)
Generic read function.
radiostation_get_tune_status
uint8_t radiostation_get_tune_status(radiostation_t *ctx, radiostation_cmd_t *cmd, uint8_t clear_stc_status_bit, uint8_t *ret_vals)
Radio Station Click Get Tune Status.
radiostation_cfg_t::scl
pin_name_t scl
Definition: radiostation.h:249
radiostation_default_cfg
void radiostation_default_cfg(radiostation_t *ctx, radiostation_cmd_t *cmd)
Click Default Configuration function.
radiostation_power_up
uint8_t radiostation_power_up(radiostation_t *ctx, radiostation_cmd_t *cmd)
Radio Station Click Power Up.
radiostation_cfg_t::sen
pin_name_t sen
Definition: radiostation.h:255
radiostation_get_revision1
uint8_t radiostation_get_revision1(radiostation_t *ctx, uint8_t *ret_vals)
Radio Station Click Set Tune Frequency.
radiostation_busy_wait_for_rdsint
void radiostation_busy_wait_for_rdsint(radiostation_t *ctx, radiostation_cmd_t *cmd)
Radio Station Click Busy Wait for RDSINT.