11
11
* published by the Free Software Foundation.
12
12
*/
13
13
14
+ /* *************************************************************************************
15
+ * INCLUDE
16
+ **************************************************************************************/
17
+
14
18
#include " SPI.h"
15
19
20
+ /* *************************************************************************************
21
+ * NAMESPACE
22
+ **************************************************************************************/
23
+
16
24
using namespace arduino ;
17
25
26
+ /* *************************************************************************************
27
+ * EXTERN GLOBAL CONSTANTS
28
+ **************************************************************************************/
29
+
18
30
extern const spi_extended_cfg_t g_spi0_ext_cfg;
19
31
extern const spi_extended_cfg_t g_spi1_ext_cfg;
20
32
extern const sci_spi_extended_cfg_t g_spi2_cfg_extend;
21
33
34
+ /* *************************************************************************************
35
+ * STATIC MEMBER INITIALISATION
36
+ **************************************************************************************/
37
+
22
38
uint8_t ArduinoSPI::initialized = 0 ;
23
39
uint8_t ArduinoSPI::interruptMode = 0 ;
24
40
uint8_t ArduinoSPI::interruptMask = 0 ;
25
41
uint8_t ArduinoSPI::interruptSave = 0 ;
26
42
43
+ /* *************************************************************************************
44
+ * GLOBAL MEMBER VARIABLES
45
+ **************************************************************************************/
46
+
27
47
static spi_event_t _spi_cb_event[13 ] = {SPI_EVENT_TRANSFER_ABORTED};
28
48
49
+ /* *************************************************************************************
50
+ * CTOR/DTOR
51
+ **************************************************************************************/
52
+
29
53
ArduinoSPI::ArduinoSPI (spi_ctrl_t *g_spi_ctrl
30
54
,const spi_cfg_t *g_spi_cfg
31
55
,const spi_extended_cfg_t *g_spi_ext_cfg, int ch):
@@ -54,6 +78,10 @@ ArduinoSPI::ArduinoSPI(int ch, bool isSci):
54
78
{
55
79
}
56
80
81
+ /* *************************************************************************************
82
+ * PUBLIC MEMBER FUNCTIONS
83
+ **************************************************************************************/
84
+
57
85
void ArduinoSPI::begin ()
58
86
{
59
87
bool isSPIObject = false ;
@@ -244,6 +272,10 @@ void ArduinoSPI::detachInterrupt() {
244
272
245
273
}
246
274
275
+ /* *************************************************************************************
276
+ * PRIVATE MEMBER FUNCTIONS
277
+ **************************************************************************************/
278
+
247
279
void ArduinoSPI::config (arduino::SPISettings const & settings)
248
280
{
249
281
if (_is_sci)
@@ -437,6 +469,10 @@ void ArduinoSPI::enableSciSpiIrqs() {
437
469
438
470
}
439
471
472
+ /* *************************************************************************************
473
+ * CALLBACKS FOR FSP FRAMEWORK
474
+ **************************************************************************************/
475
+
440
476
void spi_callback (spi_callback_args_t *p_args) {
441
477
if (SPI_EVENT_TRANSFER_COMPLETE == p_args->event ) {
442
478
_spi_cb_event[p_args->channel ] = SPI_EVENT_TRANSFER_COMPLETE;
@@ -458,10 +494,14 @@ void sci_spi_callback(spi_callback_args_t *p_args) {
458
494
}
459
495
}
460
496
497
+ /* *************************************************************************************
498
+ * OBJECT INSTANTIATION
499
+ **************************************************************************************/
500
+
461
501
#if SPI_HOWMANY > 0
462
502
ArduinoSPI SPI (SPI_CHANNEL, (bool )IS_SPI_SCI);
463
503
#endif
464
504
465
505
#if SPI_HOWMANY > 1
466
506
ArduinoSPI SPI1 (SPI1_CHANNEL, (bool )IS_SPI1_SCI);
467
- #endif
507
+ #endif
0 commit comments