Skip to content

Commit 8669417

Browse files
committed
Add HAL API for spi pinmap
Add the functions to get spi pinmaps to all targets.
1 parent 34c1766 commit 8669417

File tree

69 files changed

+2795
-2
lines changed

Some content is hidden

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

69 files changed

+2795
-2
lines changed

hal/spi_api.h

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define MBED_SPI_API_H
2222

2323
#include "device.h"
24+
#include "pinmap.h"
2425
#include "hal/dma_api.h"
2526
#include "hal/buffer.h"
2627

@@ -173,6 +174,78 @@ int spi_busy(spi_t *obj);
173174
*/
174175
uint8_t spi_get_module(spi_t *obj);
175176

177+
/** Get the pins that support SPI MOSI
178+
*
179+
* Return a PinMap array of pins that support SPI MOSI in
180+
* master mode. The array is terminated with {NC, NC, 0}.
181+
*
182+
* @return PinMap array
183+
*/
184+
const PinMap *spi_master_mosi_pinmap(void);
185+
186+
/** Get the pins that support SPI MISO
187+
*
188+
* Return a PinMap array of pins that support SPI MISO in
189+
* master mode. The array is terminated with {NC, NC, 0}.
190+
*
191+
* @return PinMap array
192+
*/
193+
const PinMap *spi_master_miso_pinmap(void);
194+
195+
/** Get the pins that support SPI CLK
196+
*
197+
* Return a PinMap array of pins that support SPI CLK in
198+
* master mode. The array is terminated with {NC, NC, 0}.
199+
*
200+
* @return PinMap array
201+
*/
202+
const PinMap *spi_master_clk_pinmap(void);
203+
204+
/** Get the pins that support SPI CS
205+
*
206+
* Return a PinMap array of pins that support SPI CS in
207+
* master mode. The array is terminated with {NC, NC, 0}.
208+
*
209+
* @return PinMap array
210+
*/
211+
const PinMap *spi_master_cs_pinmap(void);
212+
213+
/** Get the pins that support SPI MOSI
214+
*
215+
* Return a PinMap array of pins that support SPI MOSI in
216+
* slave mode. The array is terminated with {NC, NC, 0}.
217+
*
218+
* @return PinMap array
219+
*/
220+
const PinMap *spi_slave_mosi_pinmap(void);
221+
222+
/** Get the pins that support SPI MISO
223+
*
224+
* Return a PinMap array of pins that support SPI MISO in
225+
* slave mode. The array is terminated with {NC, NC, 0}.
226+
*
227+
* @return PinMap array
228+
*/
229+
const PinMap *spi_slave_miso_pinmap(void);
230+
231+
/** Get the pins that support SPI CLK
232+
*
233+
* Return a PinMap array of pins that support SPI CLK in
234+
* slave mode. The array is terminated with {NC, NC, 0}.
235+
*
236+
* @return PinMap array
237+
*/
238+
const PinMap *spi_slave_clk_pinmap(void);
239+
240+
/** Get the pins that support SPI CS
241+
*
242+
* Return a PinMap array of pins that support SPI CS in
243+
* slave mode. The array is terminated with {NC, NC, 0}.
244+
*
245+
* @return PinMap array
246+
*/
247+
const PinMap *spi_slave_cs_pinmap(void);
248+
176249
/**@}*/
177250

178251
#if DEVICE_SPI_ASYNCH

targets/TARGET_ARM_FM/TARGET_FVP_MPS2/spi_api.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,3 +331,43 @@ int spi_busy(spi_t *obj)
331331
{
332332
return ssp_busy(obj);
333333
}
334+
335+
const PinMap *spi_master_mosi_pinmap()
336+
{
337+
return PinMap_SPI_MOSI;
338+
}
339+
340+
const PinMap *spi_master_miso_pinmap()
341+
{
342+
return PinMap_SPI_MISO;
343+
}
344+
345+
const PinMap *spi_master_clk_pinmap()
346+
{
347+
return PinMap_SPI_SCLK;
348+
}
349+
350+
const PinMap *spi_master_cs_pinmap()
351+
{
352+
return PinMap_SPI_SSEL;
353+
}
354+
355+
const PinMap *spi_slave_mosi_pinmap()
356+
{
357+
return PinMap_SPI_MOSI;
358+
}
359+
360+
const PinMap *spi_slave_miso_pinmap()
361+
{
362+
return PinMap_SPI_MISO;
363+
}
364+
365+
const PinMap *spi_slave_clk_pinmap()
366+
{
367+
return PinMap_SPI_SCLK;
368+
}
369+
370+
const PinMap *spi_slave_cs_pinmap()
371+
{
372+
return PinMap_SPI_SSEL;
373+
}

targets/TARGET_ARM_SSG/TARGET_BEETLE/spi_api.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,3 +284,43 @@ uint8_t spi_get_module(spi_t *obj) {
284284
int spi_busy(spi_t *obj) {
285285
return 0;
286286
}
287+
288+
const PinMap *spi_master_mosi_pinmap()
289+
{
290+
return PinMap_SPI_MOSI;
291+
}
292+
293+
const PinMap *spi_master_miso_pinmap()
294+
{
295+
return PinMap_SPI_MISO;
296+
}
297+
298+
const PinMap *spi_master_clk_pinmap()
299+
{
300+
return PinMap_SPI_SCLK;
301+
}
302+
303+
const PinMap *spi_master_cs_pinmap()
304+
{
305+
return PinMap_SPI_SSEL;
306+
}
307+
308+
const PinMap *spi_slave_mosi_pinmap()
309+
{
310+
return PinMap_SPI_MOSI;
311+
}
312+
313+
const PinMap *spi_slave_miso_pinmap()
314+
{
315+
return PinMap_SPI_MISO;
316+
}
317+
318+
const PinMap *spi_slave_clk_pinmap()
319+
{
320+
return PinMap_SPI_SCLK;
321+
}
322+
323+
const PinMap *spi_slave_cs_pinmap()
324+
{
325+
return PinMap_SPI_SSEL;
326+
}

targets/TARGET_ARM_SSG/TARGET_CM3DS_MPS2/spi_api.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,3 +263,43 @@ int spi_busy(spi_t *obj)
263263
int32_t status = spi_pl022_get_status(obj->spi);
264264
return (status & SPI_PL022_SSPSR_BSY_MSK);
265265
}
266+
267+
const PinMap *spi_master_mosi_pinmap()
268+
{
269+
return PinMap_SPI_MOSI;
270+
}
271+
272+
const PinMap *spi_master_miso_pinmap()
273+
{
274+
return PinMap_SPI_MISO;
275+
}
276+
277+
const PinMap *spi_master_clk_pinmap()
278+
{
279+
return PinMap_SPI_SCLK;
280+
}
281+
282+
const PinMap *spi_master_cs_pinmap()
283+
{
284+
return PinMap_SPI_SSEL;
285+
}
286+
287+
const PinMap *spi_slave_mosi_pinmap()
288+
{
289+
return PinMap_SPI_MOSI;
290+
}
291+
292+
const PinMap *spi_slave_miso_pinmap()
293+
{
294+
return PinMap_SPI_MISO;
295+
}
296+
297+
const PinMap *spi_slave_clk_pinmap()
298+
{
299+
return PinMap_SPI_SCLK;
300+
}
301+
302+
const PinMap *spi_slave_cs_pinmap()
303+
{
304+
return PinMap_SPI_SSEL;
305+
}

targets/TARGET_ARM_SSG/TARGET_IOTSS/spi_api.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,3 +299,43 @@ void spi_slave_write(spi_t *obj, int value) {
299299
int spi_busy(spi_t *obj) {
300300
return ssp_busy(obj);
301301
}
302+
303+
const PinMap *spi_master_mosi_pinmap()
304+
{
305+
return PinMap_SPI_MOSI;
306+
}
307+
308+
const PinMap *spi_master_miso_pinmap()
309+
{
310+
return PinMap_SPI_MISO;
311+
}
312+
313+
const PinMap *spi_master_clk_pinmap()
314+
{
315+
return PinMap_SPI_SCLK;
316+
}
317+
318+
const PinMap *spi_master_cs_pinmap()
319+
{
320+
return PinMap_SPI_SSEL;
321+
}
322+
323+
const PinMap *spi_slave_mosi_pinmap()
324+
{
325+
return PinMap_SPI_MOSI;
326+
}
327+
328+
const PinMap *spi_slave_miso_pinmap()
329+
{
330+
return PinMap_SPI_MISO;
331+
}
332+
333+
const PinMap *spi_slave_clk_pinmap()
334+
{
335+
return PinMap_SPI_SCLK;
336+
}
337+
338+
const PinMap *spi_slave_cs_pinmap()
339+
{
340+
return PinMap_SPI_SSEL;
341+
}

targets/TARGET_ARM_SSG/TARGET_MPS2/spi_api.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,3 +299,43 @@ void spi_slave_write(spi_t *obj, int value) {
299299
int spi_busy(spi_t *obj) {
300300
return ssp_busy(obj);
301301
}
302+
303+
const PinMap *spi_master_mosi_pinmap()
304+
{
305+
return PinMap_SPI_MOSI;
306+
}
307+
308+
const PinMap *spi_master_miso_pinmap()
309+
{
310+
return PinMap_SPI_MISO;
311+
}
312+
313+
const PinMap *spi_master_clk_pinmap()
314+
{
315+
return PinMap_SPI_SCLK;
316+
}
317+
318+
const PinMap *spi_master_cs_pinmap()
319+
{
320+
return PinMap_SPI_SSEL;
321+
}
322+
323+
const PinMap *spi_slave_mosi_pinmap()
324+
{
325+
return PinMap_SPI_MOSI;
326+
}
327+
328+
const PinMap *spi_slave_miso_pinmap()
329+
{
330+
return PinMap_SPI_MISO;
331+
}
332+
333+
const PinMap *spi_slave_clk_pinmap()
334+
{
335+
return PinMap_SPI_SCLK;
336+
}
337+
338+
const PinMap *spi_slave_cs_pinmap()
339+
{
340+
return PinMap_SPI_SSEL;
341+
}

targets/TARGET_Analog_Devices/TARGET_ADUCM302X/TARGET_ADUCM3029/api/spi_api.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,4 +367,44 @@ int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length, cha
367367
}
368368
}
369369

370+
const PinMap *spi_master_mosi_pinmap()
371+
{
372+
return PinMap_SPI_MOSI;
373+
}
374+
375+
const PinMap *spi_master_miso_pinmap()
376+
{
377+
return PinMap_SPI_MISO;
378+
}
379+
380+
const PinMap *spi_master_clk_pinmap()
381+
{
382+
return PinMap_SPI_SCLK;
383+
}
384+
385+
const PinMap *spi_master_cs_pinmap()
386+
{
387+
return PinMap_SPI_SSEL;
388+
}
389+
390+
const PinMap *spi_slave_mosi_pinmap()
391+
{
392+
return PinMap_SPI_MOSI;
393+
}
394+
395+
const PinMap *spi_slave_miso_pinmap()
396+
{
397+
return PinMap_SPI_MISO;
398+
}
399+
400+
const PinMap *spi_slave_clk_pinmap()
401+
{
402+
return PinMap_SPI_SCLK;
403+
}
404+
405+
const PinMap *spi_slave_cs_pinmap()
406+
{
407+
return PinMap_SPI_SSEL;
408+
}
409+
370410
#endif

targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/spi_api.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,4 +342,44 @@ int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length, cha
342342
}
343343
}
344344

345+
const PinMap *spi_master_mosi_pinmap()
346+
{
347+
return PinMap_SPI_MOSI;
348+
}
349+
350+
const PinMap *spi_master_miso_pinmap()
351+
{
352+
return PinMap_SPI_MISO;
353+
}
354+
355+
const PinMap *spi_master_clk_pinmap()
356+
{
357+
return PinMap_SPI_SCLK;
358+
}
359+
360+
const PinMap *spi_master_cs_pinmap()
361+
{
362+
return PinMap_SPI_SSEL;
363+
}
364+
365+
const PinMap *spi_slave_mosi_pinmap()
366+
{
367+
return PinMap_SPI_MOSI;
368+
}
369+
370+
const PinMap *spi_slave_miso_pinmap()
371+
{
372+
return PinMap_SPI_MISO;
373+
}
374+
375+
const PinMap *spi_slave_clk_pinmap()
376+
{
377+
return PinMap_SPI_SCLK;
378+
}
379+
380+
const PinMap *spi_slave_cs_pinmap()
381+
{
382+
return PinMap_SPI_SSEL;
383+
}
384+
345385
#endif

0 commit comments

Comments
 (0)