mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-01-18 17:53:31 +08:00
Merge pull request #4343 from supperthomas/max32660_spi
[bsp/max32660] add the driver of spi and gpio
This commit is contained in:
commit
51c492881a
@ -122,7 +122,7 @@ CONFIG_RT_SERIAL_RB_BUFSZ=64
|
||||
# CONFIG_RT_USING_CPUTIME is not set
|
||||
# CONFIG_RT_USING_I2C is not set
|
||||
# CONFIG_RT_USING_PHY is not set
|
||||
# CONFIG_RT_USING_PIN is not set
|
||||
CONFIG_RT_USING_PIN=y
|
||||
# CONFIG_RT_USING_ADC is not set
|
||||
# CONFIG_RT_USING_DAC is not set
|
||||
# CONFIG_RT_USING_PWM is not set
|
||||
@ -478,9 +478,10 @@ CONFIG_SOC_MAXIM=y
|
||||
#
|
||||
# On-chip Peripheral Drivers
|
||||
#
|
||||
# CONFIG_BSP_USING_GPIO is not set
|
||||
CONFIG_BSP_USING_GPIO=y
|
||||
CONFIG_BSP_USING_UART=y
|
||||
# CONFIG_BSP_USING_UART0 is not set
|
||||
CONFIG_BSP_USING_UART1=y
|
||||
# CONFIG_BSP_UART1_RX_USING_DMA is not set
|
||||
# CONFIG_BSP_USING_SPI is not set
|
||||
# CONFIG_BSP_USING_ON_CHIP_FLASH is not set
|
||||
|
@ -72,10 +72,10 @@ MAX32660-EVSYS开发板常用 **板载资源** 如下:
|
||||
|
||||
| **片上外设** | **支持情况** | **备注** |
|
||||
| :----------- | :----------: | :-------------------: |
|
||||
| GPIO | | |
|
||||
| GPIO | 支持 | |
|
||||
| UART | 支持 | UART0, UART1(console) |
|
||||
| PWM | | |
|
||||
| SPI | | |
|
||||
| SPI | 支持 | SPI0, SPI1 |
|
||||
| RTC | | |
|
||||
| I2S | | |
|
||||
| I2C | | |
|
||||
|
@ -11,22 +11,20 @@
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include "gpio.h"
|
||||
|
||||
const gpio_cfg_t led_pin[] =
|
||||
{
|
||||
{PORT_0, PIN_13, GPIO_FUNC_OUT, GPIO_PAD_NONE},
|
||||
};
|
||||
#define GPIO_LED_PIN 13
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int count = 1;
|
||||
GPIO_Config(&led_pin[0]);
|
||||
GPIO_OutSet(&led_pin[0]);
|
||||
rt_pin_mode(GPIO_LED_PIN, PIN_MODE_OUTPUT);
|
||||
while (count++)
|
||||
{
|
||||
rt_pin_write(GPIO_LED_PIN, PIN_HIGH);
|
||||
rt_thread_mdelay(500);
|
||||
|
||||
rt_pin_write(GPIO_LED_PIN, PIN_LOW);
|
||||
rt_thread_mdelay(500);
|
||||
GPIO_OutToggle(&led_pin[0]);
|
||||
}
|
||||
return RT_EOK;
|
||||
}
|
||||
|
@ -43,6 +43,25 @@ menu "On-chip Peripheral Drivers"
|
||||
depends on BSP_USING_UART1 && RT_SERIAL_USING_DMA
|
||||
default n
|
||||
endif
|
||||
config BSP_USING_SPI
|
||||
bool "Enable SPI"
|
||||
select RT_USING_SPI
|
||||
default n
|
||||
|
||||
if BSP_USING_SPI
|
||||
config BSP_USING_SPI0
|
||||
bool "Enable SPI0 bus [MISO P0.4;MOSI P0.5;SCL P0.6;SS P0.7]"
|
||||
default y
|
||||
|
||||
config BSP_USING_SPI1
|
||||
bool "Enable SPI1 bus [MISO P0.0;MOSI P0.1;SCL P0.2;SS P0.3]"
|
||||
default n
|
||||
if BSP_USING_SPI1
|
||||
config BSP_USING_SPI1A
|
||||
bool "Use SPI1A. [MISO P0.10;MOSI P0.11;SCL P0.12;SS P0.13]"
|
||||
default n
|
||||
endif
|
||||
endif
|
||||
config BSP_USING_ON_CHIP_FLASH
|
||||
select PKG_USING_FAL
|
||||
bool "Enable on-chip FLASH"
|
||||
|
@ -14,6 +14,10 @@
|
||||
#include <rtthread.h>
|
||||
#include <rthw.h>
|
||||
|
||||
#include "mxc_config.h"
|
||||
#include "mxc_assert.h"
|
||||
|
||||
|
||||
#define MCU_FLASH_START_ADRESS ((uint32_t)0x0)
|
||||
#define MCU_FLASH_SIZE_KB (256)
|
||||
#define MCU_FLASH_END_ADDRESS ((uint32_t)(MCU_FLASH_START_ADRESS + MCU_FLASH_SIZE*1024))
|
||||
|
@ -117,6 +117,26 @@
|
||||
<pMon>BIN\CMSIS_AGDI.dll</pMon>
|
||||
</DebugOpt>
|
||||
<TargetDriverDllRegistry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>ARMRTXEVENTFLAGS</Key>
|
||||
<Name>-L70 -Z18 -C0 -M0 -T1</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>DLGTARM</Key>
|
||||
<Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>ARMDBGFLAGS</Key>
|
||||
<Name></Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>DLGUARM</Key>
|
||||
<Name></Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>CMSIS_AGDI</Key>
|
||||
@ -135,12 +155,12 @@
|
||||
<DebugFlag>
|
||||
<trace>0</trace>
|
||||
<periodic>0</periodic>
|
||||
<aLwin>0</aLwin>
|
||||
<aLwin>1</aLwin>
|
||||
<aCover>0</aCover>
|
||||
<aSer1>0</aSer1>
|
||||
<aSer2>0</aSer2>
|
||||
<aPa>0</aPa>
|
||||
<viewmode>0</viewmode>
|
||||
<viewmode>1</viewmode>
|
||||
<vrSel>0</vrSel>
|
||||
<aSym>0</aSym>
|
||||
<aTbox>0</aTbox>
|
||||
@ -203,7 +223,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>CPU</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
@ -271,7 +291,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>DeviceDrivers</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
@ -282,6 +302,18 @@
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\components\drivers\misc\pin.c</PathWithFileName>
|
||||
<FilenameWithoutPath>pin.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>8</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\components\drivers\serial\serial.c</PathWithFileName>
|
||||
<FilenameWithoutPath>serial.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
@ -289,7 +321,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>8</FileNumber>
|
||||
<FileNumber>9</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -301,7 +333,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>9</FileNumber>
|
||||
<FileNumber>10</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -313,7 +345,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>10</FileNumber>
|
||||
<FileNumber>11</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -325,7 +357,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>11</FileNumber>
|
||||
<FileNumber>12</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -337,7 +369,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>12</FileNumber>
|
||||
<FileNumber>13</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -349,7 +381,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>13</FileNumber>
|
||||
<FileNumber>14</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -361,7 +393,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>14</FileNumber>
|
||||
<FileNumber>15</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -381,7 +413,7 @@
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>15</FileNumber>
|
||||
<FileNumber>16</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -393,7 +425,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>16</FileNumber>
|
||||
<FileNumber>17</FileNumber>
|
||||
<FileType>2</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -405,7 +437,19 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>17</FileNumber>
|
||||
<FileNumber>18</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\libraries\HAL_Drivers\drv_gpio.c</PathWithFileName>
|
||||
<FilenameWithoutPath>drv_gpio.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>19</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -419,13 +463,13 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>finsh</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>18</FileNumber>
|
||||
<FileNumber>20</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -437,7 +481,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>19</FileNumber>
|
||||
<FileNumber>21</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -449,7 +493,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>20</FileNumber>
|
||||
<FileNumber>22</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -469,7 +513,7 @@
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>21</FileNumber>
|
||||
<FileNumber>23</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -481,7 +525,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>22</FileNumber>
|
||||
<FileNumber>24</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -493,7 +537,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>23</FileNumber>
|
||||
<FileNumber>25</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -505,7 +549,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>24</FileNumber>
|
||||
<FileNumber>26</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -517,7 +561,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>25</FileNumber>
|
||||
<FileNumber>27</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -529,7 +573,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>26</FileNumber>
|
||||
<FileNumber>28</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -541,7 +585,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>27</FileNumber>
|
||||
<FileNumber>29</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -553,7 +597,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>28</FileNumber>
|
||||
<FileNumber>30</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -565,7 +609,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>29</FileNumber>
|
||||
<FileNumber>31</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -577,7 +621,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>30</FileNumber>
|
||||
<FileNumber>32</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -589,7 +633,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>31</FileNumber>
|
||||
<FileNumber>33</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -601,7 +645,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>32</FileNumber>
|
||||
<FileNumber>34</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -613,7 +657,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>33</FileNumber>
|
||||
<FileNumber>35</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -633,7 +677,7 @@
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>34</FileNumber>
|
||||
<FileNumber>36</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -645,7 +689,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>35</FileNumber>
|
||||
<FileNumber>37</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -657,7 +701,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>36</FileNumber>
|
||||
<FileNumber>38</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -669,7 +713,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>37</FileNumber>
|
||||
<FileNumber>39</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -681,7 +725,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>38</FileNumber>
|
||||
<FileNumber>40</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -693,7 +737,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>39</FileNumber>
|
||||
<FileNumber>41</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -705,7 +749,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>40</FileNumber>
|
||||
<FileNumber>42</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -717,7 +761,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>41</FileNumber>
|
||||
<FileNumber>43</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -729,7 +773,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>42</FileNumber>
|
||||
<FileNumber>44</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -741,7 +785,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>43</FileNumber>
|
||||
<FileNumber>45</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -753,7 +797,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>44</FileNumber>
|
||||
<FileNumber>46</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -765,7 +809,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>45</FileNumber>
|
||||
<FileNumber>47</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -777,7 +821,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>46</FileNumber>
|
||||
<FileNumber>48</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -789,7 +833,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>47</FileNumber>
|
||||
<FileNumber>49</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -338,7 +338,7 @@
|
||||
<MiscControls></MiscControls>
|
||||
<Define>TARGET=32660, TARGET_REV=0x4131, __RTTHREAD__</Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>applications;.;..\..\..\libcpu\arm\common;..\..\..\libcpu\arm\cortex-m4;..\..\..\components\drivers\include;..\..\..\components\drivers\include;board;..\libraries\HAL_Drivers;..\..\..\components\finsh;.;..\..\..\include;..\libraries\MAX32660PeriphDriver\CMSIS\Device\Maxim\MAX32660\Include;..\libraries\MAX32660PeriphDriver\CMSIS\Core\Include;..\libraries\MAX32660PeriphDriver\Include</IncludePath>
|
||||
<IncludePath>applications;.;..\..\..\libcpu\arm\common;..\..\..\libcpu\arm\cortex-m4;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;board;..\libraries\HAL_Drivers;..\..\..\components\finsh;.;..\..\..\include;..\libraries\MAX32660PeriphDriver\CMSIS\Device\Maxim\MAX32660\Include;..\libraries\MAX32660PeriphDriver\CMSIS\Core\Include;..\libraries\MAX32660PeriphDriver\Include</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
@ -422,6 +422,11 @@
|
||||
<Group>
|
||||
<GroupName>DeviceDrivers</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>pin.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\drivers\misc\pin.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>serial.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@ -477,6 +482,11 @@
|
||||
<FileType>2</FileType>
|
||||
<FilePath>..\libraries\MAX32660PeriphDriver\CMSIS\Device\Maxim\MAX32660\Source\ARM\startup_max32660.s</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>drv_gpio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\HAL_Drivers\drv_gpio.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>drv_uart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
|
@ -79,6 +79,7 @@
|
||||
#define RT_USING_SERIAL
|
||||
#define RT_SERIAL_USING_DMA
|
||||
#define RT_SERIAL_RB_BUFSZ 64
|
||||
#define RT_USING_PIN
|
||||
|
||||
/* Using USB */
|
||||
|
||||
@ -159,6 +160,7 @@
|
||||
|
||||
/* On-chip Peripheral Drivers */
|
||||
|
||||
#define BSP_USING_GPIO
|
||||
#define BSP_USING_UART
|
||||
#define BSP_USING_UART1
|
||||
|
||||
|
208
bsp/maxim/libraries/HAL_Drivers/drv_gpio.c
Normal file
208
bsp/maxim/libraries/HAL_Drivers/drv_gpio.c
Normal file
@ -0,0 +1,208 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2020, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-02-11 supperthomas first version
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "drv_gpio.h"
|
||||
#include <stdbool.h>
|
||||
#include "gpio.h"
|
||||
|
||||
#ifdef RT_USING_PIN
|
||||
|
||||
#define DBG_LEVEL DBG_LOG
|
||||
#include <rtdbg.h>
|
||||
#define LOG_TAG "drv.gpio"
|
||||
|
||||
#define PIN_PORT_OFFSET 4
|
||||
|
||||
#define PIN_NUM(port, no) ((((((port) & 0xFu) << PIN_PORT_OFFSET) | ((no) & 0xFu)))
|
||||
#define PIN_PORT(pin) ((uint8_t)(((pin) >> PIN_PORT_OFFSET) & 0xFu))
|
||||
#define PIN_NO(pin) ((uint8_t)((pin) & 0xFu))
|
||||
|
||||
|
||||
#define PIN_MCU_PORT(pin) PIN_PORT(pin)
|
||||
#define PIN_MCU_PIN(pin) ((uint32_t)(1u << PIN_NO(pin)))
|
||||
|
||||
static void mcu_pin_write(rt_device_t dev, rt_base_t pin, rt_base_t value)
|
||||
{
|
||||
gpio_cfg_t tmp_gpio_cfg;
|
||||
tmp_gpio_cfg.port = PIN_PORT(pin);
|
||||
tmp_gpio_cfg.mask = PIN_MCU_PIN(pin);
|
||||
if (value)
|
||||
{
|
||||
GPIO_OutSet(&tmp_gpio_cfg);
|
||||
}
|
||||
else
|
||||
{
|
||||
GPIO_OutClr(&tmp_gpio_cfg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static int mcu_pin_read(rt_device_t dev, rt_base_t pin)
|
||||
{
|
||||
int value;
|
||||
gpio_cfg_t tmp_gpio_cfg;
|
||||
tmp_gpio_cfg.port = PIN_PORT(pin);
|
||||
tmp_gpio_cfg.mask = PIN_MCU_PIN(pin);
|
||||
|
||||
if (GPIO_InGet(&tmp_gpio_cfg))
|
||||
{
|
||||
value = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = 0;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static void mcu_pin_mode(rt_device_t dev, rt_base_t pin, rt_base_t mode)
|
||||
{
|
||||
gpio_cfg_t tmp_gpio_cfg;
|
||||
int ret = 0;
|
||||
tmp_gpio_cfg.port = PIN_PORT(pin);
|
||||
tmp_gpio_cfg.mask = PIN_MCU_PIN(pin);
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case PIN_MODE_OUTPUT:
|
||||
tmp_gpio_cfg.func = GPIO_FUNC_OUT;
|
||||
tmp_gpio_cfg.pad = GPIO_PAD_NONE;
|
||||
break;
|
||||
case PIN_MODE_INPUT:
|
||||
tmp_gpio_cfg.func = GPIO_FUNC_IN;
|
||||
tmp_gpio_cfg.pad = GPIO_PAD_NONE;
|
||||
break;
|
||||
case PIN_MODE_INPUT_PULLUP:
|
||||
tmp_gpio_cfg.func = GPIO_FUNC_IN;
|
||||
tmp_gpio_cfg.pad = GPIO_PAD_PULL_UP;
|
||||
break;
|
||||
case PIN_MODE_INPUT_PULLDOWN:
|
||||
tmp_gpio_cfg.func = GPIO_FUNC_IN;
|
||||
tmp_gpio_cfg.pad = GPIO_PAD_PULL_DOWN;
|
||||
break;
|
||||
case PIN_MODE_OUTPUT_OD:
|
||||
//not support
|
||||
LOG_E("NOT SUPPORT");
|
||||
break;
|
||||
}
|
||||
ret = GPIO_Config(&tmp_gpio_cfg);
|
||||
if (E_NO_ERROR != ret)
|
||||
{
|
||||
LOG_E("GPIO_Config error :%d", ret);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static rt_err_t mcu_pin_attach_irq(struct rt_device *device, rt_int32_t pin,
|
||||
rt_uint32_t irq_mode, void (*hdr)(void *args), void *args)
|
||||
{
|
||||
gpio_cfg_t tmp_gpio_cfg;
|
||||
tmp_gpio_cfg.port = PIN_MCU_PORT(pin);
|
||||
tmp_gpio_cfg.mask = PIN_MCU_PIN(pin);
|
||||
|
||||
|
||||
tmp_gpio_cfg.pad = GPIO_PAD_PULL_UP;
|
||||
tmp_gpio_cfg.func = GPIO_FUNC_IN;
|
||||
GPIO_Config(&tmp_gpio_cfg);
|
||||
GPIO_RegisterCallback(&tmp_gpio_cfg, hdr, args);
|
||||
|
||||
gpio_int_mode_t mcu_mode;
|
||||
gpio_int_pol_t mcu_pol;
|
||||
|
||||
switch (irq_mode)
|
||||
{
|
||||
case PIN_IRQ_MODE_RISING:
|
||||
mcu_mode = GPIO_INT_EDGE;
|
||||
mcu_pol = GPIO_INT_RISING;
|
||||
break;
|
||||
case PIN_IRQ_MODE_FALLING:
|
||||
mcu_mode = GPIO_INT_EDGE;
|
||||
mcu_pol = GPIO_INT_FALLING;
|
||||
break;
|
||||
case PIN_IRQ_MODE_RISING_FALLING:
|
||||
mcu_mode = GPIO_INT_EDGE;
|
||||
mcu_pol = GPIO_INT_BOTH;
|
||||
break;
|
||||
case PIN_IRQ_MODE_HIGH_LEVEL:
|
||||
mcu_mode = GPIO_INT_LEVEL;
|
||||
mcu_pol = GPIO_INT_HIGH;
|
||||
break;
|
||||
case PIN_IRQ_MODE_LOW_LEVEL:
|
||||
mcu_mode = GPIO_INT_LEVEL;
|
||||
mcu_pol = GPIO_INT_LOW;
|
||||
break;
|
||||
}
|
||||
|
||||
GPIO_IntConfig(&tmp_gpio_cfg, mcu_mode, mcu_pol);
|
||||
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t mcu_pin_dettach_irq(struct rt_device *device, rt_int32_t pin)
|
||||
{
|
||||
gpio_cfg_t tmp_gpio_cfg;
|
||||
tmp_gpio_cfg.port = PIN_MCU_PORT(pin);
|
||||
tmp_gpio_cfg.mask = PIN_MCU_PIN(pin);
|
||||
tmp_gpio_cfg.pad = GPIO_PAD_PULL_UP;
|
||||
tmp_gpio_cfg.func = GPIO_FUNC_IN;
|
||||
GPIO_Config(&tmp_gpio_cfg);
|
||||
GPIO_IntDisable(&tmp_gpio_cfg);
|
||||
GPIO_RegisterCallback(&tmp_gpio_cfg, NULL, NULL);
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t mcu_pin_irq_enable(struct rt_device *device, rt_base_t pin,
|
||||
rt_uint32_t enabled)
|
||||
{
|
||||
gpio_cfg_t tmp_gpio_cfg;
|
||||
tmp_gpio_cfg.port = PIN_MCU_PORT(pin);
|
||||
tmp_gpio_cfg.mask = PIN_MCU_PIN(pin);
|
||||
if (enabled)
|
||||
{
|
||||
GPIO_IntEnable(&tmp_gpio_cfg);
|
||||
NVIC_EnableIRQ((IRQn_Type)MXC_GPIO_GET_IRQ(PIN_MCU_PORT(pin)));
|
||||
}
|
||||
else
|
||||
{
|
||||
GPIO_IntDisable(&tmp_gpio_cfg);
|
||||
NVIC_DisableIRQ((IRQn_Type)MXC_GPIO_GET_IRQ(PIN_MCU_PORT(pin)));
|
||||
}
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
const static struct rt_pin_ops _mcu_pin_ops =
|
||||
{
|
||||
mcu_pin_mode,
|
||||
mcu_pin_write,
|
||||
mcu_pin_read,
|
||||
mcu_pin_attach_irq,
|
||||
mcu_pin_dettach_irq,
|
||||
mcu_pin_irq_enable,
|
||||
NULL,
|
||||
};
|
||||
|
||||
int rt_hw_pin_init(void)
|
||||
{
|
||||
GPIO_Init();
|
||||
return rt_device_pin_register("pin", &_mcu_pin_ops, RT_NULL);
|
||||
}
|
||||
INIT_BOARD_EXPORT(rt_hw_pin_init);
|
||||
|
||||
|
||||
void GPIO0_IRQHandler(void)
|
||||
{
|
||||
GPIO_Handler(PORT_0);
|
||||
}
|
||||
|
||||
#endif /* RT_USING_PIN */
|
21
bsp/maxim/libraries/HAL_Drivers/drv_gpio.h
Normal file
21
bsp/maxim/libraries/HAL_Drivers/drv_gpio.h
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2020, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-02-11 supperthomas first version
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __DRV_GPIO_H__
|
||||
#define __DRV_GPIO_H__
|
||||
|
||||
#include <board.h>
|
||||
#include <rtdevice.h>
|
||||
|
||||
int rt_hw_pin_init(void);
|
||||
|
||||
#endif /* __DRV_GPIO_H__ */
|
||||
|
169
bsp/maxim/libraries/HAL_Drivers/drv_spi.c
Normal file
169
bsp/maxim/libraries/HAL_Drivers/drv_spi.c
Normal file
@ -0,0 +1,169 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-02-14 supperthomas first version
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "board.h"
|
||||
#include "drv_spi.h"
|
||||
|
||||
#define DBG_LEVEL DBG_LOG
|
||||
#include <rtdbg.h>
|
||||
#define LOG_TAG "drv.spi"
|
||||
|
||||
#ifdef BSP_USING_SPI
|
||||
|
||||
#if defined(BSP_USING_SPI0) || defined(BSP_USING_SPI1) || defined(BSP_USING_SPI2)
|
||||
static struct mcu_drv_spi_config spi_config[] =
|
||||
{
|
||||
#ifdef BSP_USING_SPI0
|
||||
MCU_SPI0_CONFIG,
|
||||
#endif
|
||||
#ifdef BSP_USING_SPI1
|
||||
MCU_SPI1_CONFIG,
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
static struct mcu_drv_spi spi_bus_obj[sizeof(spi_config) / sizeof(spi_config[0])];
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function config spi bus
|
||||
* @param device
|
||||
* @param configuration
|
||||
* @retval RT_EOK / RT_ERROR
|
||||
*/
|
||||
static rt_err_t spi_configure(struct rt_spi_device *device,
|
||||
struct rt_spi_configuration *configuration)
|
||||
{
|
||||
RT_ASSERT(device != RT_NULL);
|
||||
RT_ASSERT(device->bus != RT_NULL);
|
||||
RT_ASSERT(device->bus->parent.user_data != RT_NULL);
|
||||
RT_ASSERT(configuration != RT_NULL);
|
||||
struct mcu_drv_spi *tmp_spi;
|
||||
tmp_spi = rt_container_of(device->bus, struct mcu_drv_spi, spi_bus);
|
||||
int mode;
|
||||
|
||||
///init
|
||||
|
||||
switch (configuration->mode & RT_SPI_MODE_3)
|
||||
{
|
||||
case RT_SPI_MODE_0/* RT_SPI_CPOL:0 , RT_SPI_CPHA:0 */:
|
||||
case RT_SPI_MODE_1/* RT_SPI_CPOL:0 , RT_SPI_CPHA:1 */:
|
||||
case RT_SPI_MODE_2/* RT_SPI_CPOL:1 , RT_SPI_CPHA:0 */:
|
||||
case RT_SPI_MODE_3/* RT_SPI_CPOL:1 , RT_SPI_CPHA:1 */:
|
||||
mode = configuration->mode & RT_SPI_MODE_3;
|
||||
break;
|
||||
default:
|
||||
LOG_E("spi_configure mode error %x\n", configuration->mode);
|
||||
return RT_ERROR;
|
||||
}
|
||||
|
||||
tmp_spi->spixfer_req.width = SPI17Y_WIDTH_1;
|
||||
tmp_spi->spixfer_req.bits = configuration->data_width;
|
||||
tmp_spi->spixfer_req.ssel = 0;
|
||||
tmp_spi->spixfer_req.deass = 1;
|
||||
tmp_spi->spixfer_req.tx_num = 0;
|
||||
tmp_spi->spixfer_req.rx_num = 0;
|
||||
tmp_spi->spixfer_req.callback = NULL;
|
||||
LOG_D("spi init mode:%d, rate:%d", mode, configuration->max_hz);
|
||||
if (SPI_Init(tmp_spi->spi_instance, mode, configuration->max_hz) != 0)
|
||||
{
|
||||
LOG_E("Error configuring SPI\n");
|
||||
while (1) {}
|
||||
}
|
||||
//init
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *message)
|
||||
{
|
||||
RT_ASSERT(device != RT_NULL);
|
||||
RT_ASSERT(device->bus != RT_NULL);
|
||||
RT_ASSERT(device->bus->parent.user_data != RT_NULL);
|
||||
|
||||
int ret = 0;
|
||||
struct mcu_drv_spi *tmp_spi;
|
||||
tmp_spi = rt_container_of(device->bus, struct mcu_drv_spi, spi_bus);
|
||||
|
||||
|
||||
tmp_spi->spixfer_req.tx_data = message->send_buf;
|
||||
tmp_spi->spixfer_req.rx_data = message->recv_buf;
|
||||
tmp_spi->spixfer_req.len = message->length;
|
||||
ret = SPI_MasterTrans(tmp_spi->spi_instance, &tmp_spi->spixfer_req);
|
||||
if (ret == E_NO_ERROR)
|
||||
{
|
||||
return message->length;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_E("spixfer faild, ret %d", ret);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* spi bus callback function */
|
||||
static const struct rt_spi_ops nrfx_spi_ops =
|
||||
{
|
||||
.configure = spi_configure,
|
||||
.xfer = spixfer,
|
||||
};
|
||||
|
||||
/*spi bus init*/
|
||||
static int rt_hw_spi_bus_init(void)
|
||||
{
|
||||
rt_err_t result = RT_ERROR;
|
||||
for (int i = 0; i < sizeof(spi_config) / sizeof(spi_config[0]); i++)
|
||||
{
|
||||
spi_bus_obj[i].spi_instance = spi_config[i].spi_instance;
|
||||
spi_bus_obj[i].spi_bus.parent.user_data = &spi_config[i]; //SPI INSTANCE
|
||||
result = rt_spi_bus_register(&spi_bus_obj[i].spi_bus, spi_config[i].bus_name, &nrfx_spi_ops);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int rt_hw_spi_init(void)
|
||||
{
|
||||
return rt_hw_spi_bus_init();
|
||||
}
|
||||
INIT_BOARD_EXPORT(rt_hw_spi_init);
|
||||
|
||||
/**
|
||||
* Attach the spi device to SPI bus, this function must be used after initialization.
|
||||
*/
|
||||
rt_err_t rt_hw_spi_device_attach(const char *bus_name, const char *device_name, rt_uint32_t cs_pin)
|
||||
{
|
||||
RT_ASSERT(bus_name != RT_NULL);
|
||||
RT_ASSERT(device_name != RT_NULL);
|
||||
RT_ASSERT(cs_pin != RT_NULL);
|
||||
|
||||
rt_err_t result;
|
||||
struct rt_spi_device *spi_device;
|
||||
/* attach the device to spi bus*/
|
||||
spi_device = (struct rt_spi_device *)rt_malloc(sizeof(struct rt_spi_device));
|
||||
RT_ASSERT(spi_device != RT_NULL);
|
||||
/* initialize the cs pin */
|
||||
result = rt_spi_bus_attach_device(spi_device, device_name, bus_name, (void *)cs_pin);
|
||||
if (result != RT_EOK)
|
||||
{
|
||||
LOG_E("%s attach to %s faild, %d", device_name, bus_name, result);
|
||||
result = RT_ERROR;
|
||||
}
|
||||
/* TODO: SET THE GPIO */
|
||||
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif /* BSP_USING_SPI0 || BSP_USING_SPI1 || BSP_USING_SPI2 */
|
||||
#endif /*BSP_USING_SPI*/
|
||||
|
||||
|
67
bsp/maxim/libraries/HAL_Drivers/drv_spi.h
Normal file
67
bsp/maxim/libraries/HAL_Drivers/drv_spi.h
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-02-14 supperthomas first version
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include <rthw.h>
|
||||
|
||||
#include "spi.h"
|
||||
|
||||
#ifndef __DRV_SPI_H_
|
||||
#define __DRV_SPI_H_
|
||||
|
||||
/**
|
||||
* @brief Attach the spi device to SPI bus, this function must be used after initialization.
|
||||
* @param bus_name spi bus name "spi0"/"spi1"/"spi2"
|
||||
* @param device_name spi device name "spi0x"/"spi1x"/"spi2x"
|
||||
* @param ss_pin spi ss pin number
|
||||
* @retval RT_ERROR / RT_EOK
|
||||
*/
|
||||
rt_err_t rt_hw_spi_device_attach(const char *bus_name, const char *device_name, rt_uint32_t ss_pin);
|
||||
|
||||
//SPI bus config
|
||||
#ifdef BSP_USING_SPI0
|
||||
#define MCU_SPI0_CONFIG \
|
||||
{ \
|
||||
.bus_name = "spi0", \
|
||||
.spi_instance = SPI0A, \
|
||||
}
|
||||
#endif
|
||||
#ifdef BSP_USING_SPI1
|
||||
#ifdef BSP_USING_SPI1A //The SPI1A is conflit with UART1 TX RX P0.10 P0.11
|
||||
#define MCU_SPI1_CONFIG \
|
||||
{ \
|
||||
.bus_name = "spi1", \
|
||||
.spi_instance = SPI1A \
|
||||
}
|
||||
#else
|
||||
#define MCU_SPI1_CONFIG \
|
||||
{ \
|
||||
.bus_name = "spi1", \
|
||||
.spi_instance = SPI1B \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct mcu_drv_spi_config
|
||||
{
|
||||
char *bus_name;
|
||||
spi_type spi_instance;
|
||||
};
|
||||
|
||||
struct mcu_drv_spi
|
||||
{
|
||||
spi_type spi_instance;
|
||||
spi_req_t spixfer_req;
|
||||
struct rt_spi_configuration *cfg;
|
||||
struct rt_spi_bus spi_bus;
|
||||
};
|
||||
|
||||
#endif /*__DRV_SPI_H_*/
|
@ -30,6 +30,9 @@ if GetDepend(['RT_USING_I2C']):
|
||||
|
||||
if GetDepend(['RT_USING_SPI']):
|
||||
src += ['Source/spi.c']
|
||||
src += ['Source/spi17y.c']
|
||||
src += ['Source/spimss.c']
|
||||
|
||||
|
||||
if GetDepend(['RT_USING_RTC']):
|
||||
src += ['Source/rtc.c']
|
||||
|
Loading…
x
Reference in New Issue
Block a user