Revision 0128be0f modules/DiWheelDrive_1-1/module.c
modules/DiWheelDrive_1-1/module.c | ||
---|---|---|
29 | 29 |
/** |
30 | 30 |
* @brief Interrupt service routine callback for I/O interrupt signals. |
31 | 31 |
* |
32 |
* @param extp EXT driver to handle the ISR. |
|
33 |
* @param channel Channel on which the interrupt was encountered. |
|
32 |
* @param args Channel on which the interrupt was encountered. |
|
34 | 33 |
*/ |
35 |
static void _moduleIsrCallback(EXTDriver* extp, expchannel_t channel) { |
|
36 |
(void)extp; |
|
37 |
|
|
34 |
static void _modulePalIsrCallback(void *args) { |
|
38 | 35 |
chSysLockFromISR(); |
39 |
chEvtBroadcastFlagsI(&aos.events.io, (1 << channel));
|
|
36 |
chEvtBroadcastFlagsI(&aos.events.io, (1 << (*(uint16_t*)args)));
|
|
40 | 37 |
chSysUnlockFromISR(); |
41 | 38 |
|
42 | 39 |
return; |
... | ... | |
56 | 53 |
/* btr */ CAN_BTR_SJW(1) | CAN_BTR_TS2(2) | CAN_BTR_TS1(13) | CAN_BTR_BRP(1), |
57 | 54 |
}; |
58 | 55 |
|
59 |
EXTConfig moduleHalExtConfig = { |
|
60 |
/* channel configrations */ { |
|
61 |
/* channel 0 */ { |
|
62 |
/* mode */ EXT_CH_MODE_DISABLED, |
|
63 |
/* callback */ NULL, |
|
64 |
}, |
|
56 |
aos_interrupt_cfg_t moduleIntConfig[10] = { |
|
65 | 57 |
/* channel 1 */ { // SYS_INT_N/SYS_SYNC_N: automatic interrupt on event |
66 |
/* mode */ EXT_MODE_GPIOC | EXT_CH_MODE_BOTH_EDGES | EXT_CH_MODE_AUTOSTART, |
|
67 |
/* callback */ _moduleIsrCallback, |
|
58 |
/* port */ GPIOC, |
|
59 |
/* pad */ GPIOC_SYS_INT_N, |
|
60 |
/* flags */ AOS_INTERRUPT_AUTOSTART, |
|
61 |
/* mode */ PAL_EVENT_MODE_BOTH_EDGES, |
|
62 |
/* callback */ _modulePalIsrCallback, |
|
63 |
/* cb arg */ 1, |
|
68 | 64 |
}, |
69 | 65 |
/* channel 2 */ { // SYS_WARMRST_N: automatic interrupt when activated |
70 |
/* mode */ EXT_MODE_GPIOD | EXT_CH_MODE_FALLING_EDGE | EXT_CH_MODE_AUTOSTART, |
|
71 |
/* callback */ _moduleIsrCallback, |
|
66 |
/* port */ GPIOD, |
|
67 |
/* pad */ GPIOD_SYS_WARMRST_N, |
|
68 |
/* flags */ AOS_INTERRUPT_AUTOSTART, |
|
69 |
/* mode */ PAL_EVENT_MODE_FALLING_EDGE, |
|
70 |
/* callback */ _modulePalIsrCallback, |
|
71 |
/* cb arg */ 2, |
|
72 | 72 |
}, |
73 | 73 |
/* channel 3 */ { // PATH_DCSTAT: must be enabled explicitely when charging is in progress to detect unexpected voltage drop |
74 |
/* mode */ EXT_MODE_GPIOC | EXT_CH_MODE_FALLING_EDGE,
|
|
75 |
/* callback */ _moduleIsrCallback,
|
|
76 |
},
|
|
77 |
/* channel 4 */ {
|
|
78 |
/* mode */ EXT_CH_MODE_DISABLED,
|
|
79 |
/* callback */ NULL,
|
|
74 |
/* port */ GPIOC,
|
|
75 |
/* pad */ GPIOC_PATH_DCSTAT,
|
|
76 |
/* flags */ 0,
|
|
77 |
/* mode */ PAL_EVENT_MODE_FALLING_EDGE,
|
|
78 |
/* callback */ _modulePalIsrCallback,
|
|
79 |
/* cb arg */ 3,
|
|
80 | 80 |
}, |
81 | 81 |
/* channel 5 */ { // COMPASS_DRDY: must be enabled explicitely |
82 |
/* mode */ EXT_MODE_GPIOB | APAL2CH_EDGE(HMC5883L_LLD_INT_EDGE), |
|
83 |
/* callback */ _moduleIsrCallback, |
|
84 |
}, |
|
85 |
/* channel 6 */ { |
|
86 |
/* mode */ EXT_CH_MODE_DISABLED, |
|
87 |
/* callback */ NULL, |
|
88 |
}, |
|
89 |
/* channel 7 */ { |
|
90 |
/* mode */ EXT_CH_MODE_DISABLED, |
|
91 |
/* callback */ NULL, |
|
82 |
/* port */ GPIOB, |
|
83 |
/* pad */ GPIOB_COMPASS_DRDY, |
|
84 |
/* flags */ 0, |
|
85 |
/* mode */ APAL2CH_EDGE(HMC5883L_LLD_INT_EDGE), |
|
86 |
/* callback */ _modulePalIsrCallback, |
|
87 |
/* cb arg */ 4, |
|
92 | 88 |
}, |
93 | 89 |
/* channel 8 */ { // SYS_PD_N: automatic interrupt when activated |
94 |
/* mode */ EXT_MODE_GPIOC | EXT_CH_MODE_FALLING_EDGE | EXT_CH_MODE_AUTOSTART, |
|
95 |
/* callback */ _moduleIsrCallback, |
|
90 |
/* port */ GPIOC, |
|
91 |
/* pad */ GPIOC_SYS_PD_N, |
|
92 |
/* flags */ AOS_INTERRUPT_AUTOSTART, |
|
93 |
/* mode */ PAL_EVENT_MODE_FALLING_EDGE, |
|
94 |
/* callback */ _modulePalIsrCallback, |
|
95 |
/* cb arg */ 5, |
|
96 | 96 |
}, |
97 | 97 |
/* channel 9 */ { // SYS_REG_EN: automatic interrupt when activated |
98 |
/* mode */ EXT_MODE_GPIOC | EXT_CH_MODE_FALLING_EDGE | EXT_CH_MODE_AUTOSTART, |
|
99 |
/* callback */ _moduleIsrCallback, |
|
100 |
}, |
|
101 |
/* channel 10 */ { |
|
102 |
/* mode */ EXT_CH_MODE_DISABLED, |
|
103 |
/* callback */ NULL, |
|
104 |
}, |
|
105 |
/* channel 11 */ { |
|
106 |
/* mode */ EXT_CH_MODE_DISABLED, |
|
107 |
/* callback */ NULL, |
|
98 |
/* port */ GPIOC, |
|
99 |
/* pad */ GPIOC_SYS_REG_EN, |
|
100 |
/* flags */ AOS_INTERRUPT_AUTOSTART, |
|
101 |
/* mode */ PAL_EVENT_MODE_FALLING_EDGE, |
|
102 |
/* callback */ _modulePalIsrCallback, |
|
103 |
/* cb arg */ 6, |
|
108 | 104 |
}, |
109 | 105 |
/* channel 12 */ { // IR_INT: must be enabled explicitely |
110 |
/* mode */ EXT_MODE_GPIOB | APAL2CH_EDGE(VCNL4020_LLD_INT_EDGE), |
|
111 |
/* callback */ _moduleIsrCallback, |
|
106 |
/* port */ GPIOB, |
|
107 |
/* pad */ GPIOB_IR_INT, |
|
108 |
/* flags */ 0, |
|
109 |
/* mode */ APAL2CH_EDGE(VCNL4020_LLD_INT_EDGE), |
|
110 |
/* callback */ _modulePalIsrCallback, |
|
111 |
/* cb arg */ 7, |
|
112 | 112 |
}, |
113 | 113 |
/* channel 13 */ { // GYRO_DRDY: must be enabled explicitely |
114 |
/* mode */ EXT_MODE_GPIOB | APAL2CH_EDGE(L3G4200D_LLD_INT_EDGE), |
|
115 |
/* callback */ _moduleIsrCallback, |
|
114 |
/* port */ GPIOB, |
|
115 |
/* pad */ GPIOB_GYRO_DRDY, |
|
116 |
/* flags */ 0, |
|
117 |
/* mode */ APAL2CH_EDGE(L3G4200D_LLD_INT_EDGE), |
|
118 |
/* callback */ _modulePalIsrCallback, |
|
119 |
/* cb arg */ 8, |
|
116 | 120 |
}, |
117 | 121 |
/* channel 14 */ { // SYS_UART_UP: automatic interrupt on event |
118 |
/* mode */ EXT_MODE_GPIOB | EXT_CH_MODE_BOTH_EDGES | EXT_CH_MODE_AUTOSTART, |
|
119 |
/* callback */ _moduleIsrCallback, |
|
122 |
/* port */ GPIOB, |
|
123 |
/* pad */ GPIOB_SYS_UART_UP, |
|
124 |
/* flags */ AOS_INTERRUPT_AUTOSTART, |
|
125 |
/* mode */ PAL_EVENT_MODE_BOTH_EDGES, |
|
126 |
/* callback */ _modulePalIsrCallback, |
|
127 |
/* cb arg */ 9, |
|
120 | 128 |
}, |
121 | 129 |
/* channel 15 */ { // ACCEL_INT_N: must be enabled explicitely |
122 |
/* mode */ EXT_MODE_GPIOB | APAL2CH_EDGE(LIS331DLH_LLD_INT_EDGE), |
|
123 |
/* callback */ _moduleIsrCallback, |
|
130 |
/* port */ GPIOB, |
|
131 |
/* pad */ GPIOB_ACCEL_INT_N, |
|
132 |
/* flags */ 0, |
|
133 |
/* mode */ APAL2CH_EDGE(LIS331DLH_LLD_INT_EDGE), |
|
134 |
/* callback */ _modulePalIsrCallback, |
|
135 |
/* cb arg */ 10, |
|
124 | 136 |
}, |
125 |
/* channel 16 */ { |
|
126 |
/* mode */ EXT_CH_MODE_DISABLED, |
|
127 |
/* callback */ NULL, |
|
128 |
}, |
|
129 |
/* channel 17 */ { |
|
130 |
/* mode */ EXT_CH_MODE_DISABLED, |
|
131 |
/* callback */ NULL, |
|
132 |
}, |
|
133 |
/* channel 18 */ { |
|
134 |
/* mode */ EXT_CH_MODE_DISABLED, |
|
135 |
/* callback */ NULL, |
|
136 |
}, |
|
137 |
}, |
|
137 |
}; |
|
138 |
|
|
139 |
aos_interrupt_driver_t moduleIntDriver = { |
|
140 |
/* config */ NULL, |
|
141 |
/* interrupts */ 10, |
|
138 | 142 |
}; |
139 | 143 |
|
140 | 144 |
I2CConfig moduleHalI2cCompassConfig = { |
... | ... | |
199 | 203 |
}; |
200 | 204 |
|
201 | 205 |
SPIConfig moduleHalSpiAccelerometerConfig = { |
206 |
/* circular buffer mode */ false, |
|
202 | 207 |
/* callback function pointer */ NULL, |
203 | 208 |
/* chip select line port */ GPIOC, |
204 | 209 |
/* chip select line pad number */ GPIOC_ACCEL_SS_N, |
... | ... | |
207 | 212 |
}; |
208 | 213 |
|
209 | 214 |
SPIConfig moduleHalSpiGyroscopeConfig = { |
215 |
/* circular buffer mode */ false, |
|
210 | 216 |
/* callback function pointer */ NULL, |
211 | 217 |
/* chip select line port */ GPIOC, |
212 | 218 |
/* chip select line pad number */ GPIOC_GYRO_SS_N, |
... | ... | |
511 | 517 |
{ |
512 | 518 |
(void)argc; |
513 | 519 |
(void)argv; |
514 |
extChannelEnable(&MODULE_HAL_EXT, MODULE_GPIO_EXTCHANNEL_COMPASSDRDY);
|
|
520 |
aosIntEnable(&moduleIntDriver, MODULE_GPIO_INT_COMPASSDRDY);
|
|
515 | 521 |
aosUtRun(stream, &moduleUtAlldHmc5883l, NULL); |
522 |
aosIntDisable(&moduleIntDriver, MODULE_GPIO_INT_COMPASSDRDY); |
|
516 | 523 |
return AOS_OK; |
517 | 524 |
} |
518 | 525 |
static ut_hmc5883ldata_t _utHmc5883lData = { |
519 | 526 |
/* HMC driver */ &moduleLldCompass, |
520 | 527 |
/* event source */ &aos.events.io, |
521 |
/* event flags */ (1 << MODULE_GPIO_EXTCHANNEL_COMPASSDRDY),
|
|
528 |
/* event flags */ (1 << MODULE_GPIO_INT_COMPASSDRDY),
|
|
522 | 529 |
/* timeout */ MICROSECONDS_PER_SECOND, |
523 | 530 |
}; |
524 | 531 |
aos_unittest_t moduleUtAlldHmc5883l = { |
... | ... | |
564 | 571 |
{ |
565 | 572 |
(void)argc; |
566 | 573 |
(void)argv; |
567 |
extChannelEnable(&MODULE_HAL_EXT, MODULE_GPIO_EXTCHANNEL_GYRODRDY);
|
|
574 |
aosIntEnable(&moduleIntDriver, MODULE_GPIO_INT_GYRODRDY);
|
|
568 | 575 |
spiStart(((ut_l3g4200ddata_t*)moduleUtAlldL3g4200d.data)->l3gd->spid, ((ut_l3g4200ddata_t*)moduleUtAlldL3g4200d.data)->spiconf); |
569 | 576 |
aosUtRun(stream, &moduleUtAlldL3g4200d, NULL); |
570 | 577 |
spiStop(((ut_l3g4200ddata_t*)moduleUtAlldL3g4200d.data)->l3gd->spid); |
578 |
aosIntDisable(&moduleIntDriver, MODULE_GPIO_INT_GYRODRDY); |
|
571 | 579 |
return AOS_OK; |
572 | 580 |
} |
573 | 581 |
static ut_l3g4200ddata_t _utL3g4200dData = { |
574 | 582 |
/* driver */ &moduleLldGyroscope, |
575 | 583 |
/* SPI configuration */ &moduleHalSpiGyroscopeConfig, |
576 | 584 |
/* event source */ &aos.events.io, |
577 |
/* event flags */ (1 << MODULE_GPIO_EXTCHANNEL_GYRODRDY),
|
|
585 |
/* event flags */ (1 << MODULE_GPIO_INT_GYRODRDY),
|
|
578 | 586 |
}; |
579 | 587 |
aos_unittest_t moduleUtAlldL3g4200d = { |
580 | 588 |
/* name */ "L3G4200D", |
... | ... | |
613 | 621 |
{ |
614 | 622 |
(void)argc; |
615 | 623 |
(void)argv; |
616 |
extChannelEnable(&MODULE_HAL_EXT, MODULE_GPIO_EXTCHANNEL_ACCELINT);
|
|
624 |
aosIntEnable(&moduleIntDriver, MODULE_GPIO_INT_ACCELINT);
|
|
617 | 625 |
spiStart(((ut_lis331dlhdata_t*)moduleUtAlldLis331dlh.data)->lisd->spid, ((ut_lis331dlhdata_t*)moduleUtAlldLis331dlh.data)->spiconf); |
618 | 626 |
aosUtRun(stream, &moduleUtAlldLis331dlh, NULL); |
619 | 627 |
spiStop(((ut_lis331dlhdata_t*)moduleUtAlldLis331dlh.data)->lisd->spid); |
628 |
aosIntDisable(&moduleIntDriver, MODULE_GPIO_INT_ACCELINT); |
|
620 | 629 |
return AOS_OK; |
621 | 630 |
} |
622 | 631 |
static ut_lis331dlhdata_t _utLis331dlhData = { |
623 | 632 |
/* driver */ &moduleLldAccelerometer, |
624 | 633 |
/* SPI configuration */ &moduleHalSpiAccelerometerConfig, |
625 | 634 |
/* event source */ &aos.events.io, |
626 |
/* event flags */ (1 << MODULE_GPIO_EXTCHANNEL_ACCELINT),
|
|
635 |
/* event flags */ (1 << MODULE_GPIO_INT_ACCELINT),
|
|
627 | 636 |
}; |
628 | 637 |
aos_unittest_t moduleUtAlldLis331dlh = { |
629 | 638 |
/* name */ "LIS331DLH", |
... | ... | |
739 | 748 |
_utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld); |
740 | 749 |
pca9544a_lld_setchannel(&moduleLldI2cMultiplexer, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
741 | 750 |
_utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld); |
742 |
extChannelEnable(&MODULE_HAL_EXT, MODULE_GPIO_EXTCHANNEL_IRINT);
|
|
751 |
aosIntEnable(&moduleIntDriver, MODULE_GPIO_INT_IRINT);
|
|
743 | 752 |
switch (sensor) { |
744 | 753 |
case FL: |
745 | 754 |
pca9544a_lld_setchannel(&moduleLldI2cMultiplexer, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
... | ... | |
760 | 769 |
default: |
761 | 770 |
break; |
762 | 771 |
} |
772 |
aosIntDisable(&moduleIntDriver, MODULE_GPIO_INT_IRINT); |
|
763 | 773 |
return AOS_OK; |
764 | 774 |
} |
765 | 775 |
// print help |
... | ... | |
779 | 789 |
/* driver */ &moduleLldProximity, |
780 | 790 |
/* timeout */ MICROSECONDS_PER_SECOND, |
781 | 791 |
/* event source */ &aos.events.io, |
782 |
/* event flags */ (1 << MODULE_GPIO_EXTCHANNEL_IRINT),
|
|
792 |
/* event flags */ (1 << MODULE_GPIO_INT_IRINT),
|
|
783 | 793 |
}; |
784 | 794 |
aos_unittest_t moduleUtAlldVcnl4020 = { |
785 | 795 |
/* name */ "VCNL4020", |
Also available in: Unified diff