Developer World
Spresense SDK Library v1.4.2-3df2e9d
cxd56_scu.h
Go to the documentation of this file.
1 /****************************************************************************
2  * bsp/include/arch/chip/cxd56_scu.h
3  *
4  * Copyright 2018 Sony Semiconductor Solutions Corporation
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in
14  * the documentation and/or other materials provided with the
15  * distribution.
16  * 3. Neither the name of Sony Semiconductor Solutions Corporation nor
17  * the names of its contributors may be used to endorse or promote
18  * products derived from this software without specific prior written
19  * permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  ****************************************************************************/
39 #ifndef __ARCH_ARM_INCLUDE_CXD56XX_CXD56_SCU_H
40 #define __ARCH_ARM_INCLUDE_CXD56XX_CXD56_SCU_H
41 
47 /*-----------------------------------------------------------------------------
48  * include files
49  *---------------------------------------------------------------------------*/
50 
51 #include <stdint.h>
52 #include <stdbool.h>
53 #include <nuttx/fs/ioctl.h>
54 
55 /****************************************************************************
56  * Pre-processor Definitions
57  ****************************************************************************/
58 
59 #define _SCUIOCBASE (0xa000)
60 
61 #define _SCUIOCVALID(c) (_IOC_TYPE(c)==_SCUIOCBASE)
62 #define _SCUIOC(nr) _IOC(_SCUIOCBASE,nr)
63 
76 #define SCUIOC_SETFIFO _SCUIOC(0x0001)
77 
85 #define SCUIOC_FREEFIFO _SCUIOC(0x0002)
86 
94 #define SCUIOC_SETSAMPLE _SCUIOC(0x0003)
95 
103 #define SCUIOC_SETSIGNCONV _SCUIOC(0x0004)
104 
112 #define SCUIOC_SETOGADJUST _SCUIOC(0x0005)
113 
121 #define SCUIOC_CLROGADJUST _SCUIOC(0x0006)
122 
130 #define SCUIOC_SETFILTER _SCUIOC(0x0007)
131 
142 #define SCUIOC_SETNOTIFY _SCUIOC(0x0008)
143 
156 #define SCUIOC_SETELEMENTS _SCUIOC(0x0009)
157 
165 #define SCUIOC_SETDECIMATION _SCUIOC(0x000a)
166 
174 #define SCUIOC_SETWATERMARK _SCUIOC(0x000b)
175 
183 #define SCUIOC_START _SCUIOC(0x0010)
184 
192 #define SCUIOC_STOP _SCUIOC(0x0011)
193 
201 #define SCUIOC_SETFIFOMODE _SCUIOC(0x0012)
202 
210 #define SCUIOC_DELFIFODATA _SCUIOC(0x0013)
211 
219 #define SCU_BUS_SPI 1
220 #define SCU_BUS_I2C0 2
221 #define SCU_BUS_I2C1 3
222 #define SCU_BUS_LPADC0 0x10
223 #define SCU_BUS_LPADC1 0x11
224 #define SCU_BUS_LPADC2 0x12
225 #define SCU_BUS_LPADC3 0x13
226 #define SCU_BUS_HPADC0 0x14
227 #define SCU_BUS_HPADC1 0x15
231 #define SCU_INST_SEND(val) ((val) & 0xff)
232 
235 #define SCU_INST_RECV(n) ((1 << 8) | (((n) - 1) & 0x7) << 12)
236 
237 #define SCU_INST_TERM (1 << 11)
238 #define SCU_INST_RESTART (1 << 10)
239 #define SCU_INST_STOP (1 << 9)
240 
242 #define SCU_INST_LAST (SCU_INST_TERM|SCU_INST_STOP)
243 
244 /* Sequencer types */
245 
246 #define SEQ_TYPE_NORMAL 0
247 #define SEQ_TYPE_DECI 1
249 /* Event control */
250 
251 #define SCU_EV_RISE_EN (1 << 31)
252 #define SCU_EV_FALL_EN (1 << 30)
253 #define SCU_EV_OUT8BITS (1 << 29)
255 #define SCU_EV_OUTSHIFT 16
256 #define SCU_EV_OUTMASK (3 << SCU_EV_OUTSHIFT)
257 #define SCU_EV_OUTALWAYS (0 << SCU_EV_OUTSHIFT)
258 #define SCU_EV_OUTSTART (1 << SCU_EV_OUTSHIFT)
259 #define SCU_EV_OUTSTOP (2 << SCU_EV_OUTSHIFT)
260 #define SCU_EV_NOTOUT (3 << SCU_EV_OUTSHIFT)
262 #define SCU_EV_WRITESAMPLEMASK 0xfff
263 
266 #define SCU_EV_WRITESAMPLES(sample) ((sample) & SCU_EV_WRITESAMPLEMASK)
267 
268 /* Event type flags */
269 
270 #define SCU_EV_RISE (1)
271 #define SCU_EV_FALL (2)
273 /* Level adjustment (decimator only) */
274 
275 #define SCU_LEVELADJ_X1 (0)
276 #define SCU_LEVELADJ_X2 (1)
277 #define SCU_LEVELADJ_X4 (2)
278 #define SCU_LEVELADJ_X8 (3)
282 /****************************************************************************
283  * Public Types
284  ****************************************************************************/
285 
297 {
305 };
306 
310 {
311  uint32_t sec;
312  uint16_t tick;
313 };
314 
318 {
319  uint32_t h;
320  uint8_t l;
321 };
322 
326 {
327  uint8_t ishift;
328  uint8_t oshift;
329  struct iir_coeff_s coeff[5];
330 };
331 
335 {
336  enum filter_pos_e pos;
337  struct iir_filter_s filter[2];
338 };
339 
360 {
361  uint16_t threshold;
362  uint16_t count0;
363  uint16_t count1;
364  uint16_t delaysamples;
365 };
366 
370 {
371  struct scutimestamp_s ts;
372  uint32_t type;
373 };
374 
378 {
379  int signo;
382  struct sensor_event_s rise;
383  struct sensor_event_s fall;
385  uint32_t ctrl;
387  FAR struct scuev_arg_s *arg;
388 };
389 
392 struct adjust_s {
393  uint16_t offset;
394  uint16_t gain;
395 };
396 
399 struct adjust_xyz_s {
400  struct adjust_s x;
401  struct adjust_s y;
402  struct adjust_s z;
403 };
404 
408 {
409  uint8_t ratio;
410  uint8_t leveladj;
411  uint8_t forcethrough;
412 };
413 
417 {
418  int signo;
423  FAR struct scutimestamp_s *ts;
424 
431  uint16_t watermark;
432 };
433 
434 struct seq_s; /* The sequencer object */
435 
457 FAR struct seq_s *seq_open(int type, int bustype);
458 
465 void seq_close(FAR struct seq_s *seq);
466 
478 int seq_read(FAR struct seq_s *seq, int fifoid, char *buffer, int length);
479 
495 int seq_ioctl(FAR struct seq_s *seq, int fifoid, int cmd, unsigned long arg);
496 
507 int seq_setinstruction(FAR struct seq_s *seq, const uint16_t *inst, uint16_t nr_insts);
508 
521 void seq_setsample(FAR struct seq_s *seq, uint8_t sample, uint8_t offset,
522  uint8_t elemsize, bool swapbyte);
523 
531 void seq_setaddress(FAR struct seq_s *seq, uint32_t slave_addr);
532 
549 int scu_spitransfer(int slavesel, uint16_t *inst, uint32_t nr_insts,
550  uint8_t *buffer, int len);
551 
569 int scu_i2ctransfer(int port, int slave, uint16_t *inst, uint32_t nr_insts,
570  uint8_t *buffer, int len);
571 
578 void scu_initialize(void);
579 
586 void scu_uninitialize(void);
587 
592 #endif /* __ARCH_ARM_INCLUDE_CXD56XX_CXD56_SCU_H */
uint16_t watermark
Definition: cxd56_scu.h:431
uint16_t delaysamples
Definition: cxd56_scu.h:364
uint32_t ctrl
Definition: cxd56_scu.h:385
Definition: cxd56_scu.h:399
FAR struct seq_s * seq_open(int type, int bustype)
uint16_t count1
Definition: cxd56_scu.h:363
int signo
Definition: cxd56_scu.h:379
Definition: cxd56_scu.h:301
Definition: cxd56_scu.h:298
FAR struct scutimestamp_s * ts
Definition: cxd56_scu.h:423
void scu_initialize(void)
Definition: cxd56_scu.h:304
uint16_t gain
Definition: cxd56_scu.h:394
uint16_t count0
Definition: cxd56_scu.h:362
Definition: cxd56_scu.h:359
Definition: cxd56_scu.h:325
FAR struct scuev_arg_s * arg
Definition: cxd56_scu.h:387
int seq_ioctl(FAR struct seq_s *seq, int fifoid, int cmd, unsigned long arg)
uint8_t l
Definition: cxd56_scu.h:320
Definition: cxd56_scu.h:303
Definition: cxd56_scu.h:317
Definition: cxd56_scu.h:407
Definition: cxd56_scu.h:334
Definition: cxd56_scu.h:300
uint16_t offset
Definition: cxd56_scu.h:393
Definition: cxd56_scu.h:392
uint8_t leveladj
Definition: cxd56_scu.h:410
void seq_setsample(FAR struct seq_s *seq, uint8_t sample, uint8_t offset, uint8_t elemsize, bool swapbyte)
int scu_spitransfer(int slavesel, uint16_t *inst, uint32_t nr_insts, uint8_t *buffer, int len)
Definition: cxd56_scu.h:416
uint16_t threshold
Definition: cxd56_scu.h:361
uint8_t forcethrough
Definition: cxd56_scu.h:411
uint8_t oshift
Definition: cxd56_scu.h:328
int signo
Definition: cxd56_scu.h:418
uint16_t tick
Definition: cxd56_scu.h:312
Definition: cxd56_scu.h:377
uint32_t sec
Definition: cxd56_scu.h:311
uint32_t type
Definition: cxd56_scu.h:372
uint8_t ratio
Definition: cxd56_scu.h:409
uint8_t ishift
Definition: cxd56_scu.h:327
Definition: cxd56_scu.h:369
void seq_setaddress(FAR struct seq_s *seq, uint32_t slave_addr)
Definition: cxd56_scu.h:299
Definition: cxd56_scu.h:302
filter_pos_e
Definition: cxd56_scu.h:296
int seq_read(FAR struct seq_s *seq, int fifoid, char *buffer, int length)
void scu_uninitialize(void)
Definition: cxd56_scu.h:309
void seq_close(FAR struct seq_s *seq)
int seq_setinstruction(FAR struct seq_s *seq, const uint16_t *inst, uint16_t nr_insts)
int scu_i2ctransfer(int port, int slave, uint16_t *inst, uint32_t nr_insts, uint8_t *buffer, int len)