移植与电子模块通信相关代码
This commit is contained in:
@@ -103,7 +103,7 @@
|
||||
<bEvRecOn>1</bEvRecOn>
|
||||
<bSchkAxf>0</bSchkAxf>
|
||||
<bTchkAxf>0</bTchkAxf>
|
||||
<nTsel>4</nTsel>
|
||||
<nTsel>0</nTsel>
|
||||
<sDll></sDll>
|
||||
<sDllPa></sDllPa>
|
||||
<sDlgDll></sDlgDll>
|
||||
@@ -114,18 +114,18 @@
|
||||
<tDlgDll></tDlgDll>
|
||||
<tDlgPa></tDlgPa>
|
||||
<tIfile></tIfile>
|
||||
<pMon>Segger\JL2CM3.dll</pMon>
|
||||
<pMon>BIN\UL2CM3.DLL</pMon>
|
||||
</DebugOpt>
|
||||
<TargetDriverDllRegistry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>UL2CM3</Key>
|
||||
<Name>UL2CM3(-S0 -C0 -P0 ) -FN1 -FC1000 -FD20000000 -FF0STM32F10x_512 -FL080000 -FS08000000 -FP0($$Device:STM32F103RE$Flash\STM32F10x_512.FLM)</Name>
|
||||
<Name>UL2CM3(-S0 -C0 -P0 ) -FN1 -FC1000 -FD20000000 -FF0STM32F10x_512 -FL080000 -FS08000000 -FP0($$Device:STM32F103RC$Flash\STM32F10x_512.FLM)</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>JL2CM3</Key>
|
||||
<Name>-U69655983 -O78 -S5 -ZTIFSpeedSel1000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(1BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_512.FLM -FS08000000 -FL080000 -FP0($$Device:STM32F103RE$Flash\STM32F10x_512.FLM)</Name>
|
||||
<Name>-U69655983 -O78 -S5 -ZTIFSpeedSel1000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(1BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_512.FLM -FS08000000 -FL080000 -FP0($$Device:STM32F103RC$Flash\STM32F10x_512.FLM)</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
@@ -499,7 +499,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>core</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
@@ -891,6 +891,18 @@
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>33</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\interface\if_can.c</PathWithFileName>
|
||||
<FilenameWithoutPath>if_can.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
@@ -901,7 +913,7 @@
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>33</FileNumber>
|
||||
<FileNumber>34</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -913,7 +925,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>34</FileNumber>
|
||||
<FileNumber>35</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -925,7 +937,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>35</FileNumber>
|
||||
<FileNumber>36</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -937,6 +949,218 @@
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>elec_det</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>37</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\elec_det\base\delay.c</PathWithFileName>
|
||||
<FilenameWithoutPath>delay.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>38</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\elec_det\base\utility.c</PathWithFileName>
|
||||
<FilenameWithoutPath>utility.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>39</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\elec_det\hardware\adc_cfg.c</PathWithFileName>
|
||||
<FilenameWithoutPath>adc_cfg.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>40</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\elec_det\hardware\dac_cfg.c</PathWithFileName>
|
||||
<FilenameWithoutPath>dac_cfg.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>41</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\elec_det\hardware\gpio_cfg.c</PathWithFileName>
|
||||
<FilenameWithoutPath>gpio_cfg.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>42</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\elec_det\hardware\hardware.c</PathWithFileName>
|
||||
<FilenameWithoutPath>hardware.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>43</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\elec_det\hardware\jw3425iic.c</PathWithFileName>
|
||||
<FilenameWithoutPath>jw3425iic.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>44</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\elec_det\hardware\power.c</PathWithFileName>
|
||||
<FilenameWithoutPath>power.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>45</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\elec_det\hardware\timer_cfg.c</PathWithFileName>
|
||||
<FilenameWithoutPath>timer_cfg.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>46</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\elec_det\driver\EWDriver.c</PathWithFileName>
|
||||
<FilenameWithoutPath>EWDriver.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>47</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\elec_det\driver\JQDriver.c</PathWithFileName>
|
||||
<FilenameWithoutPath>JQDriver.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>48</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\elec_det\driver\LGDriver.c</PathWithFileName>
|
||||
<FilenameWithoutPath>LGDriver.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>49</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\elec_det\driver\XTDriver.c</PathWithFileName>
|
||||
<FilenameWithoutPath>XTDriver.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>50</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\elec_det\interface\BaseChecker.c</PathWithFileName>
|
||||
<FilenameWithoutPath>BaseChecker.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>51</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\elec_det\interface\JQChecker.c</PathWithFileName>
|
||||
<FilenameWithoutPath>JQChecker.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>52</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\elec_det\interface\XTChecker.c</PathWithFileName>
|
||||
<FilenameWithoutPath>XTChecker.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>53</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\elec_det\elec_det.c</PathWithFileName>
|
||||
<FilenameWithoutPath>elec_det.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>rtt</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
@@ -944,8 +1168,8 @@
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>36</FileNumber>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>54</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -956,8 +1180,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>37</FileNumber>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>55</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -976,8 +1200,8 @@
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>38</FileNumber>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>56</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -988,8 +1212,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>39</FileNumber>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>57</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1000,8 +1224,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>40</FileNumber>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>58</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1012,8 +1236,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>41</FileNumber>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>59</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1024,8 +1248,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>42</FileNumber>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>60</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1036,8 +1260,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>43</FileNumber>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>61</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1048,8 +1272,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>44</FileNumber>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>62</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1060,8 +1284,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>45</FileNumber>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>63</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1072,8 +1296,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>46</FileNumber>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>64</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1084,8 +1308,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>47</FileNumber>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>65</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1096,8 +1320,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>48</FileNumber>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>66</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1108,8 +1332,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>49</FileNumber>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>67</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1120,8 +1344,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>50</FileNumber>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>68</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1132,8 +1356,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>51</FileNumber>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>69</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1144,8 +1368,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>52</FileNumber>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>70</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1156,8 +1380,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>53</FileNumber>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>71</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1168,8 +1392,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>54</FileNumber>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>72</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1180,8 +1404,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>55</FileNumber>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>73</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1192,8 +1416,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>56</FileNumber>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>74</FileNumber>
|
||||
<FileType>2</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1207,13 +1431,13 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>soft</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>57</FileNumber>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>75</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1224,8 +1448,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>58</FileNumber>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>76</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1236,8 +1460,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>59</FileNumber>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>77</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1248,8 +1472,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>60</FileNumber>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>78</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1260,8 +1484,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>61</FileNumber>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>79</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1272,8 +1496,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>62</FileNumber>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>80</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1284,8 +1508,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>63</FileNumber>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>81</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1296,8 +1520,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>64</FileNumber>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>82</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1308,8 +1532,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>65</FileNumber>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>83</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1320,8 +1544,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>66</FileNumber>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>84</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1332,8 +1556,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>67</FileNumber>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>85</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1352,20 +1576,8 @@
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>68</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\task\prot_mcu.c</PathWithFileName>
|
||||
<FilenameWithoutPath>prot_mcu.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>69</FileNumber>
|
||||
<GroupNumber>10</GroupNumber>
|
||||
<FileNumber>86</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1376,20 +1588,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>70</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\task\moter.c</PathWithFileName>
|
||||
<FilenameWithoutPath>moter.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>71</FileNumber>
|
||||
<GroupNumber>10</GroupNumber>
|
||||
<FileNumber>87</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1400,8 +1600,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>72</FileNumber>
|
||||
<GroupNumber>10</GroupNumber>
|
||||
<FileNumber>88</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1412,32 +1612,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>73</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\task\tran_for_checker.c</PathWithFileName>
|
||||
<FilenameWithoutPath>tran_for_checker.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>74</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\task\tran_for_coder2.c</PathWithFileName>
|
||||
<FilenameWithoutPath>tran_for_coder2.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>75</FileNumber>
|
||||
<GroupNumber>10</GroupNumber>
|
||||
<FileNumber>89</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1448,44 +1624,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>76</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\task\handle.c</PathWithFileName>
|
||||
<FilenameWithoutPath>handle.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>77</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\task\handle_for_checker.c</PathWithFileName>
|
||||
<FilenameWithoutPath>handle_for_checker.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>78</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\task\handle_for_coder.c</PathWithFileName>
|
||||
<FilenameWithoutPath>handle_for_coder.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>79</FileNumber>
|
||||
<GroupNumber>10</GroupNumber>
|
||||
<FileNumber>90</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1496,26 +1636,14 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>80</FileNumber>
|
||||
<GroupNumber>10</GroupNumber>
|
||||
<FileNumber>91</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\task\process.c</PathWithFileName>
|
||||
<FilenameWithoutPath>process.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>81</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\source\task\input.c</PathWithFileName>
|
||||
<FilenameWithoutPath>input.c</FilenameWithoutPath>
|
||||
<PathWithFileName>.\source\task\tran_for_slave.c</PathWithFileName>
|
||||
<FilenameWithoutPath>tran_for_slave.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
@@ -1528,8 +1656,8 @@
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>10</GroupNumber>
|
||||
<FileNumber>82</FileNumber>
|
||||
<GroupNumber>11</GroupNumber>
|
||||
<FileNumber>92</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1543,13 +1671,13 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>coder</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>11</GroupNumber>
|
||||
<FileNumber>83</FileNumber>
|
||||
<GroupNumber>12</GroupNumber>
|
||||
<FileNumber>93</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1560,8 +1688,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>11</GroupNumber>
|
||||
<FileNumber>84</FileNumber>
|
||||
<GroupNumber>12</GroupNumber>
|
||||
<FileNumber>94</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1572,8 +1700,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>11</GroupNumber>
|
||||
<FileNumber>85</FileNumber>
|
||||
<GroupNumber>12</GroupNumber>
|
||||
<FileNumber>95</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1584,8 +1712,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>11</GroupNumber>
|
||||
<FileNumber>86</FileNumber>
|
||||
<GroupNumber>12</GroupNumber>
|
||||
<FileNumber>96</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1596,8 +1724,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>11</GroupNumber>
|
||||
<FileNumber>87</FileNumber>
|
||||
<GroupNumber>12</GroupNumber>
|
||||
<FileNumber>97</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1608,8 +1736,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>11</GroupNumber>
|
||||
<FileNumber>88</FileNumber>
|
||||
<GroupNumber>12</GroupNumber>
|
||||
<FileNumber>98</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1628,8 +1756,8 @@
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>12</GroupNumber>
|
||||
<FileNumber>89</FileNumber>
|
||||
<GroupNumber>13</GroupNumber>
|
||||
<FileNumber>99</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1648,8 +1776,8 @@
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>13</GroupNumber>
|
||||
<FileNumber>90</FileNumber>
|
||||
<GroupNumber>14</GroupNumber>
|
||||
<FileNumber>100</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -1660,8 +1788,8 @@
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>13</GroupNumber>
|
||||
<FileNumber>91</FileNumber>
|
||||
<GroupNumber>14</GroupNumber>
|
||||
<FileNumber>101</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
@@ -10,20 +10,20 @@
|
||||
<TargetName>app</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<pCCUsed>5060750::V5.06 update 6 (build 750)::ARMCC</pCCUsed>
|
||||
<pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARMCC</pCCUsed>
|
||||
<uAC6>0</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
<Device>STM32F103RE</Device>
|
||||
<Device>STM32F103RC</Device>
|
||||
<Vendor>STMicroelectronics</Vendor>
|
||||
<PackID>Keil.STM32F1xx_DFP.2.1.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||
<Cpu>IRAM(0x20000000,0x10000) IROM(0x08000000,0x80000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE</Cpu>
|
||||
<Cpu>IRAM(0x20000000,0xC000) IROM(0x08000000,0x40000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
<StartupFile></StartupFile>
|
||||
<FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_512 -FS08000000 -FL080000 -FP0($$Device:STM32F103RE$Flash\STM32F10x_512.FLM))</FlashDriverDll>
|
||||
<FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_512 -FS08000000 -FL080000 -FP0($$Device:STM32F103RC$Flash\STM32F10x_512.FLM))</FlashDriverDll>
|
||||
<DeviceId>0</DeviceId>
|
||||
<RegisterFile>$$Device:STM32F103RE$Device\Include\stm32f10x.h</RegisterFile>
|
||||
<RegisterFile>$$Device:STM32F103RC$Device\Include\stm32f10x.h</RegisterFile>
|
||||
<MemoryEnv></MemoryEnv>
|
||||
<Cmp></Cmp>
|
||||
<Asm></Asm>
|
||||
@@ -33,7 +33,7 @@
|
||||
<SLE66CMisc></SLE66CMisc>
|
||||
<SLE66AMisc></SLE66AMisc>
|
||||
<SLE66LinkerMisc></SLE66LinkerMisc>
|
||||
<SFDFile>$$Device:STM32F103RE$SVD\STM32F103xx.svd</SFDFile>
|
||||
<SFDFile>$$Device:STM32F103RC$SVD\STM32F103xx.svd</SFDFile>
|
||||
<bCustSvd>0</bCustSvd>
|
||||
<UseEnv>0</UseEnv>
|
||||
<BinPath></BinPath>
|
||||
@@ -49,7 +49,7 @@
|
||||
<InvalidFlash>1</InvalidFlash>
|
||||
</TargetStatus>
|
||||
<OutputDirectory>.\Objects\app\</OutputDirectory>
|
||||
<OutputName>coder_2channel_app</OutputName>
|
||||
<OutputName>checker_slave_app</OutputName>
|
||||
<CreateExecutable>1</CreateExecutable>
|
||||
<CreateLib>0</CreateLib>
|
||||
<CreateHexFile>1</CreateHexFile>
|
||||
@@ -138,7 +138,7 @@
|
||||
</Flash1>
|
||||
<bUseTDR>1</bUseTDR>
|
||||
<Flash2>BIN\UL2CM3.DLL</Flash2>
|
||||
<Flash3>"" ()</Flash3>
|
||||
<Flash3></Flash3>
|
||||
<Flash4></Flash4>
|
||||
<pFcarmOut></pFcarmOut>
|
||||
<pFcarmGrp></pFcarmGrp>
|
||||
@@ -185,6 +185,7 @@
|
||||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>0</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<RvdsCdeCp>0</RvdsCdeCp>
|
||||
<hadIRAM2>0</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
@@ -245,12 +246,12 @@
|
||||
<IRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x10000</Size>
|
||||
<Size>0xc000</Size>
|
||||
</IRAM>
|
||||
<IROM>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x8000000</StartAddress>
|
||||
<Size>0x80000</Size>
|
||||
<Size>0x40000</Size>
|
||||
</IROM>
|
||||
<XRAM>
|
||||
<Type>0</Type>
|
||||
@@ -275,7 +276,7 @@
|
||||
<OCR_RVCT4>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x8004000</StartAddress>
|
||||
<Size>0x80000</Size>
|
||||
<Size>0x40000</Size>
|
||||
</OCR_RVCT4>
|
||||
<OCR_RVCT5>
|
||||
<Type>1</Type>
|
||||
@@ -300,7 +301,7 @@
|
||||
<OCR_RVCT9>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000020</StartAddress>
|
||||
<Size>0x10000</Size>
|
||||
<Size>0xc000</Size>
|
||||
</OCR_RVCT9>
|
||||
<OCR_RVCT10>
|
||||
<Type>0</Type>
|
||||
@@ -338,7 +339,7 @@
|
||||
<MiscControls>--diag_suppress=550,177 --locale=english</MiscControls>
|
||||
<Define>STM32F10X_HD,USE_STDPERIPH_DRIVER,RT_THREAD</Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>.\source\interface;.\source\core;.\source\stm32lib\inc;.\source\main;.\source\RTT;.\source\rt_thread\include;.\source\rt_thread;.\source\soft;.\source\task;.\source\dev;.\source\codec;.\source\coder</IncludePath>
|
||||
<IncludePath>.\source\interface;.\source\core;.\source\stm32lib\inc;.\source\main;.\source\RTT;.\source\rt_thread\include;.\source\rt_thread;.\source\soft;.\source\task;.\source\dev;.\source\codec;.\source\coder;.\source\elec_det</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
@@ -351,7 +352,7 @@
|
||||
<NoWarn>0</NoWarn>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<useXO>0</useXO>
|
||||
<uClangAs>0</uClangAs>
|
||||
<ClangAsOpt>4</ClangAsOpt>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
@@ -557,6 +558,11 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\interface\if_gpioout.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>if_can.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\interface\if_can.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
@@ -579,6 +585,147 @@
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>elec_det</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>delay.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\base\delay.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>utility.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\base\utility.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>adc_cfg.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\hardware\adc_cfg.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>dac_cfg.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\hardware\dac_cfg.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>gpio_cfg.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\hardware\gpio_cfg.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>hardware.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\hardware\hardware.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>jw3425iic.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\hardware\jw3425iic.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>power.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\hardware\power.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>timer_cfg.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\hardware\timer_cfg.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>EWDriver.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\driver\EWDriver.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>JQDriver.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\driver\JQDriver.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>LGDriver.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\driver\LGDriver.c</FilePath>
|
||||
<FileOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>2</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>0</IncludeInBuild>
|
||||
<AlwaysBuild>2</AlwaysBuild>
|
||||
<GenerateAssemblyFile>2</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>2</AssembleAssemblyFile>
|
||||
<PublicsOnly>2</PublicsOnly>
|
||||
<StopOnExitCode>11</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>1</ComprImg>
|
||||
</CommonProperty>
|
||||
<FileArmAds>
|
||||
<Cads>
|
||||
<interw>2</interw>
|
||||
<Optim>0</Optim>
|
||||
<oTime>2</oTime>
|
||||
<SplitLS>2</SplitLS>
|
||||
<OneElfS>2</OneElfS>
|
||||
<Strict>2</Strict>
|
||||
<EnumInt>2</EnumInt>
|
||||
<PlainCh>2</PlainCh>
|
||||
<Ropi>2</Ropi>
|
||||
<Rwpi>2</Rwpi>
|
||||
<wLevel>0</wLevel>
|
||||
<uThumb>2</uThumb>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<uC99>2</uC99>
|
||||
<uGnu>2</uGnu>
|
||||
<useXO>2</useXO>
|
||||
<v6Lang>0</v6Lang>
|
||||
<v6LangP>0</v6LangP>
|
||||
<vShortEn>2</vShortEn>
|
||||
<vShortWch>2</vShortWch>
|
||||
<v6Lto>2</v6Lto>
|
||||
<v6WtE>2</v6WtE>
|
||||
<v6Rtti>2</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
</FileArmAds>
|
||||
</FileOption>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>XTDriver.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\driver\XTDriver.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>BaseChecker.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\interface\BaseChecker.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>JQChecker.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\interface\JQChecker.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>XTChecker.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\interface\XTChecker.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>elec_det.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\elec_det.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>rtt</GroupName>
|
||||
<Files>
|
||||
@@ -757,21 +904,11 @@
|
||||
<Group>
|
||||
<GroupName>task</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>prot_mcu.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\prot_mcu.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>prot_uc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\prot_uc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>moter.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\moter.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>commend.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@@ -782,50 +919,20 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\transmit.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tran_for_checker.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\tran_for_checker.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tran_for_coder2.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\tran_for_coder2.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tran_for_coder2ch.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\tran_for_coder2ch.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>handle.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\handle.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>handle_for_checker.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\handle_for_checker.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>handle_for_coder.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\handle_for_coder.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mod_signals.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\mod_signals.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>process.c</FileName>
|
||||
<FileName>tran_for_slave.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\process.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>input.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\input.c</FilePath>
|
||||
<FilePath>.\source\task\tran_for_slave.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
@@ -956,7 +1063,7 @@
|
||||
<TargetName>boot</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<pCCUsed>5060750::V5.06 update 6 (build 750)::ARMCC</pCCUsed>
|
||||
<pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARMCC</pCCUsed>
|
||||
<uAC6>0</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
@@ -995,7 +1102,7 @@
|
||||
<InvalidFlash>1</InvalidFlash>
|
||||
</TargetStatus>
|
||||
<OutputDirectory>.\Objects\boot\</OutputDirectory>
|
||||
<OutputName>coder_2channel_boot</OutputName>
|
||||
<OutputName>checker_slave_boot</OutputName>
|
||||
<CreateExecutable>1</CreateExecutable>
|
||||
<CreateLib>0</CreateLib>
|
||||
<CreateHexFile>1</CreateHexFile>
|
||||
@@ -1131,6 +1238,7 @@
|
||||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>0</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<RvdsCdeCp>0</RvdsCdeCp>
|
||||
<hadIRAM2>0</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
@@ -1297,7 +1405,7 @@
|
||||
<NoWarn>0</NoWarn>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<useXO>0</useXO>
|
||||
<uClangAs>0</uClangAs>
|
||||
<ClangAsOpt>4</ClangAsOpt>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
@@ -1605,6 +1713,62 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\interface\if_gpioout.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>if_can.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\interface\if_can.c</FilePath>
|
||||
<FileOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>2</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>0</IncludeInBuild>
|
||||
<AlwaysBuild>2</AlwaysBuild>
|
||||
<GenerateAssemblyFile>2</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>2</AssembleAssemblyFile>
|
||||
<PublicsOnly>2</PublicsOnly>
|
||||
<StopOnExitCode>11</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>1</ComprImg>
|
||||
</CommonProperty>
|
||||
<FileArmAds>
|
||||
<Cads>
|
||||
<interw>2</interw>
|
||||
<Optim>0</Optim>
|
||||
<oTime>2</oTime>
|
||||
<SplitLS>2</SplitLS>
|
||||
<OneElfS>2</OneElfS>
|
||||
<Strict>2</Strict>
|
||||
<EnumInt>2</EnumInt>
|
||||
<PlainCh>2</PlainCh>
|
||||
<Ropi>2</Ropi>
|
||||
<Rwpi>2</Rwpi>
|
||||
<wLevel>0</wLevel>
|
||||
<uThumb>2</uThumb>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<uC99>2</uC99>
|
||||
<uGnu>2</uGnu>
|
||||
<useXO>2</useXO>
|
||||
<v6Lang>0</v6Lang>
|
||||
<v6LangP>0</v6LangP>
|
||||
<vShortEn>2</vShortEn>
|
||||
<vShortWch>2</vShortWch>
|
||||
<v6Lto>2</v6Lto>
|
||||
<v6WtE>2</v6WtE>
|
||||
<v6Rtti>2</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
</FileArmAds>
|
||||
</FileOption>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
@@ -1627,6 +1791,165 @@
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>elec_det</GroupName>
|
||||
<GroupOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>0</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>0</IncludeInBuild>
|
||||
<AlwaysBuild>2</AlwaysBuild>
|
||||
<GenerateAssemblyFile>2</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>2</AssembleAssemblyFile>
|
||||
<PublicsOnly>2</PublicsOnly>
|
||||
<StopOnExitCode>11</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>1</ComprImg>
|
||||
</CommonProperty>
|
||||
<GroupArmAds>
|
||||
<Cads>
|
||||
<interw>2</interw>
|
||||
<Optim>0</Optim>
|
||||
<oTime>2</oTime>
|
||||
<SplitLS>2</SplitLS>
|
||||
<OneElfS>2</OneElfS>
|
||||
<Strict>2</Strict>
|
||||
<EnumInt>2</EnumInt>
|
||||
<PlainCh>2</PlainCh>
|
||||
<Ropi>2</Ropi>
|
||||
<Rwpi>2</Rwpi>
|
||||
<wLevel>0</wLevel>
|
||||
<uThumb>2</uThumb>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<uC99>2</uC99>
|
||||
<uGnu>2</uGnu>
|
||||
<useXO>2</useXO>
|
||||
<v6Lang>0</v6Lang>
|
||||
<v6LangP>0</v6LangP>
|
||||
<vShortEn>2</vShortEn>
|
||||
<vShortWch>2</vShortWch>
|
||||
<v6Lto>2</v6Lto>
|
||||
<v6WtE>2</v6WtE>
|
||||
<v6Rtti>2</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
<interw>2</interw>
|
||||
<Ropi>2</Ropi>
|
||||
<Rwpi>2</Rwpi>
|
||||
<thumb>2</thumb>
|
||||
<SplitLS>2</SplitLS>
|
||||
<SwStkChk>2</SwStkChk>
|
||||
<NoWarn>2</NoWarn>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<useXO>2</useXO>
|
||||
<ClangAsOpt>0</ClangAsOpt>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Aads>
|
||||
</GroupArmAds>
|
||||
</GroupOption>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>delay.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\base\delay.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>utility.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\base\utility.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>adc_cfg.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\hardware\adc_cfg.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>dac_cfg.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\hardware\dac_cfg.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>gpio_cfg.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\hardware\gpio_cfg.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>hardware.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\hardware\hardware.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>jw3425iic.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\hardware\jw3425iic.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>power.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\hardware\power.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>timer_cfg.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\hardware\timer_cfg.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>EWDriver.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\driver\EWDriver.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>JQDriver.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\driver\JQDriver.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>LGDriver.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\driver\LGDriver.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>XTDriver.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\driver\XTDriver.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>BaseChecker.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\interface\BaseChecker.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>JQChecker.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\interface\JQChecker.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>XTChecker.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\interface\XTChecker.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>elec_det.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\elec_det\elec_det.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>rtt</GroupName>
|
||||
<Files>
|
||||
@@ -2583,7 +2906,7 @@
|
||||
<NoWarn>2</NoWarn>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<useXO>2</useXO>
|
||||
<uClangAs>2</uClangAs>
|
||||
<ClangAsOpt>0</ClangAsOpt>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
@@ -3125,7 +3448,7 @@
|
||||
<NoWarn>2</NoWarn>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<useXO>2</useXO>
|
||||
<uClangAs>2</uClangAs>
|
||||
<ClangAsOpt>0</ClangAsOpt>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
@@ -3136,21 +3459,11 @@
|
||||
</GroupArmAds>
|
||||
</GroupOption>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>prot_mcu.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\prot_mcu.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>prot_uc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\prot_uc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>moter.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\moter.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>commend.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@@ -3161,50 +3474,20 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\transmit.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tran_for_checker.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\tran_for_checker.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tran_for_coder2.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\tran_for_coder2.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tran_for_coder2ch.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\tran_for_coder2ch.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>handle.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\handle.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>handle_for_checker.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\handle_for_checker.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>handle_for_coder.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\handle_for_coder.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mod_signals.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\mod_signals.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>process.c</FileName>
|
||||
<FileName>tran_for_slave.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\process.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>input.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\source\task\input.c</FilePath>
|
||||
<FilePath>.\source\task\tran_for_slave.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
@@ -3269,7 +3552,7 @@
|
||||
<NoWarn>2</NoWarn>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<useXO>2</useXO>
|
||||
<uClangAs>2</uClangAs>
|
||||
<ClangAsOpt>0</ClangAsOpt>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
@@ -3348,7 +3631,7 @@
|
||||
<NoWarn>2</NoWarn>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<useXO>2</useXO>
|
||||
<uClangAs>2</uClangAs>
|
||||
<ClangAsOpt>0</ClangAsOpt>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
@@ -3426,4 +3709,13 @@
|
||||
<files/>
|
||||
</RTE>
|
||||
|
||||
<LayerInfo>
|
||||
<Layers>
|
||||
<Layer>
|
||||
<LayName>checher_slave</LayName>
|
||||
<LayPrjMark>1</LayPrjMark>
|
||||
</Layer>
|
||||
</Layers>
|
||||
</LayerInfo>
|
||||
|
||||
</Project>
|
@@ -177,6 +177,7 @@
|
||||
心跳数据在收到回复之后也会继续发送
|
||||
芯片异常时不检测电容
|
||||
str_is_print_str 函数中,len为0时返回0
|
||||
|
||||
2023.10.6
|
||||
移植与雷管通信相关代码,编译通过
|
||||
|
||||
|
@@ -12,6 +12,7 @@
|
||||
#include "crc.h"
|
||||
#include "dev_flash.h"
|
||||
#include "codec.h"
|
||||
#include "elec_det.h"
|
||||
|
||||
|
||||
|
||||
@@ -199,6 +200,76 @@ protuc_codec_export(ym_coder,protu_decode2,protu_encode2);
|
||||
|
||||
|
||||
|
||||
// 小板协议解码
|
||||
array_def *protm_decode(protu_def *p,array_def *data)
|
||||
{
|
||||
array_def *r=arr_creat();
|
||||
param_check(r);
|
||||
str_set(p->str_err,"ok");
|
||||
if(arr_length(data)<10)
|
||||
{
|
||||
DBG_WARN("recv data len too less.");
|
||||
DBG_WARN("data=%s",str_temp(arr_string(data)));
|
||||
str_set(p->str_err,"recv data len too less.");
|
||||
return r;
|
||||
}
|
||||
uint8_t src=arr_get(data,4);
|
||||
uint8_t dst=arr_get(data,5);
|
||||
if((src!=0)||(dst!=elec_local_addr())){
|
||||
DBG_WARN("src_addr/dst_addr not allowed.");
|
||||
DBG_WARN("data=%s",str_temp(arr_string(data)));
|
||||
str_set(p->str_err,"src_addr/dst_addr not allowed.");
|
||||
return r;
|
||||
}
|
||||
uint16_t len=arr_get(data,2)|(arr_get(data,3)<<8);
|
||||
uint8_t crc=crc_crc8(arr_data(data),arr_length(data)-1);
|
||||
if(len!=arr_length(data))
|
||||
{
|
||||
// 如果长度不相等则产生了数据丢失
|
||||
DBG_WARN("recv data have lossed.");
|
||||
str_set(p->str_err,"recv data have lossed.");
|
||||
return r;
|
||||
}
|
||||
uint16_t no=arr_get(data,7)|(arr_get(data,8)<<8);
|
||||
uint16_t h_no=p->cmd_no;
|
||||
if(no!=h_no)
|
||||
{
|
||||
// 发送一条指令等待其返回,此时流水号应相同
|
||||
//DBG_WARN("slave_addr=%d cmd_no error:h_no=%d,no=%d.",src,h_no,no);
|
||||
//str_set(p->str_err,"cmd no err.");
|
||||
//return r;
|
||||
}
|
||||
if(crc!=arr_get(data,-1))
|
||||
{
|
||||
DBG_WARN("recv data crc check error:%02x,%02x.",crc,arr_get(data,-1));
|
||||
str_set(p->str_err,"crc check err.");
|
||||
}
|
||||
p->cmd=arr_get(data,6);
|
||||
arr_delete(r);
|
||||
return arr_mid(data,9,len-10);
|
||||
}
|
||||
|
||||
|
||||
// 编码
|
||||
array_def *protm_encode(protu_def *p,array_def *data)
|
||||
{
|
||||
array_def *t=arr_creat();
|
||||
param_check(t);
|
||||
uint16_t len=arr_length(data)+10;
|
||||
arr_append(t,'Y');
|
||||
arr_append(t,'e');
|
||||
arr_append(t,len&0xff);
|
||||
arr_append(t,len>>8);
|
||||
arr_append(t,elec_local_addr());// 源地址
|
||||
arr_append(t,0);// 目标地址
|
||||
arr_append(t,p->cmd);// 命令码
|
||||
arr_append(t,p->cmd_no&0xff);
|
||||
arr_append(t,p->cmd_no>>8);
|
||||
arr_appends_from(t,data);
|
||||
arr_append(t,crc_crc8(arr_data(t),arr_length(t)));
|
||||
return t;
|
||||
}
|
||||
|
||||
protuc_codec_export(ym_slave,protm_decode,protm_encode);
|
||||
|
||||
|
||||
|
@@ -37,8 +37,6 @@ scheme 109~110
|
||||
#define FLASH_APP_SECTOR_NUM (50)
|
||||
#define FLASH_BUFF_SECTOR (58)
|
||||
#define FLASH_BUFF_SECTOR_NUM (50)
|
||||
#define FLASH_BUFF_SECTOR (58)
|
||||
#define FLASH_BUFF_SECTOR_NUM (50)
|
||||
#define FLASH_PARAM_SECTOR (108)
|
||||
#define FLASH_PARAM_SECTOR_NUM (1)
|
||||
#define FLASH_SCHEME_SECTOR (109)
|
||||
|
139
source/elec_det/base/define.h
Normal file
139
source/elec_det/base/define.h
Normal file
@@ -0,0 +1,139 @@
|
||||
#ifndef DEFINE_H_
|
||||
#define DEFINE_H_
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
#include "stm32f10x.h"
|
||||
#include "misc.h"
|
||||
#include "stm32f10x_adc.h"
|
||||
#include "stm32f10x_dma.h"
|
||||
#include "stm32f10x_gpio.h"
|
||||
#include "stm32f10x_usart.h"
|
||||
#include "stm32f10x_rcc.h"
|
||||
#include "stm32f10x_tim.h"
|
||||
#include "stm32f10x_dac.h"
|
||||
#include "stm32f10x_i2c.h"
|
||||
#define UNUSED(X) (void)X
|
||||
|
||||
#define SoftVersion 0x000D
|
||||
|
||||
|
||||
#if __IF_PORT_UART
|
||||
//是否使用通信缓存
|
||||
#define APP_COMM_USE_FIFO 0
|
||||
//命令通信接口
|
||||
#define APP_COMD_CAN 0
|
||||
#define APP_COMD_USART 1
|
||||
|
||||
#else
|
||||
|
||||
//是否使用通信缓存
|
||||
#define APP_COMM_USE_FIFO 1
|
||||
//命令通信接口
|
||||
#define APP_COMD_CAN 1
|
||||
#define APP_COMD_USART 1
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
typedef enum{
|
||||
FUN_E = ((uint8_t)0),//使能
|
||||
FUN_D = ((uint8_t)1) //失能
|
||||
}FUNState_e;
|
||||
|
||||
typedef union{
|
||||
uint32_t ul_data;
|
||||
uint16_t us_data;
|
||||
uint8_t uc_data;
|
||||
uint16_t us_buf[2];
|
||||
uint8_t uc_buf[4];
|
||||
}Seq_Buf_En;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define APP_BEG_ADDR 0x8004000
|
||||
#define APP_END_ADDR 0x8024000
|
||||
|
||||
//#define APP_TEST_BOARD_CFG 0x803E800
|
||||
#define MC_CODE_ADDR 0x803B000
|
||||
#define APP_TEST_PLAN_ADDR 0x803F000
|
||||
#define APP_TEST_BOOTFLAG_ADDR 0x803F800
|
||||
|
||||
#define FCM_END_ADDR 0x8040000
|
||||
#define FMC_PAGE_SIZE ((uint16_t)0x800U)
|
||||
|
||||
#define APP_TEST_PLANINFO_SIZE 2048
|
||||
|
||||
|
||||
|
||||
//系统事件定义
|
||||
#define U1_RX_FRAME_EVENT 0x01
|
||||
#define UART_MC_FRAME_EVENT 0x02
|
||||
#define CAN_MC_FRAME_EVENT 0x04
|
||||
#define TRANS_FRAME_EVENT 0x08
|
||||
|
||||
#define UART_TX_END_EVENT 1
|
||||
|
||||
#define EP1_CMD_FRAME_EVENT 1
|
||||
#define EPJ_CMD_FRAME_EVENT 1
|
||||
#define EP2_CMD_FRAME_EVENT 1
|
||||
|
||||
#define USART_APP_EXCE_EVENT 1
|
||||
#define EP_HEARTBEAD_EVENT 5
|
||||
|
||||
|
||||
/******************总线电压倍率*****/
|
||||
#define VH_Mutli 21
|
||||
#define VM_Mutli 21
|
||||
#define BOAED_SEQ_NUM_SIZE 20
|
||||
extern struct rt_event usart1_rx_event;
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
uint32_t bootflag; //更新标志
|
||||
uint16_t resistor_diff;//
|
||||
uint16_t hard_v;
|
||||
uint32_t mc_ICodeCrc32;
|
||||
uint8_t sqNum[BOAED_SEQ_NUM_SIZE];
|
||||
}BoardInfo_st;
|
||||
|
||||
typedef union{
|
||||
BoardInfo_st boardinfo;
|
||||
uint32_t ul_buf[32];
|
||||
}BoardInfo_un;
|
||||
|
||||
typedef struct {
|
||||
|
||||
uint8_t app_run_flag;
|
||||
uint8_t device_id;
|
||||
uint16_t chip_temp;
|
||||
uint16_t v2p5_adc;
|
||||
uint16_t v1p25_adc;
|
||||
uint16_t adc_shake;
|
||||
uint16_t bus_5p5v;
|
||||
uint16_t bus_26v;
|
||||
uint16_t hard_v;
|
||||
uint16_t soft_v;
|
||||
uint16_t resistor_diff;
|
||||
uint32_t plan_id;
|
||||
|
||||
}BoartCheck_st;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
extern BoartCheck_st board_st;
|
||||
extern BoardInfo_un boardinfo_un;
|
||||
|
||||
//检测小板初始化
|
||||
void Ye_BoardInit(void);
|
||||
/*
|
||||
测试小板上电自检
|
||||
*/
|
||||
void Ye_BoardCheck(void);
|
||||
//
|
||||
uint8_t UidCode_YM2JQ(uint8_t* pstJQUID, uint8_t* pstYMUID);
|
||||
uint32_t GetPasswordByUidCode(uint8_t* uidcode);
|
||||
#endif
|
63
source/elec_det/base/delay.c
Normal file
63
source/elec_det/base/delay.c
Normal file
@@ -0,0 +1,63 @@
|
||||
#include "base/delay.h"
|
||||
#include "stdbool.h"
|
||||
#include "rtthread.h"
|
||||
|
||||
|
||||
|
||||
//此函数已在别处实现
|
||||
//void delay_us(uint32_t nus)
|
||||
//{
|
||||
//}
|
||||
|
||||
void delay_ms(uint32_t nms)
|
||||
{
|
||||
while(nms > 0)
|
||||
{
|
||||
nms--;
|
||||
delay_us(1000); //普通方式延时,此时ucos无法启动调度.
|
||||
}
|
||||
|
||||
}
|
||||
void delay_nop(uint32_t nop)
|
||||
{
|
||||
while(nop > 0)
|
||||
{
|
||||
nop--;
|
||||
__NOP();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
41
source/elec_det/base/delay.h
Normal file
41
source/elec_det/base/delay.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef __DELAY_H_
|
||||
#define __DELAY_H_
|
||||
#include "base/define.h"
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
void Systick_init(uint32_t tick);
|
||||
void delay_ms(uint32_t nms);
|
||||
void delay_us(uint32_t nus);
|
||||
void delay_nop(uint32_t nop);
|
||||
#define delay_os_ms(ms) rt_thread_delay(ms)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
458
source/elec_det/base/utility.c
Normal file
458
source/elec_det/base/utility.c
Normal file
@@ -0,0 +1,458 @@
|
||||
|
||||
|
||||
#include "utility.h"
|
||||
float myatof(const char* str)
|
||||
{
|
||||
|
||||
uint32_t int_nu = 0;
|
||||
uint32_t flot_nu = 0;
|
||||
float val;
|
||||
float f_count = 1;
|
||||
while((*str != 0) && (*str != '.'))
|
||||
{
|
||||
if(*str > '9' && *str < '0')
|
||||
{
|
||||
str++;
|
||||
continue;
|
||||
}
|
||||
int_nu = int_nu*10+(*str - 48);
|
||||
str++;
|
||||
}
|
||||
|
||||
if(*str == 0)
|
||||
{
|
||||
val = int_nu;
|
||||
return val;
|
||||
}
|
||||
str++;
|
||||
while(*str != 0)
|
||||
{
|
||||
if(*str > '9' && *str < '0')
|
||||
{
|
||||
str++;
|
||||
continue;
|
||||
}
|
||||
flot_nu = flot_nu*10+(*str - 48);
|
||||
f_count *= 10;
|
||||
str++;
|
||||
}
|
||||
val = flot_nu;
|
||||
val = val / f_count + int_nu;
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
*@brief string to uint16_t
|
||||
*@param str:src string, base:
|
||||
*@return num:convert result
|
||||
*/
|
||||
uint16_t atoi16(const char* str,uint16_t base)
|
||||
{
|
||||
unsigned int num = 0;
|
||||
while (*str !=0)
|
||||
num = num * base + c2d(*str++);
|
||||
return num;
|
||||
}
|
||||
|
||||
/**
|
||||
*@brief string to uint32
|
||||
*@param str:src string, base:
|
||||
*@return num:convert result
|
||||
*/
|
||||
uint32_t atoi32(const char* str,uint16_t base)
|
||||
{
|
||||
uint32_t num = 0;
|
||||
while (*str !=0)
|
||||
num = num * base + c2d(*str++);
|
||||
return num;
|
||||
}
|
||||
|
||||
/**
|
||||
*@brief uint16 data to string
|
||||
*@param n:src num, str[5]:string buffer len:string size
|
||||
*@return void
|
||||
*/
|
||||
void itoa(uint16_t n,uint8_t str[5], uint8_t len)
|
||||
{
|
||||
|
||||
uint8_t i=len-1;
|
||||
|
||||
memset(str,0x20,len);
|
||||
do{
|
||||
str[i--]=n%10+'0';
|
||||
|
||||
}while((n/=10)>0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*@brief dec or hex string convert to uint32_t
|
||||
*@param str:src string, ret: the pointer of result
|
||||
*@return success = 1, fail = 0
|
||||
*/
|
||||
int validatoi(const char* str, int base,uint32_t* ret)
|
||||
{
|
||||
int c;
|
||||
const char* tstr = str;
|
||||
if(str == 0 || *str == '\0')
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
while(*tstr != '\0')
|
||||
{
|
||||
c = c2d(*tstr);
|
||||
if( (c >= 0) && (c < base))
|
||||
{
|
||||
tstr++;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
*ret = atoi32(str,base);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
*@brief new char to replace the old char
|
||||
*@param str:src string,oldchar:dst char,newchar:src char
|
||||
*@return void
|
||||
*/
|
||||
void replacetochar(char * str, char oldchar,char newchar)
|
||||
{
|
||||
int x;
|
||||
for (x = 0; str[x]; x++)
|
||||
if (str[x] == oldchar) str[x] = newchar;
|
||||
}
|
||||
|
||||
/**
|
||||
*@brief char to num
|
||||
*@param c:src char
|
||||
*@return convert result
|
||||
*/
|
||||
char c2d(const uint8_t c)
|
||||
{
|
||||
if (c >= '0' && c <= '9')
|
||||
return c - '0';
|
||||
if (c >= 'a' && c <= 'f')
|
||||
return 10 + c -'a';
|
||||
if (c >= 'A' && c <= 'F')
|
||||
return 10 + c -'A';
|
||||
|
||||
return (char)0;
|
||||
}
|
||||
/**
|
||||
*@brief num to char
|
||||
*@param c:src num
|
||||
*@return convert result
|
||||
*/
|
||||
char d2c(const uint8_t c)
|
||||
{
|
||||
if ( c <= 9)
|
||||
{
|
||||
return c + '0';
|
||||
}
|
||||
if (c >= 0x0a && c <= 0x0f)
|
||||
{
|
||||
return c + 'a' - 10;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*@brief 2bytes swap
|
||||
*@param i:src num
|
||||
*@return convert result
|
||||
*/
|
||||
uint16_t swaps(uint16_t i)
|
||||
{
|
||||
uint16_t ret=0;
|
||||
ret = (i & 0xFF) << 8;
|
||||
ret |= ((i >> 8)& 0xFF);
|
||||
return ret;
|
||||
}
|
||||
/**
|
||||
*@brief 4 bytes swap, bytes order 4 3 2 1 convert to 1 2 3 4
|
||||
*@param i:src num
|
||||
*@return convert result
|
||||
*/
|
||||
uint32_t swapl(uint32_t l)
|
||||
{
|
||||
uint32_t ret=0;
|
||||
ret = (l & 0xFF) << 24;
|
||||
ret |= ((l >> 8) & 0xFF) << 16;
|
||||
ret |= ((l >> 16) & 0xFF) << 8;
|
||||
ret |= ((l >> 24) & 0xFF);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
*@brief get substring
|
||||
*@param src:src string s1: target begin s2: target end sub: result pointer
|
||||
*@return void
|
||||
*/
|
||||
void mid(const char* src, const char* s1, const char* s2, char* sub)
|
||||
{
|
||||
char* sub1;
|
||||
char* sub2;
|
||||
uint16_t n;
|
||||
|
||||
sub1=strstr(src,s1);
|
||||
sub1+=strlen(s1);
|
||||
sub2=strstr(sub1,s2);
|
||||
n=sub2-sub1;
|
||||
strncpy(sub,sub1,n);
|
||||
sub[n]=0;
|
||||
}
|
||||
/**
|
||||
*@brief bytes array conver to string
|
||||
*@param *data: ponit src bytes len: array length str: resuter string pointer
|
||||
*@return void
|
||||
*/
|
||||
|
||||
void bytes2hexString(const char* data, uint32_t len, char* str)
|
||||
{
|
||||
char c_temp;
|
||||
while(len > 0)
|
||||
{
|
||||
c_temp = ((*data) &0xF0) >> 4;
|
||||
if(c_temp < 10)
|
||||
{
|
||||
*str = c_temp + '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
*str = (c_temp - 10) + 'A';
|
||||
}
|
||||
|
||||
c_temp = ((*data) &0x0F);
|
||||
str++;
|
||||
if(c_temp < 10)
|
||||
{
|
||||
*str = c_temp + '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
*str = (c_temp - 10)+ 'A';
|
||||
}
|
||||
str++;
|
||||
data++;
|
||||
len--;
|
||||
}
|
||||
*(str++) = '\0';
|
||||
|
||||
}
|
||||
/*
|
||||
Hex Datas to Bytes
|
||||
*/
|
||||
uint8_t HexStrings2Byte(char**strs,uint16_t size,uint8_t* buf,uint16_t buf_size)
|
||||
{
|
||||
char* str;
|
||||
uint8_t data = 0;
|
||||
uint16_t count = 0;
|
||||
while((size > 0) && (count < buf_size))
|
||||
{
|
||||
str = strs[count++];
|
||||
size--;
|
||||
data = 0;
|
||||
while(*str != '\0')
|
||||
{
|
||||
|
||||
if(*str == '0')
|
||||
{
|
||||
if((*(str+1) == 'X') || (*(str+1) == 'x'))
|
||||
{
|
||||
str+=2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
data <<=4;
|
||||
data |=c2d(*str);
|
||||
str++;
|
||||
}
|
||||
*buf = data;
|
||||
buf++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Hex Datas to uint32_t
|
||||
*/
|
||||
uint32_t HexStrings2UInt(char*str)
|
||||
{
|
||||
|
||||
uint32_t data = 0;
|
||||
uint16_t count = 0;
|
||||
data = 0;
|
||||
while(*str != '\0' && count < 10)
|
||||
{
|
||||
|
||||
if(*str == '0')
|
||||
{
|
||||
if((*(str+1) == 'X') || (*(str+1) == 'x'))
|
||||
{
|
||||
str+=2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
data <<=4;
|
||||
data |=c2d(*str);
|
||||
str++;
|
||||
count++;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
//冒泡排序16位数据
|
||||
void Bubble_Sort_u16(uint16_t* buf,uint32_t len)
|
||||
{
|
||||
uint32_t ul_temp1 = 0;
|
||||
uint32_t ul_temp2 = 0;
|
||||
uint16_t us_temp;
|
||||
if(len < 2)
|
||||
return;
|
||||
for(ul_temp2 = 0; ul_temp2 < len-1; ul_temp2++)
|
||||
{
|
||||
for(ul_temp1 = 0; ul_temp1 < len-1-ul_temp2; ul_temp1++)
|
||||
{
|
||||
if(buf[ul_temp1] > buf[ul_temp1+1])
|
||||
{
|
||||
us_temp = buf[ul_temp1];
|
||||
buf[ul_temp1] = buf[ul_temp1 + 1];
|
||||
buf[ul_temp1 + 1] = us_temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//数据左移
|
||||
void BufMoveLeft(uint8_t* srcbuf,uint16_t offset,uint16_t data_len)
|
||||
{
|
||||
uint8_t index = 0;
|
||||
while(data_len > 0)
|
||||
{
|
||||
srcbuf[index] = srcbuf[index+offset];
|
||||
data_len--;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
//数据右移
|
||||
void BufMoveRight(uint8_t* srcbuf,uint16_t offset,uint16_t data_len)
|
||||
{
|
||||
while(data_len > 0)
|
||||
{
|
||||
data_len--;
|
||||
srcbuf[data_len+offset] = srcbuf[data_len] ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//@brief 计算数组的CRC8值
|
||||
//@param *srcbuf 数据源指针
|
||||
//@param len 数据源长度
|
||||
//@rtvl 返回计算结果
|
||||
uint8_t CheckXOR_8(uint8_t* srcbuf,uint16_t len)
|
||||
{
|
||||
uint8_t crc = 0x00;
|
||||
while(len--)
|
||||
{
|
||||
crc ^= *srcbuf++;
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
|
||||
//@brief 计算数组异或校验值
|
||||
//@param *Ptr 数据源
|
||||
//@param num 计算长度
|
||||
//@rtvl 返回计算结果
|
||||
uint8_t CheckCRC_8(uint8_t* Ptr,uint16_t num)
|
||||
{
|
||||
uint8_t crc = 0;
|
||||
uint16_t j,i;
|
||||
|
||||
for (j = 0; j < num; j++)
|
||||
{
|
||||
crc ^= *(Ptr+j);
|
||||
for ( i = 0; i < 8; i++)
|
||||
{
|
||||
if ((crc & 0x01) != 0)
|
||||
{
|
||||
crc >>= 1;
|
||||
crc ^= 0x8c;
|
||||
}
|
||||
else
|
||||
{
|
||||
crc >>= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
//@brief 计算CRC32
|
||||
//@param *srcbuf 数据源
|
||||
//@param len 计算长度
|
||||
//@rtvl 返回计算结果
|
||||
uint32_t Crc32Calu(uint32_t* buf, uint32_t len)
|
||||
{
|
||||
uint32_t temp,crc = 0xFFFFFFFF;
|
||||
|
||||
uint32_t i,j;
|
||||
i = 0;
|
||||
if(((uint32_t)buf %4) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
while(i<len)
|
||||
{
|
||||
temp = *buf;
|
||||
i += 4;
|
||||
buf ++;
|
||||
for(j=0; j<32; j++)
|
||||
{
|
||||
if( (crc ^ temp) & 0x80000000 )
|
||||
{
|
||||
crc = 0x04C11DB7 ^(crc<<1);
|
||||
}
|
||||
else
|
||||
{
|
||||
crc <<=1;
|
||||
}
|
||||
temp<<=1;
|
||||
}
|
||||
crc&=0xFFFFFFFF;
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
/*
|
||||
@brief 获取数组中的最大值和最小值
|
||||
@param *aus_buf 缓存数组
|
||||
@param us_size 数组长度
|
||||
@param *us_max 最大值
|
||||
@param *us_min 最小值
|
||||
*/
|
||||
|
||||
void GetMaxAndMinValue(uint16_t* aus_buf,uint16_t us_size,uint16_t* us_max,uint16_t* us_min)
|
||||
{
|
||||
*us_max = 0;
|
||||
*us_min = ~0;
|
||||
while(us_size > 0)
|
||||
{
|
||||
if(*us_max < *aus_buf)
|
||||
{
|
||||
*us_max = *aus_buf;
|
||||
}
|
||||
if(*us_min > *aus_buf)
|
||||
{
|
||||
*us_min = *aus_buf;
|
||||
}
|
||||
aus_buf++;
|
||||
us_size--;
|
||||
}
|
||||
}
|
60
source/elec_det/base/utility.h
Normal file
60
source/elec_det/base/utility.h
Normal file
@@ -0,0 +1,60 @@
|
||||
#ifndef _UTILITY_H
|
||||
#define _UTILITY_H
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "stm32f10x.h"
|
||||
|
||||
float myatof(const char* str);
|
||||
uint16_t atoi16(const char* str,uint16_t base); /* Convert a string to integer number */
|
||||
uint32_t atoi32(const char* str,uint16_t base); /* Convert a string to integer number */
|
||||
void itoa(uint16_t n,uint8_t* str, uint8_t len);
|
||||
int validatoi(const char* str, int base, uint32_t* ret); /* Verify character string and Convert it to (hexa-)decimal. */
|
||||
char c2d(uint8_t c);
|
||||
char d2c(uint8_t c);
|
||||
uint16_t swaps(uint16_t i);
|
||||
uint32_t swapl(uint32_t l);
|
||||
|
||||
void replacetochar(char * str, char oldchar, char newchar);
|
||||
|
||||
void mid(const char* src, const char* s1, const char* s2, char* sub);
|
||||
|
||||
void bytes2hexString(const char* data, uint32_t len, char* str);
|
||||
//冒泡排序16位数据
|
||||
void Bubble_Sort_u16(uint16_t* buf,uint32_t len);
|
||||
//数据左移
|
||||
void BufMoveLeft(uint8_t* srcbuf,uint16_t offset,uint16_t data_len);
|
||||
//数据右移
|
||||
void BufMoveRight(uint8_t* srcbuf,uint16_t offset,uint16_t data_len);
|
||||
/*
|
||||
Hex Datas to Bytes
|
||||
*/
|
||||
uint8_t HexStrings2Byte(char**strs,uint16_t size,uint8_t* buf,uint16_t buf_size);
|
||||
/*
|
||||
Hex Datas to uint32_t
|
||||
*/
|
||||
uint32_t HexStrings2UInt(char*str);
|
||||
//@brief 计算数组异或校验值
|
||||
//@param *srcbuf 数据源
|
||||
//@param len 计算长度
|
||||
//@rtvl 返回计算结果
|
||||
uint8_t CheckCRC_8(uint8_t* Ptr,uint16_t num);
|
||||
//@brief 计算CRC32
|
||||
//@param *srcbuf 数据源
|
||||
//@param len 计算长度
|
||||
//@rtvl 返回计算结果
|
||||
uint32_t Crc32Calu(uint32_t* buf, uint32_t len);
|
||||
/*
|
||||
@brief 获取数组中的最大值和最小值
|
||||
@param *aus_buf 缓存数组
|
||||
@param us_size 数组长度
|
||||
@param *us_max 最大值
|
||||
@param *us_min 最小值
|
||||
*/
|
||||
|
||||
void GetMaxAndMinValue(uint16_t* aus_buf,uint16_t us_size,uint16_t* us_max,uint16_t* us_min);
|
||||
//@brief 计算数组的CRC8值
|
||||
//@param *srcbuf 数据源指针
|
||||
//@param len 数据源长度
|
||||
//@rtvl 返回计算结果
|
||||
uint8_t CheckXOR_8(uint8_t* srcbuf,uint16_t len);
|
||||
#endif
|
1530
source/elec_det/driver/EWDriver.c
Normal file
1530
source/elec_det/driver/EWDriver.c
Normal file
File diff suppressed because it is too large
Load Diff
326
source/elec_det/driver/EWDriver.h
Normal file
326
source/elec_det/driver/EWDriver.h
Normal file
@@ -0,0 +1,326 @@
|
||||
#ifndef EWDRIVER_H
|
||||
#define EWDRIVER_H
|
||||
#include "base/define.h"
|
||||
|
||||
#define EW_DMODE_FRAME_SIZE 16
|
||||
|
||||
#
|
||||
typedef enum {
|
||||
SINGLE_MOD = (uint8_t)0,
|
||||
DIFF_MOD = (uint8_t)1,
|
||||
OFF_MOD = (uint8_t)2,
|
||||
} EWBus_Mod_en;
|
||||
|
||||
|
||||
typedef enum{
|
||||
BEGIN_FRAME = (uint8_t)0,
|
||||
END_FRAME = (uint8_t)1,
|
||||
DATA_FRAME = (uint8_t)2,
|
||||
COMPLETE_FRAME = (uint8_t)3,
|
||||
}EW_SINGLE_FRAME_TYPE_en;
|
||||
#pragma pack(1)
|
||||
//系统运行时配置
|
||||
typedef union {
|
||||
struct{
|
||||
uint8_t fire_mos_sw : 2;//起爆mos开关选择 0 内部 1 外部 (默认0)
|
||||
uint8_t vbus_rx_sg : 2;//接收数据信号 1 vbuss_rxh 2 vbuss_rxl 3 vbusd_rx (默认 3)
|
||||
uint8_t vbus_mode : 2;//通讯类型判断 01 差分 10 单端。00 11 根据总线电压判断 (默认 01)
|
||||
uint8_t reserve01 : 2;//保留
|
||||
uint8_t reset_run_step : 3;//打点周期 0 不打点 1 5ms 2 10ms 3 20ms 4 50ms 5 100ms 6 150ms 7 200ms(默认 0)
|
||||
uint8_t uid_len : 3;//uid长度 uid_len + 7(默认 1)
|
||||
uint8_t pwd_len : 2;//密码长度 pwd_len + 4(默认0)
|
||||
uint8_t version : 5;//模块版本
|
||||
uint8_t reserve02 : 3;//保留
|
||||
uint8_t crc8 : 8;//校验位
|
||||
} runcfg_st;
|
||||
uint32_t run_param;
|
||||
uint8_t run_cfg_buf[4];
|
||||
}RunCfg_un;
|
||||
|
||||
typedef union{
|
||||
//系统状态标志结构体
|
||||
volatile struct
|
||||
{
|
||||
|
||||
uint8_t timeramend_flag : 1; //时钟校准标志 0
|
||||
uint8_t saveinfo_flag : 1; //保存延时设置信息 1
|
||||
uint8_t pswd_flag : 1; //密码验证完成标志 2
|
||||
uint8_t delay_time : 1; //延时设置完成标志 3
|
||||
|
||||
uint8_t addr_set : 1; //网络地址已设置
|
||||
uint8_t set_super_t : 1; //开启软件复位 5
|
||||
uint8_t erprom_error : 1; //系统存储错误 6
|
||||
uint8_t sys_error : 1; //系统运行异常 7
|
||||
|
||||
|
||||
uint8_t charge_8v : 1; //充电电压大于8V 8
|
||||
uint8_t charge_16V : 1; //充电电压大于16V标志 9
|
||||
uint8_t charge_20v : 1; //充电电压大于20V 10
|
||||
uint8_t fireline_flag : 1; //桥丝检测 11
|
||||
|
||||
|
||||
uint8_t charge_ctrl_flag : 1; //充放电开关检测 12
|
||||
uint8_t mosfet_flag : 1; //MOS开关检测标志 13
|
||||
uint8_t charge_cmd : 1; //已经发送充电命令 14
|
||||
uint8_t fire_flag : 1; //已点火 15
|
||||
|
||||
|
||||
uint8_t comm_frame : 1; //通讯帧结束标志
|
||||
uint8_t factory_check : 1; //工厂自检
|
||||
uint8_t comm_mode : 1; //通讯模式
|
||||
uint8_t vbusd_invert : 1; //VBUSD 的极性
|
||||
|
||||
|
||||
uint8_t comm_timeout : 1; //通信超时
|
||||
uint8_t reserve10 : 1;
|
||||
uint8_t reserve09 : 1;
|
||||
uint8_t reserve08 : 1;
|
||||
|
||||
uint8_t reserve07 : 1;
|
||||
uint8_t reserve06 : 1;
|
||||
uint8_t reserve05 : 1;
|
||||
uint8_t reserve04 : 1;
|
||||
|
||||
uint8_t reserve03 : 1;
|
||||
uint8_t reserve02 : 1;
|
||||
uint8_t reserve01 : 1;
|
||||
uint8_t reserve00 : 1;
|
||||
} State_st;
|
||||
|
||||
|
||||
volatile uint32_t data;
|
||||
volatile uint16_t us_data[2];
|
||||
volatile uint8_t datas[4];
|
||||
}System_State_un;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
#define EW_WA_CFG_WRITE 20 //写配置寄存器(掉电不保存)
|
||||
#define EW_WA_SET_COMMADDR 21 //设置网络地址
|
||||
#define EW_WA_FAST_CFG 22 //快速配置地址,延时,密码验证
|
||||
#define EW_WA_SET_DELAY 23 //设置延时
|
||||
#define EW_RA_VERIFY_PWD 24 //密码验证
|
||||
#define EW_W_ON_FIRE 25 //起爆
|
||||
#define EW_W_CHARGE 26 //充电
|
||||
#define EW_W_DISCHARGE 27 //放电
|
||||
#define EW_RA_GET_STATE 28 //读状态
|
||||
#define EW_W_AMEND 29 //时钟校准
|
||||
#define EW_RA_INSPECT 30 //巡检
|
||||
#define EW_RA_CHECK_CFG 31 //配置区验证
|
||||
#define EW_R_ELECT_TEST 32 //电性能检测
|
||||
#define EW_W_SAVE_FIRE_SET 33 //保存起爆测试
|
||||
#define EW_RA_READ_DELAY 34 //读延时
|
||||
#define EW_R_TX_CFG 35 //反码配置
|
||||
#define EW_WR_UPDATE_ADDR 36 //更新网络地址
|
||||
#define EW_RA_AMEND_VALUE 37 //读校准值
|
||||
#define EW_RA_CFG_INFO 38 //读配置信息
|
||||
#define EW_W_AUTO_ADDR 39 //自动分配地址
|
||||
#define EW_EN_MTP 40 //使失能MTP
|
||||
#define EW_RA_UID 41 //读UID
|
||||
|
||||
#define EW_COMM_TEST 60 //通信测试没问题
|
||||
#define EW_BOOTLOADER_RUN 61 //运行bootloader
|
||||
#define EW_RA_REGISTER 62 //读MTP
|
||||
#define EW_WA_REGISTER 63 //写MTP
|
||||
|
||||
/*
|
||||
@brief 单端第二版,差分接收数据
|
||||
@param *buf 数据缓存指针
|
||||
@param len 读取数据长度
|
||||
@param time_out 超时脉冲数(约1bit数据时间)
|
||||
@rtv 0 成功 否则失败
|
||||
*/
|
||||
|
||||
|
||||
uint8_t DMod_FireBusReadDatasV2(uint8_t* buf, uint8_t len, uint32_t time_out);
|
||||
|
||||
/*
|
||||
@brief 差分模式数据发送
|
||||
@param buf 发送数据缓存
|
||||
@param len 发送长度
|
||||
@param pre 数据脉冲周期
|
||||
|
||||
*/
|
||||
void DMod_SendBytes(uint8_t* buf, uint8_t len, uint16_t pre,uint8_t rw_flag);
|
||||
void DMod_SendBytesXor(uint8_t* buf, uint8_t len, uint8_t rw_flag);
|
||||
uint8_t DMod_ReadBytesXor(uint8_t* buf, uint8_t len,uint16_t retry_times);
|
||||
|
||||
/*
|
||||
@breif 通信测试
|
||||
*/
|
||||
uint8_t EW_CommTest(uint8_t* buf,uint16_t len,uint16_t cycle);
|
||||
/*
|
||||
@brief 使能MTP写
|
||||
@param addr 通信地址
|
||||
@param 使能开关
|
||||
@rtv 执行结果
|
||||
*/
|
||||
uint8_t EW_EnWriteMTP(uint16_t addr ,uint8_t en_flag);
|
||||
/*
|
||||
@brief 读MTP
|
||||
@param addr 通信地址
|
||||
@param mtpaddr MTP地址/4
|
||||
@param buf 写入数据的缓存
|
||||
@param len 数据长度
|
||||
*/
|
||||
uint8_t EW_WriteMTP(uint16_t addr,uint8_t mtpaddr,uint8_t* buf,uint8_t len);
|
||||
/*
|
||||
@brief 读MTP
|
||||
@param addr 通信地址
|
||||
@param mtpaddr MTP地址/4
|
||||
@param buf 读出数据的缓存
|
||||
@param len 数据长度
|
||||
*/
|
||||
uint8_t EW_ReadMTP(uint16_t addr,uint8_t mtpaddr,uint8_t* buf,uint8_t len);
|
||||
/*
|
||||
@brief 运行BootLoader程序
|
||||
@param addr 通信地址
|
||||
@param reboot 仅重启标准 1 有效
|
||||
@rtv 返回执行结果 0 成功
|
||||
*/
|
||||
uint8_t EW_RunBootLoader(uint16_t addr,uint8_t reboot);
|
||||
/*
|
||||
@brief 写运行配置,写入MTP中
|
||||
@param addr 通信地址
|
||||
@param runcfg 配置结构体
|
||||
@rtv 返回执行结果
|
||||
*/
|
||||
uint8_t EW_WriteRunCfg(uint16_t addr,RunCfg_un* runcfg);
|
||||
/*
|
||||
@brief 快速分配通信地址
|
||||
@param 通信地址
|
||||
@param UID
|
||||
@param uid_len UID长度
|
||||
@param ack_data 应答数据 包括2bytes延时和2bytes状态
|
||||
@rtv 执行结果
|
||||
*/
|
||||
|
||||
uint8_t EW_SetAddrByUID(uint16_t addr,uint8_t* uid,uint8_t uid_len,uint8_t* ack_data);
|
||||
/*
|
||||
@brief 快速分配通信地址
|
||||
@param 通信地址
|
||||
@param 设置延时
|
||||
@param UID
|
||||
@param UID长度
|
||||
@param 应答数据 包括2bytes延时和2bytes状态
|
||||
@rtv 执行结果
|
||||
*/
|
||||
|
||||
uint8_t EW_FastSetByUID(uint16_t addr,uint16_t delay, uint8_t pwd_flag,uint8_t* uid,uint8_t uid_len,uint8_t* ack_data);
|
||||
/*
|
||||
@brief 设置延时
|
||||
@param addr 通信地址
|
||||
@param 延期时间
|
||||
@rtv 返回执行结果
|
||||
*/
|
||||
uint8_t EW_SetDelay(uint16_t addr,uint16_t delay);
|
||||
/*
|
||||
@brief 密码验证
|
||||
@param addr 通信地址
|
||||
@param 密码数据
|
||||
@param 密码长度
|
||||
@rtv 返回执行结果
|
||||
*/
|
||||
uint8_t EW_VerfyPWD(uint16_t addr,uint8_t* pwd,uint8_t pwd_len);
|
||||
/*
|
||||
@brief 密码验证
|
||||
@param addr 通信地址
|
||||
@param 延迟起爆时间*50ms
|
||||
@rtv 返回执行结果
|
||||
*/
|
||||
uint8_t EW_Boom(uint16_t addr,uint8_t delay_count);
|
||||
/*
|
||||
@brief 分组充电
|
||||
@param addr 通信地址
|
||||
@param 充电挡位 0:直通 1 :16V 2:20V 3:2.5V
|
||||
@param 分组挡位 addr = group*4 大于addr的可以充电
|
||||
@rtv 返回执行结果
|
||||
*/
|
||||
uint8_t EW_Charge(uint16_t addr,uint8_t chg_class,uint8_t group);
|
||||
/*
|
||||
@brief 放电
|
||||
@param addr 通信地址
|
||||
*/
|
||||
uint8_t EW_DisCharge(uint16_t addr);
|
||||
/*
|
||||
@brief 读状态信息
|
||||
@param addr 通信地址
|
||||
@param *delay 返回延时数据
|
||||
@param *state 返回状态码
|
||||
@param len 数据长度
|
||||
*/
|
||||
uint8_t EW_ReadState(uint16_t addr,uint8_t* state);
|
||||
/*
|
||||
@brief 校准地址
|
||||
@param addr 通信地址
|
||||
@param cycle 校准周期 us
|
||||
@param plus_count 脉冲个数
|
||||
*/
|
||||
uint8_t EW_ClkAmend(uint16_t addr ,uint16_t cycle,uint16_t plus_count);
|
||||
/*
|
||||
@brief 巡检
|
||||
@param addr 通信地址
|
||||
@param cycle 校准周期 us
|
||||
@param plus_count 脉冲个数
|
||||
*/
|
||||
uint8_t EW_Inspect(uint16_t bgaddr ,uint16_t endaddr,uint16_t state,uint8_t* buf);
|
||||
/*
|
||||
@brief 配置验证
|
||||
@param addr 通信地址
|
||||
@param cfg_mask 源掩码信息
|
||||
@param 比较信息 (EW_Cfg & cfg_mask) == cfg_state
|
||||
@param 反码状态 0 比较通过不反码 1 比较通过反码
|
||||
@param
|
||||
*/
|
||||
uint8_t EW_CheckRunCfg(uint16_t addr,uint32_t cfg_mask ,uint16_t cfg_state,uint8_t* rtv);
|
||||
/*
|
||||
@brief 配置验证
|
||||
@param addr 通信地址
|
||||
@param check_class 检测模式 0 基本自检 1 起爆开关检测 2 电容检测 4 读电容检测时间
|
||||
@param *buf 读出测试结果
|
||||
*/
|
||||
uint8_t EW_ChecSelf(uint16_t addr,uint8_t check_class,uint8_t* buf);
|
||||
/*
|
||||
@brief 保持起爆配置信息和使能起爆
|
||||
*/
|
||||
uint8_t EW_SaveFireInfo(uint16_t addr);
|
||||
/*
|
||||
@brief 读延时和状态值
|
||||
@param addr 通信地址
|
||||
@param delay 返回延时
|
||||
*/
|
||||
uint8_t EW_ReadDelay(uint16_t addr,uint16_t* delay);
|
||||
/*
|
||||
@brief 通信反码配置
|
||||
@param addr 通信地址
|
||||
@param speed 通信挡位 0:10K 1:7K 2:5K 3:4.5K 4: 4K 4+n:4-0.5*n
|
||||
@param cur 电流挡位 0:1mA 1:2mA 2:4mA 3:8mA
|
||||
*/
|
||||
uint8_t EW_SetReportCfg(uint8_t speed,uint8_t cur);
|
||||
/*
|
||||
@brief 更新网络地址
|
||||
@param addr 通信地址
|
||||
@param new_addr 新地址
|
||||
*/
|
||||
uint8_t EW_UpdateCommAddr(uint8_t addr,uint16_t new_addr);
|
||||
/*
|
||||
@brief 读校准值
|
||||
@param addr 通信地址
|
||||
@param clk_amend 校准信息
|
||||
*/
|
||||
uint8_t EW_ReadClkAmend(uint16_t addr,uint32_t* clk_amend);
|
||||
/*
|
||||
@brief 读校准值
|
||||
@param addr 通信地址
|
||||
@param clk_amend 校准信息
|
||||
*/
|
||||
uint8_t EW_ReadRunCfgVersion(uint16_t addr,uint8_t* run_cfg,uint16_t* version);
|
||||
/*
|
||||
@brief 自动分配地址
|
||||
@param max_addr 分配的最大地址
|
||||
@param fac_addr 分配因子
|
||||
*/
|
||||
uint8_t EW_AutoSetAddr(uint16_t max_addr,uint16_t fac_addr);
|
||||
#endif
|
||||
|
||||
|
642
source/elec_det/driver/JQDriver.c
Normal file
642
source/elec_det/driver/JQDriver.c
Normal file
@@ -0,0 +1,642 @@
|
||||
#include "JQDriver.h"
|
||||
#include "base/delay.h"
|
||||
#include "hardware/adc_cfg.h"
|
||||
#include "base/utility.h"
|
||||
#include "hardware/power.h"
|
||||
#include "hardware/timer_cfg.h"
|
||||
#include "hardware/power.h"
|
||||
static uint16_t jq_idle_current;
|
||||
|
||||
#define JQ_IDLE_NOISE 100
|
||||
|
||||
#if JQ_Read_AD_Sample_C > FIREBUS_ADC_BUF_LEN
|
||||
#error "JQDriver.c Firbus AD Sample BUFFER SIZE LIMIT"
|
||||
#else
|
||||
volatile uint16_t* JQ_Read_AD_V = FireBus_ADC_Buf;
|
||||
#endif
|
||||
static uint16_t jq_ad_last_sample;
|
||||
static volatile CurrentSample_Range_eu buscurrent_range = Current_Max;
|
||||
|
||||
uint16_t JQ_FreeBack_MaxCur;
|
||||
uint16_t JQ_FreeBack_MaxTime;
|
||||
uint16_t JQ_FreeBack_MinCur;
|
||||
uint16_t JQ_FreeBack_MinTime;
|
||||
|
||||
uint16_t JQ_CommEnd_MaxCur = 0;
|
||||
uint8_t JQ_CommEnd_CurEn = 0;
|
||||
|
||||
|
||||
uint16_t JQ_EnFreeBack_Test = 0;
|
||||
|
||||
static void JQ_CommBegin()
|
||||
{
|
||||
CurrentSampleR_Def;
|
||||
WaitDelayEnd(200);//20ms
|
||||
}
|
||||
static void JQ_CommEnd()
|
||||
{
|
||||
uint16_t us_temp;
|
||||
StartDelayTime();
|
||||
if(JQ_CommEnd_CurEn > 0)
|
||||
{
|
||||
delay_os_ms(10);
|
||||
us_temp = ADC_Comm1p6mA_EndCur();
|
||||
if(us_temp > JQ_CommEnd_MaxCur)
|
||||
{
|
||||
JQ_CommEnd_MaxCur = us_temp;
|
||||
}
|
||||
}
|
||||
CurrentSampleR_Def;
|
||||
}
|
||||
|
||||
/*
|
||||
@brief 采样总线反馈数据
|
||||
@param sample_count 采样次数
|
||||
*/
|
||||
|
||||
static void JQ_Sample(uint16_t sample_count)
|
||||
{
|
||||
uint16_t us_adv = 0;
|
||||
uint16_t ul_count = 0;
|
||||
jq_ad_last_sample = GetADC_Fast(ADC_CURR_DE);
|
||||
for(ul_count = 0;ul_count < sample_count; ul_count++)
|
||||
{
|
||||
us_adv = GetADC_Fast(ADC_CURR_DE);
|
||||
JQ_Read_AD_V[ul_count] = us_adv;
|
||||
jq_ad_last_sample = us_adv;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@brief 通信反码信息初始化
|
||||
*/
|
||||
void JQ_FreeBack_Prapare(uint8_t enable_flag)
|
||||
{
|
||||
JQ_FreeBack_MaxCur = 0;
|
||||
JQ_FreeBack_MaxTime = 0;
|
||||
JQ_FreeBack_MinCur = 0xFFFF;
|
||||
JQ_FreeBack_MinTime = 0xFFFF;
|
||||
JQ_EnFreeBack_Test = enable_flag;
|
||||
}
|
||||
|
||||
//@brief 采样空闲电流
|
||||
void JQ_SampleIdleCurrent()
|
||||
{
|
||||
uint16_t sample_count;
|
||||
uint32_t ul_adc_v = 0;
|
||||
JQBUS_W_1;
|
||||
delay_ms(1);
|
||||
JQ_Sample(JQ_Read_AD_Sample_C_IDLE);
|
||||
Bubble_Sort_u16((uint16_t*)JQ_Read_AD_V,JQ_Read_AD_Sample_C_IDLE);
|
||||
sample_count = 15;
|
||||
while(sample_count < 25)
|
||||
{
|
||||
ul_adc_v +=JQ_Read_AD_V[sample_count++];
|
||||
}
|
||||
jq_idle_current = ul_adc_v/10 + JQ_IDLE_NOISE;
|
||||
delay_us(200);
|
||||
JQBUS_W_0
|
||||
delay_us(2000);
|
||||
}
|
||||
/*
|
||||
@brief 读取1bit数据
|
||||
@rtv 返回读取结果
|
||||
*/
|
||||
uint16_t JQDriver_SAMPLE_Time;
|
||||
|
||||
uint8_t JQ_ReadBit(void)
|
||||
{
|
||||
uint16_t sample_count = 0;
|
||||
uint32_t ul_adv_sum = 0;
|
||||
uint8_t uc_bit = 0;
|
||||
uint16_t uc_mincur_index = 0;
|
||||
JQBUS_W_1;
|
||||
delay_us(150);
|
||||
Get1usCount();
|
||||
JQ_Sample(JQ_Read_AD_Sample_C);
|
||||
JQDriver_SAMPLE_Time = Get1usCount();
|
||||
JQBUS_W_0;
|
||||
|
||||
while(sample_count < JQ_Read_AD_Sample_C)
|
||||
{
|
||||
if(JQ_Read_AD_V[sample_count] > jq_idle_current )
|
||||
{
|
||||
uc_bit++;
|
||||
ul_adv_sum += JQ_Read_AD_V[sample_count] ;
|
||||
}else if(uc_bit < 2)//连续两个大于2启动检测
|
||||
{
|
||||
uc_bit = 0;
|
||||
ul_adv_sum = 0;
|
||||
}
|
||||
sample_count++;
|
||||
}
|
||||
if(uc_bit > 10)
|
||||
{
|
||||
|
||||
/***************记录反码信息*************************/
|
||||
ul_adv_sum = ul_adv_sum / uc_bit;
|
||||
if( JQ_EnFreeBack_Test > 0 )
|
||||
{
|
||||
if(JQ_FreeBack_MaxCur == 0)
|
||||
{
|
||||
JQ_FreeBack_MaxCur = JQ_FreeBack_MinCur = ul_adv_sum;
|
||||
}else if(ul_adv_sum > JQ_FreeBack_MaxCur){
|
||||
JQ_FreeBack_MaxCur = ul_adv_sum;
|
||||
}else if(ul_adv_sum < JQ_FreeBack_MinCur){
|
||||
JQ_FreeBack_MinCur = ul_adv_sum;
|
||||
|
||||
}
|
||||
|
||||
if(JQ_FreeBack_MaxTime == 0)
|
||||
{
|
||||
JQ_FreeBack_MaxTime = JQ_FreeBack_MinTime = uc_bit;
|
||||
}else if(uc_bit > JQ_FreeBack_MaxTime)
|
||||
{
|
||||
JQ_FreeBack_MaxTime = uc_bit;
|
||||
}else if(uc_bit < JQ_FreeBack_MinCur){
|
||||
JQ_FreeBack_MinTime = uc_bit;
|
||||
}
|
||||
|
||||
}
|
||||
delay_us(1100);
|
||||
return 1;
|
||||
}else{
|
||||
delay_us(350);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/*
|
||||
@brief 发送不读反馈信号的命令
|
||||
@param buf 命令字节缓存区
|
||||
@param len 缓存区数据长度
|
||||
|
||||
*/
|
||||
void JQ_SendBroadCast(uint8_t* buf,uint16_t len)
|
||||
{
|
||||
uint8_t uc_data;
|
||||
uint8_t uc_bitcount;
|
||||
JQ_CommBegin();
|
||||
JQBUS_W_0;
|
||||
delay_ms(2);
|
||||
while(len > 0)
|
||||
{
|
||||
|
||||
uc_bitcount = 0;
|
||||
uc_data = *buf;
|
||||
while(uc_bitcount < 8){
|
||||
if((uc_data & 0x80) > 0)
|
||||
{
|
||||
JQBUS_W_1;
|
||||
delay_us(JQBUS_H_PLUS);
|
||||
JQBUS_W_0;
|
||||
delay_us(JQBUS_L_PLUS);
|
||||
}else{
|
||||
JQBUS_W_1;
|
||||
delay_us(JQBUS_L_PLUS);
|
||||
JQBUS_W_0;
|
||||
delay_us(JQBUS_H_PLUS);
|
||||
}
|
||||
uc_bitcount++;
|
||||
uc_data <<= 1;
|
||||
}
|
||||
len--;
|
||||
buf++;
|
||||
}
|
||||
JQBUS_IDLE;
|
||||
JQ_CommEnd();
|
||||
}
|
||||
//@breif 发送读取命令
|
||||
static void JQ_SendReadCmd(uint8_t* cmd_buf,uint16_t w_len)
|
||||
{
|
||||
uint8_t uc_data;
|
||||
uint8_t uc_bitcount;
|
||||
JQBUS_W_0;
|
||||
delay_ms(2);
|
||||
while(w_len > 0)
|
||||
{
|
||||
|
||||
uc_bitcount = 0;
|
||||
uc_data = *cmd_buf;
|
||||
while(uc_bitcount < 8){
|
||||
if((uc_data & 0x80) > 0)
|
||||
{
|
||||
JQBUS_W_1;
|
||||
delay_us(JQBUS_H_PLUS);
|
||||
JQBUS_W_0;
|
||||
delay_us(JQBUS_L_PLUS);
|
||||
}else{
|
||||
JQBUS_W_1;
|
||||
delay_us(JQBUS_L_PLUS);
|
||||
JQBUS_W_0;
|
||||
delay_us(JQBUS_H_PLUS);
|
||||
}
|
||||
uc_bitcount++;
|
||||
uc_data <<= 1;
|
||||
}
|
||||
w_len--;
|
||||
cmd_buf++;
|
||||
}
|
||||
JQBUS_RWIDLE;
|
||||
}
|
||||
/*
|
||||
@brief 发送待反馈的命令
|
||||
@param cmd_buf 命令数据缓存区
|
||||
@param read_buf 数据反馈缓存区
|
||||
@param w_len 发送缓冲区数据长度
|
||||
@param r_len =0 读取1bit应答信号 > 0,读取数据长度
|
||||
@rtv 应答ACK
|
||||
*/
|
||||
uint8_t JQ_SendRead(uint8_t* cmd_buf, uint8_t* read_buf,uint16_t w_len,uint16_t r_len)
|
||||
{
|
||||
uint8_t uc_data;
|
||||
uint8_t ack = 0;
|
||||
uint8_t uc_bitcount;
|
||||
JQ_CommBegin();
|
||||
if(w_len > 0)
|
||||
{
|
||||
JQ_SendReadCmd(cmd_buf,w_len);
|
||||
}
|
||||
Power_SetSampleRange_Seep(JQDriver_Sample_R,ADC_SPEED_HIGH);
|
||||
JQ_SampleIdleCurrent();
|
||||
while(r_len > 0)
|
||||
{
|
||||
uc_data = 0;
|
||||
uc_bitcount = 0;
|
||||
while(uc_bitcount < 8)
|
||||
{
|
||||
uc_data <<= 1;
|
||||
uc_data |= (JQ_ReadBit() & 0x01);
|
||||
uc_bitcount++;
|
||||
}
|
||||
*read_buf = uc_data;
|
||||
r_len--;
|
||||
read_buf++;
|
||||
}
|
||||
ack = JQ_ReadBit();
|
||||
JQBUS_IDLE;
|
||||
Power_SetSampleCurrentRange(Current_Max);
|
||||
JQ_CommEnd();
|
||||
return ack;
|
||||
}
|
||||
|
||||
/*
|
||||
@breif 起爆命令
|
||||
@param cmd_count 起爆命令发送次数
|
||||
@param read_buf 读取ACK数据,1bit代表一个网络号
|
||||
@param run_type 0 不读取应答信号 =1 读取应答信号 >1 读取应答信号,且强制反馈收到应答
|
||||
*/
|
||||
|
||||
void JQ_BoomCmd(uint8_t cmd_count,uint8_t* read_buf,uint8_t run_type)
|
||||
{
|
||||
static uint8_t JQBoomcmd[2]={0xA9,0xB5};
|
||||
static uint8_t JQBoomEnCmd[2] = {0x7A,0xB7};
|
||||
uint16_t us_pluscount = 0;
|
||||
uint8_t uc_data,uc_bitcount,send_count;
|
||||
send_count = 0;
|
||||
while(send_count < cmd_count)
|
||||
{
|
||||
JQ_SendBroadCast(JQBoomEnCmd,2);
|
||||
delay_os_ms(20);
|
||||
send_count++;
|
||||
}
|
||||
if(run_type == 0)
|
||||
{
|
||||
while(cmd_count > 0)
|
||||
{
|
||||
//JQ_SendBroadCast(JQBoomcmd,2);
|
||||
delay_os_ms(20);
|
||||
JQ_SendRead(JQBoomcmd,&uc_data,2,0);
|
||||
cmd_count--;
|
||||
}
|
||||
us_pluscount = 0;
|
||||
while(us_pluscount < 680)
|
||||
{
|
||||
JQBUS_W_1
|
||||
delay_us(1000);
|
||||
JQBUS_W_0
|
||||
delay_us(400);
|
||||
us_pluscount++;
|
||||
}
|
||||
}else{
|
||||
while(cmd_count > 0)
|
||||
{
|
||||
delay_os_ms(20);
|
||||
JQ_SendRead(JQBoomcmd,&uc_data,2,0);
|
||||
cmd_count--;
|
||||
}
|
||||
Power_SetSampleRange_Seep(JQDriver_Sample_R,ADC_SPEED_HIGH);
|
||||
JQ_SampleIdleCurrent();
|
||||
while(us_pluscount < 680)
|
||||
{
|
||||
uc_data = 0;
|
||||
uc_bitcount = 0;
|
||||
while(uc_bitcount < 8)
|
||||
{
|
||||
uc_data <<= 1;
|
||||
uc_data |= (JQ_ReadBit() & 0x01);
|
||||
if((run_type > 1) && (uc_data& 0x01) < 1)
|
||||
{
|
||||
delay_us(750);
|
||||
}
|
||||
uc_bitcount++;
|
||||
us_pluscount++;
|
||||
}
|
||||
*read_buf = uc_data;
|
||||
read_buf++;
|
||||
|
||||
}
|
||||
}
|
||||
Power_SetSampleCurrentRange(Current_Max);
|
||||
JQBUS_IDLE;
|
||||
JQ_CommEnd();
|
||||
}
|
||||
|
||||
/*
|
||||
@breif 起爆使能
|
||||
*/
|
||||
|
||||
|
||||
void JQ_CheckerEnBoomCmd()
|
||||
{
|
||||
static uint8_t JQBoomEnCmd[2] = {0x7A,0xB7};
|
||||
JQ_SendBroadCast(JQBoomEnCmd,2);
|
||||
}
|
||||
|
||||
/*
|
||||
@breif 起爆命令
|
||||
@param plus_count 巡检脉冲个数
|
||||
@rtv 巡检应答Ack 的脉冲个数
|
||||
|
||||
*/
|
||||
|
||||
uint16_t JQ_CheckerBoomCmd(uint16_t plus_count,uint16_t* us_shake)
|
||||
{
|
||||
static uint8_t JQBoomcmd[2]={0xA9,0xB5};
|
||||
uint16_t us_pluscount = 0;
|
||||
uint16_t us_ack_plus = 0;
|
||||
uint16_t sample_count = 0;
|
||||
uint16_t us_bitcount = 0;
|
||||
uint16_t us_temp_shake;
|
||||
uint16_t us_max,us_min;
|
||||
JQ_CheckerEnBoomCmd();
|
||||
delay_ms(20);
|
||||
JQ_SendBroadCast(JQBoomcmd,2);
|
||||
Power_SetSampleRange_Seep(JQDriver_Sample_R,ADC_SPEED_HIGH);
|
||||
JQ_SampleIdleCurrent();
|
||||
*us_shake = JQ_Read_AD_V[JQ_Read_AD_Sample_C_IDLE-2] - JQ_Read_AD_V[2];
|
||||
while(us_pluscount < plus_count)
|
||||
{
|
||||
JQBUS_W_1;
|
||||
delay_us(100);
|
||||
//700us 延时
|
||||
JQ_Sample(JQ_Read_AD_Sample_C);
|
||||
GetMaxAndMinValue((uint16_t*)JQ_Read_AD_V,JQ_Read_AD_Sample_C,&us_max,&us_min);
|
||||
us_min = us_max - us_min;
|
||||
JQBUS_W_0;
|
||||
sample_count = 0;
|
||||
while(sample_count < JQ_Read_AD_Sample_C)
|
||||
{
|
||||
if(JQ_Read_AD_V[sample_count] > jq_idle_current )
|
||||
{
|
||||
us_bitcount++;
|
||||
}else if(us_bitcount < 2)
|
||||
{
|
||||
us_bitcount = 0;
|
||||
}
|
||||
sample_count++;
|
||||
}
|
||||
if(us_bitcount > 6)
|
||||
{
|
||||
if(us_ack_plus == 0)
|
||||
{
|
||||
us_ack_plus = us_pluscount;
|
||||
}
|
||||
else{
|
||||
us_ack_plus = ~0;
|
||||
}
|
||||
delay_us(50);
|
||||
us_bitcount = 3;
|
||||
|
||||
}else{
|
||||
if(us_min > *us_shake)
|
||||
{
|
||||
*us_shake = us_min;
|
||||
}
|
||||
delay_us(100);
|
||||
us_bitcount = 3;
|
||||
}
|
||||
while(us_bitcount > 0)
|
||||
{
|
||||
JQ_Sample(JQ_Read_AD_Sample_C>>1);
|
||||
GetMaxAndMinValue((uint16_t*)JQ_Read_AD_V,JQ_Read_AD_Sample_C>>1,&us_max,&us_min);
|
||||
|
||||
us_min = us_max - us_min;
|
||||
if(us_min > *us_shake)
|
||||
{
|
||||
*us_shake = us_min;
|
||||
}
|
||||
us_bitcount--;
|
||||
}
|
||||
us_pluscount++;
|
||||
}
|
||||
JQBUS_IDLE;
|
||||
JQ_CommEnd();
|
||||
return us_ack_plus;
|
||||
}
|
||||
|
||||
static uint16_t amend_endflag = 0;
|
||||
//@brief 总线波形翻转
|
||||
void JQ_TriggerPlus(uint8_t flag)
|
||||
{
|
||||
if(flag == 1)
|
||||
{
|
||||
JQBUS_W_0;
|
||||
}else if(flag > 1){
|
||||
JQBUS_W_1;
|
||||
}
|
||||
amend_endflag = flag;
|
||||
|
||||
}
|
||||
//@brief 时钟校准
|
||||
void JQ_TimeAmend(uint16_t cycle,uint16_t delayMs)
|
||||
{
|
||||
static uint8_t cmd_buf = 0x34;
|
||||
JQ_SendBroadCast(&cmd_buf,1);
|
||||
delay_os_ms(2);
|
||||
FireBus_ClkAmend(cycle, cycle/2, delayMs+100,JQ_TriggerPlus);
|
||||
while(amend_endflag != 3)
|
||||
{
|
||||
delay_ms(10);
|
||||
}
|
||||
JQBUS_IDLE;
|
||||
delay_os_ms(20);
|
||||
}
|
||||
//@breif 巡检
|
||||
void JQ_Inspect(uint16_t maxcount,uint8_t* buf,uint8_t state)
|
||||
{
|
||||
static uint8_t cmd_buf[]={0x97,0x00,0x00,0x00};
|
||||
cmd_buf[3] = state;
|
||||
JQ_SendRead(cmd_buf,buf,4,(maxcount+7)/8);
|
||||
}
|
||||
//@brief 启动UID扫描
|
||||
void JQ_ScanUIDBegin()
|
||||
{
|
||||
static uint8_t start_readuid_cmd = 0x54;
|
||||
JQ_SendBroadCast(&start_readuid_cmd,1);
|
||||
}
|
||||
//@brief 扫描模式读取UID
|
||||
uint8_t JQ_ScanReadUID(uint16_t begnet,uint8_t* uidbuf)
|
||||
{
|
||||
|
||||
static uint8_t scan_uid_cmd[]={0x59,0x00,0x00};
|
||||
uint8_t time_out = 3;
|
||||
uint8_t*p_buf = uidbuf;
|
||||
uint8_t ack;
|
||||
rt_memset(p_buf,0,8);
|
||||
while(time_out > 0)
|
||||
{
|
||||
scan_uid_cmd[1] = (begnet >> 8);
|
||||
scan_uid_cmd[2] = begnet,
|
||||
ack = JQ_SendRead(scan_uid_cmd,p_buf,3,8);
|
||||
if(ack > 0)
|
||||
{
|
||||
return ack;
|
||||
}else{
|
||||
delay_os_ms(20);
|
||||
time_out--;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
//@brief 读延时
|
||||
uint8_t JQ_ReadDelay(uint16_t netid,uint16_t* delaybuf)
|
||||
{
|
||||
static uint8_t cmd_buf[3]={0x63,0x00,0x00};
|
||||
cmd_buf[1] = (netid >> 8);
|
||||
cmd_buf[2] = netid;
|
||||
return JQ_SendRead(cmd_buf,(uint8_t*)delaybuf,3,2);
|
||||
}
|
||||
//@brief 写延时
|
||||
void JQ_WriteDelay(uint16_t netid,uint16_t delay)
|
||||
{
|
||||
static uint8_t cmd_buf[5]={0x68};
|
||||
cmd_buf[1] = (netid >> 8);
|
||||
cmd_buf[2] = netid;
|
||||
cmd_buf[3] = (delay >> 8);
|
||||
cmd_buf[4] = delay;
|
||||
JQ_SendBroadCast(cmd_buf,5);
|
||||
}
|
||||
//@brief 验证密码
|
||||
void JQ_VerifyPWD(uint8_t* pwd)
|
||||
{
|
||||
static uint8_t cmd_buf[5] = {0x76};
|
||||
rt_memcpy(&cmd_buf[1],pwd,4);
|
||||
JQ_SendBroadCast(cmd_buf,5);
|
||||
}
|
||||
//@brief 使能起爆
|
||||
void JQ_BoomActive(void)
|
||||
{
|
||||
static uint8_t cmd_buf[] = {0x7A,0xB7};
|
||||
JQ_SendBroadCast(cmd_buf,2);
|
||||
}
|
||||
//@brief 设置充电检测判线
|
||||
void JQ_ChargJudge(uint8_t dac)
|
||||
{
|
||||
static uint8_t cmd_buf[] = {0x82,0x00};
|
||||
cmd_buf[1] = dac;
|
||||
JQ_SendBroadCast(cmd_buf,2);
|
||||
}
|
||||
//@brief 充电
|
||||
void JQ_Chage(uint16_t bgnet)
|
||||
{
|
||||
static uint8_t cmd_buf[3] = {0x89};
|
||||
cmd_buf[1] = bgnet>>8;
|
||||
cmd_buf[2] = bgnet;
|
||||
JQ_SendBroadCast(cmd_buf,3);
|
||||
}
|
||||
//@brief 放电
|
||||
void JQ_DisChage(void)
|
||||
{
|
||||
static uint8_t cmd_buf[1] = {0x8A};
|
||||
JQ_SendBroadCast(cmd_buf,1);
|
||||
}
|
||||
//@brief 快速放电
|
||||
void JQ_FastDisChage(uint8_t sw)
|
||||
{
|
||||
static uint8_t cmd_buf[2] = {0x8B};
|
||||
cmd_buf[1] = sw;
|
||||
JQ_SendBroadCast(cmd_buf,2);
|
||||
}
|
||||
//@brief 复位
|
||||
void JQ_Reset(void)
|
||||
{
|
||||
static uint8_t cmd_buf[2] = {0x55,0xAA};
|
||||
JQ_SendBroadCast(cmd_buf,2);
|
||||
}
|
||||
//@breif 读芯片ID
|
||||
uint8_t JQ_ReadChipID(uint16_t netid,uint16_t* chipid)
|
||||
{
|
||||
static uint8_t cmd_buf[3] = {0x23};
|
||||
cmd_buf[1] = netid>>8;
|
||||
cmd_buf[2] = netid;
|
||||
return JQ_SendRead(cmd_buf,(uint8_t*)chipid,3,2);
|
||||
}
|
||||
//@brief 读OTP
|
||||
uint8_t JQ_ReadOTP(uint16_t netid,uint8_t otp_bgaddr,uint8_t read_count,uint8_t* readbuf)
|
||||
{
|
||||
static uint8_t cmd_buf[4] = {0x2A};
|
||||
uint8_t otp_endaddr = otp_bgaddr+ read_count;
|
||||
cmd_buf[1] = netid>>8;
|
||||
cmd_buf[2] = netid;
|
||||
cmd_buf[3] = otp_bgaddr;
|
||||
while(otp_bgaddr < otp_endaddr)
|
||||
{
|
||||
cmd_buf[3] = otp_bgaddr;
|
||||
if(JQ_SendRead(cmd_buf,readbuf,4,1) == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
delay_os_ms(20);
|
||||
readbuf++;
|
||||
otp_bgaddr++;
|
||||
}
|
||||
return read_count - (otp_endaddr - otp_bgaddr);
|
||||
}
|
||||
//@brief 写OTP
|
||||
|
||||
uint8_t JQ_WriteOTP(uint8_t otp_bgaddr,uint8_t write_count,uint8_t* writebuf)
|
||||
{
|
||||
static uint8_t cmd_buf[3] = {0x1A};
|
||||
uint8_t otp_endaddr = otp_bgaddr+ write_count;
|
||||
|
||||
while(otp_bgaddr < otp_endaddr)
|
||||
{
|
||||
cmd_buf[1] = otp_bgaddr;
|
||||
cmd_buf[2] = *writebuf;
|
||||
JQ_SendBroadCast(cmd_buf,3);
|
||||
delay_os_ms(20);
|
||||
writebuf++;
|
||||
otp_bgaddr++;
|
||||
}
|
||||
return write_count - (otp_endaddr - otp_bgaddr);
|
||||
}
|
||||
|
||||
//写OTP使能
|
||||
void JQ_EnWOTP(void)
|
||||
{
|
||||
static uint8_t cmd_buf[2] = {0x1E,0xC9};
|
||||
JQ_SendBroadCast(cmd_buf,2);
|
||||
}
|
||||
//@breif 读取单发状态
|
||||
uint8_t JQ_ReadState(uint16_t netid,uint8_t* state)
|
||||
{
|
||||
static uint8_t cmd_buf[3] = {0x91};
|
||||
cmd_buf[1] = netid>>8;
|
||||
cmd_buf[2] = netid;
|
||||
return JQ_SendRead(cmd_buf,state,3,1);
|
||||
}
|
||||
//@braief 设置通信电压模式
|
||||
uint8_t JQ_SetPowerMode(uint16_t h_vol,uint16_t m_vol)
|
||||
{
|
||||
return 0;
|
||||
}
|
82
source/elec_det/driver/JQDriver.h
Normal file
82
source/elec_det/driver/JQDriver.h
Normal file
@@ -0,0 +1,82 @@
|
||||
#ifndef JQDRIVER_H_
|
||||
#define JQDRIVER_H_
|
||||
|
||||
#include "base/define.h"
|
||||
#include "hardware/gpio_cfg.h"
|
||||
#include "hardware/adc_cfg.h"
|
||||
#include "base/delay.h"
|
||||
|
||||
|
||||
#define JQBUS_IDLE JQBUS_W_1
|
||||
#define JQBUS_RWIDLE JQBUS_W_1
|
||||
|
||||
|
||||
#define JQBUS_H_PLUS 300
|
||||
#define JQBUS_L_PLUS 700
|
||||
#define JQ_Read_AD_Sample_C 140
|
||||
#define JQ_Read_AD_Sample_C_IDLE 80
|
||||
|
||||
extern uint16_t JQ_FreeBack_MaxCur;
|
||||
extern uint16_t JQ_FreeBack_MaxTime;
|
||||
extern uint16_t JQ_FreeBack_MinCur;
|
||||
extern uint16_t JQ_FreeBack_MinTime;
|
||||
extern uint16_t JQ_CommEnd_MaxCur ;
|
||||
extern uint8_t JQ_CommEnd_CurEn ;
|
||||
|
||||
|
||||
//@brief 读OTP
|
||||
uint8_t JQ_ReadOTP(uint16_t netid,uint8_t otp_bgaddr,uint8_t read_count,uint8_t* readbuf);
|
||||
//@breif 读取单发状态
|
||||
uint8_t JQ_ReadState(uint16_t netid,uint8_t* state);
|
||||
//@brief 写延时
|
||||
void JQ_WriteDelay(uint16_t netid,uint16_t delay);
|
||||
//@brief 读延时
|
||||
uint8_t JQ_ReadDelay(uint16_t netid,uint16_t* delaybuf);
|
||||
//@brief 启动UID扫描
|
||||
void JQ_ScanUIDBegin(void);
|
||||
//@brief 扫描模式读取UID
|
||||
uint8_t JQ_ScanReadUID(uint16_t begnet,uint8_t* uidbuf);
|
||||
//@brief 充电
|
||||
void JQ_Chage(uint16_t bgnet);
|
||||
//@brief 放电
|
||||
void JQ_DisChage(void);
|
||||
//@brief 复位
|
||||
void JQ_Reset(void);
|
||||
//@brief 使能起爆
|
||||
void JQ_BoomActive(void);
|
||||
//@brief 时钟校准
|
||||
void JQ_TimeAmend(uint16_t cycle,uint16_t delay_ms);
|
||||
//写OTP使能
|
||||
void JQ_EnWOTP(void);
|
||||
//@brief 写OTP
|
||||
|
||||
uint8_t JQ_WriteOTP(uint8_t otp_bgaddr,uint8_t write_count,uint8_t* writebuf);
|
||||
/*
|
||||
@breif 起爆命令
|
||||
@param cmd_count 起爆命令发送次数
|
||||
@param read_buf 读取ACK数据,1bit代表一个网络号
|
||||
@param run_type 0 不读取应答信号 =1 读取应答信号 >1 读取应答信号,且强制反馈收到应答
|
||||
*/
|
||||
|
||||
void JQ_BoomCmd(uint8_t cmd_count,uint8_t* read_buf,uint8_t run_type);
|
||||
/*
|
||||
@breif 起爆命令
|
||||
@param plus_count 巡检脉冲个数
|
||||
@rtv 巡检应答Ack 的脉冲个数
|
||||
*/
|
||||
uint16_t JQ_CheckerBoomCmd(uint16_t plus_count,uint16_t* us_shake);
|
||||
//@breif 巡检
|
||||
void JQ_Inspect(uint16_t maxcount,uint8_t* buf,uint8_t state);
|
||||
//@brief 设置充电检测判线
|
||||
void JQ_ChargJudge(uint8_t dac);
|
||||
//@brief 验证密码
|
||||
void JQ_VerifyPWD(uint8_t* pwd);
|
||||
//@breif 读芯片ID
|
||||
uint8_t JQ_ReadChipID(uint16_t netid,uint16_t* chipid);
|
||||
//@brief 快速放电
|
||||
void JQ_FastDisChage(uint8_t sw);
|
||||
/*
|
||||
@brief 通信反码信息初始化
|
||||
*/
|
||||
void JQ_FreeBack_Prapare(uint8_t enable_flag);
|
||||
#endif
|
356
source/elec_det/driver/LGDriver.c
Normal file
356
source/elec_det/driver/LGDriver.c
Normal file
@@ -0,0 +1,356 @@
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
//本文件是雷管驱动的底层程序,不对外
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
|
||||
#include "LGDriverAPI.h"
|
||||
#include "LGDriver.h"
|
||||
#include "board.h"
|
||||
|
||||
|
||||
|
||||
#define Long_Time 650
|
||||
#define Short_Time 400
|
||||
|
||||
|
||||
//============================================================================
|
||||
//接收波形转换
|
||||
//============================================================================
|
||||
static void LG_Receive_Switch(void)
|
||||
{
|
||||
LGDRV_PHA_H();
|
||||
Lib_delay_us(1000);
|
||||
LGDRV_PHA_L();
|
||||
Lib_delay_us(1000);
|
||||
}
|
||||
|
||||
|
||||
static u8 LG_ReceiveBit() //扫描用接收位
|
||||
{
|
||||
u8 ReturnBit = 0, ValueCnt = 0;
|
||||
u16 OffsetTime = 0;
|
||||
|
||||
LGDRV_PHA_H();
|
||||
|
||||
ValueCnt = Lib_CountFeedBackData(&OffsetTime);
|
||||
|
||||
LGDRV_PHA_L(); //这个放到了Lib_CountFeedBackData里面了
|
||||
|
||||
if(ValueCnt > 0)
|
||||
{
|
||||
ReturnBit = 1;
|
||||
PA11_1();
|
||||
|
||||
// if(950 > OffsetTime)
|
||||
// Lib_delay_us(950 - OffsetTime);
|
||||
// else
|
||||
// Lib_delay_us(950);
|
||||
|
||||
Lib_delay_us(950);
|
||||
|
||||
PA11_0();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ReturnBit = 0;
|
||||
|
||||
// if(500 > OffsetTime)
|
||||
// Lib_delay_us(500 - OffsetTime);
|
||||
// else
|
||||
// Lib_delay_us(500);
|
||||
Lib_delay_us(500);
|
||||
|
||||
}
|
||||
|
||||
return ReturnBit;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//发送一个字节
|
||||
//输入参数:要发送的数据
|
||||
//============================================================================
|
||||
static void LG_SendByte(u8 dat)
|
||||
{
|
||||
u8 i;
|
||||
u16 time_h, time_l;
|
||||
|
||||
for(i = 0; i < 8; i++)
|
||||
{
|
||||
if(dat & 0x80)
|
||||
{
|
||||
time_h = Short_Time;
|
||||
|
||||
time_l = Long_Time;
|
||||
}
|
||||
else
|
||||
{
|
||||
time_h = Long_Time;
|
||||
|
||||
time_l = Short_Time;
|
||||
}
|
||||
|
||||
LGDRV_PHA_H();
|
||||
Lib_delay_us(time_h);
|
||||
LGDRV_PHA_L();
|
||||
Lib_delay_us(time_l);
|
||||
|
||||
dat <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//发送一个字节 校时专用,仅高低时间和通用发送有差异
|
||||
//输入参数:要发送的数据
|
||||
//============================================================================
|
||||
static void LG_SendByte_CaliTime(u16 dat)
|
||||
{
|
||||
u16 i;
|
||||
//u16 time_h = 496 - Close_Pmos_Delay * 2, time_l = 496 - Open_Pmos_Delay * 2; //150ms=150ms 1000=1000.07 12000=12000.70
|
||||
|
||||
for(i = 0; i < dat; i++)
|
||||
{
|
||||
LGDRV_PHA_H();
|
||||
Lib_delay_us(496);
|
||||
LGDRV_PHA_L();
|
||||
Lib_delay_us(Lib_SetDelayData(Lib_CaliTime));
|
||||
|
||||
Lib_ResetWdg();
|
||||
}
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//接收一个字节
|
||||
//返回值:接收到的数据
|
||||
//============================================================================
|
||||
static u8 LG_ReceiveByte(void)
|
||||
{
|
||||
u8 BitValue, ReturnData = 0, i;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
BitValue = LG_ReceiveBit();
|
||||
ReturnData <<= 1;
|
||||
ReturnData += BitValue;
|
||||
}
|
||||
return ReturnData;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
//接收参数
|
||||
//返回值:接收到的数据
|
||||
//============================================================================
|
||||
u8 LG_ReceiveParameter(u8 *Parameter, u8 Length)
|
||||
{
|
||||
u8 i = 0;
|
||||
u8 ret = 0;
|
||||
|
||||
//OUTA输出高低电压标志 1:输出电压 0:输出高电压
|
||||
Lib_SetPowerOutAhSwitch(1);
|
||||
//接收转换
|
||||
LG_Receive_Switch();
|
||||
|
||||
for(i = 0; i < Length; i++)
|
||||
{
|
||||
Parameter[i] = LG_ReceiveByte();
|
||||
}
|
||||
|
||||
ret = LG_ReceiveBit();
|
||||
|
||||
//OUTA输出高低电压标志 1:输出电压 0:输出高电压
|
||||
Lib_SetPowerOutAhSwitch(0);
|
||||
|
||||
LGDRV_PHA_H();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
//接收单bitAck
|
||||
u8 LG_ReceiveAck(void)
|
||||
{
|
||||
u8 ret = 0;
|
||||
u8 i;
|
||||
|
||||
//OUTA输出高低电压标志 1:输出电压 0:输出高电压
|
||||
Lib_SetPowerOutAhSwitch(1);
|
||||
//接收转换
|
||||
LG_Receive_Switch();
|
||||
|
||||
for(i = 0; i < 1; i++)
|
||||
{
|
||||
ret += LG_ReceiveBit();
|
||||
}
|
||||
|
||||
//OUTA输出高低电压标志 1:输出电压 0:输出高电压
|
||||
Lib_SetPowerOutAhSwitch(0);
|
||||
|
||||
LGDRV_PHA_H();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
//接收单bit数据
|
||||
u16 LG_ReceiveSingleBit(u8 *Parameter, u16 Length, u8 bit)
|
||||
{
|
||||
u16 i;
|
||||
u8 j = 0;
|
||||
u16 ret = 0;
|
||||
|
||||
//OUTA输出高低电压标志 1:输出电压 0:输出高电压
|
||||
Lib_SetPowerOutAhSwitch(1);
|
||||
//接收转换
|
||||
LG_Receive_Switch();
|
||||
|
||||
for(i = 0; i < Length; i++)
|
||||
{
|
||||
j = LG_ReceiveBit();
|
||||
|
||||
if(j > 0)
|
||||
{
|
||||
Parameter[i] |= bit;
|
||||
ret++;
|
||||
}
|
||||
else
|
||||
{
|
||||
Parameter[i] &= ~bit;
|
||||
}
|
||||
}
|
||||
|
||||
//OUTA输出高低电压标志 1:输出电压 0:输出高电压
|
||||
Lib_SetPowerOutAhSwitch(0);
|
||||
|
||||
LGDRV_PHA_H();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
//延时起爆波形:总计发送660个波形,雷管数量状态位+补发波形 总计660个波形 雷管累计到652个波形会起爆
|
||||
u16 LG_ReceiveDetBomming(u8 *pStatus, u16 Length, u8 allow)
|
||||
{
|
||||
u16 j = 0;
|
||||
u16 i = 0;
|
||||
u16 ret = 0, tmp = 0;
|
||||
|
||||
//OUTA输出高低电压标志 1:输出电压 0:输出高电压
|
||||
Lib_SetPowerOutAhSwitch(0);
|
||||
//接收转换
|
||||
LG_Receive_Switch();
|
||||
|
||||
//按实际雷管数据接收数据位
|
||||
for(i = 0; i < (Length + 1); i++)
|
||||
{
|
||||
j = LG_ReceiveBit();
|
||||
|
||||
if(j > 0)
|
||||
{
|
||||
tmp++;
|
||||
|
||||
//记录起爆反馈状态
|
||||
pStatus[i] |= 0x04; //cBoomStatus
|
||||
}
|
||||
else
|
||||
{
|
||||
//记录起爆反馈状态
|
||||
pStatus[i] &= ~0x04; //~cBoomStatus
|
||||
}
|
||||
}
|
||||
|
||||
//存储实际雷管数量
|
||||
ret = tmp;
|
||||
|
||||
//OUTA输出高低电压标志 1:输出电压 0:输出高电压
|
||||
Lib_SetPowerOutAhSwitch(0);
|
||||
|
||||
//起爆数量不对 且 不允许起爆,JQ版本
|
||||
#if 0
|
||||
//直接起爆,不判断数量,YM版本
|
||||
if((Length > tmp) && ((Length - tmp) > allow))
|
||||
{
|
||||
//中止起爆,主循环查询更新状态
|
||||
LGDRV_PHA_H();
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
//预留2 0:正常模式,真实对码,真实起爆;1:真实对码,模拟起爆;2:全0对码,真实起爆;3:全0对码,模拟起爆
|
||||
if((1 == ConfigData.Reserved2) || (3 == ConfigData.Reserved2))
|
||||
{
|
||||
if(0xFF == allow)
|
||||
{
|
||||
LGDRV_PHA_H();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(i = 0; i < (660 - (Length + 1)); i++) //必爆651 发送660
|
||||
{
|
||||
LGDRV_PHA_H();
|
||||
Lib_delay_us(600);
|
||||
LGDRV_PHA_L();
|
||||
Lib_delay_us(400);
|
||||
|
||||
Lib_ResetWdg();
|
||||
}
|
||||
|
||||
LGDRV_PHA_H();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
//发送延时起爆用来清除波形计数--接收1个bit
|
||||
void LG_CleanWave_Receive(void)
|
||||
{
|
||||
//接收转换
|
||||
LG_Receive_Switch();
|
||||
|
||||
LG_ReceiveBit();
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//发送功能指令
|
||||
//输入参数:要发送的功能码数据
|
||||
//============================================================================
|
||||
void LG_SendCommand(u8 Function, u8 *Parameter, u8 Length)
|
||||
{
|
||||
u8 i = 0;
|
||||
|
||||
LGDRV_PHA_H();
|
||||
Lib_delay_ms(11);
|
||||
|
||||
/*******开始信号********/
|
||||
LGDRV_PHA_L();
|
||||
Lib_delay_us(1500);
|
||||
LGDRV_PHA_H();
|
||||
/***********************/
|
||||
|
||||
|
||||
LG_SendByte(Function);//发送指令
|
||||
|
||||
for(i = 0; i < Length; i++)
|
||||
{
|
||||
LG_SendByte(Parameter[i]);//发送参数
|
||||
}
|
||||
|
||||
LGDRV_PHA_H();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//校时指令
|
||||
void LG_SendCorrectTimeCommand(u8 Function, u16 time)
|
||||
{
|
||||
LGDRV_PHA_H();
|
||||
Lib_delay_ms(11);
|
||||
LGDRV_PHA_L();
|
||||
Lib_delay_us(1500);
|
||||
LGDRV_PHA_H();
|
||||
|
||||
LG_SendByte(Function);
|
||||
|
||||
time += 100;
|
||||
|
||||
LG_SendByte_CaliTime(time);
|
||||
|
||||
LGDRV_PHA_H();
|
||||
}
|
21
source/elec_det/driver/LGDriver.h
Normal file
21
source/elec_det/driver/LGDriver.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef __LGDRIVER_H
|
||||
#define __LGDRIVER_H
|
||||
|
||||
//--------------------static------------------------------------
|
||||
void LG_Receive_Switch(void);
|
||||
u8 LG_ReceiveBit(void);
|
||||
void LG_SendByte(u8 dat);
|
||||
void LG_SendByte_CaliTime(u16 dat);
|
||||
u8 LG_ReceiveByte(void);
|
||||
//--------------------static------------------------------------
|
||||
|
||||
//接收单bitAck
|
||||
u8 LG_ReceiveAck(void);
|
||||
u8 LG_ReceiveParameter(u8 *Parameter, u8 Length); //接收参数
|
||||
u16 LG_ReceiveSingleBit(u8 *Parameter, u16 Length, u8 bit); //接收单bit数据
|
||||
u16 LG_ReceiveDetBomming(u8 *pStatus, u16 Length, u8 allow); //延时放电
|
||||
void LG_SendCommand(u8 Function, u8 *Parameter, u8 Length); //发送功能指令
|
||||
void LG_SendCorrectTimeCommand(u8 Function, u16 time); //校时指令
|
||||
//发送延时起爆用来清除波形计数--接收1个bit
|
||||
void LG_CleanWave_Receive(void);
|
||||
#endif
|
1268
source/elec_det/driver/XTDriver.c
Normal file
1268
source/elec_det/driver/XTDriver.c
Normal file
File diff suppressed because it is too large
Load Diff
187
source/elec_det/driver/XTDriver.h
Normal file
187
source/elec_det/driver/XTDriver.h
Normal file
@@ -0,0 +1,187 @@
|
||||
#ifndef XTDRIVER_H
|
||||
#define XTDRIVER_H
|
||||
|
||||
#include "base/define.h"
|
||||
#include "hardware/gpio_cfg.h"
|
||||
#include "hardware/adc_cfg.h"
|
||||
#include "base/delay.h"
|
||||
#include "hardware/power.h"
|
||||
#include <rtthread.h>
|
||||
|
||||
|
||||
|
||||
#define XTBUS_IDLE XTBUS_W_1
|
||||
#define XTBUS_RWIDLE XTBUS_WR_1
|
||||
|
||||
#define XT_Read_AD_Sample_C 120
|
||||
|
||||
#define XT_ADC_SAMPLE_TIME 589u //采样 XT_Read_AD_Sample_C 所需时间
|
||||
|
||||
|
||||
|
||||
#define XTREGISTERVOLTAGE 80
|
||||
#define XTCOMMHIGHVOLTAGE 100 //10V 1200米干线可以,1400米干线电压不够
|
||||
#define XTCHARGEINSTRUCTIONVOLTAGE 160
|
||||
#define XTCOMMMEDIUMVOLTAGE 80
|
||||
#define XTCHARGEVOLTAGE 260 //充电20V 1200米电压不够, 充电18V 1200米分档充能充满
|
||||
|
||||
#define XTBIT0 0
|
||||
#define XTBIT1 1
|
||||
|
||||
#define XTFIRSTDELAY 138
|
||||
#define XTFIRSTCYCLE 108
|
||||
#define XTSECONDDELAY 128
|
||||
#define XTSECONDCYCLE 118
|
||||
#define XTTHRIDDELAY 123
|
||||
#define XTTHRIDCYCLE 118
|
||||
#define XTOTHERDELAY 123
|
||||
#define XTOTHERCYCLE 113
|
||||
|
||||
|
||||
#define XT_DAT_PLUS_T 100
|
||||
#define XT_BIT_DELAY 180
|
||||
|
||||
#define XT_TRIM_DELAY 293
|
||||
#define XTTRIMCYCLE 693
|
||||
|
||||
//#define XTFIRSTDELAY 140 //1200米低温可能芯片识别不出来指令
|
||||
//#define XTFIRSTCYCLE 140
|
||||
//#define XTSECONDDELAY 110
|
||||
//#define XTSECONDCYCLE 110
|
||||
//#define XTTHRIDDELAY 110
|
||||
//#define XTTHRIDCYCLE 110
|
||||
//#define XTOTHERDELAY 110
|
||||
//#define XTOTHERCYCLE 110
|
||||
//#define XTBITDELAY 180
|
||||
//#define XTTRIMDELAY 293
|
||||
//#define XTTRIMCYCLE 693
|
||||
|
||||
|
||||
#define XTCmdAndSquareUs 700 //指令与方波的时间间隔
|
||||
#define XTTimOverflowUs 100 //TIM定时器溢出时间
|
||||
#define XTSquareLowTimNum 12 //方波低电平TIM溢出数 这个时间让电容充电 100us后才会开始充电 //原值7 越长反馈幅度越大,最大15
|
||||
#define XTSquareCollectTimNum 1 //方波高电平内采样TIM溢出数
|
||||
#define XTSquareHighTimNum 7 //方波高电平TIM溢出数 确保比芯片反馈完多100us,最小7,最大15,短点好
|
||||
|
||||
#define XTCollectResistance 2 //2 - R10_4ma_54ma_MC 3-R1_33ma_540ma_MC
|
||||
#define XTCollectADCChannel AN_MAL_CH //AN_UA_CH AN_MAL_CH
|
||||
|
||||
#define XTCollectIncrementValue 150 //最小200mV 低温下扫描间隔长一点70ms,300ms一个,短了电压会不够 抢反馈
|
||||
#define XTCollectSumValue 1500
|
||||
#define XTSingleCollectAckValue 800 //单发检测
|
||||
#define XTConfirmAckCount 10
|
||||
|
||||
#define XTCollectTimerPrescaler 72 //1us
|
||||
#define XTCollectTimerOverflowUs 600 //600us //450us //要将反馈全部包进去,反馈开始时间最晚在边沿后350us
|
||||
#define XTSingleCollectTimerPrescaler 7200 //0.1ms
|
||||
#define XTSingleCollectTimerOverflowMs 500 //50ms
|
||||
#define XTSingleCollectAckTimerOverflowCnt 20000 //2s //单发充电完成
|
||||
#define XTWriteBitTimerOverflowCnt 500 //50ms 指令应答超时
|
||||
|
||||
#define XT_ADC_BUF_LEN 140
|
||||
|
||||
//************************************************************************//
|
||||
#define XT_CMDA_WRITE_FIELD 0xEC //写现场值
|
||||
#define XT_CMDA_READ_FIELD 0xEF //读现场值
|
||||
#define XT_CMDA_READ_SHELL 0xF4 //读管壳码
|
||||
#define XT_CMDA_READ_PARAM 0xF1 //读测量参数值
|
||||
#define XT_CMDA_MEASURE_RES 0xF8 //测量药头电阻
|
||||
#define XT_CMDA_MEASURE_CAP 0xDB //测量储能电容
|
||||
#define XT_CMDA_CHARGE 0xDD //单发充电
|
||||
|
||||
#define XT_CMDB_CLEAR_READH 0x1F //清除已读状态高8位
|
||||
#define XT_CMDB_CLEAR_READL 0x2A //清除已读状态低8位
|
||||
#define XT_CMDB_FIREH 0x3C //起爆高8位
|
||||
#define XT_CMDB_FIREL 0xC8 //起爆低8位
|
||||
#define XT_CMDB_INITH 0x1A //初始化寄存器高8位
|
||||
#define XT_CMDB_INITL 0x61 //初始化寄存器低8位
|
||||
#define XT_CMDB_RESETH 0x19 //软件复位高8位
|
||||
#define XT_CMDB_RESETL 0x66 //软件复位低8位
|
||||
#define XT_CMDB_READ_UIDH 0x33 //扫描高8位
|
||||
#define XT_CMDB_READ_UIDL 0x34 //扫描低8位
|
||||
#define XT_CMDB_TRIM_FASTH 0x2E //快速延期标定高8位
|
||||
#define XT_CMDB_TRIM_FASTL 0x2D //快速延期标定低8位
|
||||
#define XT_CMDB_TRIM_COMPLETEH 0x2D //完整延期标定高8位
|
||||
#define XT_CMDB_TRIM_COMPLETEL 0x33 //完整延期标定低8位
|
||||
#define XT_CMDB_CHECK_ONLINEH 0x2B //在线检测高8位
|
||||
#define XT_CMDB_CHECK_ONLINEL 0x4B //在线检测低8位
|
||||
#define XT_CMDB_CHECK_BMIDH 0x28 //验证起爆密码高8位
|
||||
#define XT_CMDB_CHECK_BMIDL 0x7F //验证起爆密码低8位
|
||||
#define XT_CMDB_CHECK_FIRE_ALLH 0x27 //获取全部验证状态高8位
|
||||
#define XT_CMDB_CHECK_FIRE_ALLL 0x52 //获取全部验证状态低8位
|
||||
#define XT_CMDB_CHECK_FIRE_EACHH 0x24 //获取逐发验证状态高8位
|
||||
#define XT_CMDB_CHECK_FIRE_EACHL 0x55 //获取逐发验证状态低8位
|
||||
#define XT_CMDB_SET_CURRENTH 0x42 //设置反馈电流大小
|
||||
#define XT_CMDB_CHARGE 0x41 //广播充电
|
||||
#define XT_CMDB_CHECK_CONFIG 0x70 //检查配置区
|
||||
|
||||
#define XT_CMDC_WRITE_UID 0x1E //写UID
|
||||
#define XT_CMDC_WRITE_BMID 0x1D //写起爆密码
|
||||
#define XT_CMDC_WRITE_SHELL 0x1B //写管壳码
|
||||
#define XT_CMDC_WRITE_FIELD 0x18 //写现场值_C
|
||||
#define XT_CMDC_WRITE_CONFIG 0x14 //写配置区
|
||||
#define XT_CMDC_WRITE_PARAM 0x12 //写测量参数值
|
||||
#define XT_CMDC_MEASURE_CAP 0x11 //测量储能电容_C
|
||||
#define XT_CMDC_LOCK 0x3E //锁定
|
||||
#define XT_CMDC_READ_PARAM 0x37 //读测量参数值_C
|
||||
#define XT_CMDC_READ_CONFIG 0x34 //读配置区
|
||||
#define XT_CMDC_READ_SHELL 0x2C //读管壳码_C
|
||||
#define XT_CMDC_MEASURE_RES 0x2F //测量药头电阻_C
|
||||
|
||||
|
||||
extern uint16_t XT_FreeBackMaxCur,XT_FreeBackMinCur,XT_FreeBackMaxTime,XT_FreeBackMinTime,XT_CommEndMaxCur;
|
||||
extern uint8_t XT_EnFreeBack_Test,XT_CommEnd_CurEn;
|
||||
|
||||
//************************************************************************//
|
||||
/*
|
||||
@brief 通信反码信息初始化
|
||||
*/
|
||||
void XT_FreeBack_Prapare(uint8_t enable_flag);
|
||||
void XT_SendSquare(uint32_t num);
|
||||
uint8_t XT_Power_Init(void);
|
||||
void XT_BUS_CTRL( uint8_t NewState );
|
||||
uint8_t XT_Write_Field(uint8_t *uid, uint8_t uidlen, uint8_t *field);
|
||||
uint8_t XT_Read_Field(uint8_t *uid, uint8_t uidlen, uint8_t *field);
|
||||
uint8_t XT_Read_Shell(uint8_t *uid, uint8_t uidlen, uint8_t *shell);
|
||||
uint8_t XT_Read_Param(uint8_t *uid, uint8_t uidlen, uint8_t *param);
|
||||
uint8_t XT_Measure_Res(uint8_t *uid, uint8_t uidlen, uint8_t *adcvalue);
|
||||
uint8_t XT_Measure_Cap(uint8_t *uid, uint8_t uidlen, uint8_t level, uint32_t *chargetime);
|
||||
|
||||
uint8_t XT_Charge_One(uint8_t *uid,uint8_t uidlen, uint8_t level,uint16_t busvoltage, uint8_t isgetack);
|
||||
void XT_Clear_Read(void);
|
||||
void XT_Fire(void);
|
||||
uint8_t XT_FireandCheck(uint8_t *delay);
|
||||
uint8_t XT_MeasureFire(uint32_t *delay) ;
|
||||
void XT_Init(uint8_t regdata);
|
||||
void XT_Reset(void);
|
||||
uint8_t XT_Read_Uid(uint8_t *uid, uint8_t uidlen);
|
||||
void XT_Trim_Fast(void);
|
||||
void XT_Trim_Faset_Cycle(uint16_t cycle,uint16_t duty);
|
||||
void XT_Trim_Complete(uint32_t delay_max);
|
||||
void XT_Trim_Complete_Cycle(uint16_t cycle,uint16_t duty, uint32_t delay_max);
|
||||
uint8_t XT_Check_Online(uint16_t index_max, uint8_t *online);
|
||||
uint8_t XT_Check_Bmid(uint8_t *bmid, uint8_t bmidlen);
|
||||
uint8_t XT_Check_Fire_All(void);
|
||||
uint8_t XT_Check_Fire_Each(uint32_t index_max, uint8_t *check);
|
||||
void XT_Set_Current(uint8_t level);
|
||||
void XT_Charge_All(uint8_t level);
|
||||
uint8_t XT_Check_Config(uint8_t *config);
|
||||
uint8_t XT_Write_Uid(uint8_t *uid, uint8_t uidlen);
|
||||
uint8_t XT_Write_Bmid(uint8_t *bmid, uint8_t bmidlen);
|
||||
uint8_t XT_Write_Shell(uint8_t *shell);
|
||||
uint8_t XT_Write_Field_All(uint8_t *field);
|
||||
uint8_t XT_Write_Config(uint8_t *config);
|
||||
uint8_t XT_Write_Param(uint8_t *param);
|
||||
uint8_t XT_Measure_Cap_All(uint8_t level, uint32_t *chargetime);
|
||||
void XT_Lock(void);
|
||||
uint8_t XT_Read_Param_All(uint8_t *param);
|
||||
uint8_t XT_Read_Config(uint8_t *config);
|
||||
uint8_t XT_Read_Shell_All(uint8_t *shell);
|
||||
uint8_t XT_Measure_Res_All(uint8_t *adcvalue);
|
||||
uint8_t XT_Get_UID_R(uint8_t *uid, uint8_t uidlen);
|
||||
uint8_t XT_Get_R(void);
|
||||
|
||||
uint8_t XT_Get_UID_C(uint8_t *uid, uint8_t uidlen, uint8_t level, uint32_t time_out,float *CapacitanceValue) ;
|
||||
uint8_t XT_Get_C(uint8_t level, uint32_t time_out, float *CapacitanceValue);
|
||||
|
||||
#endif
|
248
source/elec_det/elec_det.c
Normal file
248
source/elec_det/elec_det.c
Normal file
@@ -0,0 +1,248 @@
|
||||
#include "board.h"
|
||||
#include "bytearray.h"
|
||||
#include "mystdlib.h"
|
||||
|
||||
#include "elec_det.h"
|
||||
#include "base/delay.h"
|
||||
#include "base/utility.h"
|
||||
#include "hardware/adc_cfg.h"
|
||||
#include "hardware/dac_cfg.h"
|
||||
#include "hardware/gpio_cfg.h"
|
||||
#include "hardware/jw3425iic.h"
|
||||
#include "hardware/power.h"
|
||||
#include "hardware/timer_cfg.h"
|
||||
#include "driver/EWDriver.h"
|
||||
#include "driver/JQDriver.h"
|
||||
#include "driver/XTDriver.h"
|
||||
#include "interface/BaseChecker.h"
|
||||
#include "interface/JQChecker.h"
|
||||
#include "interface/XTChecker.h"
|
||||
|
||||
|
||||
#define PLAN_MAX_TASK 64
|
||||
|
||||
|
||||
typedef struct{
|
||||
CheckerTask_Info_st* task_info_array[PLAN_MAX_TASK];//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD><E1B9B9>ָ<EFBFBD><D6B8>
|
||||
|
||||
}self_def;
|
||||
|
||||
|
||||
static self_def g_self;
|
||||
|
||||
|
||||
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
uint8_t elec_local_addr(void)
|
||||
{
|
||||
static uint8_t addr=0;
|
||||
if(addr==0)
|
||||
addr=Gpio_GetDeivceAddr();
|
||||
return addr;
|
||||
}
|
||||
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>led1״̬
|
||||
void elec_led1_power(int power)
|
||||
{
|
||||
LED1_Out=power?1:0;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>led2״̬
|
||||
void elec_led2_power(int power)
|
||||
{
|
||||
LED2_Out=power?1:0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
array_def *elec_check_result(void)
|
||||
{
|
||||
array_def *r=arr_creat();
|
||||
|
||||
return arr_temp(r);
|
||||
}
|
||||
|
||||
|
||||
// дӲ<D0B4><D3B2><EFBFBD>汾<EFBFBD><E6B1BE>
|
||||
int elec_write_hardversion(int version)
|
||||
{
|
||||
board_st.hard_v=version;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// д<><D0B4><EFBFBD><EFBFBD>Уֵ
|
||||
int elec_write_resistor_cbv(int cbv)
|
||||
{
|
||||
board_st.resistor_diff=cbv;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD><CBBF>ֵ
|
||||
array_def *elec_check_resistor(void)
|
||||
{
|
||||
/*
|
||||
1 ͨ<><CDA8>1-4ͨ<34><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿
|
||||
2 ͨ<><CDA8>2-3ͨ<33><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿
|
||||
3 ͨ<><CDA8>1-3ͨ<33><CDA8><EFBFBD><EFBFBD><EFBFBD>迹
|
||||
4 ͨ<><CDA8>2-4ͨ<34><CDA8><EFBFBD><EFBFBD><EFBFBD>迹
|
||||
*/
|
||||
uint16_t aus_sample[5];
|
||||
uint16_t us_resistor;
|
||||
uint8_t uc_index = 0;
|
||||
AD_SampleResistor(aus_sample);
|
||||
for(uc_index = 0; uc_index < 5; uc_index++)
|
||||
{
|
||||
aus_sample[uc_index] -= board_st.resistor_diff;
|
||||
}
|
||||
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
switch(0)
|
||||
{
|
||||
case 0: us_resistor = aus_sample[0];break;
|
||||
case 1: us_resistor = aus_sample[1];break;
|
||||
case 2: us_resistor = aus_sample[2];break;
|
||||
default : us_resistor = 0;break;
|
||||
}
|
||||
array_def *r=arr_creat();
|
||||
arr_append(r,0);
|
||||
arr_append(r,us_resistor&0xff);
|
||||
arr_append(r,(us_resistor >> 8) & 0xff);
|
||||
return arr_temp(r);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// У<>鷽<EFBFBD><E9B7BD>,<2C><>0<EFBFBD>ɹ<EFBFBD>
|
||||
static int elec_check_scheme(void)
|
||||
{
|
||||
uint32_t ul_crc32;
|
||||
|
||||
ul_crc32 = Crc32Calu((uint32_t*)APP_TEST_PLAN_ADDR,(APP_TEST_PLANINFO_SIZE-4));
|
||||
if(ul_crc32 != (*(uint32_t*)(APP_TEST_PLAN_ADDR+APP_TEST_PLANINFO_SIZE-4)))
|
||||
{
|
||||
board_st.plan_id = ~0;
|
||||
LED1_Out_Off;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// <20><><EFBFBD>ط<EFBFBD><D8B7><EFBFBD>
|
||||
static void elec_load_scheme(void)
|
||||
{
|
||||
self_def *s=&g_self;
|
||||
uint8_t uc_index = 0;
|
||||
uint32_t ul_len;
|
||||
CheckerTask_Info_st* pinfo_st = (CheckerTask_Info_st*)(APP_TEST_PLAN_ADDR+256);
|
||||
for(uc_index = 0; uc_index < PLAN_MAX_TASK; uc_index++)
|
||||
{
|
||||
s->task_info_array[uc_index] = 0;
|
||||
}
|
||||
uc_index = 0;
|
||||
while((pinfo_st->runindex != 0xFF) && (uc_index < PLAN_MAX_TASK))
|
||||
{
|
||||
s->task_info_array[uc_index++] = pinfo_st;
|
||||
ul_len = pinfo_st->param_rtv_count & 0x0F;
|
||||
ul_len = (ul_len<<1)+5;
|
||||
|
||||
pinfo_st = (CheckerTask_Info_st*)((uint8_t*)pinfo_st + ul_len);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// <20><><EFBFBD>м<EFBFBD><D0BC><EFBFBD>
|
||||
array_def *elec_check_with_scheme(array_def *uid_psw)
|
||||
{
|
||||
self_def *s=&g_self;
|
||||
const uint8_t* ptaskindex = (uint8_t*)(APP_TEST_PLAN_ADDR+4);
|
||||
CheckerTask *tasks_fun_table[]={jqtaskArray,xttaskArray};
|
||||
CheckerTask_Info_st *task_par=0;
|
||||
uint8_t chip_type=0;
|
||||
uint8_t taskid=0;
|
||||
CheckerTask task_fun=0;
|
||||
uint8_t res=0;
|
||||
array_def *r=arr_creat();
|
||||
chip_type=(board_st.plan_id >> 12 ) & 0x0F;
|
||||
if(chip_type>=LENGTH(tasks_fun_table)){
|
||||
arr_append(r,1);
|
||||
return arr_temp(r);
|
||||
}
|
||||
memset(&checker_runcfg,0,sizeof(Checker_RunCfg_st));
|
||||
int task_index=0;
|
||||
int err_flag=0;
|
||||
LED1_Out_Off;
|
||||
while((ptaskindex[task_index]!=0xff)&&(task_index<PLAN_MAX_TASK)){
|
||||
memset(&checker_runcfg.task_info,0,sizeof(CheckerTask_Info_st));
|
||||
taskid=ptaskindex[task_index];
|
||||
memset(checker_runcfg.params,0,20);
|
||||
checker_runcfg.param_count = 0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
checker_runcfg.rtv_count = 0;//<2F><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>
|
||||
checker_runcfg.excue_rtv = 0;
|
||||
checker_runcfg.task_info.retry_time = 0;
|
||||
if(taskid>=CHECKER_MAXID_COUNT){
|
||||
break;
|
||||
}
|
||||
task_par= s->task_info_array[task_index];
|
||||
if(task_par==0){
|
||||
break;
|
||||
}
|
||||
task_fun=tasks_fun_table[chip_type][taskid];
|
||||
if(task_fun==0){
|
||||
break;
|
||||
}
|
||||
|
||||
// װ<>ز<EFBFBD><D8B2><EFBFBD>
|
||||
rt_memcpy(&checker_runcfg.task_info,task_par,sizeof(CheckerTask_Info_st));
|
||||
checker_runcfg.param_count = checker_runcfg.task_info.param_rtv_count & 0x0F;
|
||||
checker_runcfg.rtv_count = (checker_runcfg.task_info.param_rtv_count >> 4) & 0x0F;
|
||||
rt_memcpy(checker_runcfg.params,checker_runcfg.task_info.params,checker_runcfg.param_count*2);
|
||||
|
||||
// ִ<><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
for(int i=0;i<1+task_par->retry_time;i++)
|
||||
{
|
||||
checker_runcfg.excue_rtv=1;
|
||||
task_fun();
|
||||
Checker_Excueindex(task_index);
|
||||
if(checker_runcfg.excue_rtv==0)
|
||||
break;
|
||||
}
|
||||
|
||||
// <20><>Ѱ<EFBFBD><D1B0>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if((checker_runcfg.excue_rtv != 0)
|
||||
&& (checker_runcfg.task_info.error_jumpto != 0)
|
||||
&& (checker_runcfg.task_info.error_jumpto != 0xFF)
|
||||
)
|
||||
{
|
||||
uint8_t uc_index = task_index+1;//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1>˳<EFBFBD><CBB3>ִ<EFBFBD><D6B4>
|
||||
task_index = checker_runcfg.task_info.error_jumpto;
|
||||
while(uc_index < task_index)
|
||||
{
|
||||
Checker_MaskResult(1,uc_index);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δִ<CEB4><D6B4>
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>±꣬<C2B1><EAA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>ֵ<EFBFBD>洢<EFBFBD>ռ䱣<D5BC><E4B1A3>
|
||||
checker_runcfg.rtv_index += (s->task_info_array[uc_index]->param_rtv_count >> 4) & 0x0F;
|
||||
uc_index++;
|
||||
}
|
||||
}else{
|
||||
task_index++;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1>˳<EFBFBD><CBB3>ִ<EFBFBD><D6B4>
|
||||
}
|
||||
}
|
||||
|
||||
arr_append(r,0);
|
||||
arr_appends(r,checker_runcfg.Task_Result,8);
|
||||
arr_appends(r,checker_runcfg.Task_Excute,8);
|
||||
arr_appends(r,checker_runcfg.Test_Rtv,checker_runcfg.rtv_index*2);
|
||||
return arr_temp(r);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
31
source/elec_det/elec_det.h
Normal file
31
source/elec_det/elec_det.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef elec_det_h__
|
||||
#define elec_det_h__
|
||||
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
uint8_t elec_local_addr(void);
|
||||
|
||||
void elec_led1_power(int power);
|
||||
|
||||
void elec_led2_power(int power);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
633
source/elec_det/hardware/adc_cfg.c
Normal file
633
source/elec_det/hardware/adc_cfg.c
Normal file
@@ -0,0 +1,633 @@
|
||||
#include "adc_cfg.h"
|
||||
#include "gpio_cfg.h"
|
||||
#include "base/delay.h"
|
||||
#include "timer_cfg.h"
|
||||
#include "base/utility.h"
|
||||
#include "power.h"
|
||||
uint16_t ad0_adc_sample[AD_SCAN_SAMPLE*AD_SCAN_COUNT];
|
||||
#define ADC1_SAMPLE_BUF_LEN 200
|
||||
#define ADC1_SAMPLE_BUF_LEN2 20
|
||||
|
||||
volatile uint16_t FireBus_ADC_Buf[FIREBUS_ADC_BUF_LEN];
|
||||
|
||||
|
||||
uint16_t adc1_sample_buf[ADC1_SAMPLE_BUF_LEN];
|
||||
void AdcDef_Init(void)
|
||||
{
|
||||
|
||||
ADC_InitTypeDef ADC_InitStructure;
|
||||
DMA_InitTypeDef DMA_InitStructure;
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE );
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC2, ENABLE );
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);
|
||||
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1,ENABLE);
|
||||
|
||||
RCC_ADCCLKConfig(RCC_PCLK2_Div6); //12MHz
|
||||
|
||||
//GPIO 配置
|
||||
GPIO_InitStructure.GPIO_Pin= VCC_2V5_Pin | VCC_1V25_Pin | V_LA_M_Pin | V_LA_H_Pin | R_AD_01_Pin;
|
||||
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AIN;
|
||||
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
||||
GPIO_Init(GPIOA,&GPIO_InitStructure);
|
||||
GPIO_Write(GPIOA,GPIO_InitStructure.GPIO_Pin);
|
||||
|
||||
//GPIO 配置
|
||||
GPIO_InitStructure.GPIO_Pin= AD_OUTA_Pin | AD_OUTB_Pin | AN_UA_Pin | AN_MAL_Pin | AN_CAP_AD_Pin;
|
||||
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AIN;
|
||||
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
||||
GPIO_Init(GPIOA,&GPIO_InitStructure);
|
||||
GPIO_Write(GPIOC,GPIO_InitStructure.GPIO_Pin);
|
||||
|
||||
ADC_DeInit(ADC1);
|
||||
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
|
||||
ADC_InitStructure.ADC_ScanConvMode = ENABLE;
|
||||
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
|
||||
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
|
||||
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
|
||||
ADC_InitStructure.ADC_NbrOfChannel = AD_SCAN_SAMPLE;
|
||||
ADC_Init(ADC1, &ADC_InitStructure);
|
||||
ADC_TempSensorVrefintCmd(ENABLE);
|
||||
|
||||
|
||||
|
||||
ADC_RegularChannelConfig(ADC1, VCC_2V5_CH, 1, ADC_SampleTime_239Cycles5);
|
||||
ADC_RegularChannelConfig(ADC1, VCC_1V25_CH, 2, ADC_SampleTime_239Cycles5);
|
||||
ADC_RegularChannelConfig(ADC1, V_LA_M_CH, 3, ADC_SampleTime_239Cycles5);
|
||||
ADC_RegularChannelConfig(ADC1, V_LA_H_CH, 4, ADC_SampleTime_239Cycles5);
|
||||
ADC_RegularChannelConfig(ADC1, AD_OUTA_CH, 5, ADC_SampleTime_239Cycles5);
|
||||
ADC_RegularChannelConfig(ADC1, AD_OUTB_CH, 6, ADC_SampleTime_239Cycles5);
|
||||
ADC_RegularChannelConfig(ADC1, ADC_Channel_16, 7, ADC_SampleTime_71Cycles5);
|
||||
ADC_RegularChannelConfig(ADC1, ADC_Channel_17, 8, ADC_SampleTime_71Cycles5);
|
||||
|
||||
DMA_DeInit(DMA1_Channel1);
|
||||
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&ADC1->DR;
|
||||
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)ad0_adc_sample;
|
||||
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
|
||||
DMA_InitStructure.DMA_BufferSize = AD_SCAN_SAMPLE*AD_SCAN_COUNT;
|
||||
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
|
||||
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
|
||||
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
|
||||
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
|
||||
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
|
||||
DMA_InitStructure.DMA_Priority = DMA_Priority_Medium;
|
||||
DMA_InitStructure.DMA_M2M = DISABLE;
|
||||
DMA_Init(DMA1_Channel1,&DMA_InitStructure);
|
||||
DMA_Cmd(DMA1_Channel1,ENABLE);
|
||||
|
||||
ADC_Cmd(ADC1, ENABLE);
|
||||
ADC_ResetCalibration(ADC1);
|
||||
while(ADC_GetResetCalibrationStatus(ADC1));
|
||||
|
||||
ADC_StartCalibration(ADC1);
|
||||
while(ADC_GetCalibrationStatus(ADC1));
|
||||
|
||||
ADC_DMACmd(ADC1,ENABLE);
|
||||
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
|
||||
|
||||
|
||||
|
||||
ADC_DeInit(ADC2);
|
||||
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
|
||||
ADC_InitStructure.ADC_ScanConvMode = DISABLE;
|
||||
ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
|
||||
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
|
||||
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
|
||||
ADC_InitStructure.ADC_NbrOfChannel = 1;
|
||||
ADC_Init(ADC2, &ADC_InitStructure);
|
||||
|
||||
ADC_Cmd(ADC2, ENABLE);
|
||||
ADC_ResetCalibration(ADC2);
|
||||
while(ADC_GetResetCalibrationStatus(ADC2));
|
||||
|
||||
ADC_StartCalibration(ADC2);
|
||||
while(ADC_GetCalibrationStatus(ADC2));
|
||||
|
||||
ADC_DMACmd(ADC2,ENABLE);
|
||||
ADC_SoftwareStartConvCmd(ADC2, ENABLE);
|
||||
}
|
||||
|
||||
|
||||
void StartADC2Channel(uint32_t channel, uint32_t speed)
|
||||
{
|
||||
|
||||
ADC_RegularChannelConfig(ADC2,channel,1,speed);
|
||||
ADC_SoftwareStartConvCmd(ADC2,ENABLE);
|
||||
delay_us(100);
|
||||
}
|
||||
|
||||
void StartADC1Channel(uint32_t channel)
|
||||
{
|
||||
|
||||
ADC_RegularChannelConfig(ADC1,channel,1,ADC_SampleTime_71Cycles5);
|
||||
ADC_SoftwareStartConvCmd(ADC1,ENABLE);
|
||||
delay_us(100);
|
||||
//adc_calibration_enable(ADC0);
|
||||
}
|
||||
|
||||
/*
|
||||
使用该函数,对ADC2触发一次采样,到用该函数前,应调用一次StartADC1Channel(ch)
|
||||
*/
|
||||
uint32_t GetADC2_Fast(void)
|
||||
{
|
||||
uint16_t time_out = 10000;
|
||||
uint16_t temp = 0;
|
||||
ADC_ClearFlag(ADC2,ADC_FLAG_EOC);//清除转换结束标志
|
||||
ADC_SoftwareStartConvCmd(ADC2,ENABLE);//启动转换
|
||||
while((time_out > 0) && ( ADC_GetFlagStatus(ADC2,ADC_FLAG_EOC) == RESET))
|
||||
{
|
||||
time_out--;
|
||||
}
|
||||
temp = ADC_GetConversionValue(ADC2) & 0x0FFF;
|
||||
return temp;
|
||||
}
|
||||
/*
|
||||
使用该函数,对ADC触发一次采样,到用该函数前,应调用一次StartADC0Channel(ch)
|
||||
*/
|
||||
uint16_t GetADC_Fast(ADC_TypeDef* adc_periph)
|
||||
{
|
||||
uint16_t time_out = 10000;
|
||||
uint16_t temp = 0;
|
||||
ADC_ClearFlag(adc_periph,ADC_FLAG_EOC);//清除转换结束标志
|
||||
ADC_SoftwareStartConvCmd(adc_periph,ENABLE);//启动转换
|
||||
while((time_out > 0) && ( ADC_GetFlagStatus(adc_periph,ADC_FLAG_EOC) == RESET))
|
||||
{
|
||||
time_out--;
|
||||
}
|
||||
temp = ADC_GetConversionValue(adc_periph) & 0x0FFF;
|
||||
return temp;
|
||||
}
|
||||
|
||||
uint32_t GetADC1_Fast(void)
|
||||
{
|
||||
return GetADC_Fast(ADC1);
|
||||
}
|
||||
|
||||
|
||||
uint32_t GetADC2_Value(uint32_t channel)
|
||||
{
|
||||
StartADC2Channel(channel,ADC_SPEED_MIDLE);
|
||||
return GetADC2_Fast();
|
||||
}
|
||||
|
||||
/*
|
||||
ADC_RegularChannelConfig(ADC1, VCC_2V5_CH, 1, ADC_SampleTime_239Cycles5);
|
||||
ADC_RegularChannelConfig(ADC1, VCC_1V25_CH, 2, ADC_SampleTime_239Cycles5);
|
||||
ADC_RegularChannelConfig(ADC1, V_LA_M_CH, 3, ADC_SampleTime_239Cycles5);
|
||||
ADC_RegularChannelConfig(ADC1, V_LA_H_CH, 4, ADC_SampleTime_239Cycles5);
|
||||
ADC_RegularChannelConfig(ADC1, AD_OUTA_CH, 5, ADC_SampleTime_239Cycles5);
|
||||
ADC_RegularChannelConfig(ADC1, AD_OUTB_CH, 6, ADC_SampleTime_239Cycles5);
|
||||
ADC_RegularChannelConfig(ADC1, ADC_Channel_16, 7, ADC_SampleTime_71Cycles5);
|
||||
ADC_RegularChannelConfig(ADC1, ADC_Channel_17, 8, ADC_SampleTime_71Cycles5);
|
||||
|
||||
*/
|
||||
void GetADC1_Value(uint32_t channel,uint16_t* buf,uint16_t len)
|
||||
{
|
||||
uint8_t i = 0;
|
||||
uint16_t* buf_head = 0;
|
||||
switch(channel)
|
||||
{
|
||||
case VCC_2V5_CH: buf_head = ad0_adc_sample;break;
|
||||
case VCC_1V25_CH: buf_head = ad0_adc_sample+1;break;
|
||||
case V_LA_M_CH: buf_head = ad0_adc_sample+2;break;
|
||||
case V_LA_H_CH: buf_head = ad0_adc_sample+3;break;
|
||||
case AD_OUTA_CH: buf_head = ad0_adc_sample+4;break;
|
||||
case AD_OUTB_CH: buf_head = ad0_adc_sample+5;break;
|
||||
case ADC_Channel_16:buf_head = ad0_adc_sample+6;break;
|
||||
case ADC_Channel_17:buf_head = ad0_adc_sample+7;break;
|
||||
default:buf_head = 0;break;
|
||||
}
|
||||
if(buf_head == 0)
|
||||
return;
|
||||
if(len > AD_SCAN_COUNT)
|
||||
len = AD_SCAN_COUNT;
|
||||
for(i=0; i < len ; i++)
|
||||
{
|
||||
buf[i] = buf_head[i*AD_SCAN_SAMPLE];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
float Get_Temperature(void)
|
||||
{
|
||||
uint32_t ad_v;
|
||||
GetADC1_Value(ADC_Channel_16,(uint16_t*)&ad_v,1);
|
||||
float temper = (1.43f - ad_v*3.3f/4096) * 1000 / 4.3f + 25;
|
||||
return temper;
|
||||
}
|
||||
|
||||
|
||||
/*************************ADC App****************************************/
|
||||
/*
|
||||
@brief 稳定获取总线电流
|
||||
@rtv 返回电流值 0.1uA
|
||||
*/
|
||||
uint16_t ADC_GetBaseStableCur(void)
|
||||
{
|
||||
uint16_t us_count = 0;
|
||||
uint16_t us_temp = 0;
|
||||
uint32_t ul_base;
|
||||
StartADC2Channel(AN_UA_CH,ADC_SPEED_SLOW);
|
||||
Power_SetSampleCurrentRange(R100_0uA_160uA_UC);
|
||||
delay_ms(100);
|
||||
while(us_count < ADC1_SAMPLE_BUF_LEN)
|
||||
{
|
||||
adc1_sample_buf[us_count] = GetADC_Fast(ADC_CURR_DE);
|
||||
delay_us(20);
|
||||
if(us_count == 0)
|
||||
{
|
||||
ul_base = adc1_sample_buf[us_count] ;
|
||||
}else{
|
||||
ul_base += adc1_sample_buf[us_count] ;
|
||||
ul_base >>= 1;
|
||||
}
|
||||
us_count++;
|
||||
}
|
||||
|
||||
for(us_count = 0; us_count < ADC1_SAMPLE_BUF_LEN; us_count++)
|
||||
{
|
||||
ul_base = (ul_base*8 + adc1_sample_buf[us_count]*2 )/10;
|
||||
adc1_sample_buf[us_count] = ul_base;
|
||||
}
|
||||
Bubble_Sort_u16(adc1_sample_buf,us_count);
|
||||
|
||||
us_count = (ADC1_SAMPLE_BUF_LEN>>2);
|
||||
us_temp = ADC1_SAMPLE_BUF_LEN - (ADC1_SAMPLE_BUF_LEN>>2);
|
||||
while(us_count < us_temp)
|
||||
{
|
||||
ul_base += adc1_sample_buf[us_count++];
|
||||
}
|
||||
us_temp -= (ADC1_SAMPLE_BUF_LEN>>2);
|
||||
ul_base = ul_base / us_temp;
|
||||
ul_base = Power_ConvCur(ul_base,R100_0uA_160uA_UC);
|
||||
return ul_base;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@brief 稳定获取总线电流
|
||||
@rtv 返回电流值 0.1uA
|
||||
*/
|
||||
uint16_t ADC_Comm1p6mA_EndCur(void)
|
||||
{
|
||||
uint16_t us_count = 0;
|
||||
uint16_t us_temp = 0;
|
||||
uint32_t ul_base;
|
||||
StartADC2Channel(AN_UA_CH,ADC_SPEED_SLOW);
|
||||
Power_SetSampleCurrentRange(R10_0p1mA_1p6mA_UC);
|
||||
delay_ms(1);
|
||||
while(us_count < ADC1_SAMPLE_BUF_LEN2)
|
||||
{
|
||||
adc1_sample_buf[us_count] = GetADC_Fast(ADC_CURR_DE);
|
||||
delay_us(1);
|
||||
if(us_count == 0)
|
||||
{
|
||||
ul_base = adc1_sample_buf[us_count] ;
|
||||
}else{
|
||||
ul_base += adc1_sample_buf[us_count] ;
|
||||
ul_base >>= 1;
|
||||
}
|
||||
us_count++;
|
||||
}
|
||||
|
||||
for(us_count = 0; us_count < ADC1_SAMPLE_BUF_LEN2; us_count++)
|
||||
{
|
||||
ul_base = (ul_base*8 + adc1_sample_buf[us_count]*2 )/10;
|
||||
adc1_sample_buf[us_count] = ul_base;
|
||||
}
|
||||
Bubble_Sort_u16(adc1_sample_buf,us_count);
|
||||
|
||||
us_count = (ADC1_SAMPLE_BUF_LEN2>>2);
|
||||
us_temp = ADC1_SAMPLE_BUF_LEN2 - (ADC1_SAMPLE_BUF_LEN2>>2);
|
||||
while(us_count < us_temp)
|
||||
{
|
||||
ul_base += adc1_sample_buf[us_count++];
|
||||
}
|
||||
us_temp -= (ADC1_SAMPLE_BUF_LEN2>>2);
|
||||
ul_base = ul_base / us_temp;
|
||||
ul_base = Power_ConvCur(ul_base,R10_0p1mA_1p6mA_UC);
|
||||
return ul_base;
|
||||
}
|
||||
|
||||
/*
|
||||
@brief 电流降到指定电流下的时间
|
||||
@param 执行时间 单位0.1ms
|
||||
@rtv 最大波动AD值
|
||||
*/
|
||||
uint16_t AD_CurMonitor(uint32_t ul_times)
|
||||
{
|
||||
uint32_t ul_count = 0, ul_count2;
|
||||
uint16_t us_count = 0;
|
||||
uint16_t aus_adc[20];
|
||||
uint16_t us_maxadv,us_minadv = 0;
|
||||
uint16_t ul_shake = 0;
|
||||
LED1_Out = 0;
|
||||
for(ul_count2 =0; ul_count2 < 20;ul_count2++)
|
||||
{
|
||||
aus_adc[ul_count2] = ADC_GetCurADCFast();
|
||||
}
|
||||
LED1_Out = 1;
|
||||
ul_count2 = 0;
|
||||
while(ul_times > 0)
|
||||
{
|
||||
ul_count = 0;
|
||||
Get100usCount();
|
||||
while(ul_count< 50000 && ul_count < ul_times)
|
||||
{
|
||||
us_maxadv = 0;
|
||||
us_minadv = 0xFFF;
|
||||
|
||||
for(us_count = 0; us_count < 20;us_count++)
|
||||
{
|
||||
if(aus_adc[us_count] > us_maxadv)
|
||||
{
|
||||
us_maxadv = aus_adc[us_count];
|
||||
}
|
||||
if(aus_adc[us_count] < us_minadv)
|
||||
{
|
||||
us_minadv = aus_adc[us_count];
|
||||
}
|
||||
}
|
||||
ul_count2 %= 20;
|
||||
aus_adc[ul_count2++] = ADC_GetCurADCFast();
|
||||
if(us_maxadv < us_minadv)
|
||||
{
|
||||
us_minadv = 4096;
|
||||
}else{
|
||||
us_minadv = us_maxadv - us_minadv;
|
||||
}
|
||||
if(ul_shake < us_minadv)
|
||||
{
|
||||
ul_shake = us_minadv;
|
||||
if(ul_shake > 500){
|
||||
LED1_Out = 0;
|
||||
delay_us(50);
|
||||
LED1_Out = 1;
|
||||
}
|
||||
}
|
||||
delay_us(40);
|
||||
ul_count = GET_COUNTTIM_VAL();
|
||||
}
|
||||
if(ul_count >= ul_times)
|
||||
{
|
||||
LED1_Out = 0;
|
||||
return ul_shake;
|
||||
}
|
||||
ul_times -= ul_count;
|
||||
}
|
||||
LED1_Out= 0;
|
||||
return ul_shake;
|
||||
}
|
||||
|
||||
/*
|
||||
@brief 电流降到指定电流下的时间
|
||||
@param 采样超时
|
||||
@param end_adv 检测启动和结束判线
|
||||
@param 最大电流ad
|
||||
@param 电流下降过程中最大向上波动
|
||||
@rtv 时间采集值0.1ms
|
||||
*/
|
||||
|
||||
|
||||
uint16_t AD_GetChgEnergy(uint16_t sample_timeout, uint16_t end_adv,uint16_t* max_cul,uint16_t *shake_adv)
|
||||
{
|
||||
uint16_t aus_adc_v[5];
|
||||
uint16_t aus_adv_shake[20];
|
||||
uint16_t time_out;
|
||||
uint16_t us_count = 0;
|
||||
uint16_t us_shake_count = 0;
|
||||
uint16_t us_shake_minadc,us_shake_maxadc;
|
||||
uint8_t start_flag = 0,shake_flag = 0;
|
||||
Get100usCount();
|
||||
ADC_ClearFlag(ADC_CURR_DE,ADC_FLAG_EOC);//清除转换结束标志
|
||||
ADC_SoftwareStartConvCmd(ADC_CURR_DE, ENABLE); //启动转换
|
||||
aus_adc_v[4] = 0xFFFF;
|
||||
*max_cul = 0;
|
||||
*shake_adv = 0;
|
||||
LED1_Out = 0;
|
||||
if(end_adv == 0 || end_adv == 0xFFFF)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
while(GetCountTimerCnt() < sample_timeout)
|
||||
{
|
||||
time_out = 2000;
|
||||
while((time_out > 0) && ( ADC_GetFlagStatus(ADC_CURR_DE,ADC_FLAG_EOC) == RESET))
|
||||
{
|
||||
time_out--;
|
||||
}
|
||||
aus_adc_v[us_count] = ADC_GetConversionValue(ADC_CURR_DE) & 0x0FFF;
|
||||
aus_adv_shake[us_shake_count] = aus_adc_v[us_count];
|
||||
ADC_ClearFlag(ADC_CURR_DE,ADC_FLAG_EOC);//清除转换结束标志
|
||||
ADC_SoftwareStartConvCmd(ADC_CURR_DE, ENABLE); //启动转换
|
||||
us_count++;
|
||||
us_shake_count++;
|
||||
us_count %= 5;
|
||||
us_shake_count %= 20;
|
||||
if((us_shake_count == 0) && (start_flag > 0))
|
||||
{
|
||||
shake_flag ++;
|
||||
}
|
||||
if(shake_flag == 2)
|
||||
{
|
||||
LED1_Out = 1;
|
||||
shake_flag = 1;
|
||||
time_out = 0;
|
||||
us_shake_maxadc = 0;
|
||||
us_shake_minadc = 0x0FFF;
|
||||
while(time_out < 20)
|
||||
{
|
||||
if(aus_adv_shake[time_out] > us_shake_maxadc)
|
||||
{
|
||||
us_shake_maxadc = aus_adv_shake[time_out];
|
||||
}
|
||||
if(aus_adv_shake[time_out] < us_shake_minadc)
|
||||
{
|
||||
us_shake_minadc = aus_adv_shake[time_out];
|
||||
}
|
||||
time_out++;
|
||||
}
|
||||
us_shake_minadc = us_shake_maxadc - us_shake_minadc;
|
||||
if(us_shake_minadc > 900)
|
||||
{
|
||||
us_shake_minadc = 0;
|
||||
}
|
||||
if(*shake_adv < us_shake_minadc)
|
||||
{
|
||||
*shake_adv = us_shake_minadc;
|
||||
}
|
||||
}
|
||||
|
||||
if(us_count == 0)
|
||||
{
|
||||
Bubble_Sort_u16(aus_adc_v,5);
|
||||
if((aus_adc_v[0] > end_adv) && start_flag == 0)
|
||||
{
|
||||
start_flag = 1;
|
||||
Get100usCount();//未启动重新设置计数器
|
||||
}
|
||||
//连续5个都大于判线值
|
||||
else if(start_flag >0 )
|
||||
{
|
||||
if(*max_cul < aus_adc_v[2])
|
||||
{
|
||||
*max_cul = aus_adc_v[2];
|
||||
}
|
||||
if(aus_adc_v[4] < end_adv)
|
||||
{
|
||||
LED1_Out = 0;
|
||||
return Get100usCount();
|
||||
}
|
||||
}else if(start_flag == 0)
|
||||
{
|
||||
if(GetCountTimerCnt() > 10000)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return 40000;
|
||||
}
|
||||
|
||||
/*获取桥丝电阻*/
|
||||
void AD_SampleResistor(uint16_t* channels_re)
|
||||
{
|
||||
uint16_t aus_sample[32];
|
||||
uint8_t uc_index = 0;
|
||||
const static float resistor_cur = 2.49f;
|
||||
const static float res_mutli = 79.7;
|
||||
/*
|
||||
Gpio_ResistorSwitch
|
||||
@param 0 全关
|
||||
1 通道1-4通,过桥丝
|
||||
2 通道2-3通,过桥丝
|
||||
3 通道1-3通,测阻抗
|
||||
4 通道2-4通,测阻抗
|
||||
|
||||
*/
|
||||
float f_r1,f_r2,f_r3,f_r4;
|
||||
ADC_ResistorChannelSet(ADC_SPEED_MIDLE);
|
||||
Gpio_ResistorSwitch(1);
|
||||
delay_ms(50);
|
||||
for(uc_index = 0; uc_index < 32; uc_index++)
|
||||
{
|
||||
aus_sample[uc_index] = ADC_GetResistorADCFast();
|
||||
}
|
||||
Bubble_Sort_u16(aus_sample,uc_index);
|
||||
f_r1 = 0;
|
||||
for(uc_index = 8; uc_index < 24; uc_index++)
|
||||
{
|
||||
f_r1 += aus_sample[uc_index];
|
||||
}
|
||||
f_r1 = (((f_r1 /res_mutli)*1000)/4096)*3.3f/resistor_cur/16;
|
||||
|
||||
Gpio_ResistorSwitch(2);
|
||||
delay_ms(50);
|
||||
|
||||
for(uc_index = 0; uc_index < 32; uc_index++)
|
||||
{
|
||||
aus_sample[uc_index] = ADC_GetResistorADCFast();
|
||||
}
|
||||
Bubble_Sort_u16(aus_sample,uc_index);
|
||||
f_r2 = 0;
|
||||
for(uc_index = 8; uc_index < 24; uc_index++)
|
||||
{
|
||||
f_r2 += aus_sample[uc_index];
|
||||
}
|
||||
f_r2 = (((f_r2 /res_mutli)*1000)/4096)*3.3f/resistor_cur/16;
|
||||
|
||||
Gpio_ResistorSwitch(3);
|
||||
delay_ms(50);
|
||||
|
||||
for(uc_index = 0; uc_index < 32; uc_index++)
|
||||
{
|
||||
aus_sample[uc_index] = ADC_GetResistorADCFast();
|
||||
}
|
||||
Bubble_Sort_u16(aus_sample,uc_index);
|
||||
f_r3 = 0;
|
||||
for(uc_index = 8; uc_index < 24; uc_index++)
|
||||
{
|
||||
f_r3 += aus_sample[uc_index];
|
||||
}
|
||||
f_r3 = (((f_r3 /res_mutli)*1000)/4096)*3.3f/resistor_cur/16;
|
||||
|
||||
Gpio_ResistorSwitch(4);
|
||||
delay_ms(50);
|
||||
|
||||
for(uc_index = 0; uc_index < 32; uc_index++)
|
||||
{
|
||||
aus_sample[uc_index] = ADC_GetResistorADCFast();
|
||||
}
|
||||
Bubble_Sort_u16(aus_sample,uc_index);
|
||||
f_r4 = 0;
|
||||
for(uc_index = 8; uc_index < 24; uc_index++)
|
||||
{
|
||||
f_r4 += aus_sample[uc_index];
|
||||
}
|
||||
f_r4 = (((f_r4 /res_mutli)*1000)/4096)*3.3f/resistor_cur/16;
|
||||
|
||||
Gpio_ResistorSwitch(0);
|
||||
|
||||
channels_re[0] = (uint16_t) (((f_r1+f_r2-f_r3-f_r4)/2+0.005f)*100);
|
||||
channels_re[1] = (uint16_t) ((f_r1+0.005f)*100);
|
||||
channels_re[2] = (uint16_t) ((f_r2+0.005f)*100);
|
||||
channels_re[3] = (uint16_t) ((f_r3+0.005f)*100);
|
||||
channels_re[4] = (uint16_t) ((f_r4+0.005f)*100);
|
||||
|
||||
}
|
||||
|
||||
/*测量电容电压*/
|
||||
uint16_t AD_SampleCap(uint16_t delay)
|
||||
{
|
||||
uint32_t ul_ad = 0,ul_ad2 = 0;
|
||||
uint8_t uc_index = 0;
|
||||
uint16_t aus_sample[32];
|
||||
Gpio_CAPSwitch(1);
|
||||
ADC_CAPVolChannelSet(ADC_SPEED_MIDLE);
|
||||
delay_ms(1500);
|
||||
for(uc_index = 0; uc_index < 32; uc_index++)
|
||||
{
|
||||
aus_sample[uc_index] = ADC_GetCAPVolADCFast();
|
||||
}
|
||||
Bubble_Sort_u16(aus_sample,uc_index);
|
||||
ul_ad = 0;
|
||||
for(uc_index = 8; uc_index < 24; uc_index++)
|
||||
{
|
||||
ul_ad += aus_sample[uc_index];
|
||||
}
|
||||
//
|
||||
ul_ad >>= 4;
|
||||
|
||||
while(delay > 0)
|
||||
{
|
||||
delay_os_ms(100);
|
||||
delay--;
|
||||
}
|
||||
|
||||
for(uc_index = 0; uc_index < 32; uc_index++)
|
||||
{
|
||||
aus_sample[uc_index] = ADC_GetCAPVolADCFast();
|
||||
}
|
||||
Bubble_Sort_u16(aus_sample,uc_index);
|
||||
ul_ad2 = 0;
|
||||
for(uc_index = 8; uc_index < 24; uc_index++)
|
||||
{
|
||||
ul_ad2 += aus_sample[uc_index];
|
||||
}
|
||||
//ul_ad2 = ((ul_ad2 *25*11*100/board_st.v2p5_adc/16)+5)/10;
|
||||
ul_ad2 >>= 4;
|
||||
|
||||
if(ul_ad < ul_ad2)
|
||||
{
|
||||
ul_ad = 0;
|
||||
}else{
|
||||
ul_ad = ul_ad - ul_ad2;
|
||||
ul_ad = ((Power_ADVGetCalVal_106(ul_ad)*11)/100+5)/10 ;//((ul_ad *25*11*1000/board_st.v2p5_adc )+5)/10;
|
||||
}
|
||||
Gpio_CAPSwitch(0);
|
||||
return ul_ad;
|
||||
}
|
97
source/elec_det/hardware/adc_cfg.h
Normal file
97
source/elec_det/hardware/adc_cfg.h
Normal file
@@ -0,0 +1,97 @@
|
||||
#ifndef ADC_CFG_H_
|
||||
#define ADC_CFG_H_
|
||||
#include "base/define.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define AN_UA_CH ADC_Channel_12 //AD2
|
||||
#define AN_MAL_CH ADC_Channel_13 //AD2
|
||||
#define RAD_01_CH ADC_Channel_2 //AD2
|
||||
#define AN_CAP_AD_CH ADC_Channel_15 //AD2
|
||||
|
||||
|
||||
|
||||
#define VCC_2V5_CH ADC_Channel_1 //AD1
|
||||
#define VCC_1V25_CH ADC_Channel_3 //AD1
|
||||
#define V_LA_M_CH ADC_Channel_6 //AD1
|
||||
#define V_LA_H_CH ADC_Channel_7 //AD1
|
||||
#define AD_OUTA_CH ADC_Channel_10 //AD1
|
||||
#define AD_OUTB_CH ADC_Channel_11 //AD1
|
||||
|
||||
|
||||
#define ADC_CURR_DE ADC2
|
||||
|
||||
|
||||
|
||||
#define AD_SCAN_COUNT 16
|
||||
#define AD_SCAN_SAMPLE 8
|
||||
|
||||
#define FIREBUS_ADC_BUF_LEN 160
|
||||
extern volatile uint16_t FireBus_ADC_Buf[FIREBUS_ADC_BUF_LEN];
|
||||
|
||||
#define ADC_SPEED_SLOW ADC_SampleTime_239Cycles5
|
||||
#define ADC_SPEED_MIDLE ADC_SampleTime_71Cycles5
|
||||
#define ADC_SPEED_HIGH ADC_SampleTime_13Cycles5
|
||||
#define ADC_SPEED_HFAST ADC_SampleTime_7Cycles5
|
||||
void AdcDef_Init(void);
|
||||
void StartADC2Channel(uint32_t channel, uint32_t speed);
|
||||
#define ADC_CurChnnelSet(channel,speed) StartADC2Channel(channel,speed)
|
||||
//桥丝电阻测量通道
|
||||
#define ADC_ResistorChannelSet(speed) StartADC2Channel(RAD_01_CH,speed);
|
||||
//电容电压测量
|
||||
#define ADC_CAPVolChannelSet(speed) StartADC2Channel(AN_CAP_AD_CH,speed);
|
||||
|
||||
void StartADC1Channel(uint32_t channel);
|
||||
void StartADC2ChannelV2(uint32_t channel);
|
||||
uint32_t GetADC2_Fast(void);
|
||||
//电流采集通道
|
||||
#define ADC_GetCurADCFast() GetADC2_Fast()
|
||||
//桥丝电阻采集通道
|
||||
#define ADC_GetResistorADCFast() GetADC2_Fast()
|
||||
//电容电压采集通道
|
||||
#define ADC_GetCAPVolADCFast() GetADC2_Fast()
|
||||
|
||||
uint32_t GetADC1_Fast(void);
|
||||
|
||||
uint32_t GetADC2_Value(uint32_t channel);
|
||||
#define ADC_GetCurADC(chnnel) GetADC2_Value(channel)
|
||||
|
||||
void GetADC1_Value(uint32_t channel,uint16_t* buf,uint16_t len);
|
||||
float Get_Temperature(void);
|
||||
/*
|
||||
@brief 稳定获取总线电流
|
||||
@rtv 返回电流值 0.1uA
|
||||
*/
|
||||
uint16_t ADC_Comm1p6mA_EndCur(void);
|
||||
/*
|
||||
@brief 稳定获取总线电流
|
||||
*/
|
||||
uint16_t ADC_GetBaseStableCur(void);
|
||||
/*
|
||||
@brief 电流降到指定电流下的时间
|
||||
@param 采样超时
|
||||
@param end_adv 检测启动和结束判线
|
||||
@param 最大电流ad
|
||||
@param 电流下降过程中最大向上波动
|
||||
@rtv 时间采集值0.1ms
|
||||
*/
|
||||
uint16_t AD_GetChgEnergy(uint16_t sample_timeout, uint16_t end_adv,uint16_t* max_cul,uint16_t *shake_adv);
|
||||
/*
|
||||
@brief 电流降到指定电流下的时间
|
||||
@param 执行时间 单位0.1ms
|
||||
@rtv 最大波动AD值
|
||||
*/
|
||||
uint16_t AD_CurMonitor(uint32_t us_times);
|
||||
/*
|
||||
使用该函数,对ADC触发一次采样,到用该函数前,应调用一次StartADC0Channel(ch)
|
||||
*/
|
||||
uint16_t GetADC_Fast(ADC_TypeDef* adc_periph);
|
||||
|
||||
/*获取桥丝电阻*/
|
||||
void AD_SampleResistor(uint16_t* channels_re);
|
||||
/*测量电容电压*/
|
||||
uint16_t AD_SampleCap(uint16_t delay);
|
||||
#endif
|
69
source/elec_det/hardware/dac_cfg.c
Normal file
69
source/elec_det/hardware/dac_cfg.c
Normal file
@@ -0,0 +1,69 @@
|
||||
#include "dac_cfg.h"
|
||||
#include "gpio_cfg.h"
|
||||
/*
|
||||
@brief 默认初始化
|
||||
*/
|
||||
void DAC_Definit(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
DAC_InitTypeDef DAC_InitStructure;
|
||||
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = C_H_DAC_Pin|C_M_DAC_Pin;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
|
||||
|
||||
DAC_DeInit();
|
||||
DAC_InitStructure.DAC_Trigger = DAC_Trigger_Software;
|
||||
DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None;
|
||||
DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable;
|
||||
|
||||
|
||||
DAC_Init(DAC_Channel_1, &DAC_InitStructure);
|
||||
|
||||
|
||||
DAC_Init(DAC_Channel_2, &DAC_InitStructure);
|
||||
|
||||
DAC_Cmd(DAC_Channel_1, ENABLE);
|
||||
|
||||
DAC_Cmd(DAC_Channel_2, ENABLE);
|
||||
|
||||
|
||||
|
||||
C_H_DAC_Set(4000);
|
||||
/* configure the DAC1 */
|
||||
C_M_DAC_Set(4000);
|
||||
}
|
||||
/*
|
||||
@brief 设置高电平电压
|
||||
@param dac_val DAC0输出值 0-4096
|
||||
*/
|
||||
void C_H_DAC_Set(uint16_t dac_val)
|
||||
{
|
||||
DAC_SetChannel1Data(DAC_Align_12b_R, dac_val);
|
||||
DAC_SoftwareTriggerCmd(DAC_Channel_1,ENABLE);
|
||||
// dac_output_buffer_enable(DAC0);
|
||||
// dac_data_set(DAC0,DAC_ALIGN_12B_R,dac_val);
|
||||
// dac_trigger_enable(DAC0);
|
||||
// dac_enable(DAC0);
|
||||
// dac_software_trigger_enable(DAC0);
|
||||
}
|
||||
/*
|
||||
@brief 设置高电平电压
|
||||
@param dac_val DAC1输出值 0-4096
|
||||
*/
|
||||
void C_M_DAC_Set(uint16_t dac_val)
|
||||
{
|
||||
DAC_SetChannel2Data(DAC_Align_12b_R, dac_val);
|
||||
DAC_SoftwareTriggerCmd(DAC_Channel_2,ENABLE);
|
||||
// dac_output_buffer_enable(DAC1);
|
||||
// dac_data_set(DAC1,DAC_ALIGN_12B_R,dac_val);
|
||||
// dac_trigger_enable(DAC1);
|
||||
// dac_enable(DAC1);
|
||||
// dac_software_trigger_enable(DAC1);
|
||||
}
|
||||
|
||||
|
22
source/elec_det/hardware/dac_cfg.h
Normal file
22
source/elec_det/hardware/dac_cfg.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef DAC_CFG_H
|
||||
#define DAC_CFG_H
|
||||
#include "base/define.h"
|
||||
|
||||
#define C_H_DAC_CH DAC_OUT_0
|
||||
#define C_H_DAC_CM DAC_OUT_1
|
||||
|
||||
/*
|
||||
@brief 设置高电平电压
|
||||
@param dac_val DAC0输出值 0-4096
|
||||
*/
|
||||
void C_H_DAC_Set(uint16_t dac_val);
|
||||
/*
|
||||
@brief 设置高电平电压
|
||||
@param dac_val DAC1输出值 0-4096
|
||||
*/
|
||||
void C_M_DAC_Set(uint16_t dac_val);
|
||||
/*
|
||||
@brief 默认初始化
|
||||
*/
|
||||
void DAC_Definit(void);
|
||||
#endif
|
138
source/elec_det/hardware/gpio_cfg.c
Normal file
138
source/elec_det/hardware/gpio_cfg.c
Normal file
@@ -0,0 +1,138 @@
|
||||
#include "gpio_cfg.h"
|
||||
#include "base/delay.h"
|
||||
void CtrlGpio_DefInit(void)
|
||||
{
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,ENABLE);
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);
|
||||
|
||||
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable,ENABLE);
|
||||
//GPIO_PinRemapConfig(GPIO_Remap_SWJ_NoJTRST,ENABLE);
|
||||
|
||||
PAout(LAVC_M_Pin_Nu) = 0;
|
||||
|
||||
//GPIO 配置
|
||||
GPIO_InitStructure.GPIO_Pin=LAVC_M_Pin;
|
||||
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
|
||||
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
||||
GPIO_Init(GPIOA,&GPIO_InitStructure);
|
||||
GPIO_ResetBits(GPIOA,GPIO_InitStructure.GPIO_Pin);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = SEG0_Pin;
|
||||
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU;
|
||||
GPIO_Init(GPIOA,&GPIO_InitStructure);
|
||||
|
||||
|
||||
PBout(R10_ON_Pin_Nu) = 1;
|
||||
PBout(R510_ON_Pin_Nu) = 0;
|
||||
PBout(LED1_Pin_Nu) = 0;
|
||||
PBout(IO_APD12_Pin_Nu) = 0;
|
||||
PBout(LED2_Pin_Nu) = 0;
|
||||
PBout(OUTAL_Pin_Nu) = 0;
|
||||
PBout(OUTBL_Pin_Nu) = 0;
|
||||
PBout(OUTAH_Pin_Nu) = 0;
|
||||
PBout(IO_CAP_AD_Pin_Nu) = 0;
|
||||
|
||||
//GPIO 配置
|
||||
GPIO_InitStructure.GPIO_Pin=\
|
||||
R10_ON_Pin|R510_ON_Pin|LED1_Pin|IO_APD12_Pin|LED2_Pin|OUTAL_Pin|OUTBL_Pin|OUTAH_Pin|IO_CAP_AD_Pin;
|
||||
|
||||
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
|
||||
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
||||
GPIO_Init(GPIOB,&GPIO_InitStructure);
|
||||
|
||||
GPIO_ResetBits(GPIOB,GPIO_InitStructure.GPIO_Pin);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = FIRE_TEST_Pin;
|
||||
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING;
|
||||
GPIO_Init(GPIOB,&GPIO_InitStructure);
|
||||
|
||||
PCout(R100_ON_Pin_Nu) = 0;
|
||||
PCout(OUTBH_Pin_Nu) = 0;
|
||||
PCout(POWER_ON_Pin_Nu) = 0;
|
||||
PCout(IO_APD22_Pin_Nu) = 0;
|
||||
PCout(IO_APD21_Pin_Nu) = 0;
|
||||
PCout(IO_APD11_Pin_Nu) = 0;
|
||||
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin=\
|
||||
R100_ON_Pin|OUTBH_Pin|POWER_ON_Pin|IO_APD22_Pin|IO_APD21_Pin|IO_APD11_Pin;
|
||||
|
||||
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
|
||||
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
||||
GPIO_Init(GPIOC,&GPIO_InitStructure);
|
||||
|
||||
//GPIO 配置
|
||||
GPIO_InitStructure.GPIO_Pin=SEG4_Pin|SEG3_Pin|SEG1_Pin|SEG2_Pin;
|
||||
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU;
|
||||
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
||||
GPIO_Init(GPIOC,&GPIO_InitStructure);
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
@brief 获取设备地址
|
||||
@param 无
|
||||
@rtv 设备地址
|
||||
*/
|
||||
uint8_t Gpio_GetDeivceAddr(void)
|
||||
{
|
||||
uint16_t ul_addr ;
|
||||
ul_addr = (PCin(SEG4_Pin_Nu) & 0x01) <<4;
|
||||
ul_addr |= ((PCin(SEG3_Pin_Nu) & 0x01) <<3);
|
||||
ul_addr |= ((PCin(SEG2_Pin_Nu) & 0x01) <<2);
|
||||
ul_addr |= ((PCin(SEG1_Pin_Nu) & 0x01) <<1);
|
||||
ul_addr |= (PAin(SEG0_Pin_Nu) & 0x01);
|
||||
return ul_addr;
|
||||
// return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@brief 4限制电阻测量通道切换
|
||||
@param 0 全关
|
||||
1 通道1-4通,过桥丝
|
||||
2 通道2-3通,过桥丝
|
||||
3 通道1-3通,测阻抗
|
||||
4 通道2-4通,测阻抗
|
||||
*/
|
||||
void Gpio_ResistorSwitch(uint8_t uc_r)
|
||||
{
|
||||
/*
|
||||
1 2
|
||||
3 4
|
||||
*/
|
||||
switch(uc_r)
|
||||
{
|
||||
//1-4通,过桥丝电阻
|
||||
case 1: PCout(IO_APD11_Pin_Nu) = 1;PBout(IO_APD12_Pin_Nu) = 0;PCout(IO_APD22_Pin_Nu) = 1;PCout(IO_APD21_Pin_Nu) = 0; break;
|
||||
//2-3通,过桥丝测电阻
|
||||
case 2: PCout(IO_APD11_Pin_Nu) = 0;PBout(IO_APD12_Pin_Nu) = 1;PCout(IO_APD22_Pin_Nu) = 0;PCout(IO_APD21_Pin_Nu) = 1; break;
|
||||
//1-3通, 测阻抗
|
||||
case 3: PCout(IO_APD11_Pin_Nu) = 1;PBout(IO_APD12_Pin_Nu) = 1; PCout(IO_APD22_Pin_Nu) = 0; PCout(IO_APD21_Pin_Nu) = 0; break;
|
||||
//2-4通,测阻抗
|
||||
case 4: PCout(IO_APD11_Pin_Nu) = 0; PBout(IO_APD12_Pin_Nu) = 0; PCout(IO_APD22_Pin_Nu) = 1; PCout(IO_APD21_Pin_Nu) = 1; break;
|
||||
//全关
|
||||
default: PCout(IO_APD11_Pin_Nu) = 0; PBout(IO_APD12_Pin_Nu) = 0;PCout(IO_APD22_Pin_Nu) = 0; PCout(IO_APD21_Pin_Nu) = 0; break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@brief 测量电容电压压降GPIO配置
|
||||
*/
|
||||
|
||||
void Gpio_CAPSwitch(uint8_t uc_sw)
|
||||
{
|
||||
Gpio_ResistorSwitch(0);
|
||||
if(uc_sw > 0)
|
||||
{
|
||||
PBout(IO_CAP_AD_Pin_Nu) = 1;
|
||||
}else{
|
||||
PBout(IO_CAP_AD_Pin_Nu) = 0;
|
||||
}
|
||||
}
|
304
source/elec_det/hardware/gpio_cfg.h
Normal file
304
source/elec_det/hardware/gpio_cfg.h
Normal file
@@ -0,0 +1,304 @@
|
||||
#ifndef GPIO_CFG_H_
|
||||
#define GPIO_CFG_H_
|
||||
#include "base/define.h"
|
||||
|
||||
//具体实现思想,参考<<CM3权威指南>>第五章(87页~92页).
|
||||
//IO口操作宏定义
|
||||
#define BITBAND(addr, bitnum) ((addr & 0xF0000000)+0x2000000+((addr &0xFFFFF)<<5)+(bitnum<<2))
|
||||
#define MEM_ADDR_(addr) *((volatile unsigned long *)(addr))
|
||||
#define BIT_ADDR_(addr, bitnum) MEM_ADDR_(BITBAND(addr, bitnum))
|
||||
//IO口地址映射
|
||||
#define GPIOA_ODR_Addr (GPIOA_BASE+12) //0x4001080C
|
||||
#define GPIOB_ODR_Addr (GPIOB_BASE+12) //0x40010C0C
|
||||
#define GPIOC_ODR_Addr (GPIOC_BASE+12) //0x4001100C
|
||||
#define GPIOD_ODR_Addr (GPIOD_BASE+12) //0x4001140C
|
||||
#define GPIOE_ODR_Addr (GPIOE_BASE+12) //0x4001180C
|
||||
#define GPIOF_ODR_Addr (GPIOF_BASE+12) //0x40011A0C
|
||||
#define GPIOG_ODR_Addr (GPIOG_BASE+12) //0x40011E0C
|
||||
|
||||
#define GPIOA_IDR_Addr (GPIOA_BASE+8) //0x40010808
|
||||
#define GPIOB_IDR_Addr (GPIOB_BASE+8) //0x40010C08
|
||||
#define GPIOC_IDR_Addr (GPIOC_BASE+8) //0x40011008
|
||||
#define GPIOD_IDR_Addr (GPIOD_BASE+8) //0x40011408
|
||||
#define GPIOE_IDR_Addr (GPIOE_BASE+8) //0x40011808
|
||||
#define GPIOF_IDR_Addr (GPIOF_BASE+8) //0x40011A08
|
||||
#define GPIOG_IDR_Addr (GPIOG_BASE+8) //0x40011E08
|
||||
|
||||
//IO口操作,只对单一的IO口!
|
||||
//确保n的值小于16!
|
||||
#define PAout(n) BIT_ADDR_(GPIOA_ODR_Addr,n) //输出
|
||||
#define PAin(n) BIT_ADDR_(GPIOA_IDR_Addr,n) //输入
|
||||
|
||||
#define PBout(n) BIT_ADDR_(GPIOB_ODR_Addr,n) //输出
|
||||
#define PBin(n) BIT_ADDR_(GPIOB_IDR_Addr,n) //输入
|
||||
|
||||
#define PCout(n) BIT_ADDR_(GPIOC_ODR_Addr,n) //输出
|
||||
#define PCin(n) BIT_ADDR_(GPIOC_IDR_Addr,n) //输入
|
||||
|
||||
#define PDout(n) BIT_ADDR_(GPIOD_ODR_Addr,n) //输出
|
||||
#define PDin(n) BIT_ADDR_(GPIOD_IDR_Addr,n) //输入
|
||||
|
||||
#define PEout(n) BIT_ADDR_(GPIOE_ODR_Addr,n) //输出
|
||||
#define PEin(n) BIT_ADDR_(GPIOE_IDR_Addr,n) //输入
|
||||
|
||||
#define PFout(n) BIT_ADDR_(GPIOF_ODR_Addr,n) //输出
|
||||
#define PFin(n) BIT_ADDR_(GPIOF_IDR_Addr,n) //输入
|
||||
|
||||
#define PGout(n) BIT_ADDR_(GPIOG_ODR_Addr,n) //输出
|
||||
#define PGin(n) BIT_ADDR_(GPIOG_IDR_Addr,n) //输入
|
||||
|
||||
#define VCC_2V5_Pin GPIO_Pin_1
|
||||
#define VCC_2V5_Pin_Nu 1
|
||||
#define VCC_2V5_GPIO_Port GPIOA
|
||||
|
||||
#define R_AD_01_Pin GPIO_Pin_3
|
||||
#define R_AD_01_Nu 3
|
||||
#define R_AD_01_Port GPIOA
|
||||
|
||||
#define VCC_1V25_Pin GPIO_Pin_3
|
||||
#define VCC_1V25_Pin_Nu 3
|
||||
#define VCC_1V25_GPIO_Port GPIOA
|
||||
|
||||
|
||||
#define C_H_DAC_Pin GPIO_Pin_4
|
||||
#define C_H_DAC_Pin_Nu 4
|
||||
#define C_H_DAC_GPIO_Port GPIOA
|
||||
|
||||
#define C_M_DAC_Pin GPIO_Pin_5
|
||||
#define C_M_DAC_Pin_Nu 5
|
||||
#define C_M_DAC_GPIO_Port GPIOA
|
||||
|
||||
#define V_LA_M_Pin GPIO_Pin_6
|
||||
#define V_LA_M_Pin_Nu 6
|
||||
#define V_LA_M_GPIO_Port GPIOA
|
||||
|
||||
#define V_LA_H_Pin GPIO_Pin_7
|
||||
#define V_LA_H_Pin_Nu 7
|
||||
#define V_LA_H_GPIO_Port GPIOA
|
||||
|
||||
#define LAVC_M_Pin GPIO_Pin_8
|
||||
#define LAVC_M_Pin_Nu 8
|
||||
#define LAVC_M_GPIO_Port GPIOA
|
||||
|
||||
#define USART1_TX_Pin GPIO_Pin_9
|
||||
#define USART1_TX_Pin_Nu 9
|
||||
#define USART1_TX_GPIO_Port GPIOA
|
||||
|
||||
#define USART1_RX_Pin GPIO_Pin_10
|
||||
#define USART1_RX_Pin_Nu 10
|
||||
#define USART1_RX_GPIO_Port GPIOA
|
||||
|
||||
#define CAN1_RX_Pin GPIO_Pin_10
|
||||
#define CAN1_RX_Pin_Nu 11
|
||||
#define CAN1_RX_GPIO_Port GPIOA
|
||||
|
||||
#define CAN1_TX_Pin GPIO_Pin_11
|
||||
#define CAN1_TX_Pin_Nu 12
|
||||
#define CAN1_TX_GPIO_Port GPIOA
|
||||
|
||||
#define SEG0_Pin GPIO_Pin_15
|
||||
#define SEG0_Pin_Nu 15
|
||||
#define SEG0_GPIO_Port GPIOA
|
||||
|
||||
|
||||
#define R10_ON_Pin GPIO_Pin_0
|
||||
#define R10_ON_Pin_Nu 0
|
||||
#define R10_ON_GPIO_Port GPIOB
|
||||
|
||||
|
||||
#define R510_ON_Pin GPIO_Pin_1
|
||||
#define R510_ON_Pin_Nu 1
|
||||
#define R510_ON_GPIO_Port GPIOB
|
||||
|
||||
#define LED1_Pin GPIO_Pin_2
|
||||
#define LED1_Pin_Nu 2
|
||||
#define LED1_GPIO_Port GPIOB
|
||||
|
||||
#define IO_CAP_AD_Pin GPIO_Pin_5
|
||||
#define IO_CAP_AD_Pin_Nu 5
|
||||
#define IO_CAP_AD_Port GPIOB
|
||||
|
||||
#define FIRE_TEST_Pin GPIO_Pin_8
|
||||
#define FIRE_TEST_Pin_Nu 8
|
||||
#define FIRE_TEST_Port GPIOB
|
||||
|
||||
#define IO_APD12_Pin GPIO_Pin_9
|
||||
#define IO_APD12_Pin_Nu 9
|
||||
#define IO_APD12_GPIO_Port GPIOB
|
||||
|
||||
#define I2IC_SCL_Pin GPIO_Pin_10
|
||||
#define I2IC_SCL_Pin_Nu 10
|
||||
#define I2IC_SCL_GPIO_Port GPIOB
|
||||
|
||||
#define I2IC_SDA_Pin GPIO_Pin_11
|
||||
#define I2IC_SDA_Pin_Nu 11
|
||||
#define I2IC_SDA_GPIO_Port GPIOB
|
||||
|
||||
|
||||
#define LED2_Pin GPIO_Pin_12
|
||||
#define LED2_Pin_Nu 12
|
||||
#define LED2_GPIO_Port GPIOB
|
||||
|
||||
#define OUTAL_Pin GPIO_Pin_13
|
||||
#define OUTAL_Pin_Nu 13
|
||||
#define OUTAL_GPIO_Port GPIOB
|
||||
|
||||
#define OUTBL_Pin GPIO_Pin_14
|
||||
#define OUTBL_Pin_Nu 14
|
||||
#define OUTBL_GPIO_Port GPIOB
|
||||
|
||||
#define OUTAH_Pin GPIO_Pin_15
|
||||
#define OUTAH_Pin_Nu 15
|
||||
#define OUTAH_GPIO_Port GPIOB
|
||||
|
||||
|
||||
#define AD_OUTA_Pin GPIO_Pin_0
|
||||
#define AD_OUTA_Pin_Nu 0
|
||||
#define AD_OUTA_Port GPIOC
|
||||
|
||||
#define AD_OUTB_Pin GPIO_Pin_1
|
||||
#define AD_OUTB_Pin_Nu 1
|
||||
#define AD_OUTB_Port GPIOC
|
||||
|
||||
#define AN_UA_Pin GPIO_Pin_2
|
||||
#define AN_UA_Pin_Nu 2
|
||||
#define AN_UA_Port GPIOC
|
||||
|
||||
#define AN_MAL_Pin GPIO_Pin_3
|
||||
#define AN_MAL_Pin_Nu 3
|
||||
#define AN_MAL_Port GPIOC
|
||||
|
||||
#define R100_ON_Pin GPIO_Pin_4
|
||||
#define R100_ON_Pin_Nu 4
|
||||
#define R100_ON_GPIO_Port GPIOC
|
||||
|
||||
#define AN_CAP_AD_Pin GPIO_Pin_5
|
||||
#define AN_CAP_AD_Pin_Nu 5
|
||||
#define AN_CAP_AD_Port GPIOC
|
||||
|
||||
#define OUTBH_Pin GPIO_Pin_6
|
||||
#define OUTBH_Pin_Nu 6
|
||||
#define OUTBH_GPIO_Port GPIOC
|
||||
|
||||
#define POWER_ON_Pin GPIO_Pin_7
|
||||
#define POWER_ON_Pin_Nu 7
|
||||
#define POWER_ON_GPIO_Port GPIOC
|
||||
|
||||
#define SEG4_Pin GPIO_Pin_8
|
||||
#define SEG4_Pin_Nu 8
|
||||
#define SEG4_GPIO_Port GPIOC
|
||||
|
||||
#define SEG3_Pin GPIO_Pin_9
|
||||
#define SEG3_Pin_Nu 9
|
||||
#define SEG3_GPIO_Port GPIOC
|
||||
|
||||
#define SEG1_Pin GPIO_Pin_10
|
||||
#define SEG1_Pin_Nu 10
|
||||
#define SEG1_GPIO_Port GPIOC
|
||||
|
||||
#define SEG2_Pin GPIO_Pin_11
|
||||
#define SEG2_Pin_Nu 11
|
||||
#define SEG2_GPIO_Port GPIOC
|
||||
|
||||
#define U3_TXD_Pin GPIO_Pin_10
|
||||
#define U3_TXD_Pin_Nu 10
|
||||
#define U3_TXD_GPIO_Port GPIOC
|
||||
|
||||
#define U3_RXD_Pin GPIO_Pin_11
|
||||
#define U3_RXD_Pin_Nu 11
|
||||
#define U3_RXD_GPIO_Port GPIOC
|
||||
|
||||
#define IO_APD22_Pin GPIO_Pin_13
|
||||
#define IO_APD22_Pin_Nu 13
|
||||
#define IO_APD22_GPIO_Port GPIOC
|
||||
|
||||
|
||||
#define IO_APD21_Pin GPIO_Pin_14
|
||||
#define IO_APD21_Pin_Nu 14
|
||||
#define IO_APD21_GPIO_Port GPIOC
|
||||
|
||||
#define IO_APD11_Pin GPIO_Pin_15
|
||||
#define IO_APD11_Pin_Nu 15
|
||||
#define IO_APD11_GPIO_Port GPIOC
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define LED2_Out PBout(LED2_Pin_Nu)
|
||||
#define LED1_Out PBout(LED1_Pin_Nu)
|
||||
#define LED1_Out_On PBout(LED1_Pin_Nu)=0
|
||||
#define LED1_Out_Off PBout(LED1_Pin_Nu)=1
|
||||
|
||||
//电源开关
|
||||
|
||||
#define POWER_ON {PCout(POWER_ON_Pin_Nu) = 1;}
|
||||
#define POWER_OFF {PCout(POWER_ON_Pin_Nu) = 0;}
|
||||
|
||||
//桥驱动
|
||||
#define HMOS_SWITCH_W_1 {PAout(LAVC_M_Pin_Nu)=0; PCout(OUTBH_Pin_Nu)=0;PBout(OUTAL_Pin_Nu)=0; delay_nop(50); PBout(OUTBL_Pin_Nu)=1;PBout(OUTAH_Pin_Nu)=1;}
|
||||
#define HMOS_SWITCH_W_0 {PAout(LAVC_M_Pin_Nu)=0; PBout(OUTBL_Pin_Nu)=0;PBout(OUTAH_Pin_Nu)=0; delay_nop(50); PBout(OUTAL_Pin_Nu)=1;PCout(OUTBH_Pin_Nu)=1;}
|
||||
|
||||
#define HMOS_SWITCH_RW_1 {PCout(OUTBH_Pin_Nu)=0;PBout(OUTAL_Pin_Nu)=0; delay_nop(50); PBout(OUTBL_Pin_Nu)=1;PBout(OUTAH_Pin_Nu)=1;PAout(LAVC_M_Pin_Nu)=1;}
|
||||
#define HMOS_SWITCH_RW_0 {PAout(LAVC_M_Pin_Nu)=0; PBout(OUTBL_Pin_Nu)=0;PBout(OUTAH_Pin_Nu)=0; delay_nop(50); PBout(OUTAL_Pin_Nu)=1;PCout(OUTBH_Pin_Nu)=1;}
|
||||
|
||||
#define HMOS_SWITCH_GND {PCout(OUTBH_Pin_Nu)=0; PAout(LAVC_M_Pin_Nu)=0;PBout(OUTAH_Pin_Nu)=0;delay_nop(50);PBout(OUTBL_Pin_Nu)=1;PBout(OUTAL_Pin_Nu)=1;}
|
||||
#define HMOS_SWITCH_OFF {PCout(OUTBH_Pin_Nu)=0; PAout(LAVC_M_Pin_Nu)=0;PBout(OUTAH_Pin_Nu)=0;delay_nop(50);PBout(OUTBL_Pin_Nu)=0;PBout(OUTAL_Pin_Nu)=0;}
|
||||
#define HMOS_FAST_DISCHG {PCout(POWER_ON_Pin_Nu) = 0; PCout(OUTBH_Pin_Nu)=0; PAout(LAVC_M_Pin_Nu)=0;PBout(OUTBL_Pin_Nu)=0;delay_nop(50);PBout(OUTAH_Pin_Nu)=1;PBout(OUTAL_Pin_Nu)=1;}
|
||||
#define HMOS_SWITCH_ON {PAout(LAVC_M_Pin_Nu)=0;PCout(OUTBH_Pin_Nu)=0; PBout(OUTAL_Pin_Nu)=0;delay_nop(50);PBout(OUTBL_Pin_Nu)=1;PBout(OUTAH_Pin_Nu)=1;}
|
||||
|
||||
//芯跳桥驱动
|
||||
#define XTBus_POWER_Out HMOS_SWITCH_W_1//总线模式开关
|
||||
#define XTBUS_ON HMOS_SWITCH_ON
|
||||
#define XTBUS_OFF HMOS_SWITCH_OFF
|
||||
#define XTBUS_W_1 HMOS_SWITCH_W_1
|
||||
#define XTBUS_W_0 HMOS_SWITCH_W_0
|
||||
#define XTBUS_WR_1 HMOS_SWITCH_W_1
|
||||
#define XTBUS_WR_0 HMOS_SWITCH_W_0
|
||||
|
||||
//JQ 桥驱动
|
||||
|
||||
#define JQBus_POWER_Out HMOS_SWITCH_W_1 //总线模式开关
|
||||
#define JQBUS_ON HMOS_SWITCH_ON
|
||||
#define JQBUS_OFF HMOS_SWITCH_OFF
|
||||
#define JQBUS_W_1 HMOS_SWITCH_W_1
|
||||
#define JQBUS_W_0 HMOS_SWITCH_W_0
|
||||
|
||||
//EW 桥驱动
|
||||
#define EW_SINGLE_MOD_M {PCout(OUTBH_Pin_Nu)=0;PBout(OUTAL_Pin_Nu)=0;PBout(OUTAH_Pin_Nu)=0; delay_nop(50); PBout(OUTBL_Pin_Nu)=1;PAout(LAVC_M_Pin_Nu)=1;}
|
||||
#define EW_SINGLE_MOD_H HMOS_SWITCH_W_1
|
||||
|
||||
#define EW_DIFF_MOD_M {PCout(OUTBH_Pin_Nu)=0;PBout(OUTAL_Pin_Nu)=0;PBout(OUTAH_Pin_Nu)=0; delay_nop(50); PBout(OUTBL_Pin_Nu)=1;PAout(LAVC_M_Pin_Nu)=1;}
|
||||
#define EW_DIFF_MOD_H HMOS_SWITCH_W_1
|
||||
#define EW_DIFF_MOD_L HMOS_SWITCH_W_0
|
||||
#define EW_BUS_OFF HMOS_SWITCH_OFF
|
||||
|
||||
|
||||
void CtrlGpio_DefInit(void);
|
||||
/*
|
||||
@brief 获取设备地址
|
||||
@param 无
|
||||
@rtv 设备地址
|
||||
*/
|
||||
uint8_t Gpio_GetDeivceAddr(void);
|
||||
|
||||
/*
|
||||
@brief 4限制电阻测量通道切换
|
||||
@param 0 全关
|
||||
1 通道1-4通,过桥丝
|
||||
2 通道2-3通,过桥丝
|
||||
3 通道1-3通,测阻抗
|
||||
4 通道2-4通,测阻抗
|
||||
*/
|
||||
void Gpio_ResistorSwitch(uint8_t uc_r);
|
||||
/*
|
||||
@brief 测量电容电压压降GPIO配置
|
||||
*/
|
||||
void Gpio_CAPSwitch(uint8_t uc_sw);
|
||||
#endif
|
||||
|
89
source/elec_det/hardware/hardware.c
Normal file
89
source/elec_det/hardware/hardware.c
Normal file
@@ -0,0 +1,89 @@
|
||||
#include "base/define.h"
|
||||
#include "gpio_cfg.h"
|
||||
#include "adc_cfg.h"
|
||||
//#include "usartapp.h"
|
||||
//#include "console_usart.h"
|
||||
#include "base/delay.h"
|
||||
#include "power.h"
|
||||
//#include "database.h"
|
||||
#include "timer_cfg.h"
|
||||
#include "base/utility.h"
|
||||
//#include "yecan.h"
|
||||
#include "hardware/jw3425iic.h"
|
||||
BoartCheck_st board_st;
|
||||
BoardInfo_un boardinfo_un;
|
||||
|
||||
void test_timer_function()
|
||||
{
|
||||
static uint8_t flag_ = 0;
|
||||
LED1_Out = flag_;
|
||||
flag_ ^= 0x01;
|
||||
}
|
||||
|
||||
//检测小板初始化
|
||||
void Ye_BoardInit(void)
|
||||
{
|
||||
|
||||
AdcDef_Init();
|
||||
DAC_Definit();
|
||||
// ConsoleUsart_Init();
|
||||
// YeCanInit();
|
||||
CtrlGpio_DefInit();
|
||||
DelayTimer_Init();
|
||||
TimerCount_Init();
|
||||
CurrentSampleR_Def
|
||||
I2C_init();
|
||||
delay_ms(500);
|
||||
|
||||
}
|
||||
/*
|
||||
测试小板上电自检
|
||||
*/
|
||||
void Ye_BoardCheck(void)
|
||||
{
|
||||
uint16_t aus_buf[AD_SCAN_COUNT];
|
||||
board_st.app_run_flag = 1;
|
||||
board_st.device_id = Gpio_GetDeivceAddr();
|
||||
board_st.chip_temp = (uint16_t)(Get_Temperature()*10);
|
||||
board_st.soft_v = SoftVersion;
|
||||
board_st.hard_v = boardinfo_un.boardinfo.hard_v;
|
||||
board_st.resistor_diff = boardinfo_un.boardinfo.resistor_diff;
|
||||
board_st.plan_id = *((uint32_t*)APP_TEST_PLAN_ADDR);
|
||||
|
||||
|
||||
GetADC1_Value(VCC_1V25_CH,aus_buf,AD_SCAN_COUNT);
|
||||
Bubble_Sort_u16(aus_buf,AD_SCAN_COUNT);
|
||||
board_st.v1p25_adc = aus_buf[AD_SCAN_COUNT>>1];
|
||||
|
||||
GetADC1_Value(VCC_2V5_CH,aus_buf,AD_SCAN_COUNT);
|
||||
Bubble_Sort_u16(aus_buf,AD_SCAN_COUNT);
|
||||
board_st.v2p5_adc = aus_buf[AD_SCAN_COUNT>>1];
|
||||
|
||||
GetADC1_Value(ADC_Channel_16,aus_buf,AD_SCAN_COUNT);
|
||||
Bubble_Sort_u16(aus_buf,AD_SCAN_COUNT);
|
||||
board_st.adc_shake = aus_buf[AD_SCAN_COUNT-1] - aus_buf[0];
|
||||
|
||||
|
||||
LED1_Out = 1;
|
||||
if(0 != PowerCalPrapare())
|
||||
{
|
||||
board_st.v1p25_adc = 0;
|
||||
LED1_Out = 0;
|
||||
}
|
||||
PowerCalibration_set(POWER_DEF_V,45);
|
||||
delay_ms(100);
|
||||
board_st.bus_5p5v = Power_GetHPowerV();
|
||||
//
|
||||
#ifdef CHECKER_DEV
|
||||
PowerCalibration_set(260,50);
|
||||
delay_ms(100);
|
||||
#else
|
||||
PowerCalibration_set(90,45);
|
||||
#endif
|
||||
board_st.bus_26v = Power_GetHPowerV();
|
||||
//
|
||||
PowerCalibration_set(POWER_DEF_V,45);
|
||||
|
||||
|
||||
}
|
||||
|
731
source/elec_det/hardware/jw3425iic.c
Normal file
731
source/elec_det/hardware/jw3425iic.c
Normal file
@@ -0,0 +1,731 @@
|
||||
#include "jw3425iic.h"
|
||||
#include "gpio_cfg.h"
|
||||
#include "base/delay.h"
|
||||
#include "interface/basechecker.h"
|
||||
#include "base/utility.h"
|
||||
|
||||
|
||||
|
||||
void IIC_SDA_DIR(uint8_t dir)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
if(dir == 0)
|
||||
{
|
||||
|
||||
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
|
||||
|
||||
}else{
|
||||
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU;
|
||||
}
|
||||
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_Pin= I2IC_SDA_Pin;
|
||||
GPIO_Init(GPIOB,&GPIO_InitStructure);
|
||||
}
|
||||
|
||||
void I2C_init(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
/* enable GPIOB clock */
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
|
||||
//GPIO 配置
|
||||
GPIO_InitStructure.GPIO_Pin=I2IC_SCL_Pin | I2IC_SDA_Pin;
|
||||
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
|
||||
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
||||
GPIO_Init(GPIOB,&GPIO_InitStructure);
|
||||
IIC_SDA(1);
|
||||
IIC_SCL(1);
|
||||
}
|
||||
void I2C_Definit(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
/* enable GPIOB clock */
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
|
||||
//GPIO 配置
|
||||
GPIO_InitStructure.GPIO_Pin=I2IC_SCL_Pin | I2IC_SDA_Pin;
|
||||
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING;
|
||||
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
||||
GPIO_Init(GPIOB,&GPIO_InitStructure);
|
||||
}
|
||||
//产生IIC起始信号
|
||||
void IIC_Start(void)
|
||||
{
|
||||
SDA_OUT(); //sda线输出
|
||||
IIC_SDA(1);
|
||||
IIC_SCL(1);
|
||||
delay_us(IIC_PLUS_DELAY);
|
||||
IIC_SDA(0);//START:when CLK is high,DATA change form high to low
|
||||
delay_us(IIC_PLUS_DELAY);
|
||||
IIC_SCL(0);//钳住I2C总线,准备发送或接收数据
|
||||
}
|
||||
//产生IIC停止信号
|
||||
void IIC_Stop(void)
|
||||
{
|
||||
SDA_OUT();//sda线输出
|
||||
IIC_SCL(0);
|
||||
IIC_SDA(0);//STOP:when CLK is high DATA change form low to high
|
||||
delay_us(IIC_PLUS_DELAY);
|
||||
IIC_SCL(1);
|
||||
delay_us(IIC_PLUS_DELAY);
|
||||
IIC_SDA(1);//发送I2C总线结束信号
|
||||
}
|
||||
|
||||
//等待应答信号到来
|
||||
//返回值:1,接收应答失败
|
||||
// 0,接收应答成功
|
||||
uint8_t IIC_Wait_Ack(void)
|
||||
{
|
||||
uint32_t ucErrTime=0;
|
||||
SDA_IN(); //SDA设置为输入
|
||||
IIC_SDA(1);
|
||||
delay_us(1);
|
||||
IIC_SCL(1);
|
||||
delay_us(IIC_PLUS_DELAY>>1);
|
||||
while(READ_SDA)
|
||||
{
|
||||
ucErrTime++;
|
||||
if(ucErrTime>I2C_OPERATION_OUTTIME)
|
||||
{
|
||||
IIC_Stop();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
IIC_SCL(0);//时钟输出0
|
||||
return 0;
|
||||
}
|
||||
//产生ACK应答
|
||||
void IIC_Ack(void)
|
||||
{
|
||||
IIC_SCL(0);
|
||||
SDA_OUT();
|
||||
IIC_SDA(0);
|
||||
delay_us(IIC_PLUS_DELAY);
|
||||
IIC_SCL(1);
|
||||
delay_us(IIC_PLUS_DELAY);
|
||||
IIC_SCL(0);
|
||||
}
|
||||
//不产生ACK应答
|
||||
void IIC_NAck(void)
|
||||
{
|
||||
IIC_SCL(0);
|
||||
SDA_OUT();
|
||||
IIC_SDA(1);
|
||||
delay_us(IIC_PLUS_DELAY);
|
||||
IIC_SCL(1);
|
||||
delay_us(IIC_PLUS_DELAY);
|
||||
IIC_SCL(0);
|
||||
}
|
||||
//IIC发送一个字节
|
||||
//返回从机有无应答
|
||||
//0,有应答
|
||||
//1,无应答
|
||||
uint8_t IIC_Send_Byte(uint8_t txd)
|
||||
{
|
||||
uint8_t t;
|
||||
SDA_OUT();
|
||||
for(t=0;t<8;t++)
|
||||
{
|
||||
IIC_SCL(0);//拉低时钟开始数据传输
|
||||
delay_us(IIC_PLUS_DELAY>>1);
|
||||
IIC_SDA((txd&0x80)>>7);
|
||||
txd<<=1;
|
||||
delay_us(IIC_PLUS_DELAY>>1);
|
||||
IIC_SCL(1);
|
||||
delay_us(IIC_PLUS_DELAY);
|
||||
}
|
||||
IIC_SCL(0);
|
||||
delay_us(IIC_PLUS_DELAY >>1);
|
||||
|
||||
return IIC_Wait_Ack();
|
||||
}
|
||||
|
||||
//读1个字节,ack=1时,发送ACK,ack=0,发送nACK
|
||||
uint8_t IIC_Read_Byte(unsigned char ack)
|
||||
{
|
||||
unsigned char i,receive=0;
|
||||
SDA_IN();//SDA设置为输入
|
||||
for(i=0;i<8;i++ )
|
||||
{
|
||||
IIC_SCL(0);
|
||||
delay_us(IIC_PLUS_DELAY);
|
||||
IIC_SCL(1);
|
||||
delay_us(IIC_PLUS_DELAY>>1);
|
||||
receive<<=1;
|
||||
if(READ_SDA)receive++;
|
||||
delay_us(IIC_PLUS_DELAY >> 1);
|
||||
}
|
||||
if (!ack)
|
||||
IIC_NAck();//发送nACK
|
||||
else
|
||||
IIC_Ack(); //发送ACK
|
||||
return receive;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* @param bi_dir: option using in transceive */
|
||||
int32_t I2C_master_write(uint16_t address, uint8_t *src, uint32_t size, uint32_t *nwriten, uint8_t bi_dir)
|
||||
{
|
||||
uint32_t timeout = 0;
|
||||
uint8_t ack = 0;
|
||||
*nwriten = 0;
|
||||
__disable_irq();
|
||||
IIC_Start();
|
||||
//发送地址
|
||||
ack = IIC_Send_Byte(( address<<1));
|
||||
if(ack)
|
||||
{
|
||||
goto iic_send_stop;
|
||||
}
|
||||
while (*nwriten < size) {
|
||||
ack = IIC_Send_Byte(src[*nwriten]);
|
||||
if(ack)
|
||||
{
|
||||
break;
|
||||
}
|
||||
(*nwriten)++;
|
||||
}
|
||||
|
||||
iic_send_stop:
|
||||
if(bi_dir ==0)//bi_dir == 1时不发送停止信号
|
||||
{
|
||||
IIC_Stop();
|
||||
}
|
||||
__enable_irq();
|
||||
return ack;
|
||||
}
|
||||
|
||||
/* @param bi_dir: option using in transceive */
|
||||
int32_t I2C_master_read(uint16_t address, uint8_t *dst, uint32_t size, uint32_t *nread, uint8_t bi_dir)
|
||||
{
|
||||
uint32_t i;
|
||||
*nread = 0;
|
||||
uint8_t ack = 0;
|
||||
if (size == 0)
|
||||
return 0;
|
||||
__disable_irq();
|
||||
IIC_Start();//重新发送起始信号
|
||||
ack = IIC_Send_Byte(( address << 1) | 0x01);//发送读命令地址
|
||||
if(ack)
|
||||
goto send_stop_err;
|
||||
while(*nread < size)
|
||||
{
|
||||
if((*nread) == (size-1))//倒数1个字节,设置不应答
|
||||
{
|
||||
dst[*nread] = IIC_Read_Byte(0);
|
||||
}else{
|
||||
dst[*nread] = IIC_Read_Byte(1);
|
||||
}
|
||||
(*nread)++;
|
||||
}
|
||||
send_stop_err:
|
||||
// If receive NACK or no data to write, send STOP
|
||||
if (bi_dir == 0)
|
||||
IIC_Stop();
|
||||
__enable_irq();
|
||||
return ack;
|
||||
}
|
||||
|
||||
|
||||
/* @param bi_dir: option using in transceive */
|
||||
int32_t I2C_master_write_read(uint16_t address, uint8_t*cmd, uint8_t cmd_size,uint8_t *dst, uint32_t read_size, uint32_t *nread)
|
||||
{
|
||||
uint32_t ul_writen;
|
||||
*nread = 0;
|
||||
|
||||
if (read_size == 0)
|
||||
return 0;
|
||||
I2C_master_write(address,cmd,cmd_size,&ul_writen,1);
|
||||
if(ul_writen != cmd_size)
|
||||
{
|
||||
IIC_Stop();
|
||||
return 1;
|
||||
}
|
||||
I2C_master_read(address, dst, read_size, nread, 1);
|
||||
IIC_Stop();
|
||||
if(read_size != *nread)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t I2C_master_writeCode(uint16_t address, uint8_t *cmd_src, uint32_t cmd_len,const uint8_t* puc_cod,uint32_t code_len )
|
||||
{
|
||||
uint8_t uc_code;
|
||||
uint8_t ack = 0;
|
||||
__disable_irq();
|
||||
IIC_Start();
|
||||
//发送地址
|
||||
ack = IIC_Send_Byte(( address<<1));
|
||||
if(ack)
|
||||
{
|
||||
IIC_Stop();
|
||||
__enable_irq();
|
||||
return ack;
|
||||
}
|
||||
//发送命令
|
||||
while (cmd_len > 0) {
|
||||
ack = IIC_Send_Byte(*cmd_src);
|
||||
if(ack)
|
||||
{
|
||||
IIC_Stop();
|
||||
__enable_irq();
|
||||
return ack;
|
||||
}
|
||||
cmd_src++;
|
||||
cmd_len--;
|
||||
}
|
||||
//发送代码数据
|
||||
while (code_len > 0) {
|
||||
uc_code = *puc_cod;
|
||||
ack = IIC_Send_Byte(uc_code);
|
||||
if(ack)
|
||||
{
|
||||
IIC_Stop();
|
||||
__enable_irq();
|
||||
return ack;
|
||||
}
|
||||
puc_cod++;
|
||||
code_len--;
|
||||
}
|
||||
IIC_Stop();
|
||||
__enable_irq();
|
||||
return ack;
|
||||
}
|
||||
|
||||
|
||||
int32_t I2C_master_CodeEquel(uint16_t address, uint8_t *cmd_src, uint32_t cmd_len,const uint8_t* puc_cod,uint32_t code_len )
|
||||
{
|
||||
uint8_t uc_code;
|
||||
uint8_t uc_rdata;
|
||||
uint8_t ack = 0;
|
||||
__disable_irq();
|
||||
IIC_Start();
|
||||
//发送地址
|
||||
ack = IIC_Send_Byte(( address<<1));
|
||||
if(ack)
|
||||
{
|
||||
IIC_Stop();
|
||||
__enable_irq();
|
||||
return ack;
|
||||
}
|
||||
//发送命令
|
||||
while (cmd_len > 0) {
|
||||
ack = IIC_Send_Byte(*cmd_src);
|
||||
if(ack)
|
||||
{
|
||||
IIC_Stop();
|
||||
__enable_irq();
|
||||
return ack;
|
||||
}
|
||||
cmd_src++;
|
||||
cmd_len--;
|
||||
}
|
||||
IIC_Start();//重新发送起始信号
|
||||
ack = IIC_Send_Byte(( address << 1) | 0x01);//发送读命令地址
|
||||
if(ack)
|
||||
{
|
||||
IIC_Stop();
|
||||
__enable_irq();
|
||||
return ack;
|
||||
}
|
||||
while(code_len > 0)
|
||||
{
|
||||
uc_code = *puc_cod;
|
||||
puc_cod++;
|
||||
if(code_len == 1)//倒数1个字节,设置不应答
|
||||
{
|
||||
uc_rdata = IIC_Read_Byte(0);
|
||||
}else{
|
||||
uc_rdata = IIC_Read_Byte(1);
|
||||
}
|
||||
if(uc_code != uc_rdata)
|
||||
{
|
||||
ack = 1;
|
||||
break;
|
||||
}
|
||||
code_len--;
|
||||
}
|
||||
IIC_Stop();
|
||||
__enable_irq();
|
||||
return ack;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/******************IIC trim **********************/
|
||||
#define SLAVE_IIC_ADDR_ 0x18
|
||||
/*
|
||||
@brief Vref电压校准
|
||||
@param0 0不更新,1更新
|
||||
@param1 校准值
|
||||
*/
|
||||
void MC_VrefTrim(void)
|
||||
{
|
||||
uint8_t auc_cmd[]={0x10,0xEF,0x00};
|
||||
uint8_t auc_run_cmd[]={0x18,0xE7};
|
||||
uint32_t ul_sendlen = 0;
|
||||
uint8_t uc_ack = 0;
|
||||
auc_cmd[2] = checker_runcfg.params[1] & 0x0F;
|
||||
uc_ack = I2C_master_write(SLAVE_IIC_ADDR_,auc_cmd,sizeof(auc_cmd),&ul_sendlen,0);
|
||||
if(uc_ack != 0 || checker_runcfg.params[0] == 0)
|
||||
{
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
return ;
|
||||
}
|
||||
uc_ack = I2C_master_write(SLAVE_IIC_ADDR_,auc_run_cmd,sizeof(auc_run_cmd),&ul_sendlen,0);
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
}
|
||||
/*
|
||||
@brief Iref电压校准
|
||||
@param0 Iref1 0不更新,1更新
|
||||
@param1 Iref2 0不更新,1更新
|
||||
@param2 Iref1 校准值
|
||||
@param3 Iref2 校准值
|
||||
*/
|
||||
void MC_IrefTrim(void)
|
||||
{
|
||||
uint8_t auc_cmd[]={0x12,0xED,0x00};
|
||||
uint8_t auc_run1_cmd[]={0x19,0xE6};
|
||||
uint8_t auc_run2_cmd[]={0x1A,0xE5};
|
||||
uint32_t ul_sendlen = 0;
|
||||
uint8_t uc_ack = 0;
|
||||
auc_cmd[2] = (checker_runcfg.params[2] & 0x0F) | ((checker_runcfg.params[3] & 0x0F)<<4);
|
||||
uc_ack = I2C_master_write(SLAVE_IIC_ADDR_,auc_cmd,sizeof(auc_cmd),&ul_sendlen,0);
|
||||
if(uc_ack != 0)
|
||||
{
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
return ;
|
||||
}
|
||||
if(checker_runcfg.params[0] != 0)
|
||||
{
|
||||
uc_ack |= I2C_master_write(SLAVE_IIC_ADDR_,auc_run1_cmd,sizeof(auc_run1_cmd),&ul_sendlen,0);
|
||||
}
|
||||
if(checker_runcfg.params[1] != 0)
|
||||
{
|
||||
uc_ack |= I2C_master_write(SLAVE_IIC_ADDR_,auc_run2_cmd,sizeof(auc_run2_cmd),&ul_sendlen,0);
|
||||
}
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@brief Iref1电压校准
|
||||
@param0 0不更新,1更新
|
||||
@param1 校准值
|
||||
*/
|
||||
void MC_RC4MTrim(void)
|
||||
{
|
||||
uint8_t auc_cmd[]={0x14,0xEB,0x00};
|
||||
uint8_t auc_run_cmd[]={0x1B,0xE4};
|
||||
uint32_t ul_sendlen = 0;
|
||||
uint8_t uc_ack = 0;
|
||||
auc_cmd[2] = checker_runcfg.params[1] & 0x3F;
|
||||
uc_ack = I2C_master_write(SLAVE_IIC_ADDR_,auc_cmd,sizeof(auc_cmd),&ul_sendlen,0);
|
||||
if(uc_ack != 0 || checker_runcfg.params[0] == 0)
|
||||
{
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
return ;
|
||||
}
|
||||
uc_ack = I2C_master_write(SLAVE_IIC_ADDR_,auc_run_cmd,sizeof(auc_run_cmd),&ul_sendlen,0);
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
}
|
||||
|
||||
/*
|
||||
@brief RC128K校准
|
||||
@param0 0不更新,1更新
|
||||
@param1 校准值
|
||||
*/
|
||||
void MC_RC128KTrim(void)
|
||||
{
|
||||
uint8_t auc_cmd[]={0x15,0xEA,0x00};
|
||||
uint8_t auc_run_cmd[]={0x1C,0xE3};
|
||||
uint32_t ul_sendlen = 0;
|
||||
uint8_t uc_ack = 0;
|
||||
auc_cmd[2] = checker_runcfg.params[1] & 0x1F;
|
||||
uc_ack = I2C_master_write(SLAVE_IIC_ADDR_,auc_cmd,sizeof(auc_cmd),&ul_sendlen,0);
|
||||
if(uc_ack != 0 || checker_runcfg.params[0] == 0)
|
||||
{
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
return ;
|
||||
}
|
||||
uc_ack = I2C_master_write(SLAVE_IIC_ADDR_,auc_run_cmd,sizeof(auc_run_cmd),&ul_sendlen,0);
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
}
|
||||
|
||||
/*
|
||||
@brief 设置MTP电压
|
||||
@param0 低压
|
||||
@param1 高压
|
||||
*/
|
||||
void MC_SetMTPVol(void)
|
||||
{
|
||||
uint8_t auc_cmd[]={0x22,0xDD,0x00};
|
||||
uint32_t ul_sendlen = 0;
|
||||
uint8_t uc_ack = 0;
|
||||
auc_cmd[2] = (checker_runcfg.params[0] & 0x03) | ((checker_runcfg.params[1] & 0x0F)<<2);
|
||||
uc_ack = I2C_master_write(SLAVE_IIC_ADDR_,auc_cmd,sizeof(auc_cmd),&ul_sendlen,0);
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
}
|
||||
|
||||
/*
|
||||
@brief 设置MTP电压
|
||||
@param0 MTP地址
|
||||
@param1 擦除模式
|
||||
*/
|
||||
void MC_EraseMTP(void)
|
||||
{
|
||||
uint8_t auc_erase_cmd[]={0x00,0x00};
|
||||
uint8_t auc_setAddr_cmd[]={0x23,0xDC,0x00,0x00};
|
||||
uint32_t ul_sendlen = 0;
|
||||
uint8_t uc_ack = 0;
|
||||
auc_setAddr_cmd[2] = (checker_runcfg.params[0]>>8) & 0xFF;
|
||||
auc_setAddr_cmd[3] = checker_runcfg.params[0] & 0xFF;
|
||||
uc_ack = I2C_master_write(SLAVE_IIC_ADDR_,auc_setAddr_cmd,sizeof(auc_setAddr_cmd),&ul_sendlen,0);
|
||||
if(uc_ack != 0)
|
||||
{
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
return;
|
||||
}
|
||||
ul_sendlen = 0;
|
||||
auc_erase_cmd[0] = checker_runcfg.params[1];
|
||||
switch(checker_runcfg.params[1])
|
||||
{
|
||||
case 0x25: auc_erase_cmd[1] = 0xDA; break;//全片擦除
|
||||
case 0x26: auc_erase_cmd[1] = 0xD9; break;//块擦除
|
||||
case 0x27: auc_erase_cmd[1] = 0xD8; break;//页擦除
|
||||
case 0x28: auc_erase_cmd[1] = 0xD7; break;//字擦除
|
||||
}
|
||||
uc_ack = I2C_master_write(SLAVE_IIC_ADDR_,auc_erase_cmd,sizeof(auc_erase_cmd),&ul_sendlen,0);
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@brief MTP写入数据
|
||||
@param0..N 编程数据
|
||||
*/
|
||||
void MC_IICWriteMTP(void)
|
||||
{
|
||||
uint8_t auc_cmd[16]={0x29,0xD6};
|
||||
uint32_t ul_sendlen = 0;
|
||||
uint8_t uc_ack = 0;
|
||||
uint16_t us_index = 0;
|
||||
for(us_index = 0; us_index < checker_runcfg.param_count;us_index++)
|
||||
{
|
||||
auc_cmd[us_index+2] = checker_runcfg.params[us_index];
|
||||
}
|
||||
|
||||
uc_ack = I2C_master_write(SLAVE_IIC_ADDR_,auc_cmd,us_index+2,&ul_sendlen,0);
|
||||
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
}
|
||||
/*
|
||||
@brief MTP读数据
|
||||
@param0 读取MTP地址
|
||||
@param1 读取数据字节长度
|
||||
*/
|
||||
void MC_IICReadMTP(void)
|
||||
{
|
||||
|
||||
uint8_t auc_setAddr_cmd[]={0x23,0xDC,0x00,0x00};
|
||||
uint8_t auc_cmd[]={0x2A,0xD5};
|
||||
uint32_t ul_readlen = 0;
|
||||
uint8_t uc_ack = 0;
|
||||
uint16_t us_buf[32];
|
||||
uint32_t ul_sendlen = 0;
|
||||
auc_setAddr_cmd[2] = (checker_runcfg.params[0]>>8) & 0xFF;
|
||||
auc_setAddr_cmd[3] = checker_runcfg.params[0] & 0xFF;
|
||||
if(checker_runcfg.params[1] > 64)
|
||||
{
|
||||
checker_runcfg.params[1] = 64;
|
||||
}
|
||||
uc_ack = I2C_master_write(SLAVE_IIC_ADDR_,auc_setAddr_cmd,sizeof(auc_setAddr_cmd),&ul_sendlen,0);
|
||||
delay_ms(10);
|
||||
if(uc_ack != 0)
|
||||
{
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
return ;
|
||||
}
|
||||
uc_ack = I2C_master_write_read(SLAVE_IIC_ADDR_,auc_cmd,sizeof(auc_cmd),(uint8_t*)us_buf,checker_runcfg.params[1],&ul_readlen);
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
Checker_SetRtv(us_buf,checker_runcfg.rtv_count);
|
||||
}
|
||||
|
||||
/*
|
||||
@brief MTP状态查询
|
||||
*/
|
||||
void MC_IICCheckMTPState(void)
|
||||
{
|
||||
uint8_t auc_cmd[]={0x30,0xBF};
|
||||
uint32_t ul_readlen = 0;
|
||||
uint8_t uc_ack = 0;
|
||||
uint16_t ul_rtv;
|
||||
uc_ack = I2C_master_write_read(SLAVE_IIC_ADDR_,auc_cmd,sizeof(auc_cmd),(uint8_t*)&ul_rtv,1,&ul_readlen);
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
Checker_SetRtv(&ul_rtv,checker_runcfg.rtv_count);
|
||||
}
|
||||
|
||||
/*
|
||||
@brief MTP使能或失能
|
||||
@param0 0失/1使能
|
||||
*/
|
||||
void MC_IICEnMTP(void)
|
||||
{
|
||||
uint8_t auc_cmd[]={0x20,0x20,0};
|
||||
uint32_t ul_sendlen = 0;
|
||||
uint8_t uc_ack = 0;
|
||||
if(checker_runcfg.params[0] == 0)
|
||||
{
|
||||
auc_cmd[2] = 0x33;
|
||||
}else{
|
||||
auc_cmd[2] = 0xCC;
|
||||
}
|
||||
uc_ack = I2C_master_write(SLAVE_IIC_ADDR_,auc_cmd,sizeof(auc_cmd),&ul_sendlen,0);
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@brief MTP下载程序
|
||||
@param 更新地址
|
||||
@param 烧录长度
|
||||
*/
|
||||
void MC_IICUpdateMTP(void)
|
||||
{
|
||||
uint8_t uc_ack;
|
||||
uint8_t auc_enMTP_cmd[]={0x20,0x20,0xCC};
|
||||
uint8_t auc_setAddr_cmd[]={0x23,0xDC,0x00,0x00};
|
||||
uint8_t auc_setMTPOperReg_cmd[]={0x20,0xDF,0x00};
|
||||
uint8_t auc_earse_cmd[]={0x25,0xDA};
|
||||
uint8_t auc_setMTPVol[]={0x22,0xDD,0x18};//1.5V 5V
|
||||
uint8_t auc_program_cmd[]={0x29,0xD6};
|
||||
uint8_t auc_readCode_cmd[]={0x2A,0xD5};
|
||||
uint32_t ul_sendlen;
|
||||
uint16_t us_programLen = checker_runcfg.params[1];
|
||||
uint8_t* puc_Master_addr = (uint8_t*)(MC_CODE_ADDR + checker_runcfg.params[0]);
|
||||
uint16_t ul_rtv = 0;
|
||||
uint32_t ul_crc32 = 0;
|
||||
|
||||
ul_crc32 = Crc32Calu((uint32_t*)MC_CODE_ADDR,16*1024);
|
||||
if(ul_crc32 != boardinfo_un.boardinfo.mc_ICodeCrc32)
|
||||
{
|
||||
uc_ack = 1;
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
ul_rtv = 1;
|
||||
Checker_SetRtv(&ul_rtv,checker_runcfg.rtv_count);
|
||||
return;
|
||||
}
|
||||
|
||||
if(checker_runcfg.params[0] == 0x1000)
|
||||
{
|
||||
auc_setMTPOperReg_cmd[2] = 0x04;
|
||||
}else{
|
||||
auc_setMTPOperReg_cmd[2] = 0x00;
|
||||
}
|
||||
uc_ack = 0;
|
||||
uc_ack += I2C_master_write(SLAVE_IIC_ADDR_,auc_enMTP_cmd,sizeof(auc_enMTP_cmd),&ul_sendlen,0);
|
||||
delay_ms(5);
|
||||
uc_ack += I2C_master_write(SLAVE_IIC_ADDR_,auc_enMTP_cmd,sizeof(auc_enMTP_cmd),&ul_sendlen,0);
|
||||
delay_ms(5);
|
||||
uc_ack += I2C_master_write(SLAVE_IIC_ADDR_,auc_enMTP_cmd,sizeof(auc_enMTP_cmd),&ul_sendlen,0);
|
||||
delay_ms(5);
|
||||
//设置MTP操作范围
|
||||
if(uc_ack > 2)
|
||||
{
|
||||
uc_ack = 1;
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
ul_rtv = 2;
|
||||
Checker_SetRtv(&ul_rtv,checker_runcfg.rtv_count);
|
||||
return;
|
||||
}
|
||||
|
||||
auc_setAddr_cmd[2] = (checker_runcfg.params[0]>>8) & 0xFF;
|
||||
auc_setAddr_cmd[3] = checker_runcfg.params[0] & 0xFF;
|
||||
uc_ack = I2C_master_write(SLAVE_IIC_ADDR_,auc_setMTPOperReg_cmd,sizeof(auc_setMTPOperReg_cmd),&ul_sendlen,0);
|
||||
//设置MTP操作范围
|
||||
if(uc_ack != 0)
|
||||
{
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
ul_rtv = 3;
|
||||
Checker_SetRtv(&ul_rtv,checker_runcfg.rtv_count);
|
||||
return;
|
||||
}
|
||||
delay_ms(1);
|
||||
//设置MTP电压
|
||||
uc_ack = I2C_master_write(SLAVE_IIC_ADDR_,auc_setMTPVol,sizeof(auc_setMTPVol),&ul_sendlen,0);
|
||||
if(uc_ack != 0)
|
||||
{
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
ul_rtv = 4;
|
||||
Checker_SetRtv(&ul_rtv,checker_runcfg.rtv_count);
|
||||
return;
|
||||
}
|
||||
delay_ms(1);
|
||||
//设置地址
|
||||
uc_ack = I2C_master_write(SLAVE_IIC_ADDR_,auc_setAddr_cmd,sizeof(auc_setAddr_cmd),&ul_sendlen,0);
|
||||
if(uc_ack != 0)
|
||||
{
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
ul_rtv = 5;
|
||||
Checker_SetRtv(&ul_rtv,checker_runcfg.rtv_count);
|
||||
return;
|
||||
}
|
||||
delay_ms(1);
|
||||
//擦除
|
||||
uc_ack = I2C_master_write(SLAVE_IIC_ADDR_,auc_earse_cmd,sizeof(auc_earse_cmd),&ul_sendlen,0);
|
||||
if(uc_ack != 0)
|
||||
{
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
ul_rtv = 6;
|
||||
Checker_SetRtv(&ul_rtv,checker_runcfg.rtv_count);
|
||||
return;
|
||||
}
|
||||
delay_os_ms(200);
|
||||
//设置地址
|
||||
uc_ack = I2C_master_write(SLAVE_IIC_ADDR_,auc_setAddr_cmd,sizeof(auc_setAddr_cmd),&ul_sendlen,0);
|
||||
if(uc_ack != 0)
|
||||
{
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
ul_rtv = 7;
|
||||
Checker_SetRtv(&ul_rtv,checker_runcfg.rtv_count);
|
||||
return;
|
||||
}
|
||||
delay_ms(1);
|
||||
uc_ack = I2C_master_writeCode(SLAVE_IIC_ADDR_,auc_program_cmd,sizeof(auc_program_cmd),puc_Master_addr,us_programLen);
|
||||
if(uc_ack != 0)
|
||||
{
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
ul_rtv = 8;
|
||||
Checker_SetRtv(&ul_rtv,checker_runcfg.rtv_count);
|
||||
return;
|
||||
}
|
||||
delay_ms(20);
|
||||
//设置地址
|
||||
uc_ack = I2C_master_write(SLAVE_IIC_ADDR_,auc_setAddr_cmd,sizeof(auc_setAddr_cmd),&ul_sendlen,0);
|
||||
if(uc_ack != 0)
|
||||
{
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
ul_rtv = 9;
|
||||
Checker_SetRtv(&ul_rtv,checker_runcfg.rtv_count);
|
||||
return;
|
||||
}
|
||||
delay_ms(5);
|
||||
uc_ack = I2C_master_CodeEquel(SLAVE_IIC_ADDR_,auc_readCode_cmd,sizeof(auc_readCode_cmd),puc_Master_addr,us_programLen);
|
||||
if(uc_ack != 0)
|
||||
{
|
||||
Checker_MaskResult(uc_ack,checker_runcfg.task_info.runindex);
|
||||
ul_rtv = 10;
|
||||
Checker_SetRtv(&ul_rtv,checker_runcfg.rtv_count);
|
||||
return;
|
||||
}
|
||||
Checker_MaskResult(0,checker_runcfg.task_info.runindex);
|
||||
ul_rtv = 0;
|
||||
Checker_SetRtv(&ul_rtv,checker_runcfg.rtv_count);
|
||||
return;
|
||||
}
|
87
source/elec_det/hardware/jw3425iic.h
Normal file
87
source/elec_det/hardware/jw3425iic.h
Normal file
@@ -0,0 +1,87 @@
|
||||
#ifndef JW3425IIC_H
|
||||
#define JW3425IIC_H
|
||||
|
||||
#include "base/define.h"
|
||||
#include "gpio_cfg.h"
|
||||
|
||||
#define SDA_IN() IIC_SDA_DIR(1) //PB11输入模式
|
||||
#define SDA_OUT() IIC_SDA_DIR(0)//PB11输出模式
|
||||
#define IIC_SDA(x) PBout(I2IC_SDA_Pin_Nu)=(x)
|
||||
#define IIC_SCL(x) PBout(I2IC_SCL_Pin_Nu)=(x)
|
||||
#define READ_SDA (PBin(I2IC_SDA_Pin_Nu)&0x01)
|
||||
#define IIC_PLUS_DELAY 5
|
||||
#define I2C_OPERATION_OUTTIME 100000
|
||||
|
||||
void I2C_init(void);
|
||||
void I2C_Definit(void);
|
||||
void IIC_SDA_DIR(uint8_t dir);
|
||||
int32_t I2C_master_write(uint16_t address, uint8_t *src, uint32_t size, uint32_t *nwriten, uint8_t bi_dir);
|
||||
/* @param bi_dir: option using in transceive */
|
||||
int32_t I2C_master_read(uint16_t address, uint8_t *dst, uint32_t size, uint32_t *nread, uint8_t bi_dir);
|
||||
/* @param bi_dir: option using in transceive */
|
||||
int32_t I2C_master_write_read(uint16_t address, uint8_t*cmd, uint8_t cmd_size,uint8_t *dst, uint32_t read_size, uint32_t *nread);
|
||||
/*
|
||||
@brief Vref电压校准
|
||||
@param0 0不更新,1更新
|
||||
@param1 校准值
|
||||
*/
|
||||
void MC_VrefTrim(void);
|
||||
/*
|
||||
@brief Iref电压校准
|
||||
@param0 Iref1 0不更新,1更新
|
||||
@param1 Iref2 0不更新,1更新
|
||||
@param2 Iref1 校准值
|
||||
@param3 Iref2 校准值
|
||||
*/
|
||||
void MC_IrefTrim(void);
|
||||
/*
|
||||
@brief Iref1电压校准
|
||||
@param0 0不更新,1更新
|
||||
@param1 校准值
|
||||
*/
|
||||
void MC_RC4MTrim(void);
|
||||
/*
|
||||
@brief RC128K校准
|
||||
@param0 0不更新,1更新
|
||||
@param1 校准值
|
||||
*/
|
||||
void MC_RC128KTrim(void);
|
||||
|
||||
/*
|
||||
@brief 设置MTP电压
|
||||
@param0 低压
|
||||
@param1 高压
|
||||
*/
|
||||
void MC_SetMTPVol(void);
|
||||
/*
|
||||
@brief 设置MTP电压
|
||||
@param0 MTP地址
|
||||
@param1 擦除模式
|
||||
*/
|
||||
void MC_EraseMTP(void);
|
||||
/*
|
||||
@brief MTP写入数据
|
||||
@param0..N 编程数据
|
||||
*/
|
||||
void MC_IICWriteMTP(void);
|
||||
/*
|
||||
@brief MTP读数据
|
||||
@param0 读取数据字节长度
|
||||
*/
|
||||
void MC_IICReadMTP(void);
|
||||
/*
|
||||
@brief MTP状态查询
|
||||
*/
|
||||
void MC_IICCheckMTPState(void);
|
||||
/*
|
||||
@brief MTP下载程序
|
||||
@param 更新地址
|
||||
@param 烧录长度
|
||||
*/
|
||||
void MC_IICUpdateMTP(void);
|
||||
/*
|
||||
@brief MTP使能或失能
|
||||
@param0 0失/1使能
|
||||
*/
|
||||
void MC_IICEnMTP(void);
|
||||
#endif
|
522
source/elec_det/hardware/power.c
Normal file
522
source/elec_det/hardware/power.c
Normal file
@@ -0,0 +1,522 @@
|
||||
#include "power.h"
|
||||
#include "base/utility.h"
|
||||
#include "gpio_cfg.h"
|
||||
#include "base/delay.h"
|
||||
#define PowerCurr_AD_BUF_LEN 40
|
||||
#define POWER_SET_COUNT 20
|
||||
static CurrentSample_Range_eu latest_range = Current_Max;
|
||||
static PowerInfo_st def_power_st;
|
||||
//static uint16_t PowerCurr_AD_buf[PowerCurr_AD_BUF_LEN];
|
||||
static float f_cur_k;
|
||||
static float f_cur_b;
|
||||
static uint8_t uc_power_cal_flag = 0;
|
||||
PowerInfo_st powerinfo_arrayst[POWER_SET_COUNT] ;
|
||||
|
||||
/*
|
||||
@brief 获取内部基准1.2V电压对应的AD
|
||||
*/
|
||||
uint32_t Power_GetBaseVAD()
|
||||
{
|
||||
// y1 = kx1+b y2=kx2+b y1-y2/x1-x2
|
||||
// uint16_t adv_buf[10];
|
||||
// uint32_t temp_v;
|
||||
// GetADC0_Value(ADC_CHANNEL_17,adv_buf,10) ;
|
||||
// Bubble_Sort_u16(adv_buf,10);
|
||||
// return (adv_buf[4]+adv_buf[5]+adv_buf[6]+adv_buf[7])>>2;
|
||||
|
||||
return (uint32_t)(1.2f/3.3f*4096);
|
||||
}
|
||||
|
||||
void Power_CurCalibration()
|
||||
{
|
||||
uint16_t adv_buf[10],adv2v5,adv1v25;
|
||||
uc_power_cal_flag = 1;
|
||||
GetADC1_Value(VCC_2V5_CH,adv_buf,10) ;
|
||||
Bubble_Sort_u16(adv_buf,10);
|
||||
adv2v5 = (adv_buf[4]+adv_buf[5]+adv_buf[6]+adv_buf[7])>>2;
|
||||
|
||||
GetADC1_Value(VCC_1V25_CH,adv_buf,10) ;
|
||||
Bubble_Sort_u16(adv_buf,10);
|
||||
adv1v25 = (adv_buf[4]+adv_buf[5]+adv_buf[6]+adv_buf[7])>>2;
|
||||
|
||||
f_cur_k = 1.245f/((adv2v5 - adv1v25)+1);
|
||||
f_cur_b = 2.49f-f_cur_k*adv2v5;
|
||||
|
||||
|
||||
// GetADC0_Value(VCC_1V25_CH,adv_buf,10) ;
|
||||
// Bubble_Sort_u16(adv_buf,10);
|
||||
// adv1v25 = (adv_buf[4]+adv_buf[5]+adv_buf[6]+adv_buf[7])>>2;
|
||||
//
|
||||
// f_cur_k = 1.25f/((adv2v5 - adv1v25)+1);
|
||||
// f_cur_b = 2.5f-f_cur_k*adv2v5;
|
||||
}
|
||||
/*
|
||||
@brief 将获取的ADC值转换为电压值
|
||||
@param1 ul_adv 采样AD原始值
|
||||
@rtv 返回AD采集到的电压值 扩大1000000倍
|
||||
*/
|
||||
uint32_t Power_ADVGetCalVal_106(uint16_t ul_adv)
|
||||
{
|
||||
if(uc_power_cal_flag == 0)
|
||||
{
|
||||
Power_CurCalibration();
|
||||
}
|
||||
return (uint32_t)((f_cur_k*ul_adv+f_cur_b)*1000000);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@brief 采样高电平电压
|
||||
*/
|
||||
uint32_t Power_GetHPowerV()
|
||||
{
|
||||
uint32_t adv;
|
||||
uint16_t adv_buf[10];
|
||||
Power_CurCalibration();
|
||||
GetADC1_Value(V_LA_H_CH,adv_buf,10) ;
|
||||
Bubble_Sort_u16(adv_buf,10);
|
||||
adv = (adv_buf[4]+adv_buf[5]+adv_buf[6]+adv_buf[7])>>2;
|
||||
adv = Power_ADVGetCalVal_106(adv);
|
||||
adv = adv*11/100000;
|
||||
return adv;
|
||||
}
|
||||
|
||||
/*
|
||||
@brief 采样总线输出电压
|
||||
*/
|
||||
uint32_t Power_GetBousV()
|
||||
{
|
||||
uint32_t abus_v,bbus_v;
|
||||
uint16_t adv_buf[10];
|
||||
Power_CurCalibration();
|
||||
GetADC1_Value(AD_OUTA_CH,adv_buf,10) ;
|
||||
Bubble_Sort_u16(adv_buf,10);
|
||||
abus_v = (adv_buf[4]+adv_buf[5]+adv_buf[6]+adv_buf[7])>>2;
|
||||
|
||||
GetADC1_Value(AD_OUTB_CH,adv_buf,10) ;
|
||||
Bubble_Sort_u16(adv_buf,10);
|
||||
bbus_v = (adv_buf[4]+adv_buf[5]+adv_buf[6]+adv_buf[7])>>2;
|
||||
|
||||
if(bbus_v > abus_v)
|
||||
{
|
||||
abus_v = bbus_v;
|
||||
}
|
||||
|
||||
abus_v = Power_ADVGetCalVal_106(abus_v);
|
||||
abus_v = abus_v*11/100000;
|
||||
return abus_v;
|
||||
}
|
||||
|
||||
/*
|
||||
@brief 采样中电平电压
|
||||
*/
|
||||
uint32_t Power_GetMPowerV()
|
||||
{
|
||||
int32_t adv;
|
||||
uint16_t adv_buf[10];
|
||||
GetADC1_Value(V_LA_M_CH,adv_buf,10) ;
|
||||
Bubble_Sort_u16(adv_buf,10);
|
||||
adv = (adv_buf[4]+adv_buf[5]+adv_buf[6]+adv_buf[7])>>2;
|
||||
adv = Power_ADVGetCalVal_106(adv);
|
||||
adv = adv*11/100000;
|
||||
return adv;
|
||||
}
|
||||
|
||||
/*
|
||||
typedef enum{
|
||||
R510_0uA_32uA_UC = (uint8_t)0,//x201
|
||||
R510_0uA_580uA_MC = (uint8_t)1,//x11
|
||||
R100_0uA_160uA_UC = (uint8_t)2,//x201
|
||||
R100_0p2mA_3mA_MC = (uint8_t)3,//x11
|
||||
R10_0p1mA_1p6mA_UC = (uint8_t)4,//x201
|
||||
R10_2mA_30mA_MC = (uint8_t)5,//x11
|
||||
Current_Max = (uint8_t)6,
|
||||
Current_SampleR_OFF = (uint8_t)9,
|
||||
} CurrentSample_Range_eu;
|
||||
*/
|
||||
/*
|
||||
@brief 通过采样adc,换算电流
|
||||
@param adv adc 采样值
|
||||
@param rang 采样电阻
|
||||
@rtv uint32_t 电流值 0.1uA
|
||||
*/
|
||||
uint32_t Power_ConvCur(uint16_t adv,CurrentSample_Range_eu range)
|
||||
{
|
||||
uint32_t ul_R,ul_Mut;
|
||||
uint32_t ul_adv = Power_ADVGetCalVal_106(adv);
|
||||
switch(range)
|
||||
{
|
||||
case R510_0uA_32uA_UC: ul_R = 510; ul_Mut = 201 ; break;
|
||||
case R510_0uA_580uA_MC: ul_R = 510; ul_Mut = 11; break;
|
||||
case R100_0uA_160uA_UC: ul_R = 100; ul_Mut = 201; break;
|
||||
case R100_0p2mA_3mA_MC: ul_R = 100; ul_Mut = 11; break;
|
||||
case R10_0p1mA_1p6mA_UC: ul_R = 10; ul_Mut = 201; break;
|
||||
case R10_2mA_30mA_MC: ul_R = 10; ul_Mut = 11; break;
|
||||
case Current_Max: ul_R = 10; ul_Mut = 1; break;
|
||||
case Current_SampleR_OFF: ul_R = 510; ul_Mut = 1;break;
|
||||
default: ul_R = 510; ul_Mut = 1;break;
|
||||
}
|
||||
ul_adv = (ul_adv*100 / ul_R /ul_Mut+4)/10;
|
||||
return ul_adv;
|
||||
}
|
||||
//根据电流大小的范围,设置采样电阻
|
||||
CurrentSample_Range_eu Power_SetSampleCurrentRange(CurrentSample_Range_eu range)
|
||||
{
|
||||
|
||||
switch(range)
|
||||
{
|
||||
case R510_0uA_32uA_UC: R510_SW_ON; R100_SW_OFF; R10_SW_OFF; break;
|
||||
case R510_0uA_580uA_MC: R510_SW_ON; R100_SW_OFF; R10_SW_OFF; break;
|
||||
case R100_0uA_160uA_UC: R100_SW_ON; R510_SW_OFF; R10_SW_OFF; break;
|
||||
case R100_0p2mA_3mA_MC: R100_SW_ON; R510_SW_OFF; R10_SW_OFF; break;
|
||||
case R10_0p1mA_1p6mA_UC: R10_SW_ON; R510_SW_OFF; R100_SW_OFF; break;
|
||||
case R10_2mA_30mA_MC: R10_SW_ON; R510_SW_OFF; R100_SW_OFF; break;
|
||||
case Current_Max: R510_SW_ON; R100_SW_ON; R10_SW_ON;break;
|
||||
case Current_SampleR_OFF: R510_SW_OFF;R100_SW_OFF; R10_SW_OFF;break;
|
||||
default: range = Current_Max; R510_SW_ON; R100_SW_ON; R10_SW_ON;break;
|
||||
}
|
||||
latest_range = range;
|
||||
return latest_range;
|
||||
}
|
||||
|
||||
/*
|
||||
@brief 设置电阻采样通道和AD采样配置
|
||||
*/
|
||||
CurrentSample_Range_eu Power_SetSampleRange_Seep(CurrentSample_Range_eu range , uint32_t speed)
|
||||
{
|
||||
switch(range)
|
||||
{
|
||||
case R510_0uA_32uA_UC: ADC_CurChnnelSet(AN_UA_CH,speed); break;
|
||||
case R510_0uA_580uA_MC: ADC_CurChnnelSet(AN_MAL_CH,speed); break;
|
||||
case R100_0uA_160uA_UC: ADC_CurChnnelSet(AN_UA_CH,speed); break;
|
||||
case R100_0p2mA_3mA_MC: ADC_CurChnnelSet(AN_MAL_CH,speed); break;
|
||||
case R10_0p1mA_1p6mA_UC: ADC_CurChnnelSet(AN_UA_CH,speed); break;
|
||||
case R10_2mA_30mA_MC: ADC_CurChnnelSet(AN_MAL_CH,speed); break;
|
||||
case Current_Max: ADC_CurChnnelSet(AN_MAL_CH,speed); break;
|
||||
case Current_SampleR_OFF: ADC_CurChnnelSet(AN_MAL_CH,speed);break;
|
||||
default: ADC_CurChnnelSet(AN_MAL_CH,speed);break;
|
||||
}
|
||||
return Power_SetSampleCurrentRange(range);
|
||||
}
|
||||
|
||||
|
||||
//获取总线电流
|
||||
uint32_t Power_GetCurrent(void)
|
||||
{
|
||||
uint32_t adv;
|
||||
uint32_t count;
|
||||
CurrentSample_Range_eu range = latest_range;//档位保存
|
||||
CurrentSample_Range_eu set_range;
|
||||
uint32_t adv_base = Power_GetBaseVAD();
|
||||
if(adv_base < 500)
|
||||
return 0;
|
||||
set_range = Power_SetSampleCurrentRange(R10_2mA_30mA_MC);
|
||||
StartADC2Channel(AN_MAL_CH,ADC_SPEED_SLOW);
|
||||
delay_us(300);
|
||||
GetADC_Fast(ADC_CURR_DE);
|
||||
adv = 0;
|
||||
for(count = 0; count < 4; count++)
|
||||
{
|
||||
adv += GetADC_Fast(ADC_CURR_DE);
|
||||
}
|
||||
adv >>= 2;
|
||||
if(adv > 250){
|
||||
adv = Power_ConvCur(adv,set_range);//0.1uA
|
||||
adv = (adv+4)/10;
|
||||
Power_SetSampleCurrentRange(range);
|
||||
return adv;
|
||||
}
|
||||
set_range = Power_SetSampleCurrentRange(R100_0p2mA_3mA_MC);
|
||||
StartADC2Channel(AN_MAL_CH,ADC_SPEED_SLOW);
|
||||
delay_us(300);
|
||||
GetADC_Fast(ADC_CURR_DE);
|
||||
adv = 0;
|
||||
for(count = 0; count < 4; count++)
|
||||
{
|
||||
adv += GetADC_Fast(ADC_CURR_DE);
|
||||
}
|
||||
adv >>= 2;
|
||||
if(adv > 250){
|
||||
adv = Power_ConvCur(adv,set_range);//0.1uA
|
||||
adv = (adv+4)/10;
|
||||
Power_SetSampleCurrentRange(range);
|
||||
return adv;
|
||||
}
|
||||
|
||||
set_range = Power_SetSampleCurrentRange(R10_0p1mA_1p6mA_UC);
|
||||
StartADC2Channel(AN_UA_CH,ADC_SPEED_SLOW);
|
||||
delay_ms(2);
|
||||
GetADC_Fast(ADC_CURR_DE);
|
||||
adv = 0;
|
||||
for(count = 0; count < 4; count++)
|
||||
{
|
||||
adv += GetADC_Fast(ADC_CURR_DE);
|
||||
}
|
||||
adv >>= 2;
|
||||
if(adv > 250){
|
||||
adv = Power_ConvCur(adv,set_range);//0.1uA
|
||||
adv = (adv+4)/10;
|
||||
Power_SetSampleCurrentRange(range);
|
||||
return adv;
|
||||
}
|
||||
set_range = Power_SetSampleCurrentRange(R100_0uA_160uA_UC);
|
||||
StartADC2Channel(AN_UA_CH,ADC_SPEED_SLOW);
|
||||
delay_ms(3);
|
||||
GetADC_Fast(ADC_CURR_DE);
|
||||
adv = 0;
|
||||
for(count = 0; count < 8; count++)
|
||||
{
|
||||
adv += GetADC_Fast(ADC_CURR_DE);
|
||||
}
|
||||
adv >>= 3;
|
||||
adv = Power_ConvCur(adv,set_range);//0.1uA
|
||||
adv = (adv+4)/10;
|
||||
Power_SetSampleCurrentRange(range);
|
||||
return adv;
|
||||
}
|
||||
|
||||
/*
|
||||
@brief 电源调压准备,计数频率和电压的线性关系
|
||||
@rtv 返回值:0 成功 其他失败
|
||||
*/
|
||||
|
||||
uint8_t PowerCalPrapare(void)
|
||||
{
|
||||
//YM硬件直接由公式计算
|
||||
return 0;
|
||||
}
|
||||
//防止突然上电,导致电源崩溃
|
||||
static void PowerUpFilter(uint16_t tag_dac)
|
||||
{
|
||||
uint16_t us_lastdac_h = DAC_GetDataOutputValue(DAC_Channel_1);
|
||||
if(us_lastdac_h > (tag_dac + 200))
|
||||
{
|
||||
while(us_lastdac_h > tag_dac)
|
||||
{
|
||||
if((tag_dac + 100) < us_lastdac_h)
|
||||
{
|
||||
us_lastdac_h -= 50;
|
||||
C_H_DAC_Set(us_lastdac_h);
|
||||
}else{
|
||||
us_lastdac_h = tag_dac;
|
||||
C_H_DAC_Set(us_lastdac_h);
|
||||
}
|
||||
delay_ms(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//电压调节的关系为线性函数
|
||||
void PowerCalibration(PowerInfo_st* info_st)
|
||||
{
|
||||
|
||||
float vlp,vlm,v_adc_h,v_adc_m;
|
||||
uint16_t us_basedac_h,us_basedac_m;
|
||||
uint16_t us_lastdac_h,us_lastdac_m;
|
||||
uint16_t us_powderv;
|
||||
uint16_t us_timeout ;
|
||||
uint32_t diff=0;
|
||||
uint16_t ok_flg = 0;
|
||||
uint8_t uc_down_up_flag = 0;
|
||||
if(info_st->V_LAH < info_st->V_LAM )
|
||||
{
|
||||
info_st->V_LAH_DAC = 0;
|
||||
info_st->V_LAM_DAC = 0;
|
||||
return ;
|
||||
}
|
||||
PAout(LAVC_M_Pin_Nu)=0;PBout(OUTAH_Pin_Nu)=0;
|
||||
PBout(OUTBL_Pin_Nu)=0;PBout(OUTAL_Pin_Nu)=0;
|
||||
PCout(POWER_ON_Pin_Nu) = 1;
|
||||
vlp = info_st->V_LAH;
|
||||
vlp /= 10;
|
||||
//(VLP-1.229V)/178K + (VDAC-1.229V)/20K = 0.1229mA
|
||||
v_adc_h =( 0.1229- (vlp-1.229)/178)*20+1.229;
|
||||
us_timeout = 80;
|
||||
info_st->V_LAH_DAC = 0;
|
||||
us_basedac_h = (uint16_t)( v_adc_h/3.3 * 4096);
|
||||
PowerUpFilter(us_basedac_h);
|
||||
us_lastdac_h = 0;
|
||||
//us_basedac_h = 250;
|
||||
ok_flg = 0;
|
||||
uc_down_up_flag = 0;
|
||||
while(us_timeout > 0)
|
||||
{
|
||||
us_timeout--;
|
||||
C_H_DAC_Set(us_basedac_h);
|
||||
us_lastdac_h = us_basedac_h;
|
||||
switch(uc_down_up_flag)
|
||||
{
|
||||
case 0:delay_os_ms(100);break;//首次调压
|
||||
case 1:delay_os_ms(50);break;//降压
|
||||
case 2:delay_os_ms(10);break;//升压
|
||||
}
|
||||
us_powderv = Power_GetHPowerV();
|
||||
diff = us_powderv > info_st->V_LAH?us_powderv-info_st->V_LAH:info_st->V_LAH-us_powderv;
|
||||
if(diff < 2)
|
||||
{
|
||||
ok_flg++;
|
||||
if(ok_flg > 2)
|
||||
{
|
||||
info_st->V_LAH_DAC = us_basedac_h;
|
||||
break;
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
diff = diff *2;
|
||||
ok_flg = 0;
|
||||
if( us_powderv > info_st->V_LAH)
|
||||
{
|
||||
us_basedac_h += diff;
|
||||
uc_down_up_flag = 1;
|
||||
}else{
|
||||
us_basedac_h -= diff;
|
||||
uc_down_up_flag = 2;
|
||||
}
|
||||
|
||||
|
||||
if(us_basedac_h < 20)
|
||||
us_basedac_h = 20;
|
||||
if(us_basedac_h > 4050)
|
||||
us_basedac_h = 4050;
|
||||
|
||||
}
|
||||
if(info_st->V_LAH_DAC == 0)
|
||||
return;
|
||||
|
||||
//(VM-2.5V)/20k+(VDAC-2.5V)/4.7K = 0.25mA
|
||||
us_timeout = 100;
|
||||
info_st->V_LAM_DAC = 0;
|
||||
vlm = info_st->V_LAM ;
|
||||
vlm /= 10;
|
||||
v_adc_m =( 0.25- (vlm-2.5)/20)*4.7+2.5;
|
||||
us_basedac_m = (uint16_t)(v_adc_m / 3.3 * 4096);
|
||||
//us_lastdac_m = 250;
|
||||
ok_flg = 0;
|
||||
uc_down_up_flag = 0;
|
||||
while( us_timeout > 0)
|
||||
{
|
||||
us_timeout--;
|
||||
C_M_DAC_Set(us_basedac_m);
|
||||
us_lastdac_m = us_basedac_m;
|
||||
switch(uc_down_up_flag)
|
||||
{
|
||||
case 0:delay_os_ms(50);break;//首次调压
|
||||
case 1:delay_os_ms(40);break;//降压
|
||||
case 2:delay_os_ms(30);break;//升压
|
||||
default:delay_os_ms(50);break;
|
||||
}
|
||||
us_powderv = Power_GetMPowerV();
|
||||
diff = us_powderv > info_st->V_LAM?us_powderv-info_st->V_LAM:info_st->V_LAM-us_powderv;
|
||||
if(diff < 2)
|
||||
{
|
||||
ok_flg++;
|
||||
if(ok_flg > 2)
|
||||
{
|
||||
info_st->V_LAM_DAC = us_basedac_m;
|
||||
break;
|
||||
}
|
||||
else{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
ok_flg = 0;
|
||||
diff = diff *10;
|
||||
if( us_powderv > info_st->V_LAM)
|
||||
{
|
||||
us_basedac_m += diff;
|
||||
uc_down_up_flag = 1;
|
||||
}else{
|
||||
uc_down_up_flag = 2;
|
||||
us_basedac_m -= diff;
|
||||
}
|
||||
if(us_basedac_m < 100)
|
||||
us_basedac_m = 100;
|
||||
if(us_basedac_m > 4050)
|
||||
us_basedac_m = 4050;
|
||||
}
|
||||
|
||||
}
|
||||
//设置总线电压
|
||||
void PowerSetVoltage(PowerInfo_st* info_st)
|
||||
{
|
||||
memcpy(&def_power_st,info_st,sizeof(PowerInfo_st));
|
||||
PowerUpFilter(info_st->V_LAH_DAC);
|
||||
C_H_DAC_Set(info_st->V_LAH_DAC);
|
||||
C_M_DAC_Set(info_st->V_LAM_DAC);
|
||||
POWER_ON;
|
||||
|
||||
}
|
||||
//获取当前电压配置值
|
||||
void PowerGetSet(PowerInfo_st* info_st)
|
||||
{
|
||||
uint16_t h_dac = DAC_GetDataOutputValue(DAC_Channel_1);
|
||||
uint16_t m_dac = DAC_GetDataOutputValue(DAC_Channel_2);
|
||||
info_st->V_LAH = 0;
|
||||
info_st->V_LAH_DAC = h_dac;
|
||||
if(h_dac == def_power_st.V_LAH_DAC)
|
||||
{
|
||||
info_st->V_LAH = def_power_st.V_LAH;
|
||||
}
|
||||
info_st->V_LAM = 0;
|
||||
info_st->V_LAM_DAC = h_dac;
|
||||
if(m_dac == def_power_st.V_LAM_DAC)
|
||||
{
|
||||
info_st->V_LAM_DAC = m_dac;
|
||||
}
|
||||
}
|
||||
/*
|
||||
@brief 设置总线电压
|
||||
@param h_v/10 设置高电平电压
|
||||
@param m_v/10 设置中电平电压
|
||||
@rtv 0 执行成功 1 执行失败
|
||||
*/
|
||||
|
||||
uint8_t PowerCalibration_set(uint16_t h_v,uint16_t m_v)
|
||||
{
|
||||
uint32_t ul_index = 0;
|
||||
PowerInfo_st powerinfo_st;
|
||||
rt_memset(&powerinfo_st,0,sizeof(PowerInfo_st));
|
||||
while(ul_index < POWER_SET_COUNT)
|
||||
{
|
||||
//if( powerinfo_arrayst[ul_index].V_LAH == h_v && powerinfo_arrayst[ul_index].V_LAM == m_v)
|
||||
if( powerinfo_arrayst[ul_index].V_LAH == h_v)
|
||||
{
|
||||
break;
|
||||
}
|
||||
ul_index++;
|
||||
}
|
||||
//在现有电压列表中能够查询到校准后的电压
|
||||
if(ul_index < POWER_SET_COUNT)
|
||||
{
|
||||
memcpy(&powerinfo_st,&powerinfo_arrayst[ul_index],sizeof(PowerInfo_st));
|
||||
PowerSetVoltage(&powerinfo_st);
|
||||
return 0;
|
||||
}
|
||||
|
||||
powerinfo_st.V_LAH = h_v;
|
||||
powerinfo_st.V_LAM = m_v;
|
||||
PowerCalibration(&powerinfo_st);
|
||||
if(powerinfo_st.V_LAH_DAC == 0 || powerinfo_st.V_LAM_DAC == 0)
|
||||
{
|
||||
LED1_Out = 1;
|
||||
return 1;
|
||||
}
|
||||
//校准完成后,设置总线电压
|
||||
PowerSetVoltage(&powerinfo_st);
|
||||
//查找为使用的配置缓存,将新设置的电压保存
|
||||
ul_index = 0;
|
||||
while(ul_index < POWER_SET_COUNT)
|
||||
{
|
||||
if( powerinfo_arrayst[ul_index].V_LAH_DAC == 0 || powerinfo_arrayst[ul_index].V_LAM_DAC == 0)
|
||||
{
|
||||
memcpy(&powerinfo_arrayst[ul_index],&powerinfo_st,sizeof(PowerInfo_st));
|
||||
break;
|
||||
}
|
||||
ul_index++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
115
source/elec_det/hardware/power.h
Normal file
115
source/elec_det/hardware/power.h
Normal file
@@ -0,0 +1,115 @@
|
||||
#ifndef __POWER_H__
|
||||
#define __POWER_H__
|
||||
#include "base/define.h"
|
||||
#include "dac_cfg.h"
|
||||
#include "adc_cfg.h"
|
||||
#include "gpio_cfg.h"
|
||||
|
||||
#define R10_ON_Out PBout(R10_ON_Pin_Nu)
|
||||
#define R10_SW_ON R10_ON_Out=1
|
||||
#define R10_SW_OFF R10_ON_Out=0
|
||||
#define R510_ON_Out PBout(R510_ON_Pin_Nu)
|
||||
#define R510_SW_ON R510_ON_Out=1
|
||||
#define R510_SW_OFF R510_ON_Out=0
|
||||
#define R100_ON_Out PCout(R100_ON_Pin_Nu)
|
||||
#define R100_SW_ON R100_ON_Out=1
|
||||
#define R100_SW_OFF R100_ON_Out=0
|
||||
|
||||
|
||||
|
||||
#define POWER_DEF_V 60
|
||||
|
||||
|
||||
typedef enum{
|
||||
R510_0uA_32uA_UC = (uint8_t)0,//x201
|
||||
R510_0uA_580uA_MC = (uint8_t)1,//x11
|
||||
R100_0uA_160uA_UC = (uint8_t)2,//x201
|
||||
R100_0p2mA_3mA_MC = (uint8_t)3,//x11
|
||||
R10_0p1mA_1p6mA_UC = (uint8_t)4,//x201
|
||||
R10_2mA_30mA_MC = (uint8_t)5,//x11
|
||||
Current_Max = (uint8_t)6,
|
||||
Current_SampleR_OFF = (uint8_t)9,
|
||||
} CurrentSample_Range_eu;
|
||||
|
||||
typedef struct {
|
||||
uint16_t V_LAH;
|
||||
uint16_t V_LAM;
|
||||
uint16_t V_LAH_DAC;
|
||||
uint16_t V_LAM_DAC;
|
||||
}PowerInfo_st;
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@brief 采样总线输出电压
|
||||
*/
|
||||
uint32_t Power_GetBousV(void);
|
||||
/*
|
||||
@brief 采样高电平电压
|
||||
*/
|
||||
uint32_t Power_GetHPowerV(void);
|
||||
/*
|
||||
@brief 采样中电平电压
|
||||
*/
|
||||
uint32_t Power_GetMPowerV(void);
|
||||
/*
|
||||
@brief 获取内部基准1.2V电压对应的AD
|
||||
*/
|
||||
uint32_t Power_GetBaseVAD(void);
|
||||
//获取总线电流
|
||||
uint32_t Power_GetCurrent(void);
|
||||
//根据电流大小的范围,设置采样电阻
|
||||
CurrentSample_Range_eu Power_SetSampleCurrentRange(CurrentSample_Range_eu range) ;
|
||||
#define CurrentSampleR_Def Power_SetSampleCurrentRange(Current_Max);
|
||||
/*
|
||||
@brief 设置电阻采样通道和AD采样配置
|
||||
*/
|
||||
CurrentSample_Range_eu Power_SetSampleRange_Seep(CurrentSample_Range_eu range , uint32_t speed);
|
||||
//检测方案,上电充能采样电阻
|
||||
#define Checker_PowerOn_Sample_R R100_0p2mA_3mA_MC
|
||||
#define Checker_OnLine_Sample_R R100_0uA_160uA_UC
|
||||
#define Checker_MonitorBuf_Sample_R R100_0p2mA_3mA_MC
|
||||
|
||||
#define JQChecker_ChgEnger_Sample_R R100_0p2mA_3mA_MC
|
||||
#define XTChecker_ChgEnger_Sample_R R10_2mA_30mA_MC
|
||||
//模块通信采样电阻
|
||||
#define XTDriver_Sample_R R10_2mA_30mA_MC
|
||||
#define JQDriver_Sample_R R10_2mA_30mA_MC
|
||||
|
||||
|
||||
//电压调节的关系为线性函数
|
||||
void PowerCalibration(PowerInfo_st* info_st);
|
||||
//设置总线电压
|
||||
void PowerSetVoltage(PowerInfo_st* info_st);
|
||||
//获取当前电压配置值
|
||||
void PowerGetSet(PowerInfo_st* info_st);
|
||||
/*
|
||||
@brief 设置总线电压
|
||||
@param h_v/10 设置高电平电压
|
||||
@param m_v/10 设置中电平电压
|
||||
@rtv 0 执行成功 1 执行失败
|
||||
*/
|
||||
|
||||
uint8_t PowerCalibration_set(uint16_t h_v,uint16_t m_v);
|
||||
/*
|
||||
@brief 将获取的ADC值转换为电压值
|
||||
@param1 ul_adv 采样AD原始值
|
||||
@rtv 返回AD采集到的电压值 扩大1000000倍
|
||||
*/
|
||||
uint32_t Power_ADVGetCalVal_106(uint16_t ul_adv);
|
||||
|
||||
/*
|
||||
@brief 电源调压准备,计数频率和电压的线性关系
|
||||
@rtv 返回值:0 成功 其他失败
|
||||
*/
|
||||
|
||||
uint8_t PowerCalPrapare(void);
|
||||
/*
|
||||
@brief 通过采样adc,换算电流
|
||||
@param adv adc 采样值
|
||||
@param rang 采样电阻
|
||||
@rtv uint32_t 电流值 0.1uA
|
||||
*/
|
||||
uint32_t Power_ConvCur(uint16_t adv,CurrentSample_Range_eu range);
|
||||
#endif
|
365
source/elec_det/hardware/timer_cfg.c
Normal file
365
source/elec_det/hardware/timer_cfg.c
Normal file
@@ -0,0 +1,365 @@
|
||||
#include "base/define.h"
|
||||
#include "timer_cfg.h"
|
||||
#include "base/delay.h"
|
||||
Timerupdatefunc p_timer4update_func = NULL;
|
||||
|
||||
|
||||
/*
|
||||
@brief 发送时钟校准波形
|
||||
@param pre_us 发送的周期
|
||||
@param count 发送周期的个数
|
||||
*/
|
||||
static volatile uint16_t amend_plus_count = 0;
|
||||
|
||||
TimerTriger p_timertriger = NULL;
|
||||
void FireBus_ClkAmend(uint16_t pre_us,uint16_t trigger_us,uint16_t count,void *p_fun)
|
||||
{
|
||||
|
||||
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;//定时器初始化结构
|
||||
TIM_OCInitTypeDef TIM_OCInitStructure;//通道输出初始化结构
|
||||
NVIC_InitTypeDef NVIC_InitStructure;
|
||||
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE );
|
||||
p_timertriger = (TimerTriger)p_fun;
|
||||
amend_plus_count = count;
|
||||
NVIC_DisableIRQ(TIM3_IRQn);
|
||||
//TIM初始化
|
||||
TIM_TimeBaseStructure.TIM_Period = pre_us-1; //周期0~FFFF
|
||||
TIM_TimeBaseStructure.TIM_Prescaler = 71 ; //时钟分频
|
||||
TIM_TimeBaseStructure.TIM_ClockDivision = 0; //时钟分 1us
|
||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;//模式
|
||||
TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;
|
||||
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure); //基本初始化
|
||||
|
||||
//TIM3通道初始化
|
||||
TIM_OCStructInit(& TIM_OCInitStructure); //默认参数
|
||||
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_Timing; //工作状态
|
||||
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; //设定为输出,需要PWM输出才需要这行代码
|
||||
TIM_OCInitStructure.TIM_Pulse = pre_us-trigger_us - 1; //占空长度
|
||||
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low; //高电平
|
||||
|
||||
TIM_OC1Init(TIM3, &TIM_OCInitStructure);
|
||||
TIM_OC1PreloadConfig(TIM3, TIM_OCPreload_Enable);
|
||||
TIM_ClearFlag(TIM3,TIM_IT_CC1);
|
||||
TIM_ITConfig(TIM3, TIM_IT_CC1 , ENABLE);//使能CC1中断
|
||||
TIM_ITConfig(TIM3,TIM_IT_Update,ENABLE);
|
||||
TIM_ARRPreloadConfig(TIM3, ENABLE);
|
||||
TIM_SetCompare3(TIM3,0);
|
||||
TIM_Cmd(TIM3, ENABLE); //开启定时器
|
||||
|
||||
NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;
|
||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
|
||||
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 9;
|
||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //TIM2全局中断使能
|
||||
NVIC_ClearPendingIRQ(TIM3_IRQn);
|
||||
NVIC_Init(&NVIC_InitStructure);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
使用轮询的方式检测校准结束
|
||||
*/
|
||||
void FireBus_ClkAmendCycle(void)
|
||||
{
|
||||
//使用查询的方式,关闭中断
|
||||
NVIC_DisableIRQ(TIM3_IRQn);
|
||||
TIM_ITConfig(TIM3, TIM_IT_CC1 , DISABLE);//使能CC1中断
|
||||
TIM_ITConfig(TIM3,TIM_IT_Update,DISABLE);
|
||||
if(p_timertriger == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
__disable_irq();
|
||||
while(1)
|
||||
{
|
||||
uint8_t flag = 0;
|
||||
if( TIM_GetITStatus(TIM3,TIM_IT_Update))
|
||||
{
|
||||
if(amend_plus_count > 0)
|
||||
amend_plus_count--;
|
||||
flag = 1;
|
||||
p_timertriger(flag);
|
||||
TIM3->SR = 0;
|
||||
}else if(TIM_GetITStatus(TIM3,TIM_IT_CC1))
|
||||
{
|
||||
flag = 2;
|
||||
p_timertriger(flag);
|
||||
TIM3->SR = 0;
|
||||
}
|
||||
if(amend_plus_count == 0)
|
||||
{
|
||||
flag = 3;
|
||||
TIM_DeInit(TIM3);
|
||||
p_timertriger(flag);
|
||||
p_timertriger = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
__enable_irq();
|
||||
}
|
||||
|
||||
|
||||
void TIM3_IRQHandler()
|
||||
{
|
||||
uint8_t flag = 0;
|
||||
rt_interrupt_enter();
|
||||
if( TIM_GetITStatus(TIM3,TIM_IT_Update))
|
||||
{
|
||||
if(amend_plus_count > 0)
|
||||
amend_plus_count--;
|
||||
flag = 1;
|
||||
}else if(TIM_GetITStatus(TIM3,TIM_IT_CC1))
|
||||
{
|
||||
flag = 2;
|
||||
}
|
||||
//timer_interrupt_flag_clear(TIMER2,TIMER_FLAG_UP|TIMER_FLAG_CH2|TIMER_FLAG_CH2O);
|
||||
TIM3->SR = 0;
|
||||
if(p_timertriger != NULL)
|
||||
{
|
||||
p_timertriger(flag);
|
||||
}
|
||||
if(amend_plus_count == 0)
|
||||
{
|
||||
flag = 3;
|
||||
NVIC_DisableIRQ(TIM3_IRQn);
|
||||
TIM_DeInit(TIM3);
|
||||
p_timertriger(flag);
|
||||
p_timertriger = NULL;
|
||||
}
|
||||
rt_interrupt_leave();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@brief 超时定时器,单位10ms
|
||||
@param ms 最大可设置6553。
|
||||
@param pfunc 超时回调函数,注意回调函数中不能做长延时任务
|
||||
*/
|
||||
void RunTimeOut_Timer(uint16_t ms,Timerupdatefunc pfunc )
|
||||
{
|
||||
NVIC_InitTypeDef NVIC_InitStructure;
|
||||
//定时器初始化数据结构定义
|
||||
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE );
|
||||
p_timer4update_func = pfunc;
|
||||
ms = ms*2-1;
|
||||
|
||||
NVIC_DisableIRQ(TIM1_UP_IRQn);
|
||||
//复位计数器
|
||||
TIM_DeInit(TIM1);
|
||||
TIM_TimeBaseStructure.TIM_Period = ms; //计数上限,100*100us = 10000us = 10ms
|
||||
TIM_TimeBaseStructure.TIM_Prescaler = 36000-1;//2K; //预分频72MHz主频,分频后时钟周期0.5ms
|
||||
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; //不分频
|
||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; //向上计数
|
||||
TIM_TimeBaseStructure.TIM_RepetitionCounter=0;
|
||||
//初始化
|
||||
TIM_TimeBaseInit(TIM1,&TIM_TimeBaseStructure);
|
||||
//清中断
|
||||
TIM_ClearFlag(TIM1, TIM_FLAG_Update);
|
||||
TIM_ITConfig(TIM1,TIM_IT_Update,ENABLE);
|
||||
|
||||
//定时器清零
|
||||
TIM_SetCounter(TIM1,0);
|
||||
|
||||
TIM_ARRPreloadConfig(TIM1, DISABLE);
|
||||
|
||||
//定时器启动
|
||||
TIM_Cmd(TIM1,ENABLE);
|
||||
|
||||
NVIC_InitStructure.NVIC_IRQChannel = TIM1_UP_IRQn;
|
||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
|
||||
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 10;
|
||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //TIM2全局中断使能
|
||||
NVIC_ClearPendingIRQ(TIM1_UP_IRQn);
|
||||
NVIC_Init(&NVIC_InitStructure);
|
||||
}
|
||||
|
||||
|
||||
//停止超时定时器计数
|
||||
void RunTimeoutStop(void)
|
||||
{
|
||||
TIM_DeInit(TIM1);
|
||||
}
|
||||
//获取超时定时器计数值
|
||||
uint16_t GetRunTimeOutCount(void)
|
||||
{
|
||||
return TIM1->CNT;
|
||||
}
|
||||
|
||||
void TIM1_UP_IRQHandler()
|
||||
{
|
||||
// uint8_t flag = 0;
|
||||
rt_interrupt_enter();
|
||||
if(TIM_GetITStatus(TIM1,TIM_IT_Update))
|
||||
{
|
||||
if(p_timer4update_func != NULL)
|
||||
{
|
||||
TIM_Cmd(TIM1,DISABLE);
|
||||
p_timer4update_func();
|
||||
|
||||
}
|
||||
}
|
||||
TIM1->SR = 0x00;
|
||||
rt_interrupt_leave();
|
||||
|
||||
}
|
||||
/*
|
||||
延时定时器初始化,单次向上计数
|
||||
*/
|
||||
void DelayTimer_Init(void)
|
||||
{
|
||||
//定时器初始化数据结构定义
|
||||
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE );
|
||||
TIM_DeInit(TIM2);
|
||||
|
||||
TIM_TimeBaseStructure.TIM_Period = 0xFFFF; //计数上限,100*100us = 10000us = 10ms
|
||||
TIM_TimeBaseStructure.TIM_Prescaler = 7200-1; //预分频48,48MHz主频,分频后时钟周期1us
|
||||
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; //不分频
|
||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; //向上计数
|
||||
TIM_TimeBaseStructure.TIM_RepetitionCounter=0;
|
||||
|
||||
TIM_ARRPreloadConfig(TIM2, DISABLE);
|
||||
//初始化
|
||||
TIM_TimeBaseInit(TIM2,&TIM_TimeBaseStructure);
|
||||
StartDelayTime();
|
||||
}
|
||||
/*
|
||||
延时定时器初始化,单次向上计数
|
||||
*/
|
||||
void TimerCount_Init(void)
|
||||
{
|
||||
//定时器初始化数据结构定义
|
||||
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE );
|
||||
TIM_DeInit(TIM2);
|
||||
|
||||
TIM_TimeBaseStructure.TIM_Period = 0xFFFF; //计数上限,100*100us = 10000us = 10ms
|
||||
TIM_TimeBaseStructure.TIM_Prescaler = 7200-1; //预分频48,48MHz主频,分频后时钟周期1us
|
||||
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; //不分频
|
||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; //向上计数
|
||||
TIM_TimeBaseStructure.TIM_RepetitionCounter=0;
|
||||
|
||||
TIM_ARRPreloadConfig(TIM2, DISABLE);
|
||||
//初始化
|
||||
TIM_TimeBaseInit(TIM2,&TIM_TimeBaseStructure);
|
||||
}
|
||||
/*
|
||||
@brief 重启延时定时器
|
||||
*/
|
||||
void StartDelayTime()
|
||||
{
|
||||
TIM_Cmd(TIM2,DISABLE);
|
||||
TIM2->CNT = 0;
|
||||
TIM2->PSC = (uint32_t)7200-1;//10K 0.1ms
|
||||
TIM2->EGR |= TIM_EventSource_Update;
|
||||
TIM2->SR = 0;
|
||||
TIM_Cmd(TIM2,ENABLE);
|
||||
|
||||
}
|
||||
/*
|
||||
@brief 定时器是否运行到大于当前值
|
||||
@param 当前比较值
|
||||
*/
|
||||
uint8_t isDelayEnd(uint16_t wait_time)
|
||||
{
|
||||
if((TIM2->CNT > wait_time) && (TIM2->SR > 0) )
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
/*
|
||||
@breif 等待定时器计数值大于设定值
|
||||
@param 等待定时器的结束值,单位0.1ms
|
||||
*/
|
||||
void WaitDelayEnd(uint16_t wait_time)
|
||||
{
|
||||
while((TIM2->CNT < wait_time) && (TIM2->SR < 1))
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
/*
|
||||
@brief 获取当前定时器计数值,单位1us。并重启计数
|
||||
@rtv 返回上次的计数值
|
||||
*/
|
||||
uint16_t Get1usCount(void)
|
||||
{
|
||||
uint16_t us_value ;
|
||||
if(TIM2->SR > 0)
|
||||
{
|
||||
us_value = 65535;
|
||||
}else{
|
||||
us_value = TIM2->CNT;
|
||||
}
|
||||
|
||||
TIM_Cmd(TIM2,DISABLE);
|
||||
TIM2->CNT = 0;
|
||||
TIM2->PSC = (uint32_t)71;//1M 1us
|
||||
TIM2->EGR |= TIM_EventSource_Update;
|
||||
TIM2->SR = 0;
|
||||
TIM_Cmd(TIM2,ENABLE);
|
||||
return us_value;
|
||||
}
|
||||
|
||||
/*
|
||||
@brief 获取当前定时器计数值,单位10us。并重启计数
|
||||
@rtv 返回上次的计数值
|
||||
*/
|
||||
uint16_t Get10usCount(void)
|
||||
{
|
||||
|
||||
uint16_t us_value ;
|
||||
if(TIM2->SR > 0)
|
||||
{
|
||||
us_value = 65535;
|
||||
}else{
|
||||
us_value = TIM2->CNT;
|
||||
}
|
||||
|
||||
TIM_Cmd(TIM2,DISABLE);
|
||||
TIM2->CNT = 0;
|
||||
TIM2->PSC = (uint32_t)720-1;//100K 10us
|
||||
TIM2->EGR |= TIM_EventSource_Update;
|
||||
TIM2->SR = 0;
|
||||
TIM_Cmd(TIM2,ENABLE);
|
||||
return us_value;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@brief 获取当前定时器计数值,单位0.1ms。并重启计数
|
||||
@rtv 返回上次的计数值
|
||||
*/
|
||||
uint16_t Get100usCount(void)
|
||||
{
|
||||
|
||||
uint16_t us_value ;
|
||||
if(TIM2->SR > 0)
|
||||
{
|
||||
us_value = 65535;
|
||||
}else{
|
||||
us_value = TIM2->CNT;
|
||||
}
|
||||
|
||||
TIM_Cmd(TIM2,DISABLE);
|
||||
TIM2->CNT = 0;
|
||||
TIM2->PSC = (uint32_t)7200-1;//10K 100us
|
||||
TIM2->EGR |= TIM_EventSource_Update;
|
||||
TIM2->SR = 0;
|
||||
TIM_Cmd(TIM2,ENABLE);
|
||||
return us_value;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@brief 直接获取定时器的值
|
||||
*/
|
||||
uint16_t GetCountTimerCnt()
|
||||
{
|
||||
return TIM2->CNT;
|
||||
}
|
||||
|
68
source/elec_det/hardware/timer_cfg.h
Normal file
68
source/elec_det/hardware/timer_cfg.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef TIMER_CFG_H_
|
||||
#include "base/define.h"
|
||||
#include "stm32f10x_tim.h"
|
||||
typedef void (*Timerupdatefunc)(void );
|
||||
typedef void (*TimerTriger)(uint8_t );
|
||||
//停止超时定时器计数
|
||||
void RunTimeoutStop(void);
|
||||
/*
|
||||
@brief 发送时钟校准波形
|
||||
@param pre_us 发送的周期
|
||||
@param count 发送周期的个数
|
||||
*/
|
||||
void FireBus_ClkAmend(uint16_t pre_us,uint16_t trigger_us,uint16_t count,void *p_fun);
|
||||
|
||||
/*
|
||||
@brief 超时定时器,单位0.1ms
|
||||
@param ms 最大可设置6553。
|
||||
@param pfunc 超时回调函数,注意回调函数中不能做长延时任务
|
||||
*/
|
||||
void RunTimeOut_Timer(uint16_t ms,Timerupdatefunc pfunc );
|
||||
//获取超时定时器计数值
|
||||
uint16_t GetRunTimeOutCount(void);
|
||||
/*
|
||||
延时定时器初始化,单次向上计数
|
||||
*/
|
||||
void DelayTimer_Init(void);
|
||||
/*
|
||||
延时定时器初始化,单次向上计数
|
||||
*/
|
||||
void TimerCount_Init(void);
|
||||
|
||||
/*
|
||||
@breif 等待定时器计数值大于设定值
|
||||
@param 等待定时器的结束值,单位0.1ms
|
||||
*/
|
||||
void WaitDelayEnd(uint16_t wait_time);
|
||||
|
||||
/*
|
||||
@brief 重启延时定时器
|
||||
*/
|
||||
void StartDelayTime(void);
|
||||
|
||||
#define GET_COUNTTIM_VAL() (TIM2->CNT)
|
||||
|
||||
/*
|
||||
@brief 获取当前定时器计数值,单位1us。并重启计数
|
||||
@rtv 返回上次的计数值
|
||||
*/
|
||||
uint16_t Get1usCount(void);
|
||||
/*
|
||||
@brief 获取当前定时器计数值,单位10us。并重启计数
|
||||
@rtv 返回上次的计数值
|
||||
*/
|
||||
uint16_t Get10usCount(void);
|
||||
/*
|
||||
@brief 获取当前定时器计数值,单位0.1ms。并重启计数
|
||||
@rtv 返回上次的计数值
|
||||
*/
|
||||
uint16_t Get100usCount(void);
|
||||
/*
|
||||
@brief 直接获取定时器的值
|
||||
*/
|
||||
uint16_t GetCountTimerCnt(void);
|
||||
/*
|
||||
使用轮询的方式检测校准结束
|
||||
*/
|
||||
void FireBus_ClkAmendCycle(void);
|
||||
#endif
|
216
source/elec_det/interface/BaseChecker.c
Normal file
216
source/elec_det/interface/BaseChecker.c
Normal file
@@ -0,0 +1,216 @@
|
||||
#include "Basechecker.h"
|
||||
#include "base/utility.h"
|
||||
#include "hardware/power.h"
|
||||
#include "base/delay.h"
|
||||
#include "hardware/gpio_cfg.h"
|
||||
Checker_RunCfg_st checker_runcfg;
|
||||
uint8_t Checker_FacBuf[CHECKER_FAC_BUF_LEN];
|
||||
volatile uint8_t ThreeBindResult_flag = 1;
|
||||
uint16_t Checker_First_Set_Voltage = 88;
|
||||
/*
|
||||
@brief 标记执行结果
|
||||
@param rtv 执行返回值 1表示失败 0 表示成功
|
||||
@param taskindex 任务项目ID号
|
||||
*/
|
||||
void Checker_MaskResult(uint8_t rtv,uint8_t taskindex)
|
||||
{
|
||||
uint8_t uc_index = taskindex >> 3;
|
||||
uint8_t uc_bitindex = taskindex & 0x07;
|
||||
if(taskindex >= CHECKER_MAXRT_COUNT)
|
||||
{
|
||||
return;
|
||||
}
|
||||
checker_runcfg.excue_rtv = rtv;
|
||||
uc_bitindex = (0x01<<uc_bitindex) & 0xFF;
|
||||
if(rtv == 0)
|
||||
{
|
||||
checker_runcfg.Task_Result[uc_index] &= (~uc_bitindex);
|
||||
}else{
|
||||
checker_runcfg.Task_Result[uc_index] |= uc_bitindex;
|
||||
}
|
||||
CurrentSampleR_Def;
|
||||
}
|
||||
/*
|
||||
@brief 标记任务序列执行
|
||||
@param taskindex 任务序列号
|
||||
*/
|
||||
void Checker_Excueindex(uint8_t taskindex)
|
||||
{
|
||||
uint8_t uc_index = taskindex >> 3;
|
||||
uint8_t uc_bitindex = taskindex & 0x07;
|
||||
if(taskindex >= CHECKER_MAXRT_COUNT)
|
||||
{
|
||||
return;
|
||||
}
|
||||
uc_bitindex = (0x01<<uc_bitindex) & 0xFF;
|
||||
checker_runcfg.Task_Excute[uc_index] |= uc_bitindex;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@brief 保存测试结果值
|
||||
@param *pus_rtv 测量结果缓存
|
||||
@param count 缓存个数
|
||||
*/
|
||||
void Checker_SetRtv(uint16_t* pus_rtv, uint8_t count)
|
||||
{
|
||||
while(count > 0)
|
||||
{
|
||||
checker_runcfg.Test_Rtv[checker_runcfg.rtv_index++] = *pus_rtv;
|
||||
pus_rtv++;
|
||||
count--;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
brief 准备测试用电压
|
||||
@param 设置电压值,最多支持10个参数
|
||||
*/
|
||||
void Checker_PowerPrapare(void)
|
||||
{
|
||||
uint8_t uc_index = 0;
|
||||
uint8_t uc_rtv = 0;
|
||||
uint16_t us_h_v,us_m_v;
|
||||
if(checker_runcfg.power_prapare_exe > 0 || checker_runcfg.param_count == 0){
|
||||
Checker_MaskResult(uc_rtv,checker_runcfg.task_info.runindex);
|
||||
return ;
|
||||
}
|
||||
Checker_First_Set_Voltage = checker_runcfg.params[0];
|
||||
Bubble_Sort_u16(checker_runcfg.params,checker_runcfg.param_count);
|
||||
POWER_OFF;
|
||||
while(uc_index < checker_runcfg.param_count)
|
||||
{
|
||||
us_h_v = checker_runcfg.params[uc_index];
|
||||
uc_index++;
|
||||
if(us_h_v < 55)
|
||||
{
|
||||
uc_rtv = 1;
|
||||
continue;
|
||||
}
|
||||
us_m_v = (us_h_v>>1) > 50 ? (us_h_v>>1):50;
|
||||
uc_rtv |= PowerCalibration_set(us_h_v,us_m_v);
|
||||
|
||||
}
|
||||
PowerCalibration_set(POWER_DEF_V,POWER_DEF_V-10);
|
||||
Checker_MaskResult(uc_rtv,checker_runcfg.task_info.runindex);
|
||||
}
|
||||
|
||||
/*
|
||||
@brief 延时
|
||||
@pram1 延时时间 0.1S
|
||||
@param 使能总线电流监控
|
||||
@rtv1 波动AD值
|
||||
*/
|
||||
void Checker_WaitDelay(void)
|
||||
{
|
||||
uint32_t ul_delaytime = checker_runcfg.params[0];
|
||||
uint8_t us_monito_flag = checker_runcfg.params[1];
|
||||
uint16_t us_temp;
|
||||
if(us_monito_flag == 0)
|
||||
{
|
||||
while(ul_delaytime > 0)
|
||||
{
|
||||
delay_os_ms(100);
|
||||
ul_delaytime--;
|
||||
}
|
||||
}else{
|
||||
|
||||
Power_SetSampleRange_Seep(Checker_MonitorBuf_Sample_R,ADC_SPEED_MIDLE);
|
||||
delay_ms(1);
|
||||
us_temp = AD_CurMonitor(ul_delaytime*1000);
|
||||
CurrentSampleR_Def;
|
||||
}
|
||||
Power_SetSampleCurrentRange(Current_Max);
|
||||
Checker_MaskResult(0,checker_runcfg.task_info.runindex);
|
||||
Checker_SetRtv(&us_temp,checker_runcfg.rtv_count);
|
||||
}
|
||||
|
||||
/*
|
||||
@brief 电阻检测
|
||||
@param0 电阻检测模式 0 4线制 1 2线 1-4,2 2线 2-3 通
|
||||
@rtv0 电阻检测值
|
||||
*/
|
||||
void Checker_ResistorSample(void)
|
||||
{
|
||||
/*
|
||||
1 通道1-4通,过桥丝
|
||||
2 通道2-3通,过桥丝
|
||||
3 通道1-3通,测阻抗
|
||||
4 通道2-4通,测阻抗
|
||||
*/
|
||||
uint16_t aus_sample[5];
|
||||
uint16_t us_resistor;
|
||||
uint8_t uc_index = 0;
|
||||
AD_SampleResistor(aus_sample);
|
||||
for(uc_index = 0; uc_index < 5; uc_index++)
|
||||
{
|
||||
aus_sample[uc_index] -= board_st.resistor_diff;
|
||||
}
|
||||
switch(checker_runcfg.params[0])
|
||||
{
|
||||
case 0: us_resistor = aus_sample[0];break;
|
||||
case 1: us_resistor = aus_sample[1];break;
|
||||
case 2: us_resistor = aus_sample[2];break;
|
||||
case 3: us_resistor = aus_sample[3];break;
|
||||
case 4: us_resistor = aus_sample[4];break;
|
||||
default : us_resistor = 0;break;
|
||||
}
|
||||
Checker_MaskResult(0,checker_runcfg.task_info.runindex);
|
||||
Checker_SetRtv(&us_resistor,checker_runcfg.rtv_count);
|
||||
}
|
||||
|
||||
/*
|
||||
@brief 判断是否需要注码
|
||||
@rtv 0 不需要注码 1 注码
|
||||
*/
|
||||
uint8_t JQXT_Test_IsNeedBind(void)
|
||||
{
|
||||
uint8_t uc_index = 0;
|
||||
|
||||
if(checker_runcfg.uid_len == 0 || checker_runcfg.pwd_len == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
for(uc_index = 0; uc_index < checker_runcfg.uid_len ; uc_index++)
|
||||
{
|
||||
if(checker_runcfg.writeuid[uc_index] != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(uc_index != checker_runcfg.uid_len)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
for(uc_index = 0; uc_index < checker_runcfg.pwd_len ; uc_index++)
|
||||
{
|
||||
if(checker_runcfg.writepwd[uc_index] != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(uc_index != checker_runcfg.pwd_len)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
检测执行函数是否正常
|
||||
*/
|
||||
uint8_t Checker_FunIsValid(CheckerTask* taskArray,uint16_t run_index)
|
||||
{
|
||||
uint16_t index = 0;
|
||||
while((*taskArray !=0) && (index < CHECKER_MAXID_COUNT))
|
||||
{
|
||||
index++;
|
||||
}
|
||||
if(run_index >= index)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
101
source/elec_det/interface/BaseChecker.h
Normal file
101
source/elec_det/interface/BaseChecker.h
Normal file
@@ -0,0 +1,101 @@
|
||||
#ifndef BASECHECKER_H_
|
||||
#define BASECHECKER_H_
|
||||
#include "stm32f10x.h"
|
||||
|
||||
|
||||
#define CHECKER_NET_ID 10
|
||||
#define CHECKER_DELAY_TIME 10
|
||||
#define CHECKER_MAXRT_COUNT 64
|
||||
#define CHECKER_MAXID_COUNT 100
|
||||
|
||||
|
||||
|
||||
typedef void (*CheckerTask)(void );
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
uint8_t taskid; //任务ID
|
||||
uint8_t runindex;//任务序列
|
||||
uint8_t retry_time;//重试次数
|
||||
uint8_t error_jumpto;//失败后跳转
|
||||
uint8_t param_rtv_count;//参数个数和返回值个数
|
||||
uint16_t params[10];
|
||||
}CheckerTask_Info_st;
|
||||
|
||||
|
||||
typedef struct{
|
||||
CheckerTask_Info_st task_info;
|
||||
uint16_t params[10];//运行参数1
|
||||
uint16_t rtv_index;//返回值下标
|
||||
uint8_t rtv_count;//当前任务返回值个数
|
||||
uint8_t param_count;//参数个数
|
||||
uint8_t excue_rtv; //任务执行结果
|
||||
uint8_t power_prapare_exe;//电源准备任务执行
|
||||
uint16_t Test_Rtv[100];//保存返回参数
|
||||
uint8_t Task_Result[8];//保存运行状态
|
||||
uint8_t Task_Excute[8];//保存执行序列号
|
||||
uint16_t netid;//电子模块最新的网络ID
|
||||
uint8_t user_otp[4];//用户区OTP数据
|
||||
uint8_t writeuid[13];//注码uid
|
||||
uint8_t writepwd[8];//注码密码
|
||||
uint8_t uid_len;//密码长度 XT 7 JQ 8
|
||||
uint8_t pwd_len;//密码长度 XT 4 JQ 4
|
||||
uint8_t uid_pwd_bind_flag;
|
||||
uint8_t code_bind_check_flag;//三码绑定检测一起执行
|
||||
}Checker_RunCfg_st ;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
extern Checker_RunCfg_st checker_runcfg;
|
||||
#define CHECKER_WRITE_BUF 48 //(CHECKER_FAC_BUF_LEN-2)
|
||||
#define CHECKER_FAC_BUF_LEN 50 //len+crc8+48bytes
|
||||
extern uint8_t Checker_FacBuf[CHECKER_FAC_BUF_LEN];
|
||||
extern volatile uint8_t ThreeBindResult_flag ;
|
||||
extern uint16_t Checker_First_Set_Voltage ;//方案设置内部第一个电压
|
||||
/*
|
||||
@brief 标记执行结果
|
||||
@param rtv 执行返回值 1表示失败 0 表示成功
|
||||
@param taskindex 任务项目ID号
|
||||
*/
|
||||
void Checker_MaskResult(uint8_t rtv,uint8_t taskindex);
|
||||
/*
|
||||
@brief 标记任务序列执行
|
||||
@param taskindex 任务序列号
|
||||
*/
|
||||
void Checker_Excueindex(uint8_t taskindex);
|
||||
|
||||
/*
|
||||
@brief 保存测试结果值
|
||||
@param *pus_rtv 测量结果缓存
|
||||
@param count 缓存个数
|
||||
*/
|
||||
void Checker_SetRtv(uint16_t* pus_rtv, uint8_t count);
|
||||
|
||||
/*
|
||||
brief 准备测试用电压
|
||||
@param 设置电压值,最多支持10个参数
|
||||
*/
|
||||
void Checker_PowerPrapare(void);
|
||||
/*
|
||||
@brief 延时
|
||||
@pram1 延时时间 0.1S
|
||||
@param 使能总线电流监控
|
||||
@rtv1 波动AD值
|
||||
*/
|
||||
void Checker_WaitDelay(void);
|
||||
/*
|
||||
@brief 电阻检测
|
||||
@param0 电阻检测模式 0 4线制 1 2线 1-4,2 2线 2-3 通
|
||||
@rtv0 电阻检测值
|
||||
*/
|
||||
void Checker_ResistorSample(void);
|
||||
/*
|
||||
@brief 判断是否需要注码
|
||||
@rtv 0 不需要注码 1 注码
|
||||
*/
|
||||
uint8_t JQXT_Test_IsNeedBind(void);
|
||||
/*
|
||||
检测执行函数是否正常
|
||||
*/
|
||||
uint8_t Checker_FunIsValid(CheckerTask* taskArray,uint16_t run_index);
|
||||
#endif
|
1099
source/elec_det/interface/JQChecker.c
Normal file
1099
source/elec_det/interface/JQChecker.c
Normal file
File diff suppressed because it is too large
Load Diff
218
source/elec_det/interface/JQChecker.h
Normal file
218
source/elec_det/interface/JQChecker.h
Normal file
@@ -0,0 +1,218 @@
|
||||
#ifndef JQCHECKER_H_
|
||||
#define JQCHECKER_H_
|
||||
#include "base/define.h"
|
||||
#include "basechecker.h"
|
||||
|
||||
|
||||
|
||||
|
||||
extern Checker_RunCfg_st checker_runcfg;
|
||||
|
||||
|
||||
|
||||
|
||||
extern CheckerTask jqtaskArray[CHECKER_MAXID_COUNT];
|
||||
|
||||
|
||||
/*
|
||||
brief 准备测试用电压
|
||||
@param 设置电压值,最多支持10个参数
|
||||
*/
|
||||
void JQ_Test_PowerPrapare(void);
|
||||
|
||||
/*
|
||||
@brief 统计模块的上电充能,具有电压设置功能,采集档位 R10_0p1mA_1p6mA_UC
|
||||
@param1 总线电压
|
||||
@param2 充电结束时的AD值
|
||||
@rtv1 返回总线电流低于设置AD值的时间
|
||||
*/
|
||||
void JQ_Test_PowerOn(void);
|
||||
/*
|
||||
@brief 扫描总线上的电子模块 1发
|
||||
@param0 使能或失能通信反码信息采集
|
||||
@param1 1 uid数据全0验证 其他不验证
|
||||
*/
|
||||
void JQ_Test_ScanUID(void);
|
||||
/*
|
||||
@brief 设置总线电压
|
||||
@param1 总线电压
|
||||
@rtv1 总线电压
|
||||
*/
|
||||
void JQ_Test_SetBusV(void);
|
||||
/*
|
||||
@brief 测量总线基本电压
|
||||
@rtv1 返回总线电流 单位0.01uA
|
||||
*/
|
||||
void JQ_Test_BaseCur(void);
|
||||
/*
|
||||
@brief 读取芯片码
|
||||
@rtv 芯片代码2字节
|
||||
*/
|
||||
void JQ_Test_ReadChipID(void);
|
||||
/*
|
||||
@brief OTP全0检测
|
||||
@param0 UID区和密码区验证标志 1不验证 0 验证
|
||||
@param1 延时区和保留区验证 1不严重 0验证,错误标记区
|
||||
@param2 用户存储区
|
||||
*/
|
||||
|
||||
void JQ_Test_OTPCheck(void);
|
||||
/*
|
||||
@brief 工厂成测标志检测
|
||||
*/
|
||||
void JQ_Test_FTCheck(void);
|
||||
/*
|
||||
@brief 读芯片状态
|
||||
@param0 比较掩码,状态与掩码与等于掩码返回正常
|
||||
*/
|
||||
void JQ_Test_ReadState(void);
|
||||
/*
|
||||
@brief 写入OTP数据
|
||||
@param0 2字节OTP数据
|
||||
@param1 2字节OTP数据
|
||||
*/
|
||||
void JQ_Test_WriteUserInfo(void);
|
||||
/*
|
||||
@brief 充能统计
|
||||
@param0 充电电流判线值,AD值
|
||||
@param1 充电末电流结束值,单位0.1uA
|
||||
@param2 充电最长时间,单位100ms
|
||||
@param3 充电高压保持时间,单位0.1s
|
||||
@rtv0 充能值 单位0.1ms
|
||||
@rtv1 充末电流 单位0.1uA
|
||||
@rtv2 充电最大电流 单位0.1Ma
|
||||
@rtv3 充电抖动幅值 adv
|
||||
*/
|
||||
|
||||
void JQ_Test_ChgEnergy(void);
|
||||
/*
|
||||
@brief DAC检测
|
||||
@param DAC检测的起始值
|
||||
@param DAC检测的结束值
|
||||
*/
|
||||
void JQ_Test_CheckDAC(void);
|
||||
/*
|
||||
@brief 延时
|
||||
@pram1 延时时间 0.1S
|
||||
@param 使能总线电流监控
|
||||
@rtv1 波动AD值
|
||||
*/
|
||||
void JQ_Test_WaitDelay(void);
|
||||
/*
|
||||
@brief 写延时
|
||||
@param 延时时间
|
||||
*/
|
||||
void JQ_Test_SetDelay(void);
|
||||
/*
|
||||
@brief 读延时
|
||||
@param 延时时间
|
||||
*/
|
||||
void JQ_Test_ReadDelay(void);
|
||||
/*
|
||||
@brief 校准
|
||||
@param1 校准周期
|
||||
@param2 脉冲个数
|
||||
*/
|
||||
void JQ_Test_ClkTrim(void);
|
||||
/*
|
||||
@brief 放电
|
||||
*/
|
||||
|
||||
void JQ_Test_Discharge(void);
|
||||
/*
|
||||
@brief 复位
|
||||
*/
|
||||
void JQ_Test_Reset(void);
|
||||
/*
|
||||
@brief 起爆使能
|
||||
*/
|
||||
void JQ_Test_BootEn(void);
|
||||
/*
|
||||
@brief 起爆充能
|
||||
@param1 启动电流 adc
|
||||
@param2 脉冲个数
|
||||
@param3 延迟采集充能
|
||||
@param4 使能电压波动监控
|
||||
@rtv1 起爆后充电能量
|
||||
@rtv2 起爆脉冲波动
|
||||
@rtv3 起爆后充电电流
|
||||
@rtv4 起爆后充电电流波动
|
||||
*/
|
||||
|
||||
void JQ_Test_BoomEnergy(void);
|
||||
/*
|
||||
@brief 使能通讯末电流采样
|
||||
*/
|
||||
void JQ_Test_EnCommEndCur(void);
|
||||
/*
|
||||
@brief 获取通讯末电流采样,关闭电流采样
|
||||
@rtv 返回上次采集的通讯末电流
|
||||
*/
|
||||
void JQ_Test_GetCommEndCur(void);
|
||||
/*
|
||||
@brief 关总线
|
||||
*/
|
||||
void JQ_Test_PowerOff(void);
|
||||
/*
|
||||
@brief 密码验证
|
||||
@param0 密码源码验证使能
|
||||
*/
|
||||
void JQ_Test_PWCheck(void);
|
||||
/*
|
||||
@brief 写入OTP数据
|
||||
@param0 OTP 地址
|
||||
@param1 写入数据长度
|
||||
@param2 2Bytes OTP数据
|
||||
@param3 2Bytes OTP数据
|
||||
@param4 2Bytes OTP数据
|
||||
@param5 2Bytes OTP数据
|
||||
*/
|
||||
void JQ_Test_WriteOTP(void);
|
||||
/*
|
||||
@brief 读OTP
|
||||
@param0 OTP地址
|
||||
@param1 OTP 数量
|
||||
*/
|
||||
|
||||
void JQ_Test_ReadOTP(void);
|
||||
/*
|
||||
@brief 清除起爆命令
|
||||
*/
|
||||
void JQ_Test_ClearBoom(void);
|
||||
/*
|
||||
@brief 缓存数据写入OTP数据
|
||||
@param0 OTP 地址
|
||||
@param1 缓存区起始
|
||||
@param2 写入数据长度
|
||||
*/
|
||||
void JQ_Test_WriteBuf2OTP(void);
|
||||
/*
|
||||
@brief 写入三码数据
|
||||
*/
|
||||
void JQ_UID_PWD_Bind(void);
|
||||
/*
|
||||
@brief UID PWD 验证
|
||||
*/
|
||||
void JQ_Verify_UID_PWD(void);
|
||||
/*
|
||||
@breif 测量电容电压差
|
||||
@param0 两次测量间隔 0.1s
|
||||
@rtv0 电压差值
|
||||
*/
|
||||
void JQ_Test_CapVoltage(void);
|
||||
/*
|
||||
@breif OTP 读写使能
|
||||
*/
|
||||
|
||||
void JQ_Test_EnOTPW(void);
|
||||
/*
|
||||
@brief 获取版本号
|
||||
|
||||
*/
|
||||
void JQ_Test_ReadVersion(void);
|
||||
/*
|
||||
@breif 写模块版本 前提是要使能OTP (ENWOTP)
|
||||
@param0 模块版本号
|
||||
*/
|
||||
void JQ_Test_WriteVersion(void);
|
||||
#endif
|
1390
source/elec_det/interface/XTChecker.c
Normal file
1390
source/elec_det/interface/XTChecker.c
Normal file
File diff suppressed because it is too large
Load Diff
250
source/elec_det/interface/XTChecker.h
Normal file
250
source/elec_det/interface/XTChecker.h
Normal file
@@ -0,0 +1,250 @@
|
||||
#ifndef XTCHECKER_H_
|
||||
#define XTCHECKER_H_
|
||||
#include "base/define.h"
|
||||
#include "basechecker.h"
|
||||
|
||||
extern Checker_RunCfg_st checker_runcfg;
|
||||
extern CheckerTask xttaskArray[CHECKER_MAXID_COUNT] ;
|
||||
/*
|
||||
@brief 统计模块的上电充能,具有电压设置功能,采集档位 R10_0p1mA_1p6mA_UC
|
||||
@param1 总线电压
|
||||
@param2 充电结束时的AD值
|
||||
@rtv1 返回总线电流低于设置AD值的时间
|
||||
*/
|
||||
void XT_Test_PowerOn(void);
|
||||
/*
|
||||
@brief 设置总线电压
|
||||
@param1 总线电压
|
||||
@rtv1 总线电压
|
||||
*/
|
||||
void XT_Test_SetBusV(void);
|
||||
/*
|
||||
@brief 测量总线基本电压
|
||||
@rtv1 返回总线电流 单位0.01uA
|
||||
*/
|
||||
void XT_Test_BaseCur(void);
|
||||
/*
|
||||
@brief 扫描总线上的电子模块 1发
|
||||
@param0 UID长度
|
||||
@param1 使能或失能 UID对比
|
||||
*/
|
||||
|
||||
void XT_Test_ScanUID(void);
|
||||
/*
|
||||
@brief 写芯片配置
|
||||
@param0 UID长度
|
||||
@param1 密码长度
|
||||
@param2 反馈电流挡位
|
||||
@param4 版本标识
|
||||
@rtv 芯片配置3字节
|
||||
*/
|
||||
void XT_Test_WriteChipCfg(void);
|
||||
/*
|
||||
@brief 读取芯片配置并比对
|
||||
@param0 UID长度
|
||||
@param1 密码长度
|
||||
@param2 反馈电流挡位
|
||||
@param4 版本标识
|
||||
*/
|
||||
void XT_Test_CheckChipCfg(void);
|
||||
/*
|
||||
@brief 模拟注码
|
||||
*/
|
||||
void XT_Test_BindTestCode(void);
|
||||
/*
|
||||
@brief 充能统计
|
||||
@param0 充电电流判线值,AD值
|
||||
@param1 充电末电流结束值,单位0.1uA
|
||||
@param2 充电最长时间,单位100ms
|
||||
@param3 充电高压保持时间,单位0.1s
|
||||
@param4 充电挡位
|
||||
@rtv0 充能值 单位0.1ms
|
||||
@rtv1 充末电流 单位0.1uA
|
||||
@rtv2 充电最大电流 单位0.1Ma
|
||||
@rtv3 充电抖动幅值 adv
|
||||
*/
|
||||
|
||||
void XT_Test_ChgEnergy(void);
|
||||
/*
|
||||
@brief 写现场值,如果UID已经写入,会将现场值读取进行比对
|
||||
@param 0 编号
|
||||
@param 1 延时
|
||||
@param 2 孔号
|
||||
*/
|
||||
|
||||
void XT_Test_WriteRunField(void);
|
||||
/*
|
||||
@brief 比对现场值
|
||||
@param0 比对网络号
|
||||
@param1 比对延时
|
||||
@param2 比对孔位
|
||||
@param3 1使能或 0失能通信反码信息采集
|
||||
@rtv1 最大反馈电流
|
||||
@rtv2 最大反馈时间
|
||||
@rtv3 最小反馈电流
|
||||
@rtv4 最小反馈时间
|
||||
*/
|
||||
|
||||
void XT_Test_CheckRunField(void);
|
||||
/*
|
||||
@brief 桥丝通断检测,如果测试器有uid,将采用uid方式通信
|
||||
*/
|
||||
void XT_Test_Resister(void);
|
||||
/*
|
||||
@brief 电容容量检测,如果测试器有uid,将采用uid方式通信
|
||||
@pram 检测电压参数
|
||||
*/
|
||||
void XT_Test_Cap(void);
|
||||
/*
|
||||
@brief 写管壳码 如果测试器有uid,将采用uid方式通信
|
||||
@param 命令缓存参数的起始
|
||||
@param 写入数据长度
|
||||
*/
|
||||
void XT_Test_WriteShell(void);
|
||||
/*
|
||||
@brief 写UID
|
||||
@param 命令缓存参数的起始
|
||||
@param 写入数据长度
|
||||
*/
|
||||
void XT_Test_WriteUID(void);
|
||||
/*
|
||||
@brief 写密码
|
||||
@param 命令缓存参数的起始
|
||||
@param 写入数据长度
|
||||
*/
|
||||
void XT_Test_WritePWD(void);
|
||||
/*
|
||||
@brief 备份区标记检测,备份区用于存储检测标记
|
||||
@param0 0备份区标记 或 1比对
|
||||
@param1 备份区数据掩码 2Bytes
|
||||
@param1 备份区写入数据 2Bytes
|
||||
|
||||
*/
|
||||
|
||||
void XT_Test_CheckBackFlag(void);
|
||||
/*
|
||||
@brief 备份区标记检测,备份区用于存储检测标记
|
||||
*/
|
||||
void XT_Test_ReadBackFlag(void);
|
||||
/*
|
||||
@brief 时钟校准
|
||||
@param0 校准模式 1 快速 0 全
|
||||
@param1 校准周期
|
||||
@param2 校准时长
|
||||
*/
|
||||
void XT_Test_Trim(void);
|
||||
/*
|
||||
@brief 放电
|
||||
*/
|
||||
void XT_Test_Discharge(void);
|
||||
|
||||
/*
|
||||
@brief 失能通信末电流采集
|
||||
*/
|
||||
void XT_Test_EnCommEndCur(void);
|
||||
/*
|
||||
@brief 获取通信末电流
|
||||
*/
|
||||
void XT_Test_GetCommEndCur(void);
|
||||
/*
|
||||
@brief 在线检测
|
||||
@param 检测网络号
|
||||
*/
|
||||
void XT_Test_OneLineCheck(void);
|
||||
/*
|
||||
@brief 状态检测,如果UID已经存在,使用UID读取。否则通过扫描的方式
|
||||
@param0 状态比较掩码
|
||||
*/
|
||||
void XT_Test_CheckState(void);
|
||||
/*
|
||||
@brief 起爆
|
||||
*/
|
||||
void XT_Test_Boom(void);
|
||||
/*
|
||||
@brief 复位
|
||||
*/
|
||||
void XT_Test_Reset(void);
|
||||
/*
|
||||
@brief 关总线
|
||||
*/
|
||||
void XT_Test_PowerOFF(void);
|
||||
/*
|
||||
@brief 芯片锁存
|
||||
*/
|
||||
void XT_Test_LockCmdC(void);
|
||||
/*
|
||||
@brief 赋码设备失能
|
||||
*/
|
||||
|
||||
void XT_Test_CodeBindEn(void);
|
||||
/*
|
||||
@brief 接入检测
|
||||
@param0 上电电压
|
||||
@param1 超时次数
|
||||
*/
|
||||
void XT_Test_InputCheck(void);
|
||||
/*
|
||||
@brief 密码验证
|
||||
*/
|
||||
|
||||
void XT_Test_CheckPWD(void);
|
||||
/*
|
||||
@brief 三码写入
|
||||
@rtv 0 执行成功
|
||||
1 电压设置失败
|
||||
3 UID写入失败
|
||||
4 密码写入失败
|
||||
5 获取UID失败
|
||||
6 UID写入失败
|
||||
7 锁存失败
|
||||
8 等待接入超时
|
||||
*/
|
||||
|
||||
uint8_t XT_UID_PWD_Bind(void);
|
||||
/*
|
||||
@brief 加载配置参数
|
||||
@rtv UID长度
|
||||
@rtv 密码长度
|
||||
@rtv 版本号
|
||||
@rtv 反码数据
|
||||
*/
|
||||
void XT_Test_LoadChipCfg(void);
|
||||
/*
|
||||
@breif 测量电容电压差
|
||||
@param0 两次测量间隔 0.1s
|
||||
@rtv0 电压差值
|
||||
*/
|
||||
void XT_Test_CapVoltage(void);
|
||||
/*
|
||||
@brief 三码绑定验证
|
||||
*/
|
||||
void XT_Test_UID_PWD_Verify(void);
|
||||
/*
|
||||
@brief 写入三码数据
|
||||
*/
|
||||
void XT_Test_UID_PWD_Bind(void);
|
||||
/*
|
||||
@breif 在线检测 并扫描通信
|
||||
@param0 总线电压
|
||||
@param1 超时时间1ms 最大6S
|
||||
@param2 UID长度
|
||||
*/
|
||||
|
||||
void XT_OnLine_SCAN(void);
|
||||
/*
|
||||
@brief 芯片离线检测
|
||||
@param0 超时时间 1ms
|
||||
@param1 离线电流 0.1uA
|
||||
@param2 稳定次数
|
||||
*/
|
||||
|
||||
void XT_OFFLine_SCAN(void);
|
||||
/*
|
||||
@brief 芯片离线检测
|
||||
@param0 充电使能
|
||||
@param1 采样周期 10ms
|
||||
@param2 采样次数
|
||||
*/
|
||||
|
||||
void XT_CurMonitor(void);
|
||||
#endif
|
435
source/interface/if_can.c
Normal file
435
source/interface/if_can.c
Normal file
@@ -0,0 +1,435 @@
|
||||
#include "if_can.h"
|
||||
#include "rtthread.h"
|
||||
#include "rthw.h"
|
||||
#include "elec_det.h"
|
||||
#include "board.h"
|
||||
CanRxMsg receive_message;
|
||||
static YeCanRxFrame_st canrx_st;
|
||||
static uint8_t Can_Device_ID = 0;
|
||||
static uint32_t GetCanFilter(YeCanID_un yeid);
|
||||
uint32_t ul_exid,ul_can_mask;
|
||||
|
||||
rt_mutex_t can_tx_mutex;
|
||||
|
||||
volatile uint8_t CAN0_TX_BUSY_Flag = 0;
|
||||
/*
|
||||
@brief CAN通讯初始化, 包括CANgpio 过滤器
|
||||
*/
|
||||
void YeCanInit(void)
|
||||
{
|
||||
uint32_t ul_filter,ul_mask;
|
||||
CAN_InitTypeDef CAN_InitStructure;
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
YeCanID_un yeid_un;
|
||||
CAN_FilterInitTypeDef CAN_FilterInitStructure;
|
||||
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE);
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);
|
||||
//CAN GPIO 初始化
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
|
||||
CAN_DeInit(CAN1);
|
||||
CAN_StructInit(&CAN_InitStructure);
|
||||
CAN_InitStructure.CAN_TTCM = DISABLE;
|
||||
CAN_InitStructure.CAN_ABOM = DISABLE;
|
||||
CAN_InitStructure.CAN_AWUM = DISABLE;
|
||||
CAN_InitStructure.CAN_NART = DISABLE;
|
||||
CAN_InitStructure.CAN_RFLM = DISABLE;
|
||||
CAN_InitStructure.CAN_TXFP = ENABLE;
|
||||
CAN_InitStructure.CAN_Mode = CAN_Mode_Normal;
|
||||
CAN_InitStructure.CAN_SJW = CAN_SJW_1tq;
|
||||
CAN_InitStructure.CAN_BS1 = CAN_BS1_3tq;
|
||||
CAN_InitStructure.CAN_BS2 = CAN_BS2_2tq;
|
||||
CAN_InitStructure.CAN_Prescaler = 30;
|
||||
|
||||
CAN_Init(CAN1, &CAN_InitStructure);
|
||||
|
||||
Can_Device_ID = elec_local_addr();
|
||||
|
||||
yeid_un.Exide = 0;
|
||||
yeid_un.yecanid.ACK = 0;
|
||||
yeid_un.yecanid.FunClass = 0;
|
||||
yeid_un.yecanid.Reserve1 = 0;
|
||||
yeid_un.yecanid.Reserve0 = 0;
|
||||
yeid_un.yecanid.SegFlag = 0;
|
||||
yeid_un.yecanid.SegNum = 0;
|
||||
yeid_un.yecanid.srcMACID = 0x00;
|
||||
|
||||
yeid_un.yecanid.destMACID = 0x1F;
|
||||
ul_mask = GetCanFilter(yeid_un);
|
||||
ul_can_mask =ul_mask;
|
||||
yeid_un.yecanid.destMACID = Can_Device_ID;
|
||||
ul_filter = GetCanFilter(yeid_un);
|
||||
|
||||
CAN_FilterInitStructure.CAN_FilterNumber = 0;
|
||||
CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask;
|
||||
CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit;
|
||||
CAN_FilterInitStructure.CAN_FilterIdHigh = (ul_filter >> 16) & 0x0FFFF;;
|
||||
CAN_FilterInitStructure.CAN_FilterIdLow = ul_filter & 0x0FFFF;;
|
||||
CAN_FilterInitStructure.CAN_FilterMaskIdHigh = (ul_mask >> 16) & 0x0FFFF;;
|
||||
CAN_FilterInitStructure.CAN_FilterMaskIdLow = ul_mask & 0x0FFFF; ;
|
||||
CAN_FilterInitStructure.CAN_FilterFIFOAssignment = CAN_FIFO0;
|
||||
CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;
|
||||
CAN_FilterInit(&CAN_FilterInitStructure);
|
||||
|
||||
yeid_un.yecanid.destMACID = 0x1E;
|
||||
ul_filter = GetCanFilter(yeid_un);
|
||||
CAN_FilterInitStructure.CAN_FilterNumber = 1;
|
||||
CAN_FilterInitStructure.CAN_FilterIdHigh = (ul_filter >> 16) & 0x0FFFF;;
|
||||
CAN_FilterInitStructure.CAN_FilterIdLow = ul_filter & 0x0FFFF;;
|
||||
CAN_FilterInit(&CAN_FilterInitStructure);
|
||||
|
||||
yeid_un.yecanid.destMACID = 0x1F;
|
||||
ul_filter = GetCanFilter(yeid_un);
|
||||
CAN_FilterInitStructure.CAN_FilterNumber = 2;
|
||||
CAN_FilterInitStructure.CAN_FilterIdHigh = (ul_filter >> 16) & 0x0FFFF;;
|
||||
CAN_FilterInitStructure.CAN_FilterIdLow = ul_filter & 0x0FFFF;;
|
||||
CAN_FilterInit(&CAN_FilterInitStructure);
|
||||
|
||||
|
||||
CAN_OperatingModeRequest(CAN1,CAN_OperatingMode_Normal);
|
||||
|
||||
NVIC_InitTypeDef NVIC_InitStructure;
|
||||
|
||||
NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn;
|
||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
|
||||
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 4;
|
||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
||||
NVIC_Init(&NVIC_InitStructure);
|
||||
|
||||
CAN_ClearITPendingBit(CAN1, CAN_IT_FMP0);
|
||||
CAN_ITConfig(CAN1, CAN_IT_FMP0, ENABLE);
|
||||
can_tx_mutex = rt_mutex_create ("can0_tx_mutex",RT_IPC_FLAG_PRIO);
|
||||
|
||||
}
|
||||
/*
|
||||
@brief 根据设置CAN 的ID协议,获取帧过滤值
|
||||
*/
|
||||
static uint32_t GetCanFilter(YeCanID_un yeid)
|
||||
{
|
||||
uint32_t filter = 0;
|
||||
filter = yeid.Exide << 3;
|
||||
filter |= 0x04;//只接收扩展帧
|
||||
filter &= ~((uint32_t)0x003);//不限定帧类型
|
||||
return filter;
|
||||
}
|
||||
/*
|
||||
@brief CAN发送通讯帧
|
||||
@param 源地址
|
||||
@param 主机地址
|
||||
@param 发送数据缓存
|
||||
@param 发送数据长度
|
||||
@rtv 0 成功 1 失败
|
||||
*/
|
||||
uint8_t YeCan_SendFrame(uint8_t srcaddr,uint8_t dstaddr,const uint8_t* txdata, uint16_t len)
|
||||
{
|
||||
CanTxMsg transmit_message;
|
||||
uint8_t mailbox_number;
|
||||
YeCanID_un yeid_un;
|
||||
uint32_t time_out = 0;
|
||||
uint8_t uc_rtv = 0;
|
||||
//can_transmission_stop(CAN1,0);
|
||||
/* initialize transmit message */
|
||||
transmit_message.ExtId = 0x00;
|
||||
transmit_message.StdId = 0x00;
|
||||
transmit_message.RTR = CAN_RTR_DATA;
|
||||
transmit_message.IDE = CAN_ID_EXT;
|
||||
yeid_un.Exide = 0;
|
||||
yeid_un.yecanid.srcMACID = srcaddr;
|
||||
yeid_un.yecanid.destMACID = dstaddr;
|
||||
yeid_un.yecanid.ACK = 0;
|
||||
yeid_un.yecanid.FunClass = 1;
|
||||
yeid_un.yecanid.SegFlag = 0;
|
||||
yeid_un.yecanid.SegNum = 0;
|
||||
if(srcaddr == 0x00 || srcaddr == 0x1f)
|
||||
{
|
||||
time_out = 0;
|
||||
while(time_out < 5)
|
||||
{
|
||||
elec_led1_power(0);
|
||||
rt_thread_mdelay(50);
|
||||
elec_led1_power(1);
|
||||
rt_thread_mdelay(50);
|
||||
time_out++;
|
||||
|
||||
}
|
||||
}
|
||||
if(can_tx_mutex != RT_NULL)
|
||||
{
|
||||
if(RT_EOK != rt_mutex_take (can_tx_mutex,500))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if(len <= 8)
|
||||
{
|
||||
transmit_message.DLC = len;
|
||||
transmit_message.ExtId = yeid_un.Exide;
|
||||
memcpy(transmit_message.Data,txdata,8);
|
||||
|
||||
mailbox_number = CAN_Transmit(CAN1, &transmit_message);
|
||||
time_out = 5000;
|
||||
while( CAN_TxStatus_Ok != CAN_TransmitStatus(CAN1,mailbox_number) && time_out > 0)
|
||||
{
|
||||
time_out --;
|
||||
rt_hw_us_delay(20);
|
||||
}
|
||||
if(time_out == 0)
|
||||
{
|
||||
uc_rtv = 1;
|
||||
goto can0_tx_end;
|
||||
}
|
||||
goto can0_tx_end;
|
||||
}
|
||||
while(len > 8)
|
||||
{
|
||||
memcpy(transmit_message.Data,txdata,8);
|
||||
len -= 8;
|
||||
txdata += 8;
|
||||
|
||||
if(yeid_un.yecanid.SegNum == 0)
|
||||
{
|
||||
yeid_un.yecanid.SegFlag = 0x01;
|
||||
}else
|
||||
{
|
||||
yeid_un.yecanid.SegFlag = 0x02;
|
||||
}
|
||||
transmit_message.ExtId = yeid_un.Exide;
|
||||
transmit_message.DLC = 8;
|
||||
mailbox_number = CAN_Transmit(CAN1, &transmit_message);
|
||||
time_out = 5000;
|
||||
while( CAN_TxStatus_Ok != CAN_TransmitStatus(CAN1,mailbox_number) && time_out > 0)
|
||||
{
|
||||
time_out --;
|
||||
rt_hw_us_delay(20);
|
||||
}
|
||||
if(time_out == 0)
|
||||
{
|
||||
uc_rtv = 1;
|
||||
goto can0_tx_end;
|
||||
}
|
||||
yeid_un.yecanid.SegNum ++;
|
||||
}
|
||||
yeid_un.yecanid.SegFlag = 0x3;
|
||||
memcpy(transmit_message.Data,txdata,len);
|
||||
transmit_message.DLC = len;
|
||||
transmit_message.ExtId = yeid_un.Exide;
|
||||
mailbox_number = CAN_Transmit(CAN1, &transmit_message);
|
||||
time_out = 5000;
|
||||
while(CAN_TxStatus_Ok != CAN_TransmitStatus(CAN1,mailbox_number) && time_out > 0)
|
||||
{
|
||||
|
||||
time_out --;
|
||||
rt_hw_us_delay(20);
|
||||
}
|
||||
if(time_out == 0)
|
||||
{
|
||||
|
||||
uc_rtv = 1;
|
||||
}
|
||||
|
||||
can0_tx_end:
|
||||
CAN0_TX_BUSY_Flag = 0;
|
||||
rt_mutex_release(can_tx_mutex);
|
||||
return uc_rtv;
|
||||
}
|
||||
|
||||
|
||||
typedef struct{
|
||||
void (*end_irq)(void *t,uint32_t len);
|
||||
void *t;
|
||||
uint32_t rx_buff_size;
|
||||
}self_def;
|
||||
|
||||
static self_def g_self;
|
||||
|
||||
|
||||
|
||||
|
||||
static void save_data(void)
|
||||
{
|
||||
YeCanID_un yeid_un;
|
||||
if(receive_message.DLC > 0)
|
||||
{
|
||||
yeid_un.Exide = receive_message.ExtId;
|
||||
ul_exid = yeid_un.Exide << 3;
|
||||
ul_exid &= ul_can_mask;
|
||||
if(yeid_un.yecanid.SegFlag == 00)
|
||||
{
|
||||
memcpy(canrx_st.rx_databuf,receive_message.Data,receive_message.DLC);
|
||||
canrx_st.rx_index = receive_message.DLC;
|
||||
g_self.end_irq(g_self.t,canrx_st.rx_index);
|
||||
}
|
||||
else if(yeid_un.yecanid.SegFlag == 0x01)
|
||||
{
|
||||
canrx_st.seg_num = 0;
|
||||
memcpy(canrx_st.rx_databuf,receive_message.Data,receive_message.DLC);
|
||||
canrx_st.rx_index = receive_message.DLC;
|
||||
}else if(yeid_un.yecanid.SegFlag == 0x02)
|
||||
{
|
||||
if((canrx_st.seg_num+1) == yeid_un.yecanid.SegNum )
|
||||
{
|
||||
canrx_st.seg_num++;
|
||||
memcpy(canrx_st.rx_databuf+canrx_st.rx_index,receive_message.Data,receive_message.DLC);
|
||||
canrx_st.rx_index += receive_message.DLC;
|
||||
|
||||
}else{
|
||||
//error
|
||||
}
|
||||
}else if(yeid_un.yecanid.SegFlag == 0x03)
|
||||
{
|
||||
memcpy(canrx_st.rx_databuf+canrx_st.rx_index,receive_message.Data,receive_message.DLC);
|
||||
canrx_st.rx_index += receive_message.DLC;
|
||||
g_self.end_irq(g_self.t,canrx_st.rx_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void USB_LP_CAN1_RX0_IRQHandler(void)
|
||||
{
|
||||
rt_interrupt_enter();
|
||||
CAN_Receive(CAN1, CAN_FIFO0, &receive_message);
|
||||
if(g_self.end_irq&&canrx_st.rx_databuf){
|
||||
save_data();
|
||||
}
|
||||
CAN_ClearITPendingBit(CAN1, CAN_IT_FMP0);
|
||||
rt_interrupt_leave();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static int init(uart_def *u,int bsp)
|
||||
{
|
||||
YeCanInit();
|
||||
return 0;
|
||||
}
|
||||
static int deinit(uart_def *u)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static int set_irq(uart_def *u,void (*irq)(void *t,uint8_t d),void *t)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static int set_end_irq(uart_def *u,uint8_t *rx_buff,int rx_buff_size,
|
||||
void (*irq)(void *t,uint32_t len),void *t)
|
||||
{
|
||||
irq_disable();
|
||||
g_self.end_irq=irq;
|
||||
canrx_st.rx_databuf=rx_buff;
|
||||
g_self.rx_buff_size=rx_buff_size;
|
||||
g_self.t=t;
|
||||
irq_enable();
|
||||
return 0;
|
||||
}
|
||||
static int read(uart_def *u,uint8_t *b,int len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static int write(uart_def *u,const uint8_t *b,int len)
|
||||
{
|
||||
uint8_t src=b[4];
|
||||
uint8_t dst=b[5];
|
||||
uint8_t ret;
|
||||
ret=YeCan_SendFrame(src,dst,b,len);
|
||||
if(ret==0) return len;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
uart_init_export(can,init,deinit,set_irq,set_end_irq,read,write,0)
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct{
|
||||
uart_def *dev[2];
|
||||
int dev_index;
|
||||
int inited;
|
||||
void (*end_irq)(void *t,uint32_t len);
|
||||
void *t;
|
||||
}h_self_def;
|
||||
|
||||
static h_self_def g_hself;
|
||||
|
||||
static int h_init(uart_def *u,int bsp)
|
||||
{
|
||||
h_self_def *h=&g_hself;
|
||||
if(h->inited) return 0;
|
||||
h->dev[0]=dev_get("uart1");
|
||||
h->dev[1]=dev_get("can");
|
||||
h->dev[0]->init(h->dev[0],0);
|
||||
h->dev[1]->init(h->dev[1],0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int h_deinit(uart_def *u)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int h_set_irq(uart_def *u,void (*irq)(void *t,uint8_t d),void *t)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static void h_end_irq0(void *t,uint32_t len)
|
||||
{
|
||||
h_self_def *h=&g_hself;
|
||||
h->dev_index=0;
|
||||
if(h->end_irq)
|
||||
{
|
||||
h->end_irq(h->t,len);
|
||||
}
|
||||
}
|
||||
static void h_end_irq1(void *t,uint32_t len)
|
||||
{
|
||||
h_self_def *h=&g_hself;
|
||||
h->dev_index=1;
|
||||
if(h->end_irq)
|
||||
{
|
||||
h->end_irq(h->t,len);
|
||||
}
|
||||
}
|
||||
static int h_set_end_irq(uart_def *u,uint8_t *rx_buff,int rx_buff_size,
|
||||
void (*irq)(void *t,uint32_t len),void *t)
|
||||
{
|
||||
h_self_def *h=&g_hself;
|
||||
irq_disable();
|
||||
h->end_irq=irq;
|
||||
h->t=t;
|
||||
irq_enable();
|
||||
h->dev[0]->set_end_irq(h->dev[0],rx_buff,rx_buff_size,h_end_irq0,h);
|
||||
h->dev[1]->set_end_irq(h->dev[1],rx_buff,rx_buff_size,h_end_irq1,h);
|
||||
return 0;
|
||||
}
|
||||
static int h_read(uart_def *u,uint8_t *b,int len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static int h_write(uart_def *u,const uint8_t *b,int len)
|
||||
{
|
||||
h_self_def *h=&g_hself;
|
||||
uart_def *s=h->dev[h->dev_index];
|
||||
return s->write(s,b,len);
|
||||
}
|
||||
|
||||
|
||||
uart_init_export(host,h_init,h_deinit,h_set_irq,h_set_end_irq,h_read,h_write,0)
|
||||
|
||||
|
||||
|
||||
|
50
source/interface/if_can.h
Normal file
50
source/interface/if_can.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifndef if_can_h__
|
||||
#define if_can_h__
|
||||
|
||||
//#include "define.h"
|
||||
#include "stm32f10x_can.h"
|
||||
|
||||
typedef struct{
|
||||
uint32_t Reserve1 :3;
|
||||
uint32_t srcMACID :5;
|
||||
uint32_t Reserve0 :2;
|
||||
uint32_t destMACID :5;
|
||||
uint32_t ACK :1;
|
||||
uint32_t FunClass :6;
|
||||
uint32_t SegFlag :2;
|
||||
uint32_t SegNum :8;
|
||||
|
||||
}YeCanID_st;
|
||||
|
||||
typedef union{
|
||||
uint32_t Exide;
|
||||
YeCanID_st yecanid;
|
||||
}YeCanID_un;
|
||||
|
||||
|
||||
|
||||
typedef struct{
|
||||
|
||||
uint8_t *rx_databuf; //接收数据缓存
|
||||
uint8_t seg_num; //分段号
|
||||
uint8_t seg_flag;//分段标志
|
||||
uint16_t rx_index;//接收缓存下标
|
||||
}YeCanRxFrame_st;
|
||||
|
||||
extern volatile uint8_t CAN0_TX_BUSY_Flag;
|
||||
|
||||
/*
|
||||
@brief CAN通讯初始化, 包括CANgpio 过滤器
|
||||
*/
|
||||
void YeCanInit(void);
|
||||
/*
|
||||
@brief CAN发送通讯帧
|
||||
@param 源地址
|
||||
@param 主机地址
|
||||
@param 发送数据缓存
|
||||
@param 发送数据长度
|
||||
@rtv 0 成功 1 失败
|
||||
*/
|
||||
uint8_t YeCan_SendFrame(uint8_t srcaddr,uint8_t dstaddr,const uint8_t* txdata, uint16_t len);
|
||||
|
||||
#endif
|
@@ -6,7 +6,7 @@
|
||||
|
||||
|
||||
|
||||
#define BUILD_DATE "2023-09-20 17:48:39"
|
||||
#define BUILD_DATE "2023-10-06 18:40:44"
|
||||
#define SOFT_VERSION "0.03"
|
||||
|
||||
|
||||
|
@@ -12,7 +12,6 @@
|
||||
#include "signal.h"
|
||||
#include "prot_mcu.h"
|
||||
#include "debug.h"
|
||||
#include "handle.h"
|
||||
#include "prot_uc.h"
|
||||
#include "transmit.h"
|
||||
#include "commend.h"
|
||||
@@ -20,7 +19,6 @@
|
||||
#include "mymisc.h"
|
||||
#include "dev_backup.h"
|
||||
#include "compiler_info.h"
|
||||
#include "moter.h"
|
||||
|
||||
|
||||
|
||||
@@ -121,70 +119,9 @@ commend_export(scheme,scheme_info,"print scheme info")
|
||||
|
||||
|
||||
|
||||
typedef struct{
|
||||
int updata_run;
|
||||
}updata_def;
|
||||
static updata_def g_updata;
|
||||
static int updata_slave(list_def *argv)
|
||||
{
|
||||
void *ptr=flash_get_slave();
|
||||
tran_def *tran=app_variable("tran",0,0);
|
||||
uint8_t *data=ptr;
|
||||
data+=FLASH_FILE_HEAD_SIZE;
|
||||
flash_file *file=ptr;
|
||||
if(tran==0){
|
||||
DBG_WARN("can not find variable \"tran\"");
|
||||
return -1;
|
||||
}
|
||||
if(list_length(argv)<2){
|
||||
cmd_print("param num too less.");
|
||||
return -1;
|
||||
}
|
||||
list_def *addrs=str_atod_list(list_get_str(argv,1),',');
|
||||
for(int i=0;i<list_length(addrs);i++)
|
||||
{
|
||||
int addr=list_get_int(addrs,i);
|
||||
port_mcu *mcu=tran_get_portm(tran,addr-1);
|
||||
if(mcu){
|
||||
port_start(mcu,updata_creat(data,file->file_size));
|
||||
g_updata.updata_run++;
|
||||
}
|
||||
}
|
||||
cmd_print("start updata,addr=%s",str_temp(list_string(addrs)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void cmd_end_slot(void *obj,port_mcu *src,void *data,int ack,char *err_str)
|
||||
{
|
||||
updata_def *self=obj;
|
||||
if(self->updata_run>0)
|
||||
{
|
||||
cmd_print("addr:%d %s",port_get_addr(src),err_str);
|
||||
self->updata_run--;
|
||||
}
|
||||
}
|
||||
// 挂载命令行槽函数
|
||||
static int cmd_slot_init(void)
|
||||
{
|
||||
void *tr=app_variable("tran",0,0);
|
||||
if(tr){
|
||||
for(int i=0;i<20;i++){
|
||||
port_mcu *mcu=tran_get_portm(tr,i);
|
||||
// 连接操作结束信号
|
||||
if(mcu)
|
||||
connect(mcu,port_end_signal,0,&g_updata,cmd_end_slot);
|
||||
}
|
||||
}
|
||||
else{
|
||||
app_valid_call("tran",(void (*)(void *))cmd_slot_init,0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
app_init_export(cmd_slot_init);
|
||||
|
||||
|
||||
|
||||
commend_export(updatas,updata_slave,"updata slave")
|
||||
|
||||
|
||||
|
||||
@@ -219,23 +156,6 @@ commend_export(reboot,reboot,"reboot mcu")
|
||||
|
||||
|
||||
|
||||
static int moter(list_def *argv)
|
||||
{
|
||||
const sys_param_def *par=sys_param();
|
||||
cmd_print("moter ctl");
|
||||
if(list_length(argv)<3){
|
||||
cmd_print("param num too less.");
|
||||
return -1;
|
||||
}
|
||||
int fre=str_atoi(list_get_str(argv,1));
|
||||
int count=str_atoi(list_get_str(argv,2));
|
||||
moter_start(fre,count);
|
||||
cmd_print("moter start,fre=%d,count=%d",fre,count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
commend_export(moter,moter,"control moter up or down|use:moter [frequency] [count]")
|
||||
|
||||
|
||||
|
||||
|
@@ -6,15 +6,15 @@ import prebuild as time
|
||||
|
||||
|
||||
# 定义app和boot文件路径(没有尾缀)
|
||||
APP_FILE_SRC = "./Objects/app/coder_2channel_app"
|
||||
BOOT_FILE_SRC = "./Objects/boot/coder_2channel_boot"
|
||||
# APP_FILE_DST = "./Objects/coder_2channel_app"
|
||||
APP_FILE_DST = "./python/file/coder_2channel_app"
|
||||
BOOT_FILE_DST = "./Objects/coder_2channel_boot"
|
||||
APP_FILE_SRC = "./Objects/app/checker_slave_app"
|
||||
BOOT_FILE_SRC = "./Objects/boot/checker_slave_boot"
|
||||
# APP_FILE_DST = "./Objects/checker_slave_app"
|
||||
APP_FILE_DST = "./python/file/checker_slave_app"
|
||||
BOOT_FILE_DST = "./Objects/checker_slave_boot"
|
||||
|
||||
# 定义app和boot的数据库目录
|
||||
SQL_APP_PATH = "coder_stm32f1_app"
|
||||
SQL_BOOT_PATH = "coder_stm32f1_boot"
|
||||
SQL_APP_PATH = "checker_slave_app"
|
||||
SQL_BOOT_PATH = "checker_slave_boot"
|
||||
|
||||
|
||||
|
||||
|
@@ -36,7 +36,7 @@ static uint32_t _SysTick_Config(rt_uint32_t ticks)
|
||||
}
|
||||
|
||||
#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
|
||||
static uint32_t g_heap[20*1024/4];
|
||||
static uint32_t g_heap[10*1024/4];
|
||||
RT_WEAK void *rt_heap_begin_get(void)
|
||||
{
|
||||
return (void *)g_heap;
|
||||
|
@@ -22,7 +22,7 @@ typedef struct
|
||||
|
||||
|
||||
|
||||
#define SRAM_USER_SIZE (18*1024)
|
||||
#define SRAM_USER_SIZE (9*1024)
|
||||
#define MEM_BLOCK_SIZE (32)
|
||||
#define MEM_MAX_SIZE (((SRAM_USER_SIZE))*MEM_BLOCK_SIZE/(MEM_BLOCK_SIZE+2))
|
||||
#define MEM_ALLOC_TABLE_SIZE ((MEM_MAX_SIZE/MEM_BLOCK_SIZE)&(~3))
|
||||
|
@@ -1,470 +0,0 @@
|
||||
#include "stdio.h"
|
||||
#include "rtthread.h"
|
||||
#include "board.h"
|
||||
#include "mystdlib.h"
|
||||
#include "list.h"
|
||||
#include "mystring.h"
|
||||
#include "signal.h"
|
||||
#include "prot_mcu.h"
|
||||
#include "buff.h"
|
||||
#include "bytearray.h"
|
||||
#include "debug.h"
|
||||
#include "crc.h"
|
||||
|
||||
|
||||
|
||||
typedef struct{
|
||||
uint16_t no;
|
||||
list_def *cmds;//int
|
||||
uint8_t addr;
|
||||
uint8_t cmd;
|
||||
array_def *data;
|
||||
int retry;
|
||||
int timeout_ms;
|
||||
}protm_slave;
|
||||
|
||||
|
||||
|
||||
static int protm_slave_sub(void *a,void *b)
|
||||
{
|
||||
protm_slave *a_=a;
|
||||
protm_slave *b_=b;
|
||||
return a_->addr-b_->addr;
|
||||
}
|
||||
|
||||
static int protm_slave_del(void *t)
|
||||
{
|
||||
protm_slave *p=t;
|
||||
CHECK_DO(p->cmds,list_delete);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static protm_slave *protm_slave_creat(void)
|
||||
{
|
||||
protm_slave *p=calloc(1,sizeof(protm_slave));
|
||||
param_check(p);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
array_def *protm_decode(protm_def *p,array_def *data);
|
||||
protm_slave *protm_get_slave(protm_def *p,uint8_t addr);
|
||||
|
||||
|
||||
|
||||
typedef struct{
|
||||
array_def *data;
|
||||
int addr;
|
||||
}send_data_def;
|
||||
|
||||
|
||||
// 定义事件
|
||||
#define EVENT_RECV 0x1
|
||||
#define EVENT_SEND 0x2
|
||||
#define EVENT_TIMEOUT 0x4
|
||||
|
||||
|
||||
|
||||
struct _protm_def{
|
||||
uart_def *uart;
|
||||
array_def *buff;
|
||||
int num_to_recv;
|
||||
rt_event_t event;
|
||||
rt_timer_t timer;
|
||||
int run;
|
||||
char *str_err;
|
||||
list_def *slaves;//protm_slave
|
||||
list_def *slaves_addr;//int
|
||||
list_def *send_data;//send_data_def
|
||||
int in_send;//在发送状态时为1
|
||||
uint8_t recv_cmd;
|
||||
uint8_t recv_src;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static void recv_irq(void *t,uint8_t d)
|
||||
{
|
||||
protm_def *p=t;
|
||||
arr_append(p->buff,d);
|
||||
switch(arr_length(p->buff)){
|
||||
case 2:
|
||||
if(arr_get(p->buff,0)=='Y'&&arr_get(p->buff,1)=='e')
|
||||
{
|
||||
p->num_to_recv=4;
|
||||
}else{
|
||||
arr_remove(p->buff,0,1);
|
||||
p->num_to_recv=0;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
int len=arr_get(p->buff,2)|(arr_get(p->buff,3)<<8);
|
||||
p->num_to_recv=len;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// 此时一帧数据已完成
|
||||
if(p->num_to_recv>0&&p->num_to_recv==arr_length(p->buff))
|
||||
{
|
||||
rt_event_send(p->event,EVENT_RECV);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 与从机通信的串口是串行的,一个通信事务完成之后才能开始下一个通信
|
||||
* 协议层接收的通信事务是并行的,应用层来的通信任务会被放入队列
|
||||
*/
|
||||
|
||||
static void protm_send_next(void *t);
|
||||
int protm_send(protm_def *p,send_data_def *d);
|
||||
static void protm_send_timeout(void *t);
|
||||
static void protm_run(void *t)
|
||||
{
|
||||
protm_def *p=t;
|
||||
array_def *data;
|
||||
array_def *decode_data;
|
||||
uint32_t ev;
|
||||
while(p->run)
|
||||
{
|
||||
rt_event_recv(p->event,0xffffffff,RT_EVENT_FLAG_OR|RT_EVENT_FLAG_CLEAR,RT_WAITING_FOREVER,&ev);
|
||||
if(ev&EVENT_RECV)
|
||||
{
|
||||
// DBG_LOG("protmcu:recv event.");
|
||||
data=arr_duplicate(p->buff);
|
||||
arr_clear(p->buff);
|
||||
//DBG_LOG("recv:%s",str_temp(arr_string(data)));
|
||||
decode_data=protm_decode(p,data);
|
||||
arr_delete(data);
|
||||
emit protm_recv_signal(p,p->recv_src,p->recv_cmd,arr_temp(decode_data),str_temp(str_duplicate(p->str_err)));
|
||||
irq_disable();
|
||||
p->num_to_recv=0;
|
||||
irq_enable();
|
||||
protm_send_next(p);
|
||||
}
|
||||
else if(ev&EVENT_TIMEOUT)
|
||||
{
|
||||
protm_send_timeout(p);
|
||||
}
|
||||
if (ev&EVENT_SEND)
|
||||
{
|
||||
// DBG_LOG("protmcu:send event.");
|
||||
if(list_length(p->send_data)>0)
|
||||
{
|
||||
send_data_def *a=(send_data_def *)list_get(p->send_data,0);
|
||||
protm_send(p,a);
|
||||
}
|
||||
}
|
||||
ev=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 发送下一个
|
||||
static void protm_send_next(void *t)
|
||||
{
|
||||
protm_def *p=t;
|
||||
rt_timer_stop(p->timer);
|
||||
list_remove(p->send_data,0);
|
||||
// 如果发送列表中有数据,此时发送
|
||||
if (list_length(p->send_data)>0)
|
||||
{
|
||||
// DBG_LOG("protmcu:EVENT_SEND.");
|
||||
rt_event_send(p->event,EVENT_SEND);
|
||||
}
|
||||
else{
|
||||
irq_disable();
|
||||
p->in_send=0;
|
||||
irq_enable();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void protm_send_timeout_cb(void *t)
|
||||
{
|
||||
protm_def *p=t;
|
||||
rt_event_send(p->event,EVENT_TIMEOUT);
|
||||
}
|
||||
|
||||
// 接收超时
|
||||
static void protm_send_timeout(void *t)
|
||||
{
|
||||
protm_def *p=t;
|
||||
send_data_def *s=list_get(p->send_data,0);
|
||||
protm_slave *sl=protm_get_slave(p,s->addr);
|
||||
if(sl->retry>0){
|
||||
sl->retry--;
|
||||
DBG_WARN("slave:%d retry left ",s->addr,sl->retry);
|
||||
list_shift(p->send_data);
|
||||
}else{
|
||||
DBG_WARN("slave:%d retry timeout,remove the send data.",s->addr);
|
||||
list_remove(p->send_data,0);
|
||||
}
|
||||
// 如果发送列表中有数据,此时发送
|
||||
if (list_length(p->send_data)>0)
|
||||
{
|
||||
// DBG_LOG("protmcu:EVENT_SEND.");
|
||||
rt_event_send(p->event,EVENT_SEND);
|
||||
}
|
||||
else{
|
||||
irq_disable();
|
||||
p->in_send=0;
|
||||
irq_enable();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 发送队列删除条目
|
||||
static int _list_send_data_del(void *t)
|
||||
{
|
||||
send_data_def *a=t;
|
||||
arr_delete(a->data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
protm_def *protm_creat(uart_def *uart,int *addrs,int num)
|
||||
{
|
||||
static int count=0;
|
||||
char name[20]={0};
|
||||
protm_def *p=calloc(1,sizeof(protm_def));
|
||||
param_check(p);
|
||||
p->uart=uart;
|
||||
sprintf(name,"protm_event#%d",count);
|
||||
p->event=rt_event_create(name,RT_IPC_FLAG_FIFO);
|
||||
p->buff=arr_creat();
|
||||
p->run=1;
|
||||
p->slaves=list_creat(sizeof(protm_slave),protm_slave_sub,protm_slave_del,0);
|
||||
p->slaves_addr=list_creat_int();
|
||||
p->send_data=list_creat(sizeof(send_data_def),0,_list_send_data_del,0);
|
||||
// 创建超时定时器,超过指定时间则不再等待从机返回
|
||||
p->timer=rt_timer_create("port_timer",protm_send_timeout_cb,p,
|
||||
rt_tick_from_millisecond(55),
|
||||
RT_TIMER_FLAG_ONE_SHOT|RT_TIMER_FLAG_SOFT_TIMER);
|
||||
list_appends(p->slaves_addr,addrs,num);
|
||||
sprintf(name,"protm_t#%d",count);
|
||||
rt_thread_t rt_t=rt_thread_create(name,protm_run,p,512,5,20);
|
||||
rt_thread_startup(rt_t);
|
||||
p->uart->init(p->uart);
|
||||
p->uart->set_irq(p->uart,recv_irq,p);
|
||||
|
||||
count++;
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
// 得到指定地址的从机,找不到则添加
|
||||
protm_slave *protm_get_slave(protm_def *p,uint8_t addr)
|
||||
{
|
||||
protm_slave *r=0;
|
||||
for(int i=0;i<list_length(p->slaves);i++)
|
||||
{
|
||||
r=list_get(p->slaves,i);
|
||||
if(r->addr==addr)
|
||||
return r;
|
||||
}
|
||||
r=protm_slave_creat();
|
||||
r->addr=addr;
|
||||
r->cmds=list_creat_int();
|
||||
r->no=0;
|
||||
list_append(p->slaves,r);
|
||||
free(r);
|
||||
return list_get(p->slaves,-1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 设置所有从机流水号
|
||||
void protm_set_no_all(protm_def *p,uint16_t no,list_def *cmd/*int*/)
|
||||
{
|
||||
for(int i=0;i<list_length(p->slaves);i++)
|
||||
{
|
||||
protm_slave *s=list_get(p->slaves,i);
|
||||
s->no=no;
|
||||
list_clear(s->cmds);
|
||||
list_append_from(s->cmds,cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 设置单个从机流水号
|
||||
void protm_set_no(protm_def *p,uint8_t addr,uint16_t no,list_def *cmd/*int*/)
|
||||
{
|
||||
protm_slave *s=protm_get_slave(p,addr);
|
||||
s->no=no;
|
||||
list_clear(s->cmds);
|
||||
list_append_from(s->cmds,cmd);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 解码
|
||||
array_def *protm_decode(protm_def *p,array_def *data)
|
||||
{
|
||||
array_def *r=arr_creat();
|
||||
param_check(r);
|
||||
str_set(p->str_err,"ok");
|
||||
if(arr_length(data)<10)
|
||||
{
|
||||
DBG_WARN("recv data len too less.");
|
||||
str_set(p->str_err,"recv data len too less.");
|
||||
return r;
|
||||
}
|
||||
uint8_t src=arr_get(data,4);
|
||||
p->recv_src=src;
|
||||
uint16_t len=arr_get(data,2)|(arr_get(data,3)<<8);
|
||||
uint8_t crc=crc_crc8(arr_data(data),arr_length(data)-1);
|
||||
if(len!=arr_length(data))
|
||||
{
|
||||
// 如果长度不相等则产生了数据丢失
|
||||
DBG_WARN("recv data have lossed.");
|
||||
str_set(p->str_err,"recv data have lossed.");
|
||||
return r;
|
||||
}
|
||||
uint16_t no=arr_get(data,7)|(arr_get(data,8)<<8);
|
||||
uint16_t h_no=protm_get_slave(p,src)->no;
|
||||
if(no!=h_no)
|
||||
{
|
||||
// 发送一条指令等待其返回,此时流水号应相同
|
||||
//DBG_WARN("slave_addr=%d cmd_no error:h_no=%d,no=%d.",src,h_no,no);
|
||||
//str_set(p->str_err,"cmd no err.");
|
||||
//return r;
|
||||
}
|
||||
if(crc!=arr_get(data,-1))
|
||||
{
|
||||
DBG_WARN("recv data crc check error:%02x,%02x.",crc,arr_get(data,-1));
|
||||
str_set(p->str_err,"crc check err.");
|
||||
}
|
||||
p->recv_cmd=arr_get(data,6);
|
||||
list_def *cmds=protm_get_slave(p,src)->cmds;
|
||||
if(list_contains(cmds,(int []){p->recv_cmd})==0){
|
||||
// 命令号校验不对
|
||||
DBG_WARN("cmd check err.cmds=%s,recv_cmd=%d",tappend(list_string(cmds),0),p->recv_cmd);
|
||||
str_set(p->str_err,"cmd check err.");
|
||||
}
|
||||
arr_delete(r);
|
||||
return arr_mid(data,9,len-10);
|
||||
}
|
||||
|
||||
|
||||
// 编码
|
||||
array_def *protm_encode(protm_def *p,uint8_t dst,uint8_t cmd,list_def *comp_cmd/*int*/,array_def *data)
|
||||
{
|
||||
array_def *t=arr_creat();
|
||||
param_check(t);
|
||||
uint16_t len=arr_length(data)+10;
|
||||
protm_slave *slave=protm_get_slave(p,dst);
|
||||
slave->no++;
|
||||
protm_set_no(p,dst,slave->no,comp_cmd);
|
||||
arr_append(t,'Y');
|
||||
arr_append(t,'e');
|
||||
arr_append(t,len&0xff);
|
||||
arr_append(t,len>>8);
|
||||
arr_append(t,0);// 源地址
|
||||
arr_append(t,dst);// 目标地址
|
||||
arr_append(t,cmd);// 命令码
|
||||
arr_append(t,slave->no&0xff);
|
||||
arr_append(t,slave->no>>8);
|
||||
arr_appends_from(t,data);
|
||||
arr_append(t,crc_crc8(arr_data(t),arr_length(t)));
|
||||
return t;
|
||||
}
|
||||
|
||||
// 发送数据,发送前先开启超时定时器
|
||||
int protm_send(protm_def *p,send_data_def *d)
|
||||
{
|
||||
rt_tick_t tick=0;
|
||||
protm_slave *s=protm_get_slave(p,d->addr);
|
||||
//DBG_LOG("send:%s",str_temp(arr_string(d->data)));
|
||||
tick=rt_tick_from_millisecond(s->timeout_ms);
|
||||
rt_timer_control(p->timer,RT_TIMER_CTRL_SET_TIME,&tick);
|
||||
rt_timer_start(p->timer);
|
||||
if(d->data==0)
|
||||
{
|
||||
DBG_WARN("addr=%d,d->data=0",d->addr);
|
||||
return 0;
|
||||
}
|
||||
return p->uart->write(p->uart,arr_data(d->data),arr_length(d->data));
|
||||
}
|
||||
|
||||
|
||||
//// 槽函数,发送数据到指定地址
|
||||
//void protm_send_call(protm_def *p,list_def *addrs/*int*/,uint8_t cmd,list_def *comp_cmd/*int*/,array_def *data)
|
||||
//{
|
||||
// param_check(p);
|
||||
// for(int i=0;i<list_length(addrs);i++)
|
||||
// {
|
||||
// uint8_t dst=(uint8_t)list_get_int(addrs,i);
|
||||
// if(list_contains(p->slaves_addr,(int []){dst})==1)
|
||||
// {
|
||||
// array_def *t=0;
|
||||
// t=protm_encode(p,dst,cmd,comp_cmd,data);
|
||||
// protm_send(p,t);
|
||||
// arr_delete(t);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
|
||||
// 槽函数,发送数据到指定地址
|
||||
void protm_send_call(protm_def *p,uint8_t addr,uint8_t cmd,list_def *comp_cmd/*int*/,array_def *data,int timeout_ms,int retry)
|
||||
{
|
||||
param_check(p);
|
||||
if(list_contains(p->slaves_addr,(int []){addr})==1)
|
||||
{
|
||||
array_def *t=0;
|
||||
t=protm_encode(p,addr,cmd,comp_cmd,data);
|
||||
//protm_send(p,t);
|
||||
//arr_delete(t);
|
||||
// 添加到发送队列,发送必须等到回应或超时才能发送下一个
|
||||
DBG_LOG("send to:%d",addr);
|
||||
send_data_def sd={0};
|
||||
sd.addr=addr;sd.data=t;
|
||||
protm_slave *s=protm_get_slave(p,addr);
|
||||
s->retry=retry;
|
||||
s->timeout_ms=timeout_ms;
|
||||
list_append(p->send_data,&sd);
|
||||
if(p->in_send==0){
|
||||
irq_disable();
|
||||
p->in_send=1;
|
||||
irq_enable();
|
||||
//DBG_LOG("send call");
|
||||
rt_event_send(p->event,EVENT_SEND);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 返回1表示此地址可以发送到这个端口
|
||||
int protm_contains(protm_def *p,uint8_t addr)
|
||||
{
|
||||
param_check(p);
|
||||
return list_contains(p->slaves_addr,(int []){addr});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -1,22 +1,11 @@
|
||||
#include "stdlib.h"
|
||||
#include "signal.h"
|
||||
#include "commend.h"
|
||||
#include "handle.h"
|
||||
#include "handle_for_checker.h"
|
||||
#include "handle_for_coder.h"
|
||||
#include "input.h"
|
||||
#include "log.h"
|
||||
#include "moter.h"
|
||||
#include "process.h"
|
||||
#include "prot_mcu.h"
|
||||
#include "prot_uc.h"
|
||||
#include "tcp.h"
|
||||
#include "transmit.h"
|
||||
#include "tran_for_checker.h"
|
||||
#include "tran_for_coder.h"
|
||||
#include "tran_for_coder2.h"
|
||||
#include "tran_for_coder2ch.h"
|
||||
#include "udp.h"
|
||||
#include "tran_for_slave.h"
|
||||
|
||||
|
||||
|
||||
@@ -34,53 +23,6 @@ signal_export(cmd_reply_signal);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void port_send_signal(port_mcu *obj,uint8_t addr,uint8_t cmd,list_def *comp_cmd,array_def *data,int timeout_ms,int retry)
|
||||
{
|
||||
uint32_t param[6];
|
||||
param[0]=(uint32_t)addr;
|
||||
param[1]=(uint32_t)cmd;
|
||||
param[2]=(uint32_t)comp_cmd;
|
||||
param[3]=(uint32_t)data;
|
||||
param[4]=(uint32_t)timeout_ms;
|
||||
param[5]=(uint32_t)retry;
|
||||
_signal_emit(obj,port_send_signal,param,6);
|
||||
}
|
||||
signal_export(port_send_signal);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void port_end_signal(port_mcu *obj,port_mcu *src,void *data,int ack,char *err_str)
|
||||
{
|
||||
uint32_t param[4];
|
||||
param[0]=(uint32_t)src;
|
||||
param[1]=(uint32_t)data;
|
||||
param[2]=(uint32_t)ack;
|
||||
param[3]=(uint32_t)err_str;
|
||||
_signal_emit(obj,port_end_signal,param,4);
|
||||
}
|
||||
signal_export(port_end_signal);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void moter_end_signal(void *m)
|
||||
{
|
||||
_signal_emit(m,moter_end_signal,0,0);
|
||||
}
|
||||
signal_export(moter_end_signal);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -107,24 +49,6 @@ signal_export(protu_recv_signal);
|
||||
uint32_t param[4];
|
||||
param[0]=(uint32_t)codec_name;
|
||||
param[1]=(uint32_t)cmd;
|
||||
param[3]=(uint32_t)err_str;
|
||||
_signal_emit(obj,protm_recv_signal,param,4);
|
||||
}
|
||||
signal_export(protm_recv_signal);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void protu_recv_signal(void *obj,const char *codec_name,uint8_t cmd,array_def *data,char *err_str)
|
||||
{
|
||||
uint32_t param[4];
|
||||
param[0]=(uint32_t)codec_name;
|
||||
param[1]=(uint32_t)cmd;
|
||||
param[2]=(uint32_t)data;
|
||||
param[3]=(uint32_t)err_str;
|
||||
param[2]=(uint32_t)data;
|
||||
param[3]=(uint32_t)err_str;
|
||||
_signal_emit(obj,protu_recv_signal,param,4);
|
||||
@@ -146,28 +70,6 @@ signal_export(tran_send_signal);
|
||||
signal_export(tran_reply_signal);
|
||||
|
||||
|
||||
|
||||
void tcp_recv_signal(void *obj,array_def *data)
|
||||
{
|
||||
uint32_t param[1];
|
||||
param[0]=(uint32_t)data;
|
||||
_signal_emit(obj,tcp_recv_signal,param,1);
|
||||
}
|
||||
signal_export(tcp_recv_signal);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void tran_reply_signal(tran_def *p,array_def *data)
|
||||
{
|
||||
uint32_t param[1];
|
||||
param[0]=(uint32_t)data;
|
||||
_signal_emit(p,tran_reply_signal,param,1);
|
||||
}
|
||||
signal_export(tran_reply_signal);
|
||||
|
||||
|
||||
|
||||
@@ -187,16 +89,3 @@ signal_export(code2_start_signal);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void coder_live_send_signal(void *obj,uint8_t cmd,array_def *data)
|
||||
{
|
||||
uint32_t param[2];
|
||||
param[0]=(uint32_t)cmd;
|
||||
param[1]=(uint32_t)data;
|
||||
_signal_emit(obj,coder_live_send_signal,param,2);
|
||||
}
|
||||
signal_export(coder_live_send_signal);
|
||||
|
||||
|
||||
|
@@ -1,20 +1,16 @@
|
||||
#include "tran_for_coder2.h"
|
||||
#include "tran_for_coder2ch.h"
|
||||
#include "debug.h"
|
||||
#include "mymisc.h"
|
||||
#include "mystdlib.h"
|
||||
#include "board.h"
|
||||
#include "dev_flash.h"
|
||||
#include "tcp.h"
|
||||
#include "prot_uc.h"
|
||||
#include "handle_for_coder.h"
|
||||
#include "handle_for_checker.h"
|
||||
#include "coder_lib.h"
|
||||
#include "JQ_PSDGenerate.h"
|
||||
#include "mystring.h"
|
||||
#include "coder_judge.h"
|
||||
#include "JQ_UIDGenerate.h"
|
||||
|
||||
#include "transmit.h"
|
||||
|
||||
|
||||
|
||||
@@ -154,10 +150,10 @@ static uint32_t in_range_err(const uint8_t *src_data,const uint8_t *errbit)
|
||||
|
||||
|
||||
// 注码完成
|
||||
static void write_uid_end(ucport_def *u,port_mcu *src,void *data,int ack,char *err_str)
|
||||
static void write_uid_end(ucport_def *u,void *src,void *data,int ack,char *err_str)
|
||||
{
|
||||
write_uid_def *w=(write_uid_def *)u;
|
||||
uint8_t addr=port_get_addr(src);
|
||||
uint8_t addr=0;
|
||||
if(addr<=0||addr>w->addrs_num){
|
||||
DBG_WARN("addr err:%d",addr);
|
||||
return;
|
||||
@@ -263,17 +259,14 @@ static ucport_def *write_uid(tran_def *t, uint8_t cmd,array_def *data)
|
||||
u->ack[i*38+0]=i+slave_addr_off();
|
||||
u->ack[i*38+1]=1;
|
||||
if(1){
|
||||
port_mcu *mcu=tran_get_portm(u->u.p,i);
|
||||
// 这里打开赋码操作
|
||||
if(mcu){
|
||||
if(check_shell_code(u->item[i].shell_code)){
|
||||
port_start(mcu,code2_creat(8,4,u->item[i].uid_pw_hex));
|
||||
}else{
|
||||
// 管壳码无效,不注码,此时默认已ack
|
||||
// 管壳码无效不视为失败
|
||||
ret=0;
|
||||
write_uid_fillret(u,i+1,0xff);
|
||||
}
|
||||
if(check_shell_code(u->item[i].shell_code)){
|
||||
// 开始注码
|
||||
//port_start(mcu,code2_creat(8,4,u->item[i].uid_pw_hex));
|
||||
}else{
|
||||
// 管壳码无效,不注码,此时默认已ack
|
||||
// 管壳码无效不视为失败
|
||||
ret=0;
|
||||
write_uid_fillret(u,i+1,0xff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,89 +309,6 @@ transmit_export(ym_checker,0x02,write_uid)
|
||||
|
||||
|
||||
|
||||
typedef struct{
|
||||
rt_timer_t timer;
|
||||
void *protu;
|
||||
}live_keeper_def;
|
||||
|
||||
|
||||
static void live_start(live_keeper_def *t)
|
||||
{
|
||||
rt_tick_t tick=0;
|
||||
tick=rt_tick_from_millisecond(1000);
|
||||
rt_timer_control(t->timer,RT_TIMER_CTRL_SET_TIME,&tick);
|
||||
rt_timer_start(t->timer);
|
||||
}
|
||||
static void live_recv(live_keeper_def *t)
|
||||
{
|
||||
rt_tick_t tick=0;
|
||||
tick=rt_tick_from_millisecond(5000);
|
||||
rt_timer_control(t->timer,RT_TIMER_CTRL_SET_TIME,&tick);
|
||||
rt_timer_start(t->timer);
|
||||
//rt_timer_stop(t->timer);
|
||||
}
|
||||
|
||||
|
||||
// cmd=0x8a
|
||||
static void live_send(void *p)
|
||||
{
|
||||
live_keeper_def *live=p;
|
||||
const sys_param_def *par=sys_param();
|
||||
tran_def *t=app_variable("tran",0,0);
|
||||
uint16_t slave_online=0;
|
||||
if(t){
|
||||
slave_online=tran_get_slave_online(t);
|
||||
}
|
||||
//protu_codec_set(live->protu,protu_find_codec("ym_checker"));
|
||||
|
||||
array_def *d=arr_creat();
|
||||
arr_append(d,coder_extract_chip(0));// 模块类型
|
||||
arr_append(d,0xff);
|
||||
arr_append(d,0x03);
|
||||
arr_append(d,par->local_id&0xff);
|
||||
arr_append(d,slave_online&0xff);// 在线的小板
|
||||
arr_append(d,(slave_online>>8)&0xff);
|
||||
emit coder2_live_send_signal(p,0x8a,arr_temp(d));
|
||||
//DBG_LOG("send liver data.");
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void init_for_coder2ch(void *t)
|
||||
{
|
||||
void *protu=app_variable("protu",0,0);
|
||||
if(protu){
|
||||
live_keeper_def *live=calloc(1,sizeof(live_keeper_def));
|
||||
live->protu=protu;
|
||||
live->timer=rt_timer_create("live_t",live_send,live,
|
||||
rt_tick_from_millisecond(1000),
|
||||
RT_TIMER_FLAG_PERIODIC|RT_TIMER_FLAG_SOFT_TIMER);
|
||||
protu_codec_set(protu,protu_find_codec("ym_checker"));
|
||||
connect(protu,protu_recv_signal,0,live,live_recv);
|
||||
connect(live,coder2_live_send_signal,0,protu,protu_send_call);
|
||||
DBG_LOG("coder2ch liver created");
|
||||
live_start(live);
|
||||
}else{
|
||||
DBG_WARN("can not fond variable \"protu\"");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 如果本机为赋码仪并且连接类型为tcp
|
||||
// 初始化心跳
|
||||
static int init_live_keeper(void)
|
||||
{
|
||||
const sys_param_def *par=sys_param();
|
||||
app_valid_call("protu",init_for_coder2ch,0);
|
||||
return 0;
|
||||
}
|
||||
app_init_export(init_live_keeper);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
34
source/task/tran_for_slave.c
Normal file
34
source/task/tran_for_slave.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "tran_for_slave.h"
|
||||
#include "debug.h"
|
||||
#include "mymisc.h"
|
||||
#include "mystdlib.h"
|
||||
#include "board.h"
|
||||
#include "dev_flash.h"
|
||||
#include "prot_uc.h"
|
||||
#include "coder_lib.h"
|
||||
#include "JQ_PSDGenerate.h"
|
||||
#include "mystring.h"
|
||||
#include "coder_judge.h"
|
||||
#include "JQ_UIDGenerate.h"
|
||||
#include "transmit.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
14
source/task/tran_for_slave.h
Normal file
14
source/task/tran_for_slave.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef tran_for_slave_h__
|
||||
#define tran_for_slave_h__
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
@@ -20,49 +20,15 @@
|
||||
|
||||
|
||||
|
||||
#define PORT_NUM 2
|
||||
|
||||
|
||||
typedef struct _tran_def{
|
||||
ucport_def *u;
|
||||
port_mcu *port[PORT_NUM];
|
||||
uint32_t slave_online;// 对应位为1则从机在线
|
||||
int is_busy;
|
||||
}tran_def;
|
||||
|
||||
|
||||
|
||||
// 打印从机状态
|
||||
static void tran_print_slave_stat(void *t)
|
||||
{
|
||||
list_def *l=list_creat_int();
|
||||
uint32_t a=tran_get_slave_online(t);
|
||||
for(int i=0;i<PORT_NUM;i++)
|
||||
{
|
||||
if(a&(1<<i)){
|
||||
list_append_int(l,i+1);
|
||||
}
|
||||
}
|
||||
DBG_LOG("slave online stat:%s",str_temp(list_string(l)));
|
||||
//DBG_LOG("slave online stat:%08x",a);
|
||||
list_delete(l);
|
||||
}
|
||||
|
||||
|
||||
// 扫描从机
|
||||
static void tran_scan_slave(void *t)
|
||||
{
|
||||
for(int i=0;i<PORT_NUM;i++)
|
||||
{
|
||||
// 只给在线设备升级方案
|
||||
port_mcu *mcu=tran_get_portm(t,i);
|
||||
if(mcu&&(tran_get_slave_online(t)&(1<<i))){
|
||||
// f9用于获取运行状态,失败则设备不在线
|
||||
port_start(mcu,usercmd_creat(0xf9,arr_temp(arr_creat())));
|
||||
}
|
||||
}
|
||||
later_execute(tran_print_slave_stat,t,5500);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -71,27 +37,18 @@ static int tran_init(void)
|
||||
{
|
||||
sig_thread t=thread_creat(10);
|
||||
tran_def *tran= tran_creat(t);
|
||||
tran->slave_online=0xfffff;
|
||||
app_variable("tran",tran,0);
|
||||
later_execute(tran_scan_slave,tran,500);
|
||||
return 0;
|
||||
}
|
||||
app_init_export(tran_init);
|
||||
|
||||
|
||||
void tran_end_slot(tran_def *obj,port_mcu *src,void *data,int ack,char *err_str);
|
||||
void tran_end_slot(tran_def *obj,void *src,void *data,int ack,char *err_str);
|
||||
|
||||
tran_def *tran_creat(sig_thread t)
|
||||
{
|
||||
tran_def *tr=calloc(1,sizeof(tran_def));
|
||||
param_check(tr);
|
||||
port_init();
|
||||
for(int i=0;i<PORT_NUM;i++)
|
||||
{
|
||||
tr->port[i]=port_creat(i+1,t);
|
||||
// 连接操作结束信号
|
||||
connect(tr->port[i],port_end_signal,0,tr,tran_end_slot);
|
||||
}
|
||||
return tr;
|
||||
}
|
||||
|
||||
@@ -133,33 +90,16 @@ void tran_recv_slot(tran_def *t,const char *codec_name,uint8_t cmd,array_def *da
|
||||
}
|
||||
}
|
||||
|
||||
void tran_set_slave_online(tran_def *t,uint8_t addr,int stat)
|
||||
{
|
||||
param_check(t);
|
||||
uint32_t a=0;
|
||||
a=1<<(addr-1);
|
||||
if(stat)
|
||||
t->slave_online|=a;
|
||||
else{
|
||||
t->slave_online&=(~a);
|
||||
//DBG_LOG("a=%08x",a);
|
||||
}
|
||||
}
|
||||
uint32_t tran_get_slave_online(tran_def *t)
|
||||
{
|
||||
param_check(t);
|
||||
return t->slave_online;
|
||||
}
|
||||
|
||||
void tran_end_slot(tran_def *obj,port_mcu *src,void *data,int ack,char *err_str)
|
||||
|
||||
|
||||
void tran_end_slot(tran_def *obj,void *src,void *data,int ack,char *err_str)
|
||||
{
|
||||
//DBG_LOG("tran end slot");
|
||||
param_check(obj);
|
||||
if(strcmp(err_str,"timeout")==0)
|
||||
{
|
||||
tran_set_slave_online(obj,port_get_addr(src),0);
|
||||
}else{
|
||||
tran_set_slave_online(obj,port_get_addr(src),1);
|
||||
}
|
||||
if((obj->u)&&obj->u->doend)
|
||||
obj->u->doend(obj->u,src,data,ack,err_str);
|
||||
@@ -175,13 +115,7 @@ int tran_get_busy(tran_def *t)
|
||||
}
|
||||
|
||||
|
||||
// 获取指定通道
|
||||
port_mcu *tran_get_portm(tran_def *t,int index)
|
||||
{
|
||||
if(index<0||index>=PORT_NUM)
|
||||
return 0;
|
||||
return t->port[index];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -374,13 +308,6 @@ static void when_scheme_done(ucport_def *u)
|
||||
DBG_LOG("memused:%d",mem_perused());
|
||||
rt_thread_mdelay(100);
|
||||
DBG_LOG("memused:%d",mem_perused());
|
||||
for(int i=0;i<PORT_NUM;i++)
|
||||
{
|
||||
// 只给在线设备升级方案
|
||||
port_mcu *mcu=tran_get_portm(tran,i);
|
||||
if(mcu&&(tran_get_slave_online(tran)&(1<<i)))
|
||||
port_start(mcu,updata_scheme_creat(check_scheme()->slave_data,2048));
|
||||
}
|
||||
}
|
||||
static ucport_def *tran_scheme(tran_def *t, uint8_t cmd,array_def *data)
|
||||
{
|
||||
|
@@ -2,9 +2,9 @@
|
||||
#define transmit_h__
|
||||
|
||||
#include "rtthread.h"
|
||||
#include "handle.h"
|
||||
#include "signal.h"
|
||||
|
||||
#include "stdint.h"
|
||||
#include "bytearray.h"
|
||||
|
||||
|
||||
// 错误码定义
|
||||
@@ -25,7 +25,7 @@ typedef struct _ucport_def{
|
||||
tran_def *p;
|
||||
int (*dolater)(struct _ucport_def *u,uint8_t cmd,array_def *data,char *err_str);
|
||||
void (*del)(struct _ucport_def *h);
|
||||
void (*doend)(struct _ucport_def *h,port_mcu *src,void *data,int ack,char *err_str);
|
||||
void (*doend)(struct _ucport_def *h,void *src,void *data,int ack,char *err_str);
|
||||
}ucport_def;
|
||||
|
||||
|
||||
@@ -57,8 +57,6 @@ void tran_recv_slot(tran_def *t,const char *codec_name,uint8_t cmd,array_def *da
|
||||
|
||||
void tran_set_busy(tran_def *t,int busy);
|
||||
int tran_get_busy(tran_def *t);
|
||||
port_mcu *tran_get_portm(tran_def *t,int index);
|
||||
uint32_t tran_get_slave_online(tran_def *t);
|
||||
|
||||
|
||||
signal tran_reply_signal(tran_def *p,array_def *data);
|
||||
|
Reference in New Issue
Block a user