-
Notifications
You must be signed in to change notification settings - Fork 15
/
fmtx.h
378 lines (323 loc) · 14.1 KB
/
fmtx.h
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
/*
* low-level API for FmStick
* $Id$
* (part of FmStick).
*
* (C) 2011 Serge <piratfm@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef FMTX_H
#define FMTX_H
#ifdef FMTX
#define EXTERN
#define ASSIGN (x) =x
#else
#define EXTERN extern
#define ASSIGN(x)
#endif
#ifdef _WIN32
#define FMTX_API_EXPORT __declspec(dllexport)
#define FMTX_API_CALL _stdcall
#else
#define FMTX_API_EXPORT
#define FMTX_API_CALL
#endif
#include <inttypes.h>
#ifdef __cplusplus
extern "C" {
#endif
//MSB: Command Types
#define PCRequestError 0x80
#define PCTransfer 0x02
//MSB: Request Types
#define RequestDone 0x80
enum {
RequestNone = 0,
RequestCpuId,
RequestSi4711Reset, //reset
RequestSi4711Access, //low level access
RequestSi4711GetProp, //medium level get prop
RequestSi4711SetProp, //medium level set prop
RequestSi4711PowerStatus,
RequestSi4711PowerUp, //high level power up
RequestSi4711PowerDown, //high level power down
RequestSi4711AudioEnable, //this MUST BE!!! called after setting config to enable audio.
RequestSi4711AudioDisable,
RequestEepromSectionRead,
RequestEepromSectionWrite,
RequestSi4711AsqStatus,
RequestSi4711TuneStatus,
RequestUnknown
};
enum {
SI4711_OK = 0,
SI4711_TIMEOUT,
SI4711_COMM_ERR,
SI4711_BAD_ARG,
SI4711_NOCTS,
SI4711_ERROR_UNKNOWN
};
enum {
RTPLUS_DUMMY_CLASS = 0,
RTPLUS_ITEM_TITLE,
RTPLUS_ITEM_ALBUM,
RTPLUS_ITEM_TRACKNUMBER,
RTPLUS_ITEM_ARTIST,
RTPLUS_ITEM_COMPOSITION,
RTPLUS_ITEM_MOVEMENT,
RTPLUS_ITEM_CONDUCTOR,
RTPLUS_ITEM_COMPOSER,
RTPLUS_ITEM_BAND,
RTPLUS_ITEM_COMMENT,
RTPLUS_ITEM_GENRE,
RTPLUS_INFO_NEWS,
RTPLUS_INFO_NEWS_LOCAL,
RTPLUS_INFO_STOCKMARKET,
RTPLUS_INFO_SPORT,
RTPLUS_INFO_LOTTERY,
RTPLUS_INFO_HOROSCOPE,
RTPLUS_INFO_DAILY_DIVERSION,
RTPLUS_INFO_HEALTH,
RTPLUS_INFO_EVENT,
RTPLUS_INFO_SZENE,
RTPLUS_INFO_CINEMA,
RTPLUS_INFO_STUPIDITY_MACHINE,
RTPLUS_INFO_DATE_TIME,
RTPLUS_INFO_WEATHER,
RTPLUS_INFO_TRAFFIC,
RTPLUS_INFO_ALARM,
RTPLUS_INFO_ADVERTISEMENT,
RTPLUS_INFO_URL,
RTPLUS_INFO_OTHER,
RTPLUS_STATIONNAME_SHORT,
RTPLUS_STATIONNAME_LONG,
/* Category Code RT+ Class:
0
1 ITEM.TITLE
2 ITEM.ALBUM
3 ITEM.TRACKNUMBER
4 ITEM.ARTIST
5 ITEM.COMPOSITION
6 ITEM.MOVEMENT
7 ITEM.CONDUCTOR
8 ITEM.COMPOSER
9 ITEM.BAND
10 ITEM.COMMENT
11 ITEM.GENRE
12 INFO.NEWS
13 INFO.NEWS.LOCAL
14 INFO.STOCKMARKET
15 INFO.SPORT
16 INFO.LOTTERY
17 INFO.HOROSCOPE
18 INFO.DAILY_DIVERSION
19 INFO.HEALTH
20 INFO.EVENT
21 INFO.SZENE
22 INFO.CINEMA
23 INFO.STUPIDITY_MACHINE
24 INFO.DATE_TIME
25 INFO.WEATHER
26 INFO.TRAFFIC
27 INFO.ALARM
28 INFO.ADVERTISEMENT
29 INFO.URL
30 INFO.OTHER
31 STATIONNAME.SHORT
32 STATIONNAME.LONG
*/
RTPLUS_PROGRAMME_NOW,
RTPLUS_PROGRAMME_NEXT,
RTPLUS_PROGRAMME_PART,
RTPLUS_PROGRAMME_HOST,
RTPLUS_PROGRAMME_EDITORIAL_STAFF,
RTPLUS_PROGRAMME_FREQUENCY,
RTPLUS_PROGRAMME_HOMEPAGE,
RTPLUS_PROGRAMME_SUBCHANNEL,
RTPLUS_PHONE_HOTLINE,
RTPLUS_PHONE_STUDIO,
RTPLUS_PHONE_OTHER,
RTPLUS_SMS_STUDIO,
RTPLUS_SMS_OTHER,
RTPLUS_EMAIL_HOTLINE,
RTPLUS_EMAIL_STUDIO,
RTPLUS_EMAIL_OTHER,
RTPLUS_MMS_OTHER,
RTPLUS_CHAT,
RTPLUS_CHAT_CENTER,
RTPLUS_VOTE_QUESTION,
RTPLUS_VOTE_CENTER,
/*
33 PROGRAMME.NOW
34 PROGRAMME.NEXT
35 PROGRAMME.PART
36 PROGRAMME.HOST
37 PROGRAMME.EDITORIAL_STAFF
38 PROGRAMME.FREQUENCY
39 PROGRAMME.HOMEPAGE
40 PROGRAMME.SUBCHANNEL
41 PHONE.HOTLINE
42 PHONE.STUDIO
43 PHONE.OTHER
44 SMS.STUDIO
45 SMS.OTHER
46 EMAIL.HOTLINE
47 EMAIL.STUDIO
48 EMAIL.OTHER
49 MMS.OTHER
50 CHAT
51 CHAT.CENTER
52 VOTE.QUESTION
53 VOTE.CENTER
*/
RTPLUS_PLACE = 59,
RTPLUS_APPOINTMENT,
RTPLUS_IDENTIFIER,
RTPLUS_PURCHASE,
RTPLUS_GET_DATA
};
/** \brief FMTX mode enumeration. */
typedef enum {
FMTX_MODE_NONE, /*!< No FMTX detected. */
FMTX_MODE_POWER_DOWN, /*!< FMTX present in power-down mode. */
FMTX_MODE_POWER_UP, /*!< FMTX present in power-up mode. */
FMTX_MODE_TRANSMITTING, /*!< FMTX present in running mode. */
FMTX_MODE_OK, /*!< FMTX present in running mode and command is successfully. */
} FMTX_MODE_ENUM; // The current mode of the FMTX: none inserted, in bootloader mode or in normal application mode
typedef enum {
FMTX_SPECIAL_FRONTEND, /*!< Do Stuff on-the-go. */
FMTX_SPECIAL_EEPROM /*!< Don't do stuff in-real, just create EEPROM image. */
} FMTX_SPECIAL_ENUM;
/*********************************************************
* EEPROM Info
*********************************************************/
#define TX_CONFIG_OFFSET 0x1E00
#define FMTX_EEPROM_CMDSIZE 0x08
#define FMTX_MAX_EEPROM_CMDS 62
typedef struct {
uint16_t syncWord;
uint8_t numCmds;
uint8_t startupFlag;
//unused 5 bytes;
uint8_t commandData[FMTX_MAX_EEPROM_CMDS*FMTX_EEPROM_CMDSIZE];
} eeprom_data;
/*********************************************************
* Shared Vars
*********************************************************/
EXTERN FMTX_MODE_ENUM fmtxCmdStatus;
EXTERN FMTX_SPECIAL_ENUM fmtxCmdSpecial;
/*********************************************************
* High-level API
*********************************************************/
EXTERN FMTX_API_EXPORT FMTX_API_CALL FMTX_MODE_ENUM fmtxEEPROMInfoClean(void);
EXTERN FMTX_API_EXPORT FMTX_API_CALL FMTX_MODE_ENUM fmtxEEPROMReadConfig(void);
EXTERN FMTX_API_EXPORT FMTX_API_CALL FMTX_MODE_ENUM fmtxEEPROMWriteConfig(int autorun);
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxEEPROMGetStartupFlag(void);
EXTERN FMTX_API_EXPORT FMTX_API_CALL FMTX_MODE_ENUM fmtxEEPROMSetStartupFlag(uint8_t flag, int force);
EXTERN FMTX_API_EXPORT FMTX_API_CALL FMTX_MODE_ENUM fmtxEEPROMWriteFwChunk(const uint8_t *data, int size, uint16_t offset);
EXTERN FMTX_API_EXPORT FMTX_API_CALL FMTX_MODE_ENUM fmtxEEPROMReadFwChunk(uint8_t *data, int size, uint16_t offset);
/*********************************************************
* Low-level API
*********************************************************/
EXTERN FMTX_API_EXPORT FMTX_API_CALL FMTX_MODE_ENUM fmtxIoAppDeviceFound(void);
EXTERN FMTX_API_EXPORT FMTX_API_CALL FMTX_MODE_ENUM fmtxIoAppFeReset(void);
EXTERN FMTX_API_EXPORT FMTX_API_CALL FMTX_MODE_ENUM fmtxIoAppFeGetMode(int *transmitting);
EXTERN FMTX_API_EXPORT FMTX_API_CALL FMTX_MODE_ENUM fmtxIoAppFeUp(void);
EXTERN FMTX_API_EXPORT FMTX_API_CALL FMTX_MODE_ENUM fmtxIoAppFeDown(void);
EXTERN FMTX_API_EXPORT FMTX_API_CALL FMTX_MODE_ENUM fmtxIoAppIdString(char *cpuid, char *rev);
EXTERN FMTX_API_EXPORT FMTX_API_CALL FMTX_MODE_ENUM fmtxIoAppAsqStatus(uint8_t *flags, int8_t *level);
EXTERN FMTX_API_EXPORT FMTX_API_CALL FMTX_MODE_ENUM fmtxIoAppSetProperty(int16_t i16Prop, int16_t i16Val);
EXTERN FMTX_API_EXPORT FMTX_API_CALL FMTX_MODE_ENUM fmtxIoAppGetProperty(int16_t i16Prop, int16_t *pi16Val);
EXTERN FMTX_API_EXPORT FMTX_API_CALL FMTX_MODE_ENUM fmtxIoAppCommand(uint8_t u8Cmd, uint8_t *pu8Resp, uint8_t u8Amount, ...);
/*********************************************************
* Medium-level API
*********************************************************/
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxAudioGetAcompFlags();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxAudioSetAcompFlags(uint8_t u8Val);
EXTERN FMTX_API_EXPORT FMTX_API_CALL int16_t fmtxAudioGetAcompThreshold();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxAudioSetAcompThreshold(int16_t i16Val);
EXTERN FMTX_API_EXPORT FMTX_API_CALL double fmtxAudioGetAcompAttackTime();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxAudioSetAcompAttackTime(double dVal);
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxAudioGetAcompReleaseTimeId();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxAudioSetAcompReleaseTimeId(uint8_t u8Val);
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxAudioGetAcompGain();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxAudioSetAcompGain(uint8_t u8Val);
EXTERN FMTX_API_EXPORT FMTX_API_CALL double fmtxAudioGetLimiterReleaseTime();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxAudioSetLimiterReleaseTime(double dVal);
/* audio signal measurement */
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxAudioGetAsqIntFlags();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxAudiosetAsqIntFlags(uint8_t u8Val);
EXTERN FMTX_API_EXPORT FMTX_API_CALL int8_t fmtxAudioGetAsqLevelLow();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxAudioSetAsqLevelLow(int8_t i8Val);
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint16_t fmtxAudioGetAsqDurationLow();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxAudioSetAsqDurationLow(uint16_t u16Val);
EXTERN FMTX_API_EXPORT FMTX_API_CALL int8_t fmtxAudioGetAsqLevelHigh();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxAudioSetAsqLevelHigh(int8_t i8Val);
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint16_t fmtxAudioGetAsqDurationHigh();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxAudioSetAsqDurationHigh(uint16_t u16Val);
/* digital audio interface */
EXTERN FMTX_API_EXPORT FMTX_API_CALL FMTX_MODE_ENUM fmtxIoAppEnableAudio(void);
EXTERN FMTX_API_EXPORT FMTX_API_CALL FMTX_MODE_ENUM fmtxIoAppDisableAudio(void);
/* analogue audio interface */
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint16_t fmtxAudioGetInputLevels();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxAudioSetInputLevels(uint16_t atten, uint16_t level);
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint16_t fmtxAudioGetInputMute();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxAudioSetInputMute(uint16_t u16Val);
/* transmitting parameters */
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxTransmitterGetComponentFlags();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxTransmitterSetComponentFlags(uint8_t u8Val);
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxTransmitterGetPreemphasisId();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxTransmitterSetPreemphasisId(uint8_t u8Val);
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint32_t fmtxTransmitterGetAudioDeviation();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxTransmitterSetAudioDeviation(uint32_t u32Val);
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint32_t fmtxTransmitterGetPilotDeviation();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxTransmitterSetPilotDeviation(uint32_t u32Val);
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint32_t fmtxTransmitterGetRDSDeviation();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxTransmitterSetRDSDeviation(uint32_t u32Val);
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint16_t fmtxTransmitterGetPilotFrequency();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxTransmitterSetPilotFrequency(uint16_t u16Val);
EXTERN FMTX_API_EXPORT FMTX_API_CALL FMTX_MODE_ENUM fmtxTransmitterGetTuneStatus(double *freq, uint8_t *power, double *rfcap);
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxTransmitterSetTuneFreq(double freq);
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxTransmitterSetTunePower(uint8_t power, double rfcap);
/* RDS parameters */
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint16_t fmtxRDSGetPI();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxRDSSetPI(uint16_t u16Val);
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxRDSGetPsMixId();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxRDSSetPsMixId(uint8_t u8Val);
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint16_t fmtxRDSGetPsMiscFlags();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxRDSSetPsMiscFlags(uint16_t u16Val);
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxRDSGetPsRepeatCount();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxRDSSetPsRepeatCount(uint8_t u8Val);
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxRDSGetPsMessageCount();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxRDSSetPsMessageCount(uint8_t u8Val);
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxRDSGetPsAFStatus(double *freq);
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxRDSSetPsAF(double freq, uint8_t enabled);
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxRDSGetFifoSize();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxRDSSetFifoSize(uint8_t u8Val);
/* hackish commands for getting PS and RT data from eeprom */
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxRDSGetPsMessageById(uint8_t Id, char *messages);
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxRDSSetPsMessageById(uint8_t Id, char *messages);
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxRDSGetRtMessage(char *messages); //returns one long string with RT message
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxRDSSetRtMessage(const char *message);
/* RTPlus info must be setted after Rt message due fmtxRDSSetRtMessage() flusher circular buffer */
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxRDSSetRtPlusInfo(int content1, int content1_pos, int content1_len,
int content2, int content2_pos, int content2_len);
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxRDSSendTimeStamp();
EXTERN FMTX_API_EXPORT FMTX_API_CALL uint8_t fmtxRDSSendCustomGroup(uint8_t flags, uint8_t B0, uint8_t B1, uint8_t C0, uint8_t C1, uint8_t D0, uint8_t D1);
#ifdef __cplusplus
}
#endif
#endif // FMTX_H