优化代码结构等等 zsxfly20240511
This commit is contained in:
parent
d3db2cee3a
commit
5976e0c61c
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -100,7 +100,10 @@
|
||||||
<tRSysVw>1</tRSysVw>
|
<tRSysVw>1</tRSysVw>
|
||||||
<sRunDeb>0</sRunDeb>
|
<sRunDeb>0</sRunDeb>
|
||||||
<sLrtime>0</sLrtime>
|
<sLrtime>0</sLrtime>
|
||||||
<nTsel>6</nTsel>
|
<bEvRecOn>1</bEvRecOn>
|
||||||
|
<bSchkAxf>0</bSchkAxf>
|
||||||
|
<bTchkAxf>0</bTchkAxf>
|
||||||
|
<nTsel>4</nTsel>
|
||||||
<sDll></sDll>
|
<sDll></sDll>
|
||||||
<sDllPa></sDllPa>
|
<sDllPa></sDllPa>
|
||||||
<sDlgDll></sDlgDll>
|
<sDlgDll></sDlgDll>
|
||||||
|
@ -190,6 +193,16 @@
|
||||||
<LintExecutable></LintExecutable>
|
<LintExecutable></LintExecutable>
|
||||||
<LintConfigFile></LintConfigFile>
|
<LintConfigFile></LintConfigFile>
|
||||||
<bLintAuto>0</bLintAuto>
|
<bLintAuto>0</bLintAuto>
|
||||||
|
<bAutoGenD>0</bAutoGenD>
|
||||||
|
<LntExFlags>0</LntExFlags>
|
||||||
|
<pMisraName></pMisraName>
|
||||||
|
<pszMrule></pszMrule>
|
||||||
|
<pSingCmds></pSingCmds>
|
||||||
|
<pMultCmds></pMultCmds>
|
||||||
|
<pMisraNamep></pMisraNamep>
|
||||||
|
<pszMrulep></pszMrulep>
|
||||||
|
<pSingCmdsp></pSingCmdsp>
|
||||||
|
<pMultCmdsp></pMultCmdsp>
|
||||||
<SystemViewers>
|
<SystemViewers>
|
||||||
<Entry>
|
<Entry>
|
||||||
<Name>System Viewer\UART1</Name>
|
<Name>System Viewer\UART1</Name>
|
||||||
|
@ -210,7 +223,6 @@
|
||||||
<FileNumber>1</FileNumber>
|
<FileNumber>1</FileNumber>
|
||||||
<FileType>2</FileType>
|
<FileType>2</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<Focus>1</Focus>
|
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\..\..\core\mdk\startup.s</PathWithFileName>
|
<PathWithFileName>..\..\..\core\mdk\startup.s</PathWithFileName>
|
||||||
|
@ -231,7 +243,6 @@
|
||||||
<FileNumber>2</FileNumber>
|
<FileNumber>2</FileNumber>
|
||||||
<FileType>5</FileType>
|
<FileType>5</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<Focus>1</Focus>
|
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\src\cfg.h</PathWithFileName>
|
<PathWithFileName>..\src\cfg.h</PathWithFileName>
|
||||||
|
@ -244,7 +255,6 @@
|
||||||
<FileNumber>3</FileNumber>
|
<FileNumber>3</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<Focus>1</Focus>
|
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\src\main.c</PathWithFileName>
|
<PathWithFileName>..\src\main.c</PathWithFileName>
|
||||||
|
@ -257,7 +267,6 @@
|
||||||
<FileNumber>4</FileNumber>
|
<FileNumber>4</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<Focus>0</Focus>
|
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\src\app_uart.c</PathWithFileName>
|
<PathWithFileName>..\src\app_uart.c</PathWithFileName>
|
||||||
|
@ -270,20 +279,6 @@
|
||||||
<FileNumber>5</FileNumber>
|
<FileNumber>5</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<Focus>0</Focus>
|
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
|
||||||
<bDave2>0</bDave2>
|
|
||||||
<PathWithFileName>..\src\app_speed_governor.c</PathWithFileName>
|
|
||||||
<FilenameWithoutPath>app_speed_governor.c</FilenameWithoutPath>
|
|
||||||
<RteFlg>0</RteFlg>
|
|
||||||
<bShared>0</bShared>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<GroupNumber>2</GroupNumber>
|
|
||||||
<FileNumber>6</FileNumber>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<tvExp>0</tvExp>
|
|
||||||
<Focus>0</Focus>
|
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\..\..\modules\src\sftmr.c</PathWithFileName>
|
<PathWithFileName>..\..\..\modules\src\sftmr.c</PathWithFileName>
|
||||||
|
@ -293,10 +288,9 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>7</FileNumber>
|
<FileNumber>6</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<Focus>0</Focus>
|
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\src\app_control_out.c</PathWithFileName>
|
<PathWithFileName>..\src\app_control_out.c</PathWithFileName>
|
||||||
|
@ -306,10 +300,9 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>8</FileNumber>
|
<FileNumber>7</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<Focus>0</Focus>
|
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\src\app_ws2812.c</PathWithFileName>
|
<PathWithFileName>..\src\app_ws2812.c</PathWithFileName>
|
||||||
|
@ -319,10 +312,9 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>2</GroupNumber>
|
<GroupNumber>2</GroupNumber>
|
||||||
<FileNumber>9</FileNumber>
|
<FileNumber>8</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<Focus>0</Focus>
|
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\src\app_ble_uart_proc.c</PathWithFileName>
|
<PathWithFileName>..\src\app_ble_uart_proc.c</PathWithFileName>
|
||||||
|
@ -330,6 +322,42 @@
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<bShared>0</bShared>
|
<bShared>0</bShared>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<GroupNumber>2</GroupNumber>
|
||||||
|
<FileNumber>9</FileNumber>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<tvExp>0</tvExp>
|
||||||
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
<bDave2>0</bDave2>
|
||||||
|
<PathWithFileName>..\src\app_radar.c</PathWithFileName>
|
||||||
|
<FilenameWithoutPath>app_radar.c</FilenameWithoutPath>
|
||||||
|
<RteFlg>0</RteFlg>
|
||||||
|
<bShared>0</bShared>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<GroupNumber>2</GroupNumber>
|
||||||
|
<FileNumber>10</FileNumber>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<tvExp>0</tvExp>
|
||||||
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
<bDave2>0</bDave2>
|
||||||
|
<PathWithFileName>..\src\app_buzzer.c</PathWithFileName>
|
||||||
|
<FilenameWithoutPath>app_buzzer.c</FilenameWithoutPath>
|
||||||
|
<RteFlg>0</RteFlg>
|
||||||
|
<bShared>0</bShared>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<GroupNumber>2</GroupNumber>
|
||||||
|
<FileNumber>11</FileNumber>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<tvExp>0</tvExp>
|
||||||
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
<bDave2>0</bDave2>
|
||||||
|
<PathWithFileName>..\src\app_bat.c</PathWithFileName>
|
||||||
|
<FilenameWithoutPath>app_bat.c</FilenameWithoutPath>
|
||||||
|
<RteFlg>0</RteFlg>
|
||||||
|
<bShared>0</bShared>
|
||||||
|
</File>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
|
@ -340,10 +368,9 @@
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>3</GroupNumber>
|
<GroupNumber>3</GroupNumber>
|
||||||
<FileNumber>10</FileNumber>
|
<FileNumber>12</FileNumber>
|
||||||
<FileType>5</FileType>
|
<FileType>5</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<Focus>1</Focus>
|
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\..\..\drivers\api\drvs.h</PathWithFileName>
|
<PathWithFileName>..\..\..\drivers\api\drvs.h</PathWithFileName>
|
||||||
|
@ -353,10 +380,9 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>3</GroupNumber>
|
<GroupNumber>3</GroupNumber>
|
||||||
<FileNumber>11</FileNumber>
|
<FileNumber>13</FileNumber>
|
||||||
<FileType>4</FileType>
|
<FileType>4</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<Focus>1</Focus>
|
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\..\..\drivers\lib\drvs.lib</PathWithFileName>
|
<PathWithFileName>..\..\..\drivers\lib\drvs.lib</PathWithFileName>
|
||||||
|
@ -374,10 +400,9 @@
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>4</GroupNumber>
|
<GroupNumber>4</GroupNumber>
|
||||||
<FileNumber>12</FileNumber>
|
<FileNumber>14</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<Focus>1</Focus>
|
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\..\..\modules\src\debug.c</PathWithFileName>
|
<PathWithFileName>..\..\..\modules\src\debug.c</PathWithFileName>
|
||||||
|
@ -389,16 +414,15 @@
|
||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>ble\app</GroupName>
|
<GroupName>ble\app</GroupName>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>1</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<cbSel>0</cbSel>
|
<cbSel>0</cbSel>
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>5</GroupNumber>
|
<GroupNumber>5</GroupNumber>
|
||||||
<FileNumber>13</FileNumber>
|
<FileNumber>15</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<Focus>0</Focus>
|
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\..\..\ble\app\app.c</PathWithFileName>
|
<PathWithFileName>..\..\..\ble\app\app.c</PathWithFileName>
|
||||||
|
@ -408,10 +432,9 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>5</GroupNumber>
|
<GroupNumber>5</GroupNumber>
|
||||||
<FileNumber>14</FileNumber>
|
<FileNumber>16</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<Focus>0</Focus>
|
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\..\..\ble\app\app_actv.c</PathWithFileName>
|
<PathWithFileName>..\..\..\ble\app\app_actv.c</PathWithFileName>
|
||||||
|
@ -421,10 +444,9 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>5</GroupNumber>
|
<GroupNumber>5</GroupNumber>
|
||||||
<FileNumber>15</FileNumber>
|
<FileNumber>17</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<Focus>0</Focus>
|
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\..\..\ble\app\app_gapc.c</PathWithFileName>
|
<PathWithFileName>..\..\..\ble\app\app_gapc.c</PathWithFileName>
|
||||||
|
@ -434,10 +456,9 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>5</GroupNumber>
|
<GroupNumber>5</GroupNumber>
|
||||||
<FileNumber>16</FileNumber>
|
<FileNumber>18</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<Focus>0</Focus>
|
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\..\..\ble\app\app_gapm.c</PathWithFileName>
|
<PathWithFileName>..\..\..\ble\app\app_gapm.c</PathWithFileName>
|
||||||
|
@ -447,10 +468,9 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>5</GroupNumber>
|
<GroupNumber>5</GroupNumber>
|
||||||
<FileNumber>17</FileNumber>
|
<FileNumber>19</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<Focus>0</Focus>
|
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\..\..\ble\app\app_gatt.c</PathWithFileName>
|
<PathWithFileName>..\..\..\ble\app\app_gatt.c</PathWithFileName>
|
||||||
|
@ -460,10 +480,9 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>5</GroupNumber>
|
<GroupNumber>5</GroupNumber>
|
||||||
<FileNumber>18</FileNumber>
|
<FileNumber>20</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<Focus>0</Focus>
|
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\..\..\ble\app\app_msg.c</PathWithFileName>
|
<PathWithFileName>..\..\..\ble\app\app_msg.c</PathWithFileName>
|
||||||
|
@ -475,16 +494,15 @@
|
||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>ble\lib</GroupName>
|
<GroupName>ble\lib</GroupName>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>1</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<cbSel>0</cbSel>
|
<cbSel>0</cbSel>
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>6</GroupNumber>
|
<GroupNumber>6</GroupNumber>
|
||||||
<FileNumber>19</FileNumber>
|
<FileNumber>21</FileNumber>
|
||||||
<FileType>4</FileType>
|
<FileType>4</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<Focus>0</Focus>
|
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\..\..\ble\lib\ble6.lib</PathWithFileName>
|
<PathWithFileName>..\..\..\ble\lib\ble6.lib</PathWithFileName>
|
||||||
|
@ -496,16 +514,15 @@
|
||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>ble\pre</GroupName>
|
<GroupName>ble\pre</GroupName>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>1</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<cbSel>0</cbSel>
|
<cbSel>0</cbSel>
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>7</GroupNumber>
|
<GroupNumber>7</GroupNumber>
|
||||||
<FileNumber>20</FileNumber>
|
<FileNumber>22</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<Focus>0</Focus>
|
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\..\..\ble\prf\prf_diss.c</PathWithFileName>
|
<PathWithFileName>..\..\..\ble\prf\prf_diss.c</PathWithFileName>
|
||||||
|
@ -515,10 +532,9 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>7</GroupNumber>
|
<GroupNumber>7</GroupNumber>
|
||||||
<FileNumber>21</FileNumber>
|
<FileNumber>23</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<Focus>0</Focus>
|
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\..\..\ble\prf\prf_sess.c</PathWithFileName>
|
<PathWithFileName>..\..\..\ble\prf\prf_sess.c</PathWithFileName>
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
<TargetName>uartTest</TargetName>
|
<TargetName>uartTest</TargetName>
|
||||||
<ToolsetNumber>0x4</ToolsetNumber>
|
<ToolsetNumber>0x4</ToolsetNumber>
|
||||||
<ToolsetName>ARM-ADS</ToolsetName>
|
<ToolsetName>ARM-ADS</ToolsetName>
|
||||||
|
<pCCUsed>5060750::V5.06 update 6 (build 750)::ARMCC</pCCUsed>
|
||||||
|
<uAC6>0</uAC6>
|
||||||
<TargetOption>
|
<TargetOption>
|
||||||
<TargetCommonOption>
|
<TargetCommonOption>
|
||||||
<Device>B6x</Device>
|
<Device>B6x</Device>
|
||||||
|
@ -123,47 +125,6 @@
|
||||||
<HexOffset>0</HexOffset>
|
<HexOffset>0</HexOffset>
|
||||||
<Oh166RecLen>16</Oh166RecLen>
|
<Oh166RecLen>16</Oh166RecLen>
|
||||||
</OPTHX>
|
</OPTHX>
|
||||||
<Simulator>
|
|
||||||
<UseSimulator>0</UseSimulator>
|
|
||||||
<LoadApplicationAtStartup>1</LoadApplicationAtStartup>
|
|
||||||
<RunToMain>1</RunToMain>
|
|
||||||
<RestoreBreakpoints>1</RestoreBreakpoints>
|
|
||||||
<RestoreWatchpoints>1</RestoreWatchpoints>
|
|
||||||
<RestoreMemoryDisplay>1</RestoreMemoryDisplay>
|
|
||||||
<RestoreFunctions>1</RestoreFunctions>
|
|
||||||
<RestoreToolbox>1</RestoreToolbox>
|
|
||||||
<LimitSpeedToRealTime>0</LimitSpeedToRealTime>
|
|
||||||
<RestoreSysVw>1</RestoreSysVw>
|
|
||||||
</Simulator>
|
|
||||||
<Target>
|
|
||||||
<UseTarget>1</UseTarget>
|
|
||||||
<LoadApplicationAtStartup>1</LoadApplicationAtStartup>
|
|
||||||
<RunToMain>1</RunToMain>
|
|
||||||
<RestoreBreakpoints>1</RestoreBreakpoints>
|
|
||||||
<RestoreWatchpoints>1</RestoreWatchpoints>
|
|
||||||
<RestoreMemoryDisplay>1</RestoreMemoryDisplay>
|
|
||||||
<RestoreFunctions>0</RestoreFunctions>
|
|
||||||
<RestoreToolbox>1</RestoreToolbox>
|
|
||||||
<RestoreTracepoints>1</RestoreTracepoints>
|
|
||||||
<RestoreSysVw>1</RestoreSysVw>
|
|
||||||
</Target>
|
|
||||||
<RunDebugAfterBuild>0</RunDebugAfterBuild>
|
|
||||||
<TargetSelection>6</TargetSelection>
|
|
||||||
<SimDlls>
|
|
||||||
<CpuDll></CpuDll>
|
|
||||||
<CpuDllArguments></CpuDllArguments>
|
|
||||||
<PeripheralDll></PeripheralDll>
|
|
||||||
<PeripheralDllArguments></PeripheralDllArguments>
|
|
||||||
<InitializationFile></InitializationFile>
|
|
||||||
</SimDlls>
|
|
||||||
<TargetDlls>
|
|
||||||
<CpuDll></CpuDll>
|
|
||||||
<CpuDllArguments></CpuDllArguments>
|
|
||||||
<PeripheralDll></PeripheralDll>
|
|
||||||
<PeripheralDllArguments></PeripheralDllArguments>
|
|
||||||
<InitializationFile></InitializationFile>
|
|
||||||
<Driver>Segger\JL2CM3.dll</Driver>
|
|
||||||
</TargetDlls>
|
|
||||||
</DebugOption>
|
</DebugOption>
|
||||||
<Utilities>
|
<Utilities>
|
||||||
<Flash1>
|
<Flash1>
|
||||||
|
@ -222,12 +183,14 @@
|
||||||
<hadXRAM>0</hadXRAM>
|
<hadXRAM>0</hadXRAM>
|
||||||
<uocXRam>0</uocXRam>
|
<uocXRam>0</uocXRam>
|
||||||
<RvdsVP>0</RvdsVP>
|
<RvdsVP>0</RvdsVP>
|
||||||
|
<RvdsMve>0</RvdsMve>
|
||||||
<hadIRAM2>0</hadIRAM2>
|
<hadIRAM2>0</hadIRAM2>
|
||||||
<hadIROM2>0</hadIROM2>
|
<hadIROM2>0</hadIROM2>
|
||||||
<StupSel>0</StupSel>
|
<StupSel>0</StupSel>
|
||||||
<useUlib>1</useUlib>
|
<useUlib>1</useUlib>
|
||||||
<EndSel>0</EndSel>
|
<EndSel>0</EndSel>
|
||||||
<uLtcg>0</uLtcg>
|
<uLtcg>0</uLtcg>
|
||||||
|
<nSecure>0</nSecure>
|
||||||
<RoSelD>0</RoSelD>
|
<RoSelD>0</RoSelD>
|
||||||
<RwSelD>0</RwSelD>
|
<RwSelD>0</RwSelD>
|
||||||
<CodeSel>0</CodeSel>
|
<CodeSel>0</CodeSel>
|
||||||
|
@ -348,7 +311,7 @@
|
||||||
</ArmAdsMisc>
|
</ArmAdsMisc>
|
||||||
<Cads>
|
<Cads>
|
||||||
<interw>1</interw>
|
<interw>1</interw>
|
||||||
<Optim>0</Optim>
|
<Optim>4</Optim>
|
||||||
<oTime>0</oTime>
|
<oTime>0</oTime>
|
||||||
<SplitLS>0</SplitLS>
|
<SplitLS>0</SplitLS>
|
||||||
<OneElfS>1</OneElfS>
|
<OneElfS>1</OneElfS>
|
||||||
|
@ -361,9 +324,15 @@
|
||||||
<uThumb>0</uThumb>
|
<uThumb>0</uThumb>
|
||||||
<uSurpInc>0</uSurpInc>
|
<uSurpInc>0</uSurpInc>
|
||||||
<uC99>1</uC99>
|
<uC99>1</uC99>
|
||||||
|
<uGnu>0</uGnu>
|
||||||
<useXO>0</useXO>
|
<useXO>0</useXO>
|
||||||
<v6Lang>1</v6Lang>
|
<v6Lang>1</v6Lang>
|
||||||
<v6LangP>1</v6LangP>
|
<v6LangP>1</v6LangP>
|
||||||
|
<vShortEn>1</vShortEn>
|
||||||
|
<vShortWch>1</vShortWch>
|
||||||
|
<v6Lto>0</v6Lto>
|
||||||
|
<v6WtE>0</v6WtE>
|
||||||
|
<v6Rtti>0</v6Rtti>
|
||||||
<VariousControls>
|
<VariousControls>
|
||||||
<MiscControls>--c99 --gnu --thumb --bss_threshold=0 --preinclude=..\src\cfg.h</MiscControls>
|
<MiscControls>--c99 --gnu --thumb --bss_threshold=0 --preinclude=..\src\cfg.h</MiscControls>
|
||||||
<Define></Define>
|
<Define></Define>
|
||||||
|
@ -381,6 +350,7 @@
|
||||||
<NoWarn>0</NoWarn>
|
<NoWarn>0</NoWarn>
|
||||||
<uSurpInc>0</uSurpInc>
|
<uSurpInc>0</uSurpInc>
|
||||||
<useXO>0</useXO>
|
<useXO>0</useXO>
|
||||||
|
<uClangAs>0</uClangAs>
|
||||||
<VariousControls>
|
<VariousControls>
|
||||||
<MiscControls>--thumb</MiscControls>
|
<MiscControls>--thumb</MiscControls>
|
||||||
<Define></Define>
|
<Define></Define>
|
||||||
|
@ -436,11 +406,6 @@
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\src\app_uart.c</FilePath>
|
<FilePath>..\src\app_uart.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
|
||||||
<FileName>app_speed_governor.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\src\app_speed_governor.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
<File>
|
||||||
<FileName>sftmr.c</FileName>
|
<FileName>sftmr.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
|
@ -461,6 +426,21 @@
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\src\app_ble_uart_proc.c</FilePath>
|
<FilePath>..\src\app_ble_uart_proc.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>app_radar.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\src\app_radar.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>app_buzzer.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\src\app_buzzer.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>app_bat.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\src\app_bat.c</FilePath>
|
||||||
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
|
@ -552,4 +532,10 @@
|
||||||
</Target>
|
</Target>
|
||||||
</Targets>
|
</Targets>
|
||||||
|
|
||||||
|
<RTE>
|
||||||
|
<apis/>
|
||||||
|
<components/>
|
||||||
|
<files/>
|
||||||
|
</RTE>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -0,0 +1,97 @@
|
||||||
|
#include "b6x.h"
|
||||||
|
#include "drvs.h"
|
||||||
|
#include "dbg.h"
|
||||||
|
|
||||||
|
#include "app_bat.h"
|
||||||
|
#include "sys_config.h"
|
||||||
|
|
||||||
|
#define BAT_Message_interval 1000
|
||||||
|
|
||||||
|
tmr_id_t BAT_Message_tmr_id;
|
||||||
|
BAT_Message_t BAT_Message;
|
||||||
|
uint16_t Bat_Voltage_Last;
|
||||||
|
uint16_t Voltage_lag_count;
|
||||||
|
|
||||||
|
uint8_t Bat_STA_Last;
|
||||||
|
|
||||||
|
// 门锁状态更新标志
|
||||||
|
bool GRB_Door_lock_updata=0;
|
||||||
|
// uint8_t bat_str[50]={0,0},bat_str_len=0;
|
||||||
|
|
||||||
|
static tmr_tk_t BAT_Message_Handle(tmr_id_t id) {
|
||||||
|
uint16_t Bat_Voltage = get_bat_voltage() * 10;
|
||||||
|
|
||||||
|
if(Bat_Voltage_Last >= Bat_Voltage){
|
||||||
|
if(Bat_Percent_Low > Bat_Voltage){
|
||||||
|
BAT_Message.Bat_STA =(BAT_Message.Bat_STA & 0xF3)|Bat_Low_STA;
|
||||||
|
WS2812_GRBs.GRBs=GRB_RED;
|
||||||
|
}else if(Bat_Percent_30 > Bat_Voltage){
|
||||||
|
BAT_Message.Bat_STA =(BAT_Message.Bat_STA & 0x03)|Bat_30_STA;
|
||||||
|
WS2812_GRBs.GRBs=GRB_RED;
|
||||||
|
}else if(Bat_Percent_60 > Bat_Voltage){
|
||||||
|
BAT_Message.Bat_STA =(BAT_Message.Bat_STA & 0x03)|Bat_60_STA;
|
||||||
|
WS2812_GRBs.GRBs=GRB_BLUE;
|
||||||
|
}else if(Bat_Percent_100 > Bat_Voltage){
|
||||||
|
BAT_Message.Bat_STA =(BAT_Message.Bat_STA & 0x03)|Bat_100_STA;
|
||||||
|
WS2812_GRBs.GRBs=GRB_GREEN;
|
||||||
|
}else{
|
||||||
|
BAT_Message.Bat_STA =(BAT_Message.Bat_STA & 0xF3)|Bat_Full_STA;
|
||||||
|
WS2812_GRBs.GRBs=GRB_GREEN;
|
||||||
|
}
|
||||||
|
if(0==(BAT_Message.Bat_STA & Bat_Charge_STA)){
|
||||||
|
Bat_Voltage_Last =Bat_Voltage;
|
||||||
|
}else{
|
||||||
|
if(Bat_Voltage <= (Bat_Voltage_Last - 15)){
|
||||||
|
BAT_Message.Bat_STA =(BAT_Message.Bat_STA & 0xFC)|Bat_NotCharge_STA;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Voltage_lag_count=0;
|
||||||
|
}else {
|
||||||
|
Voltage_lag_count++;
|
||||||
|
if((3000/BAT_Message_interval) ==Voltage_lag_count){//3s
|
||||||
|
Voltage_lag_count=0;
|
||||||
|
uint16_t in_acc_percent= get_in_acc_percent();
|
||||||
|
|
||||||
|
// bat_str_len =sprintf((char *)bat_str, "ACC=%d%%\n", in_acc_percent);
|
||||||
|
// uart_send(UART1_PORT,bat_str_len,bat_str);
|
||||||
|
|
||||||
|
if(in_acc_percent <= 5){ // 油门小于2%时,才判断是否在充电
|
||||||
|
// uart_putc(UART1_PORT,'A');
|
||||||
|
if(Bat_Voltage >= (Bat_Voltage_Last + 15)){
|
||||||
|
BAT_Message.Bat_STA =(BAT_Message.Bat_STA & 0xFC)|Bat_Charge_STA;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
BAT_Message.Bat_STA =(BAT_Message.Bat_STA & 0xFC);
|
||||||
|
}
|
||||||
|
Bat_Voltage_Last =Bat_Voltage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if((Bat_STA_Last != BAT_Message.Bat_STA) || GRB_Door_lock_updata != Get_Status(OUT_Door_lock)){
|
||||||
|
GRB_Door_lock_updata=Get_Status(OUT_Door_lock);
|
||||||
|
// bat_str_len =sprintf((char *)bat_str, "STA=%#X,Vol=%d\n", BAT_Message.Bat_STA ,Bat_Voltage);
|
||||||
|
// uart_send(UART1_PORT,bat_str_len,bat_str);
|
||||||
|
|
||||||
|
Bat_STA_Last =BAT_Message.Bat_STA;
|
||||||
|
if( Get_Status(OUT_Door_lock)){
|
||||||
|
if(BAT_Message.Bat_STA & Bat_Charge_STA){
|
||||||
|
Time_Event_On(GRB_WS2812_Event,NULL);
|
||||||
|
}else if(BAT_Message.Bat_STA & Bat_Low_STA){
|
||||||
|
Time_Event_Blink(GRB_WS2812_Event,150,150,0xffff,NULL);
|
||||||
|
}else{
|
||||||
|
Time_Event_Blink(GRB_WS2812_Event,500,500,0xffff,NULL);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
Time_Event_Off(GRB_WS2812_Event,NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
BAT_Message.Bat_Voltage =Bat_Voltage;
|
||||||
|
|
||||||
|
return (BAT_Message_interval / 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BAT_Message_Init(void) {
|
||||||
|
BAT_Message_tmr_id = sftmr_start(10, BAT_Message_Handle);
|
||||||
|
Bat_Voltage_Last =get_bat_voltage() * 10;
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
#ifndef _APP_BAT_H_
|
||||||
|
#define _APP_BAT_H_
|
||||||
|
|
||||||
|
// 充电状态
|
||||||
|
typedef enum {
|
||||||
|
Bat_NotCharge_STA=0x01,
|
||||||
|
Bat_Charge_STA=0x02,
|
||||||
|
Bat_Full_STA=0x04,
|
||||||
|
Bat_Low_STA=0x08,
|
||||||
|
Bat_30_STA=0x10,
|
||||||
|
Bat_60_STA=0x20,
|
||||||
|
Bat_100_STA=0x40,
|
||||||
|
} BAT_STA_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
Bat_Percent_Low =420,
|
||||||
|
Bat_Percent_30 =454,
|
||||||
|
Bat_Percent_60 =489,
|
||||||
|
Bat_Percent_100 =535,
|
||||||
|
} BAT_Percent_t;
|
||||||
|
|
||||||
|
// typedef enum {
|
||||||
|
// Bat_Percent_Low =240,
|
||||||
|
// Bat_Percent_30 =260,
|
||||||
|
// Bat_Percent_60 =300,
|
||||||
|
// Bat_Percent_100 =350,
|
||||||
|
// } BAT_Percent_t;
|
||||||
|
|
||||||
|
typedef struct BAT_Message{
|
||||||
|
uint8_t Bat_STA;
|
||||||
|
uint16_t Bat_Voltage; // 480=48.0V
|
||||||
|
} BAT_Message_t;
|
||||||
|
|
||||||
|
|
||||||
|
void BAT_Message_Init(void);
|
||||||
|
|
||||||
|
#endif
|
|
@ -5,12 +5,11 @@
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "prf_sess.h"
|
#include "prf_sess.h"
|
||||||
#include "app_uart.h"
|
#include "app_uart.h"
|
||||||
#include "app_speed_governor.h"
|
|
||||||
#include "app_control_out.h"
|
#include "app_control_out.h"
|
||||||
#include "app_ws2812.h"
|
#include "app_ws2812.h"
|
||||||
|
|
||||||
extern BLE_GRB_Data_t BLE_WS2812_GRBs;
|
extern BLE_GRB_Data_t BLE_WS2812_GRBs;
|
||||||
extern radar_daraframe_t radar_daraframe;
|
// extern radar_daraframe_t radar_daraframe;
|
||||||
|
|
||||||
#define BLE_MAX_LEN (BLE_MTU - 3)
|
#define BLE_MAX_LEN (BLE_MTU - 3)
|
||||||
#define NULL_CNT 20
|
#define NULL_CNT 20
|
||||||
|
@ -27,23 +26,22 @@ void sess_cb_rxd(uint8_t conidx, uint16_t len, const uint8_t *data)
|
||||||
uart_send(UART1_PORT, len, data);
|
uart_send(UART1_PORT, len, data);
|
||||||
if(len == 9 && 0xa5 ==data[0] && 0x5a ==data[len-1]){
|
if(len == 9 && 0xa5 ==data[0] && 0x5a ==data[len-1]){
|
||||||
|
|
||||||
app_set_speed(*(int8_t *)(&data[2]));
|
// app_set_speed(*(int8_t *)(&data[2]));
|
||||||
|
|
||||||
Set_Status(OUT_High_brake,(0x01 & (data[1] >> 0)));
|
Set_Status(OUT_High_brake,(0x01 & (data[1] >> 0)));
|
||||||
Set_Status(OUT_Low_brake,(0x01 & (data[1] >> 1)));
|
Set_Status(OUT_Low_brake,(0x01 & (data[1] >> 1)));
|
||||||
Set_Status(OUT_Push_key,(0x01 & (data[1] >> 2)));
|
|
||||||
Set_Status(OUT_High_speed,(0x01 & (data[1] >> 3)));
|
|
||||||
Set_Status(OUT_Low_speed,(0x01 & (data[1] >> 4)));
|
Set_Status(OUT_Low_speed,(0x01 & (data[1] >> 4)));
|
||||||
Set_Status(OUT_Door_lock,(0x01 & (data[1] >> 5)));
|
Set_Status(OUT_Door_lock,(0x01 & (data[1] >> 5)));
|
||||||
Set_Status(OUT_Switch_gear,(0x01 & (data[1] >> 6)));
|
|
||||||
|
|
||||||
BLE_WS2812_GRBs.len = data[3];
|
BLE_WS2812_GRBs.len = data[3];
|
||||||
BLE_WS2812_GRBs.GRBs = ((uint32_t)data[4]<<17)|((uint32_t)data[5]<<9)|((uint32_t)data[6]<<1);
|
BLE_WS2812_GRBs.GRBs = ((uint32_t)data[4]<<17)|((uint32_t)data[5]<<9)|((uint32_t)data[6]<<1);
|
||||||
buff[0]=0xa5;
|
buff[0]=0xa5;
|
||||||
buff[1]=data[1];
|
buff[1]=data[1];
|
||||||
buff[2]=(*(int8_t *)(&data[2]))<0?-data[2]:data[2];
|
buff[2]=(*(int8_t *)(&data[2]))<0?-data[2]:data[2];
|
||||||
buff[3]=radar_daraframe.Left_data+1;
|
// buff[3]=radar_daraframe.Left_data+1;
|
||||||
buff[4]=radar_daraframe.Right_data+2;
|
// buff[4]=radar_daraframe.Right_data+2;
|
||||||
buff[5]=buff[1]+buff[2]+buff[3]+buff[4];
|
buff[5]=buff[1]+buff[2]+buff[3]+buff[4];
|
||||||
buff[6]=0x5a;
|
buff[6]=0x5a;
|
||||||
sess_txd_send(app_env.curidx, 7, buff);
|
sess_txd_send(app_env.curidx, 7, buff);
|
||||||
|
|
|
@ -0,0 +1,113 @@
|
||||||
|
#include "b6x.h"
|
||||||
|
#include "drvs.h"
|
||||||
|
#include "dbg.h"
|
||||||
|
|
||||||
|
#include "sys_config.h"
|
||||||
|
|
||||||
|
static Time_Events_t Time_Events[Time_Event_MAX];
|
||||||
|
tmr_tk_t Time_Event_tmr_id;
|
||||||
|
|
||||||
|
void Event_Handle(uint16_t Event_List ,bool isOn,void *Parameter){
|
||||||
|
// uart_putc(UART1_PORT,'E');
|
||||||
|
// uart_putc(UART1_PORT,'0'+Event_List);
|
||||||
|
// uart_putc(UART1_PORT,'0'+isOn);
|
||||||
|
// uart_putc(UART1_PORT,'\n');
|
||||||
|
(void)Parameter;
|
||||||
|
switch(Event_List){
|
||||||
|
case Buzzer_Event:
|
||||||
|
Set_Status(OUT_Buzzer,isOn);
|
||||||
|
break;
|
||||||
|
case GRB_WS2812_Event:
|
||||||
|
GRB_WS2812_Write_color(WS2812_GRBs.len, isOn ? WS2812_GRBs.GRBs : 0x0);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static tmr_tk_t Time_Event_Handle(tmr_id_t id) {
|
||||||
|
for (uint16_t i = 0; i < Time_Event_MAX; i++) {
|
||||||
|
Time_Events_t *Events = &Time_Events[i];
|
||||||
|
|
||||||
|
if (Events->delay == 1) {
|
||||||
|
switch (Events->mode) {
|
||||||
|
case Time_MODE_OFF:
|
||||||
|
// 关闭
|
||||||
|
Events->isOn = false;
|
||||||
|
break;
|
||||||
|
case Time_MODE_ON:
|
||||||
|
// 打开
|
||||||
|
Events->isOn = true;
|
||||||
|
if(Events->Ms_delayoff){
|
||||||
|
Events->mode = Time_MODE_OFF;
|
||||||
|
Events->delay =1 + Events->Ms_delayoff;
|
||||||
|
Events->Ms_delayoff =0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Time_MODE_BLINK:
|
||||||
|
// 闪烁
|
||||||
|
if (Events->blinkCount > 0) {
|
||||||
|
if (Events->isOn) {
|
||||||
|
Events->isOn = false;
|
||||||
|
if(0xffff != Events->blinkCount) {Events->blinkCount--;}
|
||||||
|
Events->delay =1 + Events->Ms_off / Time_delay_interval;
|
||||||
|
} else {
|
||||||
|
Events->isOn = true;
|
||||||
|
Events->delay =1 + Events->Ms_on / Time_delay_interval;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Events->mode = Time_MODE_OFF;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Event_Handle(i, Events->isOn,Events->Parameter);
|
||||||
|
}
|
||||||
|
if(Events->delay >= 1){
|
||||||
|
Events->delay--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (Time_delay_interval / 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Time_Event_Init(void) {
|
||||||
|
for (uint16_t i = 0; i < Time_Event_MAX; i++) {
|
||||||
|
Time_Events[i].mode = Time_MODE_OFF;
|
||||||
|
Time_Events[i].delay = 1;
|
||||||
|
Time_Events[i].Ms_on = 0;
|
||||||
|
Time_Events[i].Ms_off = 0;
|
||||||
|
Time_Events[i].blinkCount = 0;
|
||||||
|
Time_Events[i].isOn = false;
|
||||||
|
Time_Events[i].Parameter=NULL;
|
||||||
|
}
|
||||||
|
Time_Event_tmr_id = sftmr_start(10, Time_Event_Handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Time_Event_DelayOff(uint16_t ledIndex ,uint16_t Ms_delayoff,void *Parameter) {
|
||||||
|
Time_Events[ledIndex].mode = Time_MODE_ON;
|
||||||
|
Time_Events[ledIndex].delay = 1;
|
||||||
|
Time_Events[ledIndex].Ms_delayoff =1 + Ms_delayoff;
|
||||||
|
Time_Events[ledIndex].Parameter=Parameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Time_Event_On(uint16_t ledIndex,void *Parameter) {
|
||||||
|
Time_Events[ledIndex].mode = Time_MODE_ON;
|
||||||
|
Time_Events[ledIndex].delay = 1;
|
||||||
|
Time_Events[ledIndex].Parameter=Parameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Time_Event_Off(uint16_t ledIndex,void *Parameter) {
|
||||||
|
Time_Events[ledIndex].mode = Time_MODE_OFF;
|
||||||
|
Time_Events[ledIndex].delay = 1;
|
||||||
|
Time_Events[ledIndex].Parameter=Parameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Time_Event_Blink(uint16_t ledIndex, uint16_t Ms_on, uint16_t Ms_off, uint16_t blinkCount,void *Parameter) {
|
||||||
|
Time_Events[ledIndex].mode = Time_MODE_BLINK;
|
||||||
|
Time_Events[ledIndex].Ms_on = Ms_on;
|
||||||
|
Time_Events[ledIndex].Ms_off = Ms_off;
|
||||||
|
Time_Events[ledIndex].blinkCount = blinkCount;
|
||||||
|
Time_Events[ledIndex].delay =1 + Ms_on / Time_delay_interval;
|
||||||
|
Time_Events[ledIndex].Parameter=Parameter;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
#ifndef _APP_BUZZER_H_
|
||||||
|
#define _APP_BUZZER_H_
|
||||||
|
|
||||||
|
#define Time_delay_interval 50
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
Time_MODE_OFF,
|
||||||
|
Time_MODE_ON,
|
||||||
|
Time_MODE_BLINK
|
||||||
|
} Time_Event_Mode;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
Time_Event_Mode mode;
|
||||||
|
uint16_t delay;
|
||||||
|
uint16_t blinkCount;
|
||||||
|
uint16_t Ms_delayoff;
|
||||||
|
uint16_t Ms_on;
|
||||||
|
uint16_t Ms_off;
|
||||||
|
bool isOn;
|
||||||
|
void *Parameter;
|
||||||
|
} Time_Events_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
Buzzer_Event,
|
||||||
|
GRB_WS2812_Event,
|
||||||
|
Time_Event_MAX
|
||||||
|
} Time_Event_List;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void Time_Event_Init(void);
|
||||||
|
|
||||||
|
void Time_Event_DelayOff(uint16_t ledIndex ,uint16_t Ms_delayoff, void *Parameter);
|
||||||
|
|
||||||
|
void Time_Event_On(uint16_t ledIndex, void *Parameter);
|
||||||
|
|
||||||
|
void Time_Event_Off(uint16_t ledIndex, void *Parameter);
|
||||||
|
|
||||||
|
void Time_Event_Blink(uint16_t ledIndex, uint16_t Ms_on, uint16_t Ms_off, uint16_t blinkCount, void *Parameter);
|
||||||
|
|
||||||
|
#endif
|
|
@ -2,177 +2,146 @@
|
||||||
#include "drvs.h"
|
#include "drvs.h"
|
||||||
#include "dbg.h"
|
#include "dbg.h"
|
||||||
#include "sftmr.h"
|
#include "sftmr.h"
|
||||||
|
#include "sys_config.h"
|
||||||
|
|
||||||
#include "app_uart.h"
|
|
||||||
#include "app_speed_governor.h"
|
|
||||||
#include "app_control_out.h"
|
//管理员模式速度极限
|
||||||
|
uint8_t M_mode_sLim =M_DEFAULT_sLim;
|
||||||
|
//游客模式速度极限
|
||||||
|
uint8_t U_mode_sLim =U_DEFAULT_sLim;
|
||||||
|
|
||||||
// 使能电平
|
// 使能电平
|
||||||
bool app_control_en[PA_MAX]={
|
bool app_control_en[PA_MAX]={
|
||||||
[IN_GPS] =OE_LOW, // GPS超距 /L:超出活动区域(同)
|
[IN_GPS] =OE_LOW, // GPS输入0 /边沿触发/L:低使能(反)
|
||||||
[IN_EXTI0_Custom0] =OE_LOW, // 管理员模式
|
[IN_Back] =OE_LOW, // 倒车 /边沿触发
|
||||||
[OUT_Door_lock] =OE_HIGH, // 开锁 /H:开锁(同)
|
[IN_Brake] =OE_LOW, // 制动 /边沿触发
|
||||||
[OUT_Push_key] =OE_HIGH, // 开启推车 /L:开启推车(反)
|
[IN_Manager_Mode] =OE_LOW, // 管理员模式 /边沿触发
|
||||||
[OUT_Switch_gear] =OE_LOW, // 限速/H:限速(反)
|
|
||||||
[OUT_High_speed] =OE_LOW, // 使能高速档位 /H:高使能(反)
|
[OUT_Buzzer] =OE_HIGH, // 蜂鸣器 /H:高使能
|
||||||
[OUT_Low_speed] =OE_HIGH, // 使能低速档位 /L:低使能(反)
|
[OUT_Low_speed] =OE_HIGH, // 使能低速档位 /L:低使能(反)
|
||||||
[OUT_Back_car] =OE_HIGH, // 使能倒车 /L:低使能倒车(反)
|
[OUT_Back_car] =OE_HIGH, // 使能倒车 /L:低使能倒车(反)
|
||||||
[OUT_Low_brake] =OE_HIGH, // 使能低制动 /L:低使能(反)
|
[OUT_Low_brake] =OE_HIGH, // 使能低制动 /L:低使能(反)
|
||||||
[OUT_High_brake] =OE_LOW // 使能高制动 /H:高使能(反)
|
[OUT_High_brake] =OE_LOW, // 使能高制动 /H:高使能(反)
|
||||||
|
[OUT_Door_lock] =OE_HIGH, // 开锁 /H:开锁(同)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// 油门控制输入初始化/PA08/CH3
|
||||||
|
// 电池电压检测/充电检测/PA04/CH7
|
||||||
|
static void acc_in_bat_in_sadc_init(void)
|
||||||
|
{
|
||||||
|
// Analog Enable
|
||||||
|
GPIO_DIR_CLR(GPIO08 | GPIO04);
|
||||||
|
|
||||||
|
// ADC
|
||||||
|
iom_ctrl(PA04, IOM_ANALOG);//BAT//AIN3//电池电量
|
||||||
|
iom_ctrl(PA08, IOM_ANALOG);//ACC//AIN7//油门
|
||||||
|
|
||||||
|
// sadc init
|
||||||
|
#if SADC_VREF==VREF_VDD
|
||||||
|
sadc_init(SADC_ANA_VREF_VDD);//设置参考电压(3.3V)
|
||||||
|
#elif SADC_VREF==VREF_1V2
|
||||||
|
sadc_init(SADC_ANA_VREF_1V2);//设置参考电压(1.2V)
|
||||||
|
#elif SADC_VREF==VREF_2V4
|
||||||
|
sadc_init(SADC_ANA_VREF_2V4);//设置参考电压(2.4V)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取油门输入信号原始ADC值
|
||||||
|
uint16_t get_in_acc_raw(void){
|
||||||
|
return (sadc_read(SADC_CH_AIN7, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取油门输入电压信号(unit:mV)
|
||||||
|
uint16_t get_in_acc_voltage(void){
|
||||||
|
return ((((SADC_VREF * sadc_read(SADC_CH_AIN7, 3))/1024)/ACC_DOWN_Res)*(ACC_UP_Res+ACC_DOWN_Res));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取输入油门百分比(unit:%)(踏板信号)
|
||||||
|
uint16_t get_in_acc_percent(void){
|
||||||
|
uint16_t acc_voltage =get_in_acc_voltage();
|
||||||
|
if(900 > acc_voltage) {return 0;}
|
||||||
|
else if(3800 < acc_voltage){return 100;}
|
||||||
|
else{
|
||||||
|
return ((acc_voltage-900)/29);
|
||||||
|
// return (100*(acc_voltage - 900)/(3800-900));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取电池电压值(unit:V)
|
||||||
|
float get_bat_voltage(void){
|
||||||
|
return (((((SADC_VREF / 1000.0) * sadc_read(SADC_CH_AIN3, 3))/1024.0)/BAT_DOWN_Res)*(BAT_UP_Res+BAT_DOWN_Res));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 油门调节输出初始化/PWM4/PA05
|
||||||
|
static void acc_out_pwm_init(void){
|
||||||
|
|
||||||
|
iom_ctrl(PA05, IOM_SEL_TIMER);
|
||||||
|
|
||||||
|
// CTMR
|
||||||
|
pwm_init(PWM_CTMR, 15, 1023);//fo =16MHz /((15+1)*(1023+1))
|
||||||
|
|
||||||
|
pwm_chnl_cfg_t chnl_conf;
|
||||||
|
chnl_conf.duty = 0;
|
||||||
|
chnl_conf.ccer = PWM_CCER_SIPH;
|
||||||
|
chnl_conf.ccmr = PWM_CCMR_MODE1;
|
||||||
|
pwm_chnl_set(PWM_CTMR_CH4, &chnl_conf);
|
||||||
|
|
||||||
|
pwm_start(PWM_CTMR);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置输出油门大小
|
||||||
|
void set_out_acc_percent(uint8_t percent){
|
||||||
|
pwm_duty_upd(PWM_CTMR_CH4 , ACC_PERCENT(percent));
|
||||||
|
}
|
||||||
|
|
||||||
//中控控制IO初始化
|
//中控控制IO初始化
|
||||||
void app_control_init(void){
|
void app_control_init(void){
|
||||||
// out
|
// out
|
||||||
gpio_dir_output(OUT_Door_lock,OE_LOW);// 默认锁车
|
gpio_dir_output(OUT_Door_lock,OE_LOW);// 默认锁车
|
||||||
gpio_dir_output(OUT_Push_key,OE_LOW);// 默认关闭推车模式
|
|
||||||
gpio_dir_output(OUT_Switch_gear,OE_LOW);// 默认转把调速模式
|
|
||||||
gpio_dir_output(OUT_High_speed,OE_LOW);// 高速档位,默认失能
|
|
||||||
gpio_dir_output(OUT_Low_speed,OE_LOW);// 低速档位,默认失能
|
gpio_dir_output(OUT_Low_speed,OE_LOW);// 低速档位,默认失能
|
||||||
gpio_dir_output(OUT_Back_car,OE_LOW);// 默认前进模式
|
gpio_dir_output(OUT_Back_car,OE_LOW);// 默认前进模式
|
||||||
gpio_dir_output(OUT_Low_brake,OE_LOW);// 默认关低制动
|
gpio_dir_output(OUT_Low_brake,OE_LOW);// 默认关低制动
|
||||||
gpio_dir_output(OUT_High_brake,OE_HIGH);// 默认关高制动
|
gpio_dir_output(OUT_High_brake,OE_HIGH);// 默认关高制动
|
||||||
|
gpio_dir_output(OUT_Buzzer,OE_LOW);// 默认关蜂鸣器
|
||||||
//in
|
//in
|
||||||
gpio_dir_input(OUT_Door_lock,IE_DOWN);// 默认锁车
|
gpio_dir_input(OUT_Door_lock,IE_DOWN);// 默认锁车
|
||||||
gpio_dir_input(OUT_Push_key,IE_DOWN);// 默认关闭推车模式
|
|
||||||
gpio_dir_input(OUT_Switch_gear,IE_DOWN);// 默认转把调速模式
|
|
||||||
gpio_dir_input(OUT_High_speed,IE_DOWN);// 高速档位,默认失能
|
|
||||||
gpio_dir_input(OUT_Low_speed,IE_DOWN);// 低速档位,默认失能
|
gpio_dir_input(OUT_Low_speed,IE_DOWN);// 低速档位,默认失能
|
||||||
gpio_dir_input(OUT_Back_car,IE_DOWN);// 默认前进模式
|
gpio_dir_input(OUT_Back_car,IE_DOWN);// 默认前进模式
|
||||||
gpio_dir_input(OUT_Low_brake,IE_DOWN);// 默认关低制动
|
gpio_dir_input(OUT_Low_brake,IE_DOWN);// 默认关低制动
|
||||||
gpio_dir_input(OUT_High_brake,IE_UP);// 默认关高制动
|
gpio_dir_input(OUT_High_brake,IE_UP);// 默认关高制动
|
||||||
|
gpio_dir_input(OUT_Buzzer,IE_DOWN);// 默认关蜂鸣器
|
||||||
|
|
||||||
//默认都失能
|
//默认都失能
|
||||||
Set_Status(OUT_Door_lock,0);
|
Set_Status(OUT_Door_lock,0);
|
||||||
Set_Status(OUT_Push_key,0);
|
|
||||||
Set_Status(OUT_Switch_gear,0);
|
|
||||||
Set_Status(OUT_High_speed,0);
|
|
||||||
Set_Status(OUT_Low_speed,0);
|
Set_Status(OUT_Low_speed,0);
|
||||||
Set_Status(OUT_Back_car,0); //失能倒车
|
Set_Status(OUT_Back_car,0); //失能倒车
|
||||||
Set_Status(OUT_Low_brake,0);
|
Set_Status(OUT_Low_brake,0);
|
||||||
Set_Status(OUT_High_brake,0);
|
Set_Status(OUT_High_brake,0);
|
||||||
|
Set_Status(OUT_Buzzer,0);
|
||||||
// app_set_Door_lock_status(0);// 默认锁车
|
|
||||||
// app_set_Push_status(0);// 默认关闭推车模式
|
|
||||||
// app_set_gears_status(0);// 默认转把调速模式
|
|
||||||
// app_set_brake_status(0);// 默认关制动
|
|
||||||
// app_set_Back_car_status(0);// 默认前进模式
|
|
||||||
|
|
||||||
// in
|
// in
|
||||||
gpio_dir_input(IN_EXTI0_Custom0, IE_UP); // Input enable, pull-up
|
gpio_dir_input(IN_GPS, IE_UP); // Input enable, pull-up
|
||||||
// gpio_dir_input(IN_EXTI1_Custom1, IE_UP);
|
gpio_dir_input(IN_Back, IE_UP);
|
||||||
gpio_dir_input(IN_GPS, IE_UP);
|
gpio_dir_input(IN_Brake, IE_UP);
|
||||||
|
gpio_dir_input(IN_Manager_Mode, IE_UP);
|
||||||
|
|
||||||
// EXTI config
|
// // EXTI config
|
||||||
exti_init(EXTI_DBC(15, 4));
|
// exti_init(EXTI_DBC(15, 4));
|
||||||
exti_set(EXTI_FTS, EXTI_SRC(IN_EXTI0_Custom0) | EXTI_SRC(IN_GPS)); // falling
|
// exti_set(EXTI_FTS, EXTI_SRC(IN_GPS) | EXTI_SRC(IN_Back) | EXTI_SRC(IN_Brake) | EXTI_SRC(IN_Manager_Mode)); // falling
|
||||||
exti_set(EXTI_DBE, EXTI_SRC(IN_EXTI0_Custom0) | EXTI_SRC(IN_GPS));
|
// exti_set(EXTI_DBE, EXTI_SRC(IN_GPS) | EXTI_SRC(IN_Back) | EXTI_SRC(IN_Brake) | EXTI_SRC(IN_Manager_Mode));
|
||||||
exti_set(EXTI_IER, EXTI_SRC(IN_EXTI0_Custom0) | EXTI_SRC(IN_GPS));
|
// exti_set(EXTI_IER, EXTI_SRC(IN_GPS) | EXTI_SRC(IN_Back) | EXTI_SRC(IN_Brake) | EXTI_SRC(IN_Manager_Mode));
|
||||||
|
|
||||||
// IRQ enable
|
// IRQ enable
|
||||||
NVIC_EnableIRQ(EXTI_IRQn);
|
// NVIC_EnableIRQ(EXTI_IRQn);
|
||||||
|
|
||||||
|
acc_in_bat_in_sadc_init();
|
||||||
|
acc_out_pwm_init();
|
||||||
|
|
||||||
__enable_irq();
|
__enable_irq();
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取档位状态/0:管理员模式速度无限制/1:游客模式油门限速/2:低速档/3:高速档
|
|
||||||
uint8_t app_get_gears_status(void){
|
|
||||||
uint8_t ret=0;
|
|
||||||
|
|
||||||
if(0 ==Get_Status(OUT_Switch_gear) && 1 ==Get_Status(OUT_High_speed) && 0 ==Get_Status(OUT_Low_speed)){
|
|
||||||
ret =0;
|
|
||||||
}else if(0 ==Get_Status(OUT_Switch_gear) && 0 ==Get_Status(OUT_High_speed) && 1 ==Get_Status(OUT_Low_speed)){
|
|
||||||
ret =1;
|
|
||||||
}else if(1 ==Get_Status(OUT_Switch_gear) && 0 ==Get_Status(OUT_High_speed) && 0 ==Get_Status(OUT_Low_speed)){
|
|
||||||
ret =2;
|
|
||||||
}else if(0 ==Get_Status(OUT_Switch_gear) && 0 ==Get_Status(OUT_High_speed) && 0 ==Get_Status(OUT_Low_speed)){
|
|
||||||
ret =3;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
//设置档位状态/0:管理员模式速度无限制/1:游客模式油门限速/2:低速档/3:高速档
|
|
||||||
uint8_t app_set_gears_status(uint8_t val){
|
|
||||||
if(0 ==val){ //管理员模式速度无限制
|
|
||||||
Set_Status(OUT_Switch_gear,0);
|
|
||||||
Set_Status(OUT_High_speed,1);
|
|
||||||
Set_Status(OUT_Low_speed,0);
|
|
||||||
}else if(1 ==val){//游客模式油门限速
|
|
||||||
Set_Status(OUT_Switch_gear,0);
|
|
||||||
Set_Status(OUT_High_speed,0);
|
|
||||||
Set_Status(OUT_Low_speed,1);
|
|
||||||
}else if(2 ==val){//低速模式
|
|
||||||
Set_Status(OUT_Switch_gear,1);
|
|
||||||
Set_Status(OUT_High_speed,0);
|
|
||||||
Set_Status(OUT_Low_speed,0);
|
|
||||||
}else if(3 ==val){//高速模式
|
|
||||||
Set_Status(OUT_Switch_gear,0);
|
|
||||||
Set_Status(OUT_High_speed,0);
|
|
||||||
Set_Status(OUT_Low_speed,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return app_get_gears_status();
|
|
||||||
}
|
|
||||||
|
|
||||||
//获取刹车状态/0:取消刹车/1:低刹/2:高刹
|
|
||||||
uint8_t app_get_brake_status(void){
|
|
||||||
uint8_t ret=0;
|
|
||||||
|
|
||||||
if(0 ==Get_Status(OUT_Low_brake) && 0 ==Get_Status(OUT_High_brake)){
|
|
||||||
ret =0;
|
|
||||||
}else if(1 ==Get_Status(OUT_Low_brake) && 0 ==Get_Status(OUT_High_brake)){
|
|
||||||
ret =1;
|
|
||||||
}else if(0 ==Get_Status(OUT_Low_brake) && 1 ==Get_Status(OUT_High_brake)){
|
|
||||||
ret =2;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
//设置刹车状态/0:取消刹车/1:低刹/2:高刹
|
|
||||||
uint8_t app_set_brake_status(uint8_t val){
|
|
||||||
if(1 ==val){//低刹
|
|
||||||
Set_Status(OUT_Low_brake,1);
|
|
||||||
Set_Status(OUT_High_brake,0);
|
|
||||||
}else if(2 ==val){//高刹
|
|
||||||
Set_Status(OUT_Low_brake,0);
|
|
||||||
Set_Status(OUT_High_brake,1);
|
|
||||||
}else{ //无刹
|
|
||||||
Set_Status(OUT_Low_brake,0);
|
|
||||||
Set_Status(OUT_High_brake,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return app_get_brake_status();
|
|
||||||
}
|
|
||||||
|
|
||||||
//获取电门锁状态设置/0:锁车状态/1:开锁状态
|
|
||||||
uint8_t app_get_Door_lock_status(void){
|
|
||||||
|
|
||||||
return Get_Status(OUT_Door_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
//电门锁状态设置/0:锁车/1:开锁
|
|
||||||
uint8_t app_set_Door_lock_status(bool val){
|
|
||||||
Set_Status(OUT_Door_lock,val);
|
|
||||||
|
|
||||||
return Get_Status(OUT_Door_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
//推车模式设置/0:退出推车状态/1:推车状态
|
|
||||||
uint8_t app_set_Push_status(bool val){
|
|
||||||
|
|
||||||
Set_Status(OUT_Push_key,val);
|
|
||||||
|
|
||||||
return Get_Status(OUT_Push_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
//设置行驶方向/0:前进;1:倒车
|
|
||||||
uint8_t app_set_Back_car_status(bool val){
|
|
||||||
Set_Status(OUT_Back_car,val);
|
|
||||||
|
|
||||||
return Get_Status(OUT_Back_car);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// GPIO外部中端处理
|
// GPIO外部中端处理
|
||||||
void EXTI_IRQHandler(void)
|
void EXTI_IRQHandler(void)
|
||||||
{
|
{
|
||||||
|
@ -181,24 +150,49 @@ void EXTI_IRQHandler(void)
|
||||||
if (irq_sta & EXTI_SRC(IN_GPS))//
|
if (irq_sta & EXTI_SRC(IN_GPS))//
|
||||||
{
|
{
|
||||||
EXTI->ICR.Word = EXTI_SRC(IN_GPS);
|
EXTI->ICR.Word = EXTI_SRC(IN_GPS);
|
||||||
if(1==Get_Status(IN_GPS)){
|
|
||||||
Set_Status(OUT_Door_lock,0);//GPS超出范围,直接锁车
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (irq_sta & EXTI_SRC(IN_EXTI0_Custom0))
|
if (irq_sta & EXTI_SRC(IN_Back))
|
||||||
{
|
{
|
||||||
EXTI->ICR.Word = EXTI_SRC(IN_EXTI0_Custom0);
|
EXTI->ICR.Word = EXTI_SRC(IN_Back);
|
||||||
if(1==Get_Status(IN_EXTI0_Custom0)){ //进入管理员模式
|
|
||||||
Set_Status(OUT_High_speed,1);//开启高速模式
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (irq_sta & EXTI_SRC(IN_EXTI1_Custom1))
|
if (irq_sta & EXTI_SRC(IN_Brake))
|
||||||
{
|
{
|
||||||
EXTI->ICR.Word = EXTI_SRC(IN_EXTI1_Custom1);
|
EXTI->ICR.Word = EXTI_SRC(IN_Brake);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (irq_sta & EXTI_SRC(IN_Manager_Mode))
|
||||||
|
{
|
||||||
|
EXTI->ICR.Word = EXTI_SRC(IN_Manager_Mode);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PAD控制进入管理员模式
|
||||||
|
bool PAD_Manager_Mode=0;
|
||||||
|
// PAD控制进入游客模式
|
||||||
|
bool PAD_User_Mode=0;
|
||||||
|
// 系统自动刹车
|
||||||
|
bool SYS_AUTO_brake=0;
|
||||||
|
// 系统自动减速
|
||||||
|
bool SYS_AUTO_Speed_Cut=0;
|
||||||
|
|
||||||
|
// 控制进程,定时调用
|
||||||
|
void Control_procedure(void){
|
||||||
|
|
||||||
|
//电门锁
|
||||||
|
Set_Status(OUT_Door_lock,(PAD_User_Mode || PAD_Manager_Mode || Get_Status(IN_GPS) || Get_Status(IN_Manager_Mode) ));
|
||||||
|
|
||||||
|
// 倒车
|
||||||
|
Set_Status(OUT_Back_car,Get_Status(IN_Back));
|
||||||
|
// 刹车
|
||||||
|
Set_Status(OUT_Low_brake,(Get_Status(IN_Brake) || SYS_AUTO_brake));
|
||||||
|
Set_Status(OUT_High_brake,(Get_Status(IN_Brake) || SYS_AUTO_brake));
|
||||||
|
|
||||||
|
//油门控制
|
||||||
|
set_out_acc_percent((SYS_AUTO_Speed_Cut?0.5:1)*get_in_acc_percent()*((PAD_Manager_Mode || Get_Status(IN_Manager_Mode)) ? sys_conf_info.M_mode_sLim : sys_conf_info.U_mode_sLim) / 100.0);
|
||||||
|
}
|
||||||
|
|
|
@ -1,77 +1,67 @@
|
||||||
#ifndef _APP_CONTROL_OUT_H_
|
#ifndef _APP_CONTROL_OUT_H_
|
||||||
#define _APP_CONTROL_OUT_H_
|
#define _APP_CONTROL_OUT_H_
|
||||||
#include "b6x.h"
|
|
||||||
#include "drvs.h"
|
// ADC参考电压
|
||||||
|
#define VREF_1V2 1200
|
||||||
|
#define VREF_2V4 2400
|
||||||
|
#define VREF_VDD 3300
|
||||||
|
#define SADC_VREF VREF_2V4
|
||||||
|
|
||||||
|
// Dmin =(0.9V*(1024/3.3))/2 =139.6;
|
||||||
|
// Dmax =(3.8V*(1024/3.3))/2 =589.6;
|
||||||
|
#define ACC_Dmin 138
|
||||||
|
#define ACC_Dmax 591
|
||||||
|
|
||||||
|
#define ACC_PERCENT(s) (ACC_Dmin + ((ACC_Dmax - ACC_Dmin)*(s))/100)
|
||||||
|
|
||||||
|
|
||||||
// GPIO的输出需反向
|
// GPIO的输出需反向
|
||||||
enum app_control{
|
enum app_control{
|
||||||
IN_GPS =PA03, // GPS输入/0:被拉低就执行锁车
|
IN_GPS =PA09, // GPS输入0 /边沿触发
|
||||||
IN_EXTI0_Custom0 =PA08, // 自定义输入0
|
IN_Back =PA10, // 倒车 /边沿触发
|
||||||
IN_EXTI1_Custom1 =PA09, // 自定义输入1 /防盗检测/下降沿触发防盗
|
IN_Brake =PA11, // 制动 /边沿触发
|
||||||
OUT_Door_lock =PA18, // 电门锁 /H:开锁
|
IN_Manager_Mode =PA12, // 管理员模式 /边沿触发
|
||||||
OUT_Push_key =PA14, // 推车键 /L:开启推车
|
|
||||||
OUT_Switch_gear =PA13, // 调速模式选择/H:限速模式/L:不限速
|
OUT_Buzzer =PA13, // 蜂鸣器 /H:高使能
|
||||||
OUT_High_speed =PA11, // 高速档位 /L:低使能
|
OUT_Low_speed =PA14, // 低速档位 /L:低使能
|
||||||
OUT_Low_speed =PA12, // 低速档位 /L:低使能
|
|
||||||
OUT_Back_car =PA15, // 前进后退 /H:前进/L:后退
|
OUT_Back_car =PA15, // 前进后退 /H:前进/L:后退
|
||||||
OUT_Low_brake =PA16, // 低制动 /L:低使能
|
OUT_Low_brake =PA16, // 低制动 /L:低使能
|
||||||
OUT_High_brake =PA17 // 高制动 /H:低使能
|
OUT_High_brake =PA17, // 高制动 /H:低使能
|
||||||
|
OUT_Door_lock =PA18, // 电门锁 /H:开锁
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//enum app_control{
|
|
||||||
// IN_GPS =PA08, // GPS输入/0:锁车
|
|
||||||
// IN_EXTI0_Custom0 =PA08, // 自定义输入0
|
|
||||||
// IN_EXTI1_Custom1 =PA09, // 自定义输入1 /防盗检测/下降沿触发防盗
|
|
||||||
|
|
||||||
// OUT_Door_lock =PA13, // 电门锁 /1:开锁
|
|
||||||
// OUT_Push_key =PA12, // 推车键 /1:开启推车
|
|
||||||
// OUT_Switch_gear =PA11, // 调速模式选择/1:限速模式/0:不限速
|
|
||||||
// OUT_High_speed =PA14, // 高速档位 /1:使能
|
|
||||||
// OUT_Low_speed =PA15, // 低速档位 /1:使能
|
|
||||||
// OUT_Back_car =PA16, // 前进后退 /0:前进/1:后退
|
|
||||||
// OUT_Low_brake =PA17, // 低制动 /1:使能
|
|
||||||
// OUT_High_brake =PA18 // 高制动 /1:使能
|
|
||||||
//};
|
|
||||||
|
|
||||||
extern bool app_control_en[PA_MAX];
|
extern bool app_control_en[PA_MAX];
|
||||||
|
|
||||||
|
// PAD控制进入管理员模式
|
||||||
|
extern bool PAD_Manager_Mode;
|
||||||
|
// PAD控制进入游客模式
|
||||||
|
extern bool PAD_User_Mode;
|
||||||
|
// 系统自动刹车
|
||||||
|
extern bool SYS_AUTO_brake;
|
||||||
|
// 系统自动减速
|
||||||
|
extern bool SYS_AUTO_Speed_Cut;
|
||||||
|
|
||||||
// 写1使能,写0失能
|
// 写1使能,写0失能
|
||||||
#define Set_Status(pad,activity) (gpio_put(pad, ((0 == activity) ? !app_control_en[pad] : app_control_en[pad])))
|
#define Set_Status(pad,activity) (gpio_put(pad, ((0 == activity) ? !app_control_en[pad] : app_control_en[pad])))
|
||||||
|
// 获取状态 1使能,0失能
|
||||||
#define Get_Status(pad) ((app_control_en[pad] == gpio_get(pad)) ? 1 : 0)
|
#define Get_Status(pad) ((app_control_en[pad] == gpio_get(pad)) ? 1 : 0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//中控控制IO初始化
|
//中控控制IO初始化
|
||||||
void app_control_init(void);
|
void app_control_init(void);
|
||||||
|
|
||||||
// 设置控制状态
|
// 获取电池电压值(unit:V)
|
||||||
bool app_set_control_status(uint8_t pad, uint8_t val);
|
float get_bat_voltage(void);
|
||||||
|
|
||||||
//获取档位状态/0:管理员模式速度无限制/1:游客模式油门限速/2:低速档/3:高速档
|
// 获取输入油门百分比(unit:%)(踏板信号)
|
||||||
uint8_t app_get_gears_status(void);
|
uint16_t get_in_acc_percent(void);
|
||||||
|
// 设置输出油门百分比(unit:%)
|
||||||
//获取刹车状态/0:取消刹车/1:低刹/2:高刹
|
void set_out_acc_percent(uint8_t percent);
|
||||||
uint8_t app_get_brake_status(void);
|
|
||||||
|
|
||||||
|
|
||||||
//设置档位状态/0:管理员模式速度无限制/1:游客模式油门限速/2:低速档/3:高速档
|
// 控制进程,定时调用
|
||||||
uint8_t app_set_gears_status(uint8_t val);
|
void Control_procedure(void);
|
||||||
|
|
||||||
//设置刹车状态/0:取消刹车/1:低刹/2:高刹
|
|
||||||
uint8_t app_set_brake_status(uint8_t val);
|
|
||||||
|
|
||||||
//获取电门锁状态
|
|
||||||
uint8_t app_get_Door_lock_status(void);
|
|
||||||
//电门锁状态设置/0:锁车状态/1:开锁状态
|
|
||||||
uint8_t app_set_Door_lock_status(bool val);
|
|
||||||
|
|
||||||
//推车模式设置/0:退出推车状态/1:推车状态
|
|
||||||
uint8_t app_set_Push_status(bool val);
|
|
||||||
|
|
||||||
//设置行驶方向/0:前进;1:倒车
|
|
||||||
uint8_t app_set_Back_car_status(bool val);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,160 @@
|
||||||
|
#include "b6x.h"
|
||||||
|
#include "drvs.h"
|
||||||
|
#include "dbg.h"
|
||||||
|
#include "app_radar.h"
|
||||||
|
#include "sftmr.h"
|
||||||
|
|
||||||
|
#include "sys_config.h"
|
||||||
|
|
||||||
|
|
||||||
|
radar_daraframe_t radar_daraframe;
|
||||||
|
|
||||||
|
// 定时处理数和获取数据
|
||||||
|
tmr_id_t radar_timer_tmr_id;
|
||||||
|
|
||||||
|
bool radar_flag=0;
|
||||||
|
uint8_t radar_flag_cnt=0;
|
||||||
|
|
||||||
|
// uint8_t radar_str[50]={0,0},radar_str_len=0;
|
||||||
|
|
||||||
|
// 定时处理数和获取数据
|
||||||
|
static tmr_tk_t radar_timer_handler(tmr_id_t id){
|
||||||
|
(void)(id);
|
||||||
|
uint16_t Car_Distance=0;
|
||||||
|
|
||||||
|
if(Get_Status(OUT_Door_lock)){
|
||||||
|
// 定时发送状态信息
|
||||||
|
if(radar_flag_cnt > 4){
|
||||||
|
uint8_t ret_data[12]={0,0};
|
||||||
|
radar_flag_cnt =0;
|
||||||
|
ret_data[radar_flag_cnt++] =BAT_Message.Bat_STA; // 电池状态
|
||||||
|
ret_data[radar_flag_cnt++] =BAT_Message.Bat_Voltage >> 8; //电池电压
|
||||||
|
ret_data[radar_flag_cnt++] =BAT_Message.Bat_Voltage & 0xff;
|
||||||
|
ret_data[radar_flag_cnt++] =get_in_acc_percent();// 当前油门百分比
|
||||||
|
ret_data[radar_flag_cnt++] =(Get_Status(IN_GPS)<<0) | (Get_Status(IN_Back)<<1) | (Get_Status(OUT_Low_brake)<<2)
|
||||||
|
| (Get_Status(IN_Manager_Mode)<<3) | (Get_Status(PAD_Manager_Mode)<<4)
|
||||||
|
| (Get_Status(PAD_User_Mode)<<5);
|
||||||
|
app_uart_Sendcmd(UART1_PORT,0x10,0x01,ret_data,radar_flag_cnt);
|
||||||
|
radar_flag_cnt =0;
|
||||||
|
}else {
|
||||||
|
radar_flag_cnt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(radar_flag == 1){
|
||||||
|
// radar_str_len =sprintf((char *)radar_str, "F=%d,B=%d\n", radar_daraframe.Front_data ,radar_daraframe.Back_data);
|
||||||
|
// uart_send(UART1_PORT,radar_str_len,radar_str);
|
||||||
|
radar_flag = 0;
|
||||||
|
}
|
||||||
|
if(Get_Status(OUT_Door_lock) && !(PAD_Manager_Mode || Get_Status(IN_Manager_Mode))){
|
||||||
|
if(Get_Status(IN_Back)){//如果是倒车状态
|
||||||
|
// uint8_t data[8]={0x02,0x03,0x01,0x00,0x00,0x01,0x85,0xC5};//读取处理值数据//520ms
|
||||||
|
uint8_t data[8]={0x02,0x03,0x01,0x01,0x00,0x01,0xD4,0x05};////读取实时值数据//120ms
|
||||||
|
Car_Distance =radar_daraframe.Back_data/100;
|
||||||
|
radar_daraframe.Back_data=0xffff;
|
||||||
|
uart_send(UART1_PORT,8,data);
|
||||||
|
}else{
|
||||||
|
// uint8_t data[8]={0x01,0x03,0x01,0x00,0x00,0x01,0x85,0xf6};//读取处理值数据//520ms
|
||||||
|
uint8_t data[8]={0x01,0x03,0x01,0x01,0x00,0x01,0xD4,0x36};//读取实时值数据//120ms
|
||||||
|
Car_Distance =radar_daraframe.Front_data/100;
|
||||||
|
radar_daraframe.Front_data=0xffff;
|
||||||
|
uart_send(UART1_PORT,8,data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Car_Distance < (Get_Status(IN_Back)?sys_conf_info.AUTO_Brake_Distance_B :sys_conf_info.AUTO_Brake_Distance)){//小于自动刹车距离时
|
||||||
|
if(!SYS_AUTO_brake){
|
||||||
|
Time_Event_Blink(Buzzer_Event,100,100,0xffff,NULL);
|
||||||
|
}
|
||||||
|
SYS_AUTO_brake =1;//使能自动刹车
|
||||||
|
SYS_AUTO_Speed_Cut=1;
|
||||||
|
}else if(Car_Distance < (Get_Status(IN_Back)?sys_conf_info.AUTO_Speed_Cut_Distance_B :sys_conf_info.AUTO_Speed_Cut_Distance)){//小于自动减速距离时
|
||||||
|
if(SYS_AUTO_brake || !SYS_AUTO_Speed_Cut){
|
||||||
|
Time_Event_Blink(Buzzer_Event,200,500,0xffff,NULL);
|
||||||
|
}
|
||||||
|
SYS_AUTO_brake =0;
|
||||||
|
SYS_AUTO_Speed_Cut=1;
|
||||||
|
}else{
|
||||||
|
if(SYS_AUTO_brake || SYS_AUTO_Speed_Cut){
|
||||||
|
Time_Event_Off(Buzzer_Event,NULL);
|
||||||
|
}
|
||||||
|
SYS_AUTO_brake =0;
|
||||||
|
SYS_AUTO_Speed_Cut=0;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(SYS_AUTO_brake || SYS_AUTO_Speed_Cut){
|
||||||
|
Time_Event_Off(Buzzer_Event,NULL);
|
||||||
|
}
|
||||||
|
SYS_AUTO_brake =0;
|
||||||
|
SYS_AUTO_Speed_Cut=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _MS(300);//300ms
|
||||||
|
}
|
||||||
|
|
||||||
|
// 雷达测离初始化
|
||||||
|
void app_radar_init(void){
|
||||||
|
// sftmr_init(); //main函数中已初始化
|
||||||
|
radar_timer_tmr_id = sftmr_start(10, radar_timer_handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t radar_buff[10],radar_state;
|
||||||
|
uint16_t i;
|
||||||
|
|
||||||
|
// 串口数据接收
|
||||||
|
void app_radar_Receive(uint8_t data){
|
||||||
|
switch(radar_state){
|
||||||
|
case 0://dev_addr
|
||||||
|
if (data == 0x01 || data == 0x02) {
|
||||||
|
radar_buff[0]=data;
|
||||||
|
radar_state = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1://cmd_id
|
||||||
|
if (data == 0x03) {
|
||||||
|
radar_buff[1]=data;
|
||||||
|
radar_state = 2;
|
||||||
|
}else {
|
||||||
|
radar_state = 0;
|
||||||
|
radar_buff[0]=0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2://length
|
||||||
|
if (data == 0x02) {
|
||||||
|
radar_buff[2]=data;
|
||||||
|
radar_state = 3;
|
||||||
|
i=0;
|
||||||
|
}else {
|
||||||
|
radar_state = 0;
|
||||||
|
radar_buff[0]=0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3://data
|
||||||
|
radar_buff[3+i] =data;
|
||||||
|
i++;
|
||||||
|
if(i==2){
|
||||||
|
i=0;
|
||||||
|
radar_state = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 4://crc16
|
||||||
|
radar_buff[5+i] =data;
|
||||||
|
i++;
|
||||||
|
if(i==2){
|
||||||
|
uint16_t crc16 =crc16_checkout(radar_buff,5);
|
||||||
|
if(crc16 == (((uint16_t)radar_buff[6] << 8 ) | radar_buff[5])){
|
||||||
|
if(0x01 == radar_buff[0]){
|
||||||
|
radar_daraframe.Front_data = ((uint16_t)radar_buff[3] << 8 ) | radar_buff[4];
|
||||||
|
}else if(0x02 == radar_buff[0]){
|
||||||
|
radar_daraframe.Back_data = ((uint16_t)radar_buff[3] << 8 ) | radar_buff[4];
|
||||||
|
}
|
||||||
|
radar_flag = 1;
|
||||||
|
}
|
||||||
|
i=0;
|
||||||
|
radar_state = 0;
|
||||||
|
radar_buff[0]=0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
#ifndef _RADAR_H_
|
||||||
|
#define _RADAR_H_
|
||||||
|
#include "sftmr.h"
|
||||||
|
|
||||||
|
#define BUFF_MAX 10
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct radar_daraframe{
|
||||||
|
volatile uint16_t Front_data;
|
||||||
|
volatile uint16_t Back_data;
|
||||||
|
} radar_daraframe_t;
|
||||||
|
|
||||||
|
extern radar_daraframe_t radar_daraframe;
|
||||||
|
extern uint8_t radar_buff[];
|
||||||
|
extern uint8_t Rec_lenght;
|
||||||
|
|
||||||
|
// 雷达测离初始化
|
||||||
|
void app_radar_init(void);
|
||||||
|
|
||||||
|
// 串口数据接收
|
||||||
|
void app_radar_Receive(uint8_t data);
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,88 +0,0 @@
|
||||||
#include "b6x.h"
|
|
||||||
#include "drvs.h"
|
|
||||||
#include "dbg.h"
|
|
||||||
#include "app_speed_governor.h"
|
|
||||||
#include "sftmr.h"
|
|
||||||
#include "app_control_out.h"
|
|
||||||
#include "app_uart.h"
|
|
||||||
|
|
||||||
#define speed_timeout 500
|
|
||||||
#define radar_timeout 500
|
|
||||||
|
|
||||||
extern radar_daraframe_t radar_daraframe;
|
|
||||||
|
|
||||||
|
|
||||||
tmr_id_t speed_tmr_id; // softTimer ID
|
|
||||||
tmr_id_t radar_tmr_id;
|
|
||||||
|
|
||||||
static tmr_tk_t speed_timer_handler(tmr_id_t id);
|
|
||||||
static tmr_tk_t radar_timer_handler(tmr_id_t id);
|
|
||||||
|
|
||||||
//转把速度调节初始化/PWM4/PA05
|
|
||||||
void app_speed_governing_init(int8_t c8_speed){
|
|
||||||
|
|
||||||
if(c8_speed >= 0){
|
|
||||||
app_set_Back_car_status(0);//前进
|
|
||||||
}else{
|
|
||||||
app_set_Back_car_status(1);//后退
|
|
||||||
c8_speed = -c8_speed;
|
|
||||||
}
|
|
||||||
|
|
||||||
iom_ctrl(PA05, IOM_SEL_TIMER);
|
|
||||||
|
|
||||||
// CTMR
|
|
||||||
pwm_init(PWM_CTMR, 15, 999);//fo =16MHz /((15+1)*(999+1))
|
|
||||||
|
|
||||||
pwm_chnl_cfg_t chnl_conf;
|
|
||||||
chnl_conf.duty = SPEED(c8_speed);
|
|
||||||
chnl_conf.ccer = PWM_CCER_SIPH;
|
|
||||||
chnl_conf.ccmr = PWM_CCMR_MODE1;
|
|
||||||
pwm_chnl_set(PWM_CTMR_CH4, &chnl_conf);
|
|
||||||
|
|
||||||
pwm_start(PWM_CTMR);
|
|
||||||
|
|
||||||
sftmr_init();
|
|
||||||
speed_tmr_id = sftmr_start(10, speed_timer_handler);
|
|
||||||
radar_tmr_id = sftmr_start(10, radar_timer_handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
static tmr_tk_t speed_timer_handler(tmr_id_t id){
|
|
||||||
|
|
||||||
(void)(id);
|
|
||||||
|
|
||||||
// app_set_Back_car_status(0);//前进
|
|
||||||
pwm_duty_upd(PWM_CTMR_CH4 , 0);//速度清零
|
|
||||||
uart_putc(UART1_PORT,'S');
|
|
||||||
return 0;//单次
|
|
||||||
}
|
|
||||||
|
|
||||||
static tmr_tk_t radar_timer_handler(tmr_id_t id){
|
|
||||||
|
|
||||||
(void)(id);
|
|
||||||
|
|
||||||
radar_daraframe.Left_data =0;
|
|
||||||
radar_daraframe.Right_data =0;
|
|
||||||
uart_putc(UART1_PORT,'R');
|
|
||||||
return 0;//单次
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//设置速度 0~100
|
|
||||||
void app_set_speed(int8_t c8_speed){
|
|
||||||
if(c8_speed >= 0){
|
|
||||||
app_set_Back_car_status(0);//前进
|
|
||||||
}else{
|
|
||||||
app_set_Back_car_status(1);//后退
|
|
||||||
c8_speed = -c8_speed;
|
|
||||||
}
|
|
||||||
sftmr_Refresh(speed_tmr_id,_MS(speed_timeout));
|
|
||||||
pwm_duty_upd(PWM_CTMR_CH4 , SPEED(c8_speed));
|
|
||||||
}
|
|
||||||
|
|
||||||
//刷新雷达数据
|
|
||||||
void app_updata_radar(void){
|
|
||||||
sftmr_Refresh(radar_tmr_id,_MS(radar_timeout));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
#ifndef _SPEED_GOVERNOR_H_
|
|
||||||
#define _SPEED_GOVERNOR_H_
|
|
||||||
#include "sftmr.h"
|
|
||||||
|
|
||||||
#define PWM_MIN 136
|
|
||||||
#define PWM_MAX 580
|
|
||||||
|
|
||||||
#define SPEED(s) (PWM_MIN + ((PWM_MAX-PWM_MIN)*(s))/100)
|
|
||||||
|
|
||||||
|
|
||||||
//转把速度调节初始化/PWM4/PA05
|
|
||||||
void app_speed_governing_init(int8_t c8_speed);
|
|
||||||
|
|
||||||
//设置速度
|
|
||||||
void app_set_speed(int8_t c8_speed);
|
|
||||||
|
|
||||||
//刷新雷达数据
|
|
||||||
void app_updata_radar(void);
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -2,10 +2,7 @@
|
||||||
#include "drvs.h"
|
#include "drvs.h"
|
||||||
#include "dbg.h"
|
#include "dbg.h"
|
||||||
#include "rbuf.h"
|
#include "rbuf.h"
|
||||||
#include "app_uart.h"
|
#include "sys_config.h"
|
||||||
#include "app_speed_governor.h"
|
|
||||||
#include "app_control_out.h"
|
|
||||||
#include "app_ws2812.h"
|
|
||||||
|
|
||||||
void app_uart_Init(uint8_t port, uint32_t baudrate, uint8_t io_tx, uint8_t io_rx)
|
void app_uart_Init(uint8_t port, uint32_t baudrate, uint8_t io_tx, uint8_t io_rx)
|
||||||
{
|
{
|
||||||
|
@ -36,88 +33,68 @@ uint8_t crc8_checkout(uint8_t *buff, uint8_t length)
|
||||||
return crc;
|
return crc;
|
||||||
}
|
}
|
||||||
|
|
||||||
radar_daraframe_t radar_daraframe;
|
// CRC-16/MODBUS polynomial: x^16 + x^15 + x^2 + 1 (0x8005)
|
||||||
|
uint16_t crc16_checkout(uint8_t *buff, uint16_t length) {
|
||||||
|
uint8_t i;
|
||||||
|
uint16_t crc = 0xffff; // Initial value
|
||||||
|
while (length--)
|
||||||
|
{
|
||||||
|
crc ^= *buff++;
|
||||||
|
for (i = 0; i < 8; ++i)
|
||||||
|
{
|
||||||
|
if (crc & 1)
|
||||||
|
crc = (crc >> 1) ^ 0xA001; // 0xA001 = reverse 0x8005
|
||||||
|
else
|
||||||
|
crc = (crc >> 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uart_daraframe_t uart1_daraframe;
|
uart_daraframe_t uart1_daraframe;
|
||||||
volatile uint8_t uart1_state =0;
|
volatile uint8_t uart1_state =0;
|
||||||
volatile uint8_t uart1_data_cnt =0;
|
volatile uint8_t uart1_data_cnt =0;
|
||||||
|
|
||||||
extern GRB_Data_t WS2812_GRBs;
|
|
||||||
bool uart2_Back_car=0;
|
bool uart2_Back_car=0;
|
||||||
|
|
||||||
static void app_uart1_hande(void){
|
static void app_uart1_hande(void){
|
||||||
uint8_t ret_data[MAX_LEN]={0,0};
|
uint8_t ret_data[MAX_LEN]={0,0};
|
||||||
uint8_t length;
|
uint8_t length=0;
|
||||||
|
|
||||||
switch(uart1_daraframe.cmd_id){
|
switch(uart1_daraframe.cmd_id){
|
||||||
case 0x01://电门锁
|
case 0x01: // 配置系统参数
|
||||||
if(1 ==uart1_daraframe.length){//电门锁状态设置/0:锁车状态/1:开锁状态
|
sys_conf_info.M_mode_sLim= uart1_daraframe.data[0];
|
||||||
ret_data[0] =app_set_Door_lock_status(uart1_daraframe.data[0]);
|
sys_conf_info.U_mode_sLim= uart1_daraframe.data[1];
|
||||||
length = 1;
|
sys_conf_info.AUTO_Brake_Distance= uart1_daraframe.data[2];
|
||||||
app_uart_Sendcmd(UART1_PORT, uart1_daraframe.cmd_id, uart1_daraframe.reg_addr, ret_data, length);
|
sys_conf_info.AUTO_Speed_Cut_Distance= uart1_daraframe.data[3];
|
||||||
}
|
sys_conf_info.AUTO_Brake_Distance_B= uart1_daraframe.data[4];
|
||||||
|
sys_conf_info.AUTO_Speed_Cut_Distance_B= uart1_daraframe.data[5];
|
||||||
|
write_cfg(&sys_conf_info);
|
||||||
|
case 0x02: // 读取系统配置
|
||||||
|
ret_data[length++]=sys_conf_info.M_mode_sLim;
|
||||||
|
ret_data[length++]=sys_conf_info.U_mode_sLim;
|
||||||
|
ret_data[length++]=sys_conf_info.AUTO_Brake_Distance;
|
||||||
|
ret_data[length++]=sys_conf_info.AUTO_Speed_Cut_Distance;
|
||||||
|
ret_data[length++]=sys_conf_info.AUTO_Brake_Distance_B;
|
||||||
|
ret_data[length++]=sys_conf_info.AUTO_Speed_Cut_Distance_B;
|
||||||
|
|
||||||
|
app_uart_Sendcmd(UART1_PORT,uart1_daraframe.cmd_id,0x01,ret_data,length);
|
||||||
break;
|
break;
|
||||||
case 0x02://油门控制
|
case 0x03: //0 命令控制进入管理员模式//1 命令控制进入游客模式
|
||||||
if(3 ==uart1_daraframe.length){
|
PAD_Manager_Mode =uart1_daraframe.data[0];
|
||||||
if(1==Get_Status(IN_GPS)){
|
PAD_User_Mode =uart1_daraframe.data[1];
|
||||||
Set_Status(OUT_Door_lock,0);//GPS超出范围,直接锁车
|
if(1==PAD_User_Mode && 1==PAD_Manager_Mode){
|
||||||
}
|
PAD_User_Mode=0;
|
||||||
if(app_get_Door_lock_status()){//开锁时
|
PAD_Manager_Mode=1;
|
||||||
if(0 > *(int8_t *)(&uart1_daraframe.data[0])){//倒车
|
|
||||||
if(1 == uart2_Back_car){
|
|
||||||
// NVIC_EnableIRQ(UART2_IRQn);
|
|
||||||
// app_uart_Init(UART2_PORT,9600,PA10,PA04);//倒车雷达
|
|
||||||
}
|
|
||||||
uart2_Back_car =0;
|
|
||||||
|
|
||||||
}else {//前进
|
|
||||||
if(0 == uart2_Back_car){
|
|
||||||
// NVIC_DisableIRQ(UART2_IRQn);
|
|
||||||
// app_uart_Init(UART2_PORT,9600,PA10,PA09);//磁刹控制器
|
|
||||||
}
|
|
||||||
uart2_Back_car =1;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
app_set_speed(*(int8_t *)(&uart1_daraframe.data[0]));
|
|
||||||
ret_data[0] = uart1_daraframe.data[0];//当前油门状态 倒车:-100~0 / 前进:0~100
|
|
||||||
ret_data[1] = app_set_brake_status(uart1_daraframe.data[1]);//当前刹车状态
|
|
||||||
if(1==Get_Status(IN_EXTI0_Custom0)){
|
|
||||||
ret_data[2] = app_set_gears_status(0);//进入管理员模式
|
|
||||||
}else {
|
|
||||||
ret_data[2] = app_set_gears_status(uart1_daraframe.data[2]);//当前速度档位
|
|
||||||
}
|
|
||||||
ret_data[3] = radar_daraframe.Left_data;
|
|
||||||
ret_data[4] = radar_daraframe.Right_data;
|
|
||||||
length = 5;
|
|
||||||
app_uart_Sendcmd(UART1_PORT, uart1_daraframe.cmd_id, uart1_daraframe.reg_addr, ret_data, length);
|
|
||||||
}else{
|
|
||||||
|
|
||||||
ret_data[0] = app_get_Door_lock_status();
|
|
||||||
length = 1;
|
|
||||||
app_uart_Sendcmd(UART1_PORT, uart1_daraframe.cmd_id, uart1_daraframe.reg_addr, ret_data, length);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
app_uart_Sendcmd(UART1_PORT,uart1_daraframe.cmd_id,0x01,uart1_daraframe.data,uart1_daraframe.length);
|
||||||
break;
|
break;
|
||||||
case 0x03://推车模式
|
case 0x04:
|
||||||
if(1 ==uart1_daraframe.length){//推车模式设置/0:退出推车状态/1:推车状态
|
|
||||||
ret_data[0] =app_set_Push_status(uart1_daraframe.data[0]);
|
|
||||||
length = 1;
|
|
||||||
app_uart_Sendcmd(UART1_PORT, uart1_daraframe.cmd_id, uart1_daraframe.reg_addr, ret_data, length);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 0x04://GRB
|
|
||||||
WS2812_GRBs.len =uart1_daraframe.length;
|
|
||||||
|
|
||||||
for(length=0;length < WS2812_GRBs.len;length++){//G3,R3,B2
|
|
||||||
WS2812_GRBs.GRBs[length] = ((uint32_t)(uart1_daraframe.data[length] & 0xE0)<<16) | ((uint32_t)(uart1_daraframe.data[length] & 0x1C)<<11) | ((uint32_t)(uart1_daraframe.data[length] & 0x03)<<6);
|
|
||||||
}
|
|
||||||
|
|
||||||
// WS2812_GRBs.len =uart1_daraframe.length / 3;
|
app_uart_Sendcmd(UART1_PORT,uart1_daraframe.cmd_id,0x01,uart1_daraframe.data,uart1_daraframe.length);
|
||||||
// for(length=0;length < WS2812_GRBs.len;length++){
|
|
||||||
// WS2812_GRBs.GRBs[length] = ((uint32_t)uart1_daraframe.data[3*length + 0]<<16) | ((uint32_t)uart1_daraframe.data[3*length +1]<<8) | ((uint32_t)uart1_daraframe.data[3*length +2]);
|
|
||||||
// }
|
|
||||||
// app_uart_Sendcmd(UART2_PORT, uart1_daraframe.cmd_id, uart1_daraframe.reg_addr, uart1_daraframe.data, length);
|
|
||||||
// app_uart_Sendcmd(UART1_PORT, uart1_daraframe.cmd_id, uart1_daraframe.reg_addr, uart1_daraframe.data, length);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default :
|
default :
|
||||||
|
@ -211,8 +188,9 @@ void UART1_IRQHandler(void)
|
||||||
if (state & 0x01) //(BIT_RXRD)
|
if (state & 0x01) //(BIT_RXRD)
|
||||||
{
|
{
|
||||||
UART1->IDR.RXRD = 1; // Disable RXRD Interrupt
|
UART1->IDR.RXRD = 1; // Disable RXRD Interrupt
|
||||||
|
uint8_t data = UART1->RBR;
|
||||||
uart1_Receive(UART1->RBR);
|
app_radar_Receive(data);
|
||||||
|
uart1_Receive(data);
|
||||||
UART1->ICR.RXRD = 1; // Clear RXRD Interrupt Flag
|
UART1->ICR.RXRD = 1; // Clear RXRD Interrupt Flag
|
||||||
UART1->IER.RXRD = 1; // Enable RXRD Interrupt
|
UART1->IER.RXRD = 1; // Enable RXRD Interrupt
|
||||||
}
|
}
|
||||||
|
@ -223,39 +201,9 @@ void UART1_IRQHandler(void)
|
||||||
***************************************UART2*****************************************************
|
***************************************UART2*****************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint8_t uart2_state =0;
|
|
||||||
|
|
||||||
static void uart2_Receive(uint8_t data)
|
static void uart2_Receive(uint8_t data)
|
||||||
{
|
{
|
||||||
switch(uart2_state){
|
|
||||||
case 0://header
|
|
||||||
if (data == 0x0C || data == 0x0D) {
|
|
||||||
radar_daraframe.header = data;
|
|
||||||
uart2_state = 1;//to data
|
|
||||||
//debug("header");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1://data
|
|
||||||
//debug("data:%x", data);
|
|
||||||
if(0x0c == radar_daraframe.header){
|
|
||||||
radar_daraframe.Left_data = data;
|
|
||||||
}else if(0x0d == radar_daraframe.header){
|
|
||||||
radar_daraframe.Right_data = data;
|
|
||||||
}
|
|
||||||
uart2_state = 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// uart_putc(UART2_PORT,data);
|
|
||||||
// uart_putc(UART2_PORT,'0'+uart2_state);
|
|
||||||
if(uart2_state == 2){
|
|
||||||
radar_daraframe.header = 0;
|
|
||||||
app_updata_radar();
|
|
||||||
uart2_state = 0;
|
|
||||||
/*
|
|
||||||
rx handler codes....
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UART2_IRQHandler(void)
|
void UART2_IRQHandler(void)
|
||||||
|
@ -270,8 +218,8 @@ void UART2_IRQHandler(void)
|
||||||
UART2->ICR.RXRD = 1; // Clear RXRD Interrupt Flag
|
UART2->ICR.RXRD = 1; // Clear RXRD Interrupt Flag
|
||||||
UART2->IER.RXRD = 1; // Enable RXRD Interrupt
|
UART2->IER.RXRD = 1; // Enable RXRD Interrupt
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//发送命令
|
//发送命令
|
||||||
void app_uart_Sendcmd(uint8_t port, volatile uint8_t cmd_id ,volatile uint8_t reg_addr ,volatile uint8_t *data, volatile uint8_t length)
|
void app_uart_Sendcmd(uint8_t port, volatile uint8_t cmd_id ,volatile uint8_t reg_addr ,volatile uint8_t *data, volatile uint8_t length)
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
//数据帧头
|
//数据帧头
|
||||||
#define FRAME_HEADER 0xA100
|
#define FRAME_HEADER 0xA100
|
||||||
|
|
||||||
#define MAX_LEN 127
|
#define MAX_LEN 32
|
||||||
|
|
||||||
//失能数据校验
|
//0:失能数据校验
|
||||||
#define DISABLE_CRC8 1
|
#define DISABLE_CRC8 1
|
||||||
|
|
||||||
typedef struct uart_daraframe
|
typedef struct uart_daraframe
|
||||||
|
@ -22,12 +22,7 @@ typedef struct uart_daraframe
|
||||||
volatile uint8_t crc;
|
volatile uint8_t crc;
|
||||||
} uart_daraframe_t;
|
} uart_daraframe_t;
|
||||||
|
|
||||||
typedef struct radar_daraframe
|
|
||||||
{
|
|
||||||
uint8_t header;
|
|
||||||
uint8_t Left_data;
|
|
||||||
uint8_t Right_data;
|
|
||||||
} radar_daraframe_t;
|
|
||||||
|
|
||||||
|
|
||||||
//初始化
|
//初始化
|
||||||
|
@ -36,5 +31,7 @@ void app_uart_Init(uint8_t port, uint32_t baudrate, uint8_t io_tx, uint8_t io_rx
|
||||||
void app_uart_Sendcmd(uint8_t port, volatile uint8_t cmd_id ,volatile uint8_t reg_addr ,volatile uint8_t *data, volatile uint8_t length);
|
void app_uart_Sendcmd(uint8_t port, volatile uint8_t cmd_id ,volatile uint8_t reg_addr ,volatile uint8_t *data, volatile uint8_t length);
|
||||||
|
|
||||||
uint8_t crc8_checkout(uint8_t *buff, uint8_t length);
|
uint8_t crc8_checkout(uint8_t *buff, uint8_t length);
|
||||||
|
// CRC-16/MODBUS polynomial: x^16 + x^15 + x^2 + 1 (0x8005)
|
||||||
|
uint16_t crc16_checkout(uint8_t *buff, uint16_t length);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -11,11 +11,18 @@ uint32_t ___WS2812_DIN___ =1<< OUT_GRB_WS2812_DIN;
|
||||||
#define WS2812_DIN_H GPIO_DAT_SET(___WS2812_DIN___)
|
#define WS2812_DIN_H GPIO_DAT_SET(___WS2812_DIN___)
|
||||||
#define WS2812_DIN_L GPIO_DAT_CLR(___WS2812_DIN___)
|
#define WS2812_DIN_L GPIO_DAT_CLR(___WS2812_DIN___)
|
||||||
|
|
||||||
|
BLE_GRB_Data_t WS2812_GRBs={
|
||||||
|
.len=73,
|
||||||
|
.GRBs=0x00,
|
||||||
|
};
|
||||||
|
|
||||||
void GRB_WS2812_Init(void)
|
void GRB_WS2812_Init(void)
|
||||||
{
|
{
|
||||||
gpio_dir_output(OUT_GRB_WS2812_DIN,OE_HIGH);
|
// gpio_dir_output(OUT_GRB_WS2812_DIN,OE_HIGH);
|
||||||
gpio_dir_input(OUT_GRB_WS2812_DIN,IE_UP);
|
// gpio_dir_input(OUT_GRB_WS2812_DIN,IE_UP);
|
||||||
gpio_put_hi(OUT_GRB_WS2812_DIN);
|
// gpio_put_hi(OUT_GRB_WS2812_DIN);
|
||||||
|
GPIO_DIR_SET(___WS2812_DIN___);
|
||||||
|
WS2812_DIN_L;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GRB_WS2812_Reset(void)
|
void GRB_WS2812_Reset(void)
|
||||||
|
@ -25,6 +32,7 @@ void GRB_WS2812_Init(void)
|
||||||
WS2812_DIN_L;
|
WS2812_DIN_L;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__attribute__((section("ram_func.fshc.")))
|
||||||
void GRB_WS2812_Write_24Bits(uint32_t GRB888)
|
void GRB_WS2812_Write_24Bits(uint32_t GRB888)
|
||||||
{
|
{
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
@ -46,9 +54,8 @@ void GRB_WS2812_Write_24Bits(uint32_t GRB888)
|
||||||
|
|
||||||
void GRB_WS2812_Write_GRBs(uint8_t len, uint32_t *GRB888)
|
void GRB_WS2812_Write_GRBs(uint8_t len, uint32_t *GRB888)
|
||||||
{
|
{
|
||||||
|
|
||||||
while(len--)GRB_WS2812_Write_24Bits(*GRB888++);
|
|
||||||
GRB_WS2812_Reset();
|
GRB_WS2812_Reset();
|
||||||
|
while(len--)GRB_WS2812_Write_24Bits(*GRB888++);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GRB_WS2812_Write_color(uint8_t len, uint32_t GRB888)
|
void GRB_WS2812_Write_color(uint8_t len, uint32_t GRB888)
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
typedef struct GRB_Data{
|
typedef struct GRB_Data{
|
||||||
uint8_t len;
|
uint8_t len;
|
||||||
|
|
||||||
uint32_t GRBs[127];
|
uint32_t GRBs[127];
|
||||||
} GRB_Data_t;
|
} GRB_Data_t;
|
||||||
|
|
||||||
|
@ -15,14 +14,21 @@ typedef struct BLE_GRB_Data{
|
||||||
uint32_t GRBs;
|
uint32_t GRBs;
|
||||||
} BLE_GRB_Data_t;
|
} BLE_GRB_Data_t;
|
||||||
|
|
||||||
|
#define GRB_RED 0x00ff00;
|
||||||
|
#define GRB_GREEN 0xff0000;
|
||||||
|
#define GRB_BLUE 0x0000ff;
|
||||||
|
|
||||||
|
|
||||||
|
extern BLE_GRB_Data_t WS2812_GRBs;
|
||||||
|
|
||||||
void GRB_WS2812_Init(void);
|
void GRB_WS2812_Init(void);
|
||||||
|
|
||||||
void GRB_WS2812_Write_24Bits(uint32_t GRB888);
|
void GRB_WS2812_Write_24Bits(uint32_t GRB888);
|
||||||
|
|
||||||
void GRB_WS2812_Reset(void);
|
void GRB_WS2812_Reset(void);
|
||||||
|
|
||||||
void GRB_WS2812_Write_color(uint8_t len, uint32_t GRB888);
|
|
||||||
void GRB_WS2812_Write_GRBs(uint8_t len, uint32_t *GRB888);
|
void GRB_WS2812_Write_GRBs(uint8_t len, uint32_t *GRB888);
|
||||||
|
void GRB_WS2812_Write_color(uint8_t len, uint32_t GRB888);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,28 +1,52 @@
|
||||||
#include "b6x.h"
|
#include "b6x.h"
|
||||||
|
#include "regs.h"
|
||||||
#include "drvs.h"
|
#include "drvs.h"
|
||||||
#include "dbg.h"
|
#include "dbg.h"
|
||||||
#include "app_uart.h"
|
|
||||||
#include "sftmr.h"
|
|
||||||
#include "app_speed_governor.h"
|
|
||||||
#include "app_control_out.h"
|
|
||||||
#include "app_ws2812.h"
|
|
||||||
|
|
||||||
#include "bledef.h"
|
#include "bledef.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
#include "sftmr.h"
|
||||||
|
|
||||||
|
#include "sys_config.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define FLASH_INFO_CODE_ADDR (FLASH_BASE + 0x08)
|
||||||
|
#define OTA_BANK_A_BASE (0x18004000)
|
||||||
|
#define OTA_BANK_B_BASE (0x18020000)
|
||||||
|
#define OTA_BANK_A (OTA_BANK_A_BASE - FLASH_BASE)
|
||||||
|
#define OTA_BANK_B (OTA_BANK_B_BASE - FLASH_BASE)
|
||||||
|
|
||||||
|
|
||||||
GRB_Data_t WS2812_GRBs;
|
|
||||||
BLE_GRB_Data_t BLE_WS2812_GRBs;
|
BLE_GRB_Data_t BLE_WS2812_GRBs;
|
||||||
|
|
||||||
extern void app_ble_procedure(void);
|
extern void app_ble_procedure(void);
|
||||||
|
|
||||||
|
|
||||||
|
//************************************************
|
||||||
|
#define IWDT_WINDOW (32768) //32.768KHz 1S
|
||||||
|
|
||||||
|
//看门狗配置
|
||||||
|
void IWDT_IRQHandler(void)
|
||||||
|
{
|
||||||
|
iwdt_feed();//喂狗
|
||||||
|
}
|
||||||
|
|
||||||
|
static void iwdtInit(void)
|
||||||
|
{
|
||||||
|
iwdt_init(IWDT_INTEN_BIT | IWDT_CR_DFLT);
|
||||||
|
iwdt_conf(IWDT_WINDOW);
|
||||||
|
|
||||||
|
NVIC_EnableIRQ(IWDT_IRQn);
|
||||||
|
__enable_irq();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void sysInit(void)
|
static void sysInit(void)
|
||||||
{
|
{
|
||||||
// Todo config, if need
|
// Todo config, if need
|
||||||
iwdt_disable();
|
iwdt_disable();
|
||||||
|
|
||||||
// rcc_ble_en();
|
// rcc_ble_en();
|
||||||
// rcc_adc_en();
|
rcc_adc_en();
|
||||||
|
|
||||||
rcc_fshclk_set(FSH_CLK_DPSC42);
|
rcc_fshclk_set(FSH_CLK_DPSC42);
|
||||||
APBMISC->XOSC16M_CTRL.XOSC16M_CAP_TR = 0x22;
|
APBMISC->XOSC16M_CTRL.XOSC16M_CAP_TR = 0x22;
|
||||||
|
@ -38,49 +62,136 @@ static void devInit(void)
|
||||||
// Init BLE App
|
// Init BLE App
|
||||||
// app_init(rsn);
|
// app_init(rsn);
|
||||||
|
|
||||||
|
sftmr_init();
|
||||||
|
|
||||||
|
iwdtInit();
|
||||||
// rf_pa_set(0x0C);
|
// rf_pa_set(0x0C);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t str[30]={0,0},str_len=0;
|
||||||
|
|
||||||
static tmr_tk_t test_timer_handler(tmr_id_t id){
|
// static tmr_tk_t test_timer_handler(tmr_id_t id){
|
||||||
|
|
||||||
(void)(id);
|
// (void)(id);
|
||||||
|
// // uint16_t adc_data;
|
||||||
|
|
||||||
GRB_WS2812_Write_GRBs(WS2812_GRBs.len ,WS2812_GRBs.GRBs);
|
// // adc_data = sadc_read(SADC_CH_AIN3, 0);
|
||||||
// GRB_WS2812_Write_color(BLE_WS2812_GRBs.len,BLE_WS2812_GRBs.GRBs);
|
// // str_len =sprintf((char *)str, "\nBAT0 = %.2f V /%d\n", get_bat_voltage(),adc_data);
|
||||||
return 10;
|
// // uart_send(UART1_PORT,str_len,str);
|
||||||
|
|
||||||
|
// // adc_data = sadc_read(SADC_CH_AIN7, 0);
|
||||||
|
// // str_len =sprintf((char *)str, "ACC = %d %% /%d\n", get_in_acc_percent(),adc_data);
|
||||||
|
// // uart_send(UART1_PORT,str_len,str);
|
||||||
|
|
||||||
|
|
||||||
|
// // GRB_WS2812_Write_GRBs(WS2812_GRBs.len ,WS2812_GRBs.GRBs);
|
||||||
|
// // GRB_WS2812_Write_color(BLE_WS2812_GRBs.len,BLE_WS2812_GRBs.GRBs);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// return 3;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t bank;
|
||||||
|
SYS_CONF_t sys_conf_info;
|
||||||
|
|
||||||
|
__attribute__((section("ram_func.fshc.")))
|
||||||
|
static void flash_sector_erase(uint32_t offset)
|
||||||
|
{
|
||||||
|
GLOBAL_INT_DISABLE();
|
||||||
|
|
||||||
|
while (SYSCFG->ACC_CCR_BUSY);
|
||||||
|
|
||||||
|
fshc_erase(offset, FSH_CMD_ER_SECTOR);
|
||||||
|
|
||||||
|
GLOBAL_INT_RESTORE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void write_cfg(SYS_CONF_t *sys_config_info_t){
|
||||||
|
flash_sector_erase(bank);
|
||||||
|
flash_write(bank, (uint32_t *)sys_config_info_t,sizeof(SYS_CONF_t)/sizeof(uint32_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
sysInit();
|
sysInit();
|
||||||
devInit();
|
devInit();
|
||||||
|
|
||||||
// Global Interrupt Enable
|
// Global Interrupt Enable
|
||||||
GLOBAL_INT_START();
|
GLOBAL_INT_START();
|
||||||
|
|
||||||
|
uint32_t curr_code_addr = RD_32(FLASH_INFO_CODE_ADDR);
|
||||||
|
if(curr_code_addr == OTA_BANK_A_BASE)
|
||||||
|
{
|
||||||
|
bank = OTA_BANK_B;
|
||||||
|
}
|
||||||
|
else if(curr_code_addr == OTA_BANK_B_BASE)
|
||||||
|
{
|
||||||
|
bank = OTA_BANK_A;
|
||||||
|
}
|
||||||
|
// read config
|
||||||
|
// read flash
|
||||||
|
flash_read(bank, (uint32_t *)(&sys_conf_info),sizeof(sys_conf_info)/sizeof(uint32_t));
|
||||||
|
|
||||||
|
if(0xAA !=sys_conf_info.HEAD){
|
||||||
|
sys_conf_info.HEAD=0xAA;
|
||||||
|
sys_conf_info.M_mode_sLim = M_DEFAULT_sLim,//read flash
|
||||||
|
sys_conf_info.U_mode_sLim = U_DEFAULT_sLim,//read flash
|
||||||
|
sys_conf_info.AUTO_Brake_Distance =DEF_AUTO_Brake_Distance,//自动刹车距离
|
||||||
|
sys_conf_info.AUTO_Speed_Cut_Distance =DEF_AUTO_Speed_Cut_Distance,//自动减速距离
|
||||||
|
sys_conf_info.AUTO_Brake_Distance_B =DEF_AUTO_Brake_Distance,//自动刹车距离
|
||||||
|
sys_conf_info.AUTO_Speed_Cut_Distance_B =DEF_AUTO_Speed_Cut_Distance,//自动减速距离
|
||||||
|
write_cfg(&sys_conf_info);
|
||||||
|
}
|
||||||
|
|
||||||
app_control_init();
|
app_control_init();
|
||||||
app_speed_governing_init(0);
|
|
||||||
app_uart_Init(UART1_PORT,115200,PA06,PA07);//上位机
|
|
||||||
app_uart_Init(UART2_PORT,9600,20,PA04);//倒车雷达
|
|
||||||
|
|
||||||
// app_uart_Init(UART1_PORT,115200,PA03,PA04);//上位机
|
app_uart_Init(UART1_PORT,9600,PA06,PA07);//上位机//倒车雷达
|
||||||
// app_uart_Init(UART2_PORT,9600,PA06,PA07);//倒车雷达
|
// app_uart_Init(UART2_PORT,9600,20,PA03);
|
||||||
|
app_radar_init();
|
||||||
|
Time_Event_Init();
|
||||||
|
|
||||||
|
uint8_t str[50]={0,0},str_len=0;
|
||||||
|
|
||||||
|
str_len =sprintf((char *)str, "HEAD=%#X,M_s=%d,U_s=%d\n Brake=%d,Speed_Cut=%d\n Brake_B=%d,Speed_Cut_B=%d\n",
|
||||||
|
sys_conf_info.HEAD,
|
||||||
|
sys_conf_info.M_mode_sLim,
|
||||||
|
sys_conf_info.U_mode_sLim,
|
||||||
|
sys_conf_info.AUTO_Brake_Distance,
|
||||||
|
sys_conf_info.AUTO_Speed_Cut_Distance,
|
||||||
|
sys_conf_info.AUTO_Brake_Distance_B,
|
||||||
|
sys_conf_info.AUTO_Speed_Cut_Distance_B);
|
||||||
|
uart_send(UART1_PORT,str_len,str);
|
||||||
|
|
||||||
bootDelayMs(1000);
|
|
||||||
GRB_WS2812_Init();
|
GRB_WS2812_Init();
|
||||||
sftmr_start(20, test_timer_handler);
|
|
||||||
|
// GRB_WS2812_Write_color(WS2812_GRBs.len,0xff);
|
||||||
|
// bootDelayMs(1000);
|
||||||
|
// GRB_WS2812_Write_color(WS2812_GRBs.len,0x00);
|
||||||
|
// bootDelayMs(1000);
|
||||||
|
// GRB_WS2812_Write_color(WS2812_GRBs.len,0xff00);
|
||||||
|
// bootDelayMs(1000);
|
||||||
|
// GRB_WS2812_Write_color(WS2812_GRBs.len,0x00);
|
||||||
|
// bootDelayMs(1000);
|
||||||
|
// GRB_WS2812_Write_color(WS2812_GRBs.len,0xff0000);
|
||||||
|
// bootDelayMs(1000);
|
||||||
|
|
||||||
|
BAT_Message_Init();
|
||||||
|
// ADC初始化
|
||||||
|
// sftmr_start(20, test_timer_handler);
|
||||||
while(1){
|
while(1){
|
||||||
// SoftTimer Polling
|
// SoftTimer Polling
|
||||||
sftmr_schedule();
|
sftmr_schedule();
|
||||||
// Schedule Messages & Events
|
// Schedule Messages & Events
|
||||||
// ble_schedule();
|
// ble_schedule();
|
||||||
|
|
||||||
|
|
||||||
// User's Procedure
|
// User's Procedure
|
||||||
// app_ble_procedure();
|
// app_ble_procedure();
|
||||||
|
|
||||||
|
Control_procedure();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,4 +211,3 @@ int main(void)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
#ifndef _SYS_CONFIG_H_
|
||||||
|
#define _SYS_CONFIG_H_
|
||||||
|
#include "app_control_out.h"
|
||||||
|
#include "app_uart.h"
|
||||||
|
#include "stdio.h"
|
||||||
|
#include "app_radar.h"
|
||||||
|
#include "app_ws2812.h"
|
||||||
|
#include "app_buzzer.h"
|
||||||
|
#include "app_bat.h"
|
||||||
|
|
||||||
|
typedef struct SYS_CONF{
|
||||||
|
uint32_t HEAD;
|
||||||
|
uint32_t M_mode_sLim;
|
||||||
|
uint32_t U_mode_sLim;
|
||||||
|
uint32_t AUTO_Brake_Distance;
|
||||||
|
uint32_t AUTO_Speed_Cut_Distance;
|
||||||
|
uint32_t AUTO_Brake_Distance_B;
|
||||||
|
uint32_t AUTO_Speed_Cut_Distance_B;
|
||||||
|
|
||||||
|
}SYS_CONF_t;
|
||||||
|
|
||||||
|
extern uint32_t bank;
|
||||||
|
extern SYS_CONF_t sys_conf_info;
|
||||||
|
extern BAT_Message_t BAT_Message;
|
||||||
|
|
||||||
|
// 写配置
|
||||||
|
void write_cfg(SYS_CONF_t *sys_config_info_t);
|
||||||
|
|
||||||
|
|
||||||
|
// 油门ADC
|
||||||
|
#define ACC_UP_Res 5.1 //上分压电阻(unit:KΩ)
|
||||||
|
#define ACC_DOWN_Res 5.1 //下分压电阻
|
||||||
|
|
||||||
|
// 电池ADC
|
||||||
|
#define BAT_UP_Res 68.0 //上分压电阻(unit:KΩ)
|
||||||
|
#define BAT_DOWN_Res 3.0 //下分压电阻
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************速度************************/
|
||||||
|
// 管理员模式默认速度极限(0-100%)
|
||||||
|
#define M_DEFAULT_sLim 80
|
||||||
|
// 管理员模式默认速度极限(0-100%)
|
||||||
|
#define U_DEFAULT_sLim 60
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************刹车************************/
|
||||||
|
// 默认自动刹车距离0~45dm(分米)
|
||||||
|
#define DEF_AUTO_Brake_Distance 10
|
||||||
|
// 默认自动减速距离0~45dm
|
||||||
|
#define DEF_AUTO_Speed_Cut_Distance 16
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue