Developer World
Spresense SDK Library v3.2.0-ebc0364
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 ****************************************************************************/
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{
324};
325
346{
347 uint16_t threshold;
348 uint16_t count0;
349 uint16_t count1;
350 uint16_t delaysamples;
351};
352
356{
358 uint32_t type;
359};
360
364{
365 int signo;
370 uint32_t ctrl;
372 struct scuev_arg_s *arg;
373};
374
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;
410
417 uint16_t watermark;
418};
419
420struct seq_s; /* The sequencer object */
421
443struct seq_s *seq_open(int type, int bustype);
444
451void seq_close(struct seq_s *seq);
452
464int seq_read(struct seq_s *seq, int fifoid, char *buffer, int length);
465
481int seq_ioctl(struct seq_s *seq, int fifoid, int cmd, unsigned long arg);
482
493int seq_setinstruction(struct seq_s *seq, const uint16_t *inst,
494 uint16_t nr_insts);
495
508void seq_setsample(struct seq_s *seq, uint8_t sample, uint8_t offset,
509 uint8_t elemsize, bool swapbyte);
510
518void seq_setaddress(struct seq_s *seq, uint32_t slave_addr);
519
536int scu_spitransfer(int slavesel, uint16_t *inst, uint32_t nr_insts,
537 uint8_t *buffer, int len);
538
556int scu_i2ctransfer(int port, int slave, uint16_t *inst, uint32_t nr_insts,
557 uint8_t *buffer, int len);
558
565void scu_initialize(void);
566
574
579#endif /* __ARCH_ARM_INCLUDE_CXD56XX_SCU_H */
filter_pos_e
Definition: scu.h:283
@ FILTER_POS_FE
Definition: scu.h:290
@ FILTER_POS_FF
Definition: scu.h:286
@ FILTER_POS_EE
Definition: scu.h:288
@ FILTER_POS_AF
Definition: scu.h:287
@ FILTER_POS_NONE
Definition: scu.h:284
@ FILTER_POS_AE
Definition: scu.h:289
@ FILTER_POS_AA
Definition: scu.h:285
int scu_i2ctransfer(int port, int slave, uint16_t *inst, uint32_t nr_insts, uint8_t *buffer, int len)
int seq_read(struct seq_s *seq, int fifoid, char *buffer, int length)
void scu_initialize(void)
int seq_ioctl(struct seq_s *seq, int fifoid, int cmd, unsigned long arg)
void seq_setaddress(struct seq_s *seq, uint32_t slave_addr)
void seq_close(struct seq_s *seq)
void seq_setsample(struct seq_s *seq, uint8_t sample, uint8_t offset, uint8_t elemsize, bool swapbyte)
int seq_setinstruction(struct seq_s *seq, const uint16_t *inst, uint16_t nr_insts)
int scu_spitransfer(int slavesel, uint16_t *inst, uint32_t nr_insts, uint8_t *buffer, int len)
void scu_uninitialize(void)
struct seq_s * seq_open(int type, int bustype)
Definition: scu.h:378
uint16_t gain
Definition: scu.h:380
uint16_t offset
Definition: scu.h:379
Definition: scu.h:386
struct adjust_s z
Definition: scu.h:389
struct adjust_s y
Definition: scu.h:388
struct adjust_s x
Definition: scu.h:387
Definition: scu.h:395
uint8_t forcethrough
Definition: scu.h:398
uint8_t leveladj
Definition: scu.h:397
uint8_t ratio
Definition: scu.h:396
Definition: scu.h:304
uint8_t l
Definition: scu.h:306
Definition: scu.h:312
uint8_t oshift
Definition: scu.h:314
struct iir_coeff_s coeff[5]
Definition: scu.h:315
uint8_t ishift
Definition: scu.h:313
Definition: scu.h:321
enum filter_pos_e pos
Definition: scu.h:322
struct iir_filter_s filter[2]
Definition: scu.h:323
Definition: scu.h:356
struct scutimestamp_s ts
Definition: scu.h:357
uint32_t type
Definition: scu.h:358
Definition: scu.h:364
struct sensor_event_s rise
Definition: scu.h:367
int signo
Definition: scu.h:365
struct sensor_event_s fall
Definition: scu.h:368
uint32_t ctrl
Definition: scu.h:370
struct scuev_arg_s * arg
Definition: scu.h:372
Definition: scu.h:404
struct scutimestamp_s * ts
Definition: scu.h:409
int signo
Definition: scu.h:405
uint16_t watermark
Definition: scu.h:417
Definition: scu.h:296
uint16_t tick
Definition: scu.h:298
uint32_t sec
Definition: scu.h:297
Definition: scu.h:346
uint16_t count1
Definition: scu.h:349
uint16_t threshold
Definition: scu.h:347
uint16_t count0
Definition: scu.h:348
uint16_t delaysamples
Definition: scu.h:350