Skip to content

Commit ffe05f7

Browse files
authored
Merge pull request #2866 from pradeep-gr/master
MBED OS 3 to 5 changes added for SPI
2 parents b4f3841 + 324dbaf commit ffe05f7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1165
-1129
lines changed

targets/TARGET_ONSEMI/TARGET_NCS36510/Pad.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,18 @@ boolean fPadIOCtrl(uint8_t PadNum, uint8_t OutputDriveStrength, uint8_t OutputDr
108108
{
109109
PadReg_t *PadRegOffset;
110110
/** \verbatim
111-
Table: O/p drive strength
112-
113-
Drive strength 3.3V (min/typ/max) 1V (min/typ/max)
114-
000 1/1.4/2.1 mA 0.043/0.07/0.11 mA
115-
001 2/2.7/4.1 mA 0.086/0.15/0.215 mA
116-
010 4.1/5.3/7.8 mA 0.188/0.3/0.4 mA
117-
011 8.1/10.4/15 8 mA 0.4/0.6/0.81 mA
118-
100 20.8/26/37 mA* 1/1.6/2.2 mA
119-
101 40.5/50/70 mA* 2/3/4.3 mA
120-
11x 57/73/102 mA* 3/4.6/6.2 mA
121-
122-
*Values are only accessible when CDBGPWRUPREQ is high. This limits the maximum output current in functional mode. \endverbatim */
111+
Table: O/p drive strength
112+
113+
Drive strength 3.3V (min/typ/max) 1V (min/typ/max)
114+
000 1/1.4/2.1 mA 0.043/0.07/0.11 mA
115+
001 2/2.7/4.1 mA 0.086/0.15/0.215 mA
116+
010 4.1/5.3/7.8 mA 0.188/0.3/0.4 mA
117+
011 8.1/10.4/15 8 mA 0.4/0.6/0.81 mA
118+
100 20.8/26/37 mA* 1/1.6/2.2 mA
119+
101 40.5/50/70 mA* 2/3/4.3 mA
120+
11x 57/73/102 mA* 3/4.6/6.2 mA
121+
122+
*Values are only accessible when CDBGPWRUPREQ is high. This limits the maximum output current in functional mode. \endverbatim */
123123

124124

125125
if((PadNum <= PAD_NUM_OF_IO) &&

targets/TARGET_ONSEMI/TARGET_NCS36510/PeripheralPins.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,31 +67,39 @@ const PinMap PinMap_SPI_SCLK[] = {
6767
{SPI1_SCLK_2, SPI_0, 6},
6868
{SPI1_SCLK_3, SPI_0, 6},
6969
{SPI2_SCLK, SPI_1, 6},
70-
{NC, NC, 0}
70+
{NC, NC, 0}
7171
};
7272

7373
const PinMap PinMap_SPI_MOSI[] = {
7474
/*todo: other pins are possible, need to add */
7575
{SPI1_SDATAO_2, SPI_0, 6},
7676
{SPI1_SDATAO_3, SPI_0, 6},
77-
{SPI2_SDATAO, SPI_1, 6},
78-
{NC, NC, 0}
77+
{SPI2_SDATAO, SPI_1, 6},
78+
{NC, NC, 0}
7979
};
8080

8181
const PinMap PinMap_SPI_MISO[] = {
8282
/*todo: other pins are possible, need to add */
8383
{SPI1_SDATAI_2, SPI_0, 6},
8484
{SPI1_SDATAI_3, SPI_0, 6},
85-
{SPI2_SDATAI, SPI_1, 6},
86-
{NC, NC, 0}
85+
{SPI2_SDATAI, SPI_1, 6},
86+
{NC, NC, 0}
8787
};
8888

8989
const PinMap PinMap_SPI_SSEL[] = {
9090
/*todo: other pins are possible, need to add */
9191
/* TODO what about SSNO */
92-
{SPI1_SSNI_2, SPI_0, 6},
93-
{SPI2_SSNI, SPI_1, 6},
94-
{NC, NC, 0}
92+
{SPI1_SSNO0_1, SPI_0, 6},
93+
{SPI1_SSNO1_1, SPI_0, 6},
94+
{SPI1_SSNO2_1, SPI_0, 6},
95+
{SPI1_SSNO3_1, SPI_0, 6},
96+
{SPI1_SSNI_2, SPI_0, 6},
97+
{SPI1_SSNO0_2, SPI_0, 6},
98+
{SPI1_SSNO1_2, SPI_0, 6},
99+
{SPI1_SSNO2_2, SPI_0, 6},
100+
{SPI2_SSNI, SPI_1, 6},
101+
{SPI2_SSNO0, SPI_1, 6},
102+
{NC, NC, 0}
95103
};
96104

97105

targets/TARGET_ONSEMI/TARGET_NCS36510/PinNames.h

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ extern "C" {
3737
#endif
3838

3939
typedef enum {
40-
GPIO0 = 0,
40+
GPIO0 = 0,
4141
GPIO1,
4242
GPIO2,
4343
GPIO3,
@@ -64,56 +64,56 @@ typedef enum {
6464
UART2_TX = GPIO8,
6565
UART2_RX = GPIO9,
6666

67-
I2C1_SCLK_1 = GPIO2,
68-
I2C1_SDATA_1 = GPIO3,
69-
I2C1_SCLK_2 = GPIO5,
70-
I2C1_SDATA_2 = GPIO4,
71-
I2C1_SCLK = I2C1_SCLK_1, /*Default*/
72-
I2C1_SDATA = I2C1_SDATA_1, /*Default*/
73-
74-
I2C2_SCLK_1 = GPIO14,
75-
I2C2_SDATA_1 = GPIO15,
76-
I2C2_SCLK_2 = GPIO17,
77-
I2C2_SDATA_2 = GPIO16,
78-
I2C2_SCLK = I2C2_SCLK_2, /*Default*/
79-
I2C2_SDATA = I2C2_SDATA_2, /*Default*/
80-
I2C_SCL = I2C1_SCLK_1, /*Default*/
81-
I2C_SDA = I2C1_SDATA_1, /*Default*/
67+
I2C1_SCLK_1 = GPIO2,
68+
I2C1_SDATA_1 = GPIO3,
69+
I2C1_SCLK_2 = GPIO5,
70+
I2C1_SDATA_2 = GPIO4,
71+
I2C1_SCLK = I2C1_SCLK_1, /*Default*/
72+
I2C1_SDATA = I2C1_SDATA_1, /*Default*/
73+
74+
I2C2_SCLK_1 = GPIO14,
75+
I2C2_SDATA_1 = GPIO15,
76+
I2C2_SCLK_2 = GPIO17,
77+
I2C2_SDATA_2 = GPIO16,
78+
I2C2_SCLK = I2C2_SCLK_2, /*Default*/
79+
I2C2_SDATA = I2C2_SDATA_2, /*Default*/
80+
I2C_SCL = I2C1_SCLK_1, /*Default*/
81+
I2C_SDA = I2C1_SDATA_1, /*Default*/
8282

8383
/* SPI 1 with 1st set of CROSS BAR */
84-
SPI1_SSNO0_1 = GPIO0,
85-
SPI1_SSNO1_1 = GPIO1,
86-
SPI1_SSNO2_1 = GPIO2,
87-
SPI1_SSNO3_1 = GPIO3,
84+
SPI1_SSNO0_1 = GPIO0,
85+
SPI1_SSNO1_1 = GPIO1,
86+
SPI1_SSNO2_1 = GPIO2,
87+
SPI1_SSNO3_1 = GPIO3,
8888

8989
/* SPI 1 with 2st set of CROSS BAR */
90-
SPI1_SCLK_2 = GPIO4,
91-
SPI1_SDATAO_2 = GPIO5,
92-
SPI1_SDATAI_2 = GPIO6,
93-
SPI1_SSNI_2 = GPIO7,
94-
SPI1_SSNO0_2 = GPIO8,
95-
SPI1_SSNO1_2 = GPIO9,
96-
SPI1_SSNO2_2 = GPIO10,
97-
98-
SPI1_SCLK = SPI1_SCLK_2, /*Default*/
99-
SPI1_SDATAO = SPI1_SDATAO_2, /*Default*/
100-
SPI1_SDATAI = SPI1_SDATAI_2, /*Default*/
101-
SPI1_SSNI = SPI1_SSNI_2, /*Default*/
102-
SPI1_SSNO0 = SPI1_SSNO0_2, /*Default*/
103-
SPI1_SSNO1 = SPI1_SSNO1_2, /*Default*/
104-
SPI1_SSNO2 = SPI1_SSNO2_2, /*Default*/
90+
SPI1_SCLK_2 = GPIO4,
91+
SPI1_SDATAO_2 = GPIO5,
92+
SPI1_SDATAI_2 = GPIO6,
93+
SPI1_SSNI_2 = GPIO7,
94+
SPI1_SSNO0_2 = GPIO8,
95+
SPI1_SSNO1_2 = GPIO9,
96+
SPI1_SSNO2_2 = GPIO10,
97+
98+
SPI1_SCLK = SPI1_SCLK_2, /*Default*/
99+
SPI1_SDATAO = SPI1_SDATAO_2, /*Default*/
100+
SPI1_SDATAI = SPI1_SDATAI_2, /*Default*/
101+
SPI1_SSNI = SPI1_SSNI_2, /*Default*/
102+
SPI1_SSNO0 = SPI1_SSNO0_2, /*Default*/
103+
SPI1_SSNO1 = SPI1_SSNO1_2, /*Default*/
104+
SPI1_SSNO2 = SPI1_SSNO2_2, /*Default*/
105105

106106
/* SPI 1 with 3rd set of CROSS BAR */
107-
SPI1_SCLK_3 = GPIO8,
108-
SPI1_SDATAO_3 = GPIO9,
109-
SPI1_SDATAI_3 = GPIO10,
107+
SPI1_SCLK_3 = GPIO8,
108+
SPI1_SDATAO_3 = GPIO9,
109+
SPI1_SDATAI_3 = GPIO10,
110110

111111
/* SPI 2 */
112-
SPI2_SCLK = GPIO14,
113-
SPI2_SDATAO = GPIO15,
114-
SPI2_SDATAI = GPIO16,
115-
SPI2_SSNI = GPIO17,
116-
SPI2_SSNO0 = GPIO17,
112+
SPI2_SCLK = GPIO14,
113+
SPI2_SDATAO = GPIO15,
114+
SPI2_SDATAI = GPIO16,
115+
SPI2_SSNI = GPIO17,
116+
SPI2_SSNO0 = GPIO17,
117117

118118
// Generic signals namings
119119
LED1 = GPIO4,
@@ -157,17 +157,17 @@ typedef enum {
157157
} PinDirection;
158158

159159
typedef enum {
160-
PushPullPullDown = 0,
161-
PushPullNoPull = 1,
162-
PushPullPullUp = 2,
160+
PushPullPullDown = 0,
161+
PushPullNoPull = 1,
162+
PushPullPullUp = 2,
163163
OpenDrainPullDown = 3,
164-
OpenDrainNoPull = 4,
165-
OpenDrainPullUp = 5,
166-
PullNone = PushPullNoPull,
167-
PullUp = PushPullPullUp,
168-
PullDown = PushPullPullDown,
169-
OpenDrain = OpenDrainPullUp,
170-
PullDefault = PullNone
164+
OpenDrainNoPull = 4,
165+
OpenDrainPullUp = 5,
166+
PullNone = PushPullNoPull,
167+
PullUp = PushPullPullUp,
168+
PullDown = PushPullPullDown,
169+
OpenDrain = OpenDrainPullUp,
170+
PullDefault = PullNone
171171

172172
} PinMode;
173173

targets/TARGET_ONSEMI/TARGET_NCS36510/adc_sar.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ extern "C" {
4343
#endif
4444

4545
/* ADC register bits */
46-
#define ADC_CONTROL_MODE_BIT_POS 0
47-
#define ADC_CONTROL_MEASTYPE_BIT_POS 3
48-
#define ADC_CONTROL_INPUTSCALE_BIT_POS 4
49-
#define ADC_CONTROL_MEAS_CH_BIT_POS 8
50-
#define ADC_CONTROL_REF_CH_BIT_POS 12
51-
#define ADC_PRESCALE_VAL_BIT_POS 0
52-
#define ADC_PRESCALE_EN_BIT_POS 8
53-
#define ADC_DELAY_SAMPLE_RATE_BIT_POS 0
54-
#define ADC_DELAY_WARMUP_BIT_POS 16
55-
#define ADC_DELAY_SAMPLE_TIME_BIT_POS 24
46+
#define ADC_CONTROL_MODE_BIT_POS 0
47+
#define ADC_CONTROL_MEASTYPE_BIT_POS 3
48+
#define ADC_CONTROL_INPUTSCALE_BIT_POS 4
49+
#define ADC_CONTROL_MEAS_CH_BIT_POS 8
50+
#define ADC_CONTROL_REF_CH_BIT_POS 12
51+
#define ADC_PRESCALE_VAL_BIT_POS 0
52+
#define ADC_PRESCALE_EN_BIT_POS 8
53+
#define ADC_DELAY_SAMPLE_RATE_BIT_POS 0
54+
#define ADC_DELAY_WARMUP_BIT_POS 16
55+
#define ADC_DELAY_SAMPLE_TIME_BIT_POS 24
5656

5757
typedef enum {
5858
ADC_CHANNEL0 = 0,

targets/TARGET_ONSEMI/TARGET_NCS36510/adc_sar_map.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ typedef struct {
4545
struct {
4646
__IO uint32_t MODE :1; /** 1= Continuous Conversion 0= Single Shot */
4747
__IO uint32_t START_CONV :1; /** 1= Start Conversion 0= No effect*/
48-
__IO uint32_t ABORT :1; /** 1= Aborts the Continuous Conversion mode 0=No effect */
48+
__IO uint32_t ABORT :1; /** 1= Aborts the Continuous Conversion mode 0=No effect */
4949
__IO uint32_t MEASUREMENT_TYPE :1; /** 1= Absolute 0= Differential */
5050
__IO uint32_t INPUT_SCALE :3; /** 000 – 1.0 001 – 0.6923 010 – 0.5294 011 – 0.4286 100 – 0.3600 101 – 0.3103 110 – 0.2728 111 – 0.2432 */
51-
__I uint32_t BIT7:1; /** NA Always read backs 0*/
52-
__IO uint32_t CONV_CH :3; /** Selects 1 or 8 channels to do a conversion on. 000 – A[0] 000 – A[1] 010 – A[2] 011 – A[3] 100 – N/A 101 – N/A 110 – Temperature sensor 111 – Battery */
53-
__I uint32_t NA :1; /** NA */
54-
__IO uint32_t REF_CH :3; /** Selects 1 to 8 channels for reference channel 000 – A[0] 000 – A[1] 010 – A[2] 011 – A[3] 100 – N/A 101 – N/A 110 – Temperature sensor 111 – Battery */
51+
__I uint32_t BIT7:1; /** NA Always read backs 0*/
52+
__IO uint32_t CONV_CH :3; /** Selects 1 or 8 channels to do a conversion on. 000 – A[0] 000 – A[1] 010 – A[2] 011 – A[3] 100 – N/A 101 – N/A 110 – Temperature sensor 111 – Battery */
53+
__I uint32_t NA :1; /** NA */
54+
__IO uint32_t REF_CH :3; /** Selects 1 to 8 channels for reference channel 000 – A[0] 000 – A[1] 010 – A[2] 011 – A[3] 100 – N/A 101 – N/A 110 – Temperature sensor 111 – Battery */
5555
} BITS;
5656
__IO uint32_t WORD;
5757
} CONTROL;
@@ -67,9 +67,9 @@ typedef struct {
6767
__IO uint32_t IR;
6868
union {
6969
struct {
70-
__IO uint32_t PRESC_VAL :8; /**Set the pre-scalar value. The SAR ADC nominally runs at 4MHz, so this value should be programmed to 32 Mhz/4mhz -1=7 */
71-
__IO uint32_t PRESC_EN :1; /** 1= enables PreScalar 0= Disable Prescalar */
72-
// __IO uint32_t PHASE_CTRL :1; /** 1 = Phase 2 is delayed two 32MHz clock from phase 1. 0= Phase 2 is delayed one 32MHz clock from phase 1. */
70+
__IO uint32_t PRESC_VAL :8; /**Set the pre-scalar value. The SAR ADC nominally runs at 4MHz, so this value should be programmed to 32 Mhz/4mhz -1=7 */
71+
__IO uint32_t PRESC_EN :1; /** 1= enables PreScalar 0= Disable Prescalar */
72+
// __IO uint32_t PHASE_CTRL :1; /** 1 = Phase 2 is delayed two 32MHz clock from phase 1. 0= Phase 2 is delayed one 32MHz clock from phase 1. */
7373
} BITS;
7474
__IO uint32_t WORD;
7575
} PRESCALE;

targets/TARGET_ONSEMI/TARGET_NCS36510/architecture.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,24 @@
5353
*************************************************************************************************/
5454

5555
/* Interrupt Control and State Register (0xE000ED04)
56-
* 31 NMIPENDSET R/W 0 NMI pended
57-
* 28 PENDSVSET R/W 0 Write 1 to pend system call; Read value
58-
* indicates pending status
59-
* 27 PENDSVCLR W 0 Write 1 to clear PendSV pending status
60-
* 26 PENDSTSET R/W 0 Write 1 to pend Systick exception; Read
61-
* value indicates pending status
62-
* 25 PENDSTCLR W 0 Write 1 to clear Systick pending status
63-
* 23 ISRPREEMPT R 0 Indicate that a pending interrupt is going
64-
* to be active in next step (for debug)
65-
* 22 ISRPENDING R 0 External interrupt pending (excluding
66-
* system exceptions such as NMI for
67-
* fault)
68-
* 21:12 VECTPENDING R 0 Pending ISR number
69-
* 11 RETTOBASE R 0 Set to 1 when the processor is running
70-
* an exception handler and will return to
71-
* thread level if interrupt return and no
72-
* other exceptions pending
73-
* 9:0 VECTACTIVE R 0 Current running interrupt service routine
56+
* 31 NMIPENDSET R/W 0 NMI pended
57+
* 28 PENDSVSET R/W 0 Write 1 to pend system call; Read value
58+
* indicates pending status
59+
* 27 PENDSVCLR W 0 Write 1 to clear PendSV pending status
60+
* 26 PENDSTSET R/W 0 Write 1 to pend Systick exception; Read
61+
* value indicates pending status
62+
* 25 PENDSTCLR W 0 Write 1 to clear Systick pending status
63+
* 23 ISRPREEMPT R 0 Indicate that a pending interrupt is going
64+
* to be active in next step (for debug)
65+
* 22 ISRPENDING R 0 External interrupt pending (excluding
66+
* system exceptions such as NMI for
67+
* fault)
68+
* 21:12 VECTPENDING R 0 Pending ISR number
69+
* 11 RETTOBASE R 0 Set to 1 when the processor is running
70+
* an exception handler and will return to
71+
* thread level if interrupt return and no
72+
* other exceptions pending
73+
* 9:0 VECTACTIVE R 0 Current running interrupt service routine
7474
*/
7575
#define RUNNING_IN_ISR (((SCB->ICSR & 0x3FF) > 0 ) ? 1 : 0)
7676

targets/TARGET_ONSEMI/TARGET_NCS36510/assert_onsemi.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ void fOnAssert(const char *filename, unsigned int line);
5555
/** Can be assigned to hook into the assertion. */
5656
extern void (*assertCallback)(const char *filename, unsigned int line);
5757

58-
#define ASSERT(test) ((test) ? (void)0 : fOnAssert(__FILE__, __LINE__))
58+
#define ASSERT(test) ((test) ? (void)0 : fOnAssert(__FILE__, __LINE__))
5959

60-
#define VERIFY(test) ASSERT(test)
60+
#define VERIFY(test) ASSERT(test)
6161

6262
#else
6363

64-
#define ASSERT(test) ((test) ? (void)0 : 1)
64+
#define ASSERT(test) ((test) ? (void)0 : 1)
6565

66-
#define VERIFY(test) ((void)(test))
66+
#define VERIFY(test) ((void)(test))
6767

6868
#endif // DEBUG
6969

targets/TARGET_ONSEMI/TARGET_NCS36510/char_driver.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242

4343
#include "driver.h"
4444

45-
#define DRV_NO_ERROR (True)
46-
#define DRV_ERROR (False)
45+
#define DRV_NO_ERROR (True)
46+
#define DRV_ERROR (False)
4747

4848
/** A character driver structure. */
4949
typedef struct char_driver {

0 commit comments

Comments
 (0)