Developer World
Spresense SDK Library v2.3.0-e949ae4
scu.h
Go to the documentation of this file.
1 /****************************************************************************
2  * arch/arm/include/cxd56xx/scu.h
3  *
4  * Licensed to the Apache Software Foundation (ASF) under one or more
5  * contributor license agreements. See the NOTICE file distributed with
6  * this work for additional information regarding copyright ownership. The
7  * ASF licenses this file to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance with the
9  * License. You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16  * License for the specific language governing permissions and limitations
17  * under the License.
18  *
19  ****************************************************************************/
24 #ifndef __ARCH_ARM_INCLUDE_CXD56XX_SCU_H
25 #define __ARCH_ARM_INCLUDE_CXD56XX_SCU_H
26 
32 /****************************************************************************
33  * Included Files
34  ****************************************************************************/
35 
36 #include <stdint.h>
37 #include <stdbool.h>
38 #include <nuttx/fs/ioctl.h>
39 
40 /****************************************************************************
41  * Pre-processor Prototypes
42  ****************************************************************************/
43 
44 #define _SCUIOCBASE (0xa000)
45 
46 #define _SCUIOCVALID(c) (_IOC_TYPE(c)==_SCUIOCBASE)
47 #define _SCUIOC(nr) _IOC(_SCUIOCBASE,nr)
48 
61 #define SCUIOC_SETFIFO _SCUIOC(0x0001)
62 
70 #define SCUIOC_FREEFIFO _SCUIOC(0x0002)
71 
79 #define SCUIOC_SETSAMPLE _SCUIOC(0x0003)
80 
88 #define SCUIOC_SETSIGNCONV _SCUIOC(0x0004)
89 
97 #define SCUIOC_SETOGADJUST _SCUIOC(0x0005)
98 
106 #define SCUIOC_CLROGADJUST _SCUIOC(0x0006)
107 
115 #define SCUIOC_SETFILTER _SCUIOC(0x0007)
116 
127 #define SCUIOC_SETNOTIFY _SCUIOC(0x0008)
128 
141 #define SCUIOC_SETELEMENTS _SCUIOC(0x0009)
142 
150 #define SCUIOC_SETDECIMATION _SCUIOC(0x000a)
151 
159 #define SCUIOC_SETWATERMARK _SCUIOC(0x000b)
160 
168 #define SCUIOC_START _SCUIOC(0x0010)
169 
177 #define SCUIOC_STOP _SCUIOC(0x0011)
178 
186 #define SCUIOC_SETFIFOMODE _SCUIOC(0x0012)
187 
195 #define SCUIOC_DELFIFODATA _SCUIOC(0x0013)
196 
204 #define SCU_BUS_SPI 1
205 #define SCU_BUS_I2C0 2
206 #define SCU_BUS_I2C1 3
207 #define SCU_BUS_LPADC0 0x10
208 #define SCU_BUS_LPADC1 0x11
209 #define SCU_BUS_LPADC2 0x12
210 #define SCU_BUS_LPADC3 0x13
211 #define SCU_BUS_HPADC0 0x14
212 #define SCU_BUS_HPADC1 0x15
216 #define SCU_INST_SEND(val) ((val) & 0xff)
217 
220 #define SCU_INST_RECV(n) ((1 << 8) | (((n) - 1) & 0x7) << 12)
221 
222 #define SCU_INST_TERM (1 << 11)
223 #define SCU_INST_RESTART (1 << 10)
224 #define SCU_INST_STOP (1 << 9)
225 
228 #define SCU_INST_LAST (SCU_INST_TERM|SCU_INST_STOP)
229 
230 /* Sequencer types */
231 
232 #define SEQ_TYPE_NORMAL 0
233 #define SEQ_TYPE_DECI 1
235 /* Event control */
236 
237 #define SCU_EV_RISE_EN (1 << 31)
238 #define SCU_EV_FALL_EN (1 << 30)
239 #define SCU_EV_OUT8BITS (1 << 29)
241 #define SCU_EV_OUTSHIFT 16
242 #define SCU_EV_OUTMASK (3 << SCU_EV_OUTSHIFT)
243 #define SCU_EV_OUTALWAYS (0 << SCU_EV_OUTSHIFT)
244 #define SCU_EV_OUTSTART (1 << SCU_EV_OUTSHIFT)
245 #define SCU_EV_OUTSTOP (2 << SCU_EV_OUTSHIFT)
246 #define SCU_EV_NOTOUT (3 << SCU_EV_OUTSHIFT)
248 #define SCU_EV_WRITESAMPLEMASK 0xfff
249 
252 #define SCU_EV_WRITESAMPLES(sample) ((sample) & SCU_EV_WRITESAMPLEMASK)
253 
254 /* Event type flags */
255 
256 #define SCU_EV_RISE (1)
257 #define SCU_EV_FALL (2)
259 /* Level adjustment (decimator only) */
260 
261 #define SCU_LEVELADJ_X1 (0)
262 #define SCU_LEVELADJ_X2 (1)
263 #define SCU_LEVELADJ_X4 (2)
264 #define SCU_LEVELADJ_X8 (3)
268 /****************************************************************************
269  * Public Types
270  ****************************************************************************/
271 
283 {
291 };
292 
296 {
297  uint32_t sec;
298  uint16_t tick;
299 };
300 
304 {
305  uint32_t h;
306  uint8_t l;
307 };
308 
312 {
313  uint8_t ishift;
314  uint8_t oshift;
315  struct iir_coeff_s coeff[5];
316 };
317 
321 {
322  enum filter_pos_e pos;
323  struct iir_filter_s filter[2];
324 };
325 
346 {
347  uint16_t threshold;
348  uint16_t count0;
349  uint16_t count1;
350  uint16_t delaysamples;
351 };
352 
356 {
357  struct scutimestamp_s ts;
358  uint32_t type;
359 };
360 
364 {
365  int signo;
367  struct sensor_event_s rise;
368  struct sensor_event_s fall;
370  uint32_t ctrl;
372  FAR struct scuev_arg_s *arg;
373 };
374 
377 struct adjust_s
378 {
379  uint16_t offset;
380  uint16_t gain;
381 };
382 
386 {
387  struct adjust_s x;
388  struct adjust_s y;
389  struct adjust_s z;
390 };
391 
395 {
396  uint8_t ratio;
397  uint8_t leveladj;
398  uint8_t forcethrough;
399 };
400 
404 {
405  int signo;
409  FAR struct scutimestamp_s *ts;
410 
417  uint16_t watermark;
418 };
419 
420 struct seq_s; /* The sequencer object */
421 
443 FAR struct seq_s *seq_open(int type, int bustype);
444 
451 void seq_close(FAR struct seq_s *seq);
452 
464 int seq_read(FAR struct seq_s *seq, int fifoid, char *buffer, int length);
465 
481 int seq_ioctl(FAR struct seq_s *seq, int fifoid, int cmd, unsigned long arg);
482 
493 int seq_setinstruction(FAR struct seq_s *seq, const uint16_t *inst,
494  uint16_t nr_insts);
495 
508 void seq_setsample(FAR struct seq_s *seq, uint8_t sample, uint8_t offset,
509  uint8_t elemsize, bool swapbyte);
510 
518 void seq_setaddress(FAR struct seq_s *seq, uint32_t slave_addr);
519 
536 int scu_spitransfer(int slavesel, uint16_t *inst, uint32_t nr_insts,
537  uint8_t *buffer, int len);
538 
556 int scu_i2ctransfer(int port, int slave, uint16_t *inst, uint32_t nr_insts,
557  uint8_t *buffer, int len);
558 
565 void scu_initialize(void);
566 
573 void scu_uninitialize(void);
574 
579 #endif /* __ARCH_ARM_INCLUDE_CXD56XX_SCU_H */
uint16_t watermark
Definition: scu.h:417
uint16_t delaysamples
Definition: scu.h:350
uint32_t ctrl
Definition: scu.h:370
Definition: scu.h:385
FAR struct seq_s * seq_open(int type, int bustype)
uint16_t count1
Definition: scu.h:349
int signo
Definition: scu.h:365
Definition: scu.h:287
Definition: scu.h:284
FAR struct scutimestamp_s * ts
Definition: scu.h:409
void scu_initialize(void)
Definition: scu.h:290
uint16_t gain
Definition: scu.h:380
uint16_t count0
Definition: scu.h:348
Definition: scu.h:345
Definition: scu.h:311
FAR struct scuev_arg_s * arg
Definition: scu.h:372
int seq_ioctl(FAR struct seq_s *seq, int fifoid, int cmd, unsigned long arg)
uint8_t l
Definition: scu.h:306
Definition: scu.h:289
Definition: scu.h:303
Definition: scu.h:394
Definition: scu.h:320
Definition: scu.h:286
uint16_t offset
Definition: scu.h:379
Definition: scu.h:377
uint8_t leveladj
Definition: scu.h:397
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: scu.h:403
uint16_t threshold
Definition: scu.h:347
uint8_t forcethrough
Definition: scu.h:398
uint8_t oshift
Definition: scu.h:314
int signo
Definition: scu.h:405
uint16_t tick
Definition: scu.h:298
Definition: scu.h:363
uint32_t sec
Definition: scu.h:297
uint32_t type
Definition: scu.h:358
uint8_t ratio
Definition: scu.h:396
uint8_t ishift
Definition: scu.h:313
Definition: scu.h:355
void seq_setaddress(FAR struct seq_s *seq, uint32_t slave_addr)
Definition: scu.h:285
Definition: scu.h:288
filter_pos_e
Definition: scu.h:282
int seq_read(FAR struct seq_s *seq, int fifoid, char *buffer, int length)
void scu_uninitialize(void)
Definition: scu.h:295
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)