.
This commit is contained in:
parent
f82b125112
commit
a70e50b822
@ -1117,8 +1117,8 @@
|
|||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\User\task\dr16_task.c</PathWithFileName>
|
<PathWithFileName>..\User\task\up_task.c</PathWithFileName>
|
||||||
<FilenameWithoutPath>dr16_task.c</FilenameWithoutPath>
|
<FilenameWithoutPath>up_task.c</FilenameWithoutPath>
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<bShared>0</bShared>
|
<bShared>0</bShared>
|
||||||
</File>
|
</File>
|
||||||
@ -1129,20 +1129,8 @@
|
|||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\User\task\r12ds_task.c</PathWithFileName>
|
<PathWithFileName>..\User\task\rc_task.c</PathWithFileName>
|
||||||
<FilenameWithoutPath>r12ds_task.c</FilenameWithoutPath>
|
<FilenameWithoutPath>rc_task.c</FilenameWithoutPath>
|
||||||
<RteFlg>0</RteFlg>
|
|
||||||
<bShared>0</bShared>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<GroupNumber>8</GroupNumber>
|
|
||||||
<FileNumber>73</FileNumber>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<tvExp>0</tvExp>
|
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
|
||||||
<bDave2>0</bDave2>
|
|
||||||
<PathWithFileName>..\User\task\up_task.c</PathWithFileName>
|
|
||||||
<FilenameWithoutPath>up_task.c</FilenameWithoutPath>
|
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<bShared>0</bShared>
|
<bShared>0</bShared>
|
||||||
</File>
|
</File>
|
||||||
@ -1156,7 +1144,7 @@
|
|||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>9</GroupNumber>
|
<GroupNumber>9</GroupNumber>
|
||||||
<FileNumber>74</FileNumber>
|
<FileNumber>73</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
@ -1168,7 +1156,7 @@
|
|||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>9</GroupNumber>
|
<GroupNumber>9</GroupNumber>
|
||||||
<FileNumber>75</FileNumber>
|
<FileNumber>74</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
@ -1180,7 +1168,7 @@
|
|||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>9</GroupNumber>
|
<GroupNumber>9</GroupNumber>
|
||||||
<FileNumber>76</FileNumber>
|
<FileNumber>75</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
@ -1192,7 +1180,7 @@
|
|||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>9</GroupNumber>
|
<GroupNumber>9</GroupNumber>
|
||||||
<FileNumber>77</FileNumber>
|
<FileNumber>76</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
@ -1204,7 +1192,7 @@
|
|||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>9</GroupNumber>
|
<GroupNumber>9</GroupNumber>
|
||||||
<FileNumber>78</FileNumber>
|
<FileNumber>77</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
@ -1216,7 +1204,7 @@
|
|||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>9</GroupNumber>
|
<GroupNumber>9</GroupNumber>
|
||||||
<FileNumber>79</FileNumber>
|
<FileNumber>78</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
@ -1236,7 +1224,7 @@
|
|||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>10</GroupNumber>
|
<GroupNumber>10</GroupNumber>
|
||||||
<FileNumber>80</FileNumber>
|
<FileNumber>79</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
@ -1248,7 +1236,7 @@
|
|||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>10</GroupNumber>
|
<GroupNumber>10</GroupNumber>
|
||||||
<FileNumber>81</FileNumber>
|
<FileNumber>80</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
@ -1260,7 +1248,7 @@
|
|||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>10</GroupNumber>
|
<GroupNumber>10</GroupNumber>
|
||||||
<FileNumber>82</FileNumber>
|
<FileNumber>81</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
@ -1272,7 +1260,7 @@
|
|||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>10</GroupNumber>
|
<GroupNumber>10</GroupNumber>
|
||||||
<FileNumber>83</FileNumber>
|
<FileNumber>82</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
@ -1284,7 +1272,7 @@
|
|||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>10</GroupNumber>
|
<GroupNumber>10</GroupNumber>
|
||||||
<FileNumber>84</FileNumber>
|
<FileNumber>83</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
@ -1296,31 +1284,7 @@
|
|||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>10</GroupNumber>
|
<GroupNumber>10</GroupNumber>
|
||||||
<FileNumber>85</FileNumber>
|
<FileNumber>84</FileNumber>
|
||||||
<FileType>1</FileType>
|
|
||||||
<tvExp>0</tvExp>
|
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
|
||||||
<bDave2>0</bDave2>
|
|
||||||
<PathWithFileName>..\User\device\dr16.c</PathWithFileName>
|
|
||||||
<FilenameWithoutPath>dr16.c</FilenameWithoutPath>
|
|
||||||
<RteFlg>0</RteFlg>
|
|
||||||
<bShared>0</bShared>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<GroupNumber>10</GroupNumber>
|
|
||||||
<FileNumber>86</FileNumber>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<tvExp>0</tvExp>
|
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
|
||||||
<bDave2>0</bDave2>
|
|
||||||
<PathWithFileName>..\User\device\r12ds.c</PathWithFileName>
|
|
||||||
<FilenameWithoutPath>r12ds.c</FilenameWithoutPath>
|
|
||||||
<RteFlg>0</RteFlg>
|
|
||||||
<bShared>0</bShared>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<GroupNumber>10</GroupNumber>
|
|
||||||
<FileNumber>87</FileNumber>
|
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
@ -1330,17 +1294,29 @@
|
|||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<bShared>0</bShared>
|
<bShared>0</bShared>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<GroupNumber>10</GroupNumber>
|
||||||
|
<FileNumber>85</FileNumber>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<tvExp>0</tvExp>
|
||||||
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
<bDave2>0</bDave2>
|
||||||
|
<PathWithFileName>..\User\device\rc.c</PathWithFileName>
|
||||||
|
<FilenameWithoutPath>rc.c</FilenameWithoutPath>
|
||||||
|
<RteFlg>0</RteFlg>
|
||||||
|
<bShared>0</bShared>
|
||||||
|
</File>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>Application/User/USB_DEVICE/App</GroupName>
|
<GroupName>Application/User/USB_DEVICE/App</GroupName>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>1</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<cbSel>0</cbSel>
|
<cbSel>0</cbSel>
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>11</GroupNumber>
|
<GroupNumber>11</GroupNumber>
|
||||||
<FileNumber>88</FileNumber>
|
<FileNumber>86</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
@ -1352,7 +1328,7 @@
|
|||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>11</GroupNumber>
|
<GroupNumber>11</GroupNumber>
|
||||||
<FileNumber>89</FileNumber>
|
<FileNumber>87</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
@ -1364,7 +1340,7 @@
|
|||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>11</GroupNumber>
|
<GroupNumber>11</GroupNumber>
|
||||||
<FileNumber>90</FileNumber>
|
<FileNumber>88</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
@ -1378,13 +1354,13 @@
|
|||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>Application/User/USB_DEVICE/Target</GroupName>
|
<GroupName>Application/User/USB_DEVICE/Target</GroupName>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>1</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<cbSel>0</cbSel>
|
<cbSel>0</cbSel>
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>12</GroupNumber>
|
<GroupNumber>12</GroupNumber>
|
||||||
<FileNumber>91</FileNumber>
|
<FileNumber>89</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
@ -1398,13 +1374,13 @@
|
|||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>Middlewares/USB_Device_Library</GroupName>
|
<GroupName>Middlewares/USB_Device_Library</GroupName>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>1</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<cbSel>0</cbSel>
|
<cbSel>0</cbSel>
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>13</GroupNumber>
|
<GroupNumber>13</GroupNumber>
|
||||||
<FileNumber>92</FileNumber>
|
<FileNumber>90</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
@ -1416,7 +1392,7 @@
|
|||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>13</GroupNumber>
|
<GroupNumber>13</GroupNumber>
|
||||||
<FileNumber>93</FileNumber>
|
<FileNumber>91</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
@ -1428,7 +1404,7 @@
|
|||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>13</GroupNumber>
|
<GroupNumber>13</GroupNumber>
|
||||||
<FileNumber>94</FileNumber>
|
<FileNumber>92</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
@ -1440,7 +1416,7 @@
|
|||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>13</GroupNumber>
|
<GroupNumber>13</GroupNumber>
|
||||||
<FileNumber>95</FileNumber>
|
<FileNumber>93</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -1228,21 +1228,16 @@
|
|||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\User\task\error_detect_task.c</FilePath>
|
<FilePath>..\User\task\error_detect_task.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
|
||||||
<FileName>dr16_task.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\User\task\dr16_task.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>r12ds_task.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\User\task\r12ds_task.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
<File>
|
||||||
<FileName>up_task.c</FileName>
|
<FileName>up_task.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\User\task\up_task.c</FilePath>
|
<FilePath>..\User\task\up_task.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>rc_task.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\User\task\rc_task.c</FilePath>
|
||||||
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
@ -1308,21 +1303,16 @@
|
|||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\User\device\vofa.c</FilePath>
|
<FilePath>..\User\device\vofa.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
|
||||||
<FileName>dr16.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\User\device\dr16.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>r12ds.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\User\device\r12ds.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
<File>
|
||||||
<FileName>GO_M8010_6_Driver.c</FileName>
|
<FileName>GO_M8010_6_Driver.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\User\device\GO_M8010_6_Driver.c</FilePath>
|
<FilePath>..\User\device\GO_M8010_6_Driver.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>rc.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\User\device\rc.c</FilePath>
|
||||||
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
|
Binary file not shown.
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#define SBUS_RX_BUF_NUM 50u
|
#define SBUS_RX_BUF_NUM 50u
|
||||||
|
|
||||||
#define RC_FRAME_LENGTH 25u
|
#define RC_FRAME_LENGTH 25u
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
#include "LD_remote.h"
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "bsp_usart.h"
|
|
||||||
#include "error_detect.h"
|
|
||||||
|
|
||||||
static uint8_t sbus_rx_buf_new[SBUS_RX_BUF_NUM]; // SBUS 数据缓冲区
|
|
||||||
static RC_Ctrl_New_t rc_ctrl_new; // SBUS 数据结构
|
|
||||||
|
|
||||||
/* SBUS 数据解析 */
|
|
||||||
static void sbus_to_rc_new(volatile const uint8_t *sbus_buf) {
|
|
||||||
if (sbus_buf == NULL) return;
|
|
||||||
|
|
||||||
rc_ctrl_new.ch[0] = (sbus_buf[1] | (sbus_buf[2] << 8)) & 0x07FF;
|
|
||||||
rc_ctrl_new.ch[1] = ((sbus_buf[2] >> 3) | (sbus_buf[3] << 5)) & 0x07FF;
|
|
||||||
rc_ctrl_new.ch[2] = ((sbus_buf[3] >> 6) | (sbus_buf[4] << 2) | (sbus_buf[5] << 10)) & 0x07FF;
|
|
||||||
rc_ctrl_new.ch[3] = ((sbus_buf[5] >> 1) | (sbus_buf[6] << 7)) & 0x07FF;
|
|
||||||
|
|
||||||
rc_ctrl_new.sw[0] = ((sbus_buf[6] >> 4) | (sbus_buf[7] << 4)) & 0x07FF;
|
|
||||||
rc_ctrl_new.sw[1] = ((sbus_buf[7] >> 7) | (sbus_buf[8] << 1) | (sbus_buf[9] << 9)) & 0x07FF;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 初始化函数 */
|
|
||||||
void RC_New_Init(void) {
|
|
||||||
HAL_UARTEx_ReceiveToIdle_DMA(&huart3, sbus_rx_buf_new, SBUS_RX_BUF_NUM);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 获取数据指针 */
|
|
||||||
const RC_Ctrl_New_t* RC_New_GetData(void) {
|
|
||||||
return &rc_ctrl_new;
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
#ifndef LD_H
|
|
||||||
#define LD_H
|
|
||||||
#include "user_math.h"
|
|
||||||
|
|
||||||
|
|
||||||
#include "main.h"
|
|
||||||
|
|
||||||
/* SBUS 数据结构 */
|
|
||||||
typedef struct {
|
|
||||||
int16_t ch[4]; // 4 个通道
|
|
||||||
int16_t sw[8]; // 8 个开关
|
|
||||||
} RC_Ctrl_New_t;
|
|
||||||
|
|
||||||
/* 函数声明 */
|
|
||||||
void RC_New_Init(void);
|
|
||||||
const RC_Ctrl_New_t* RC_New_GetData(void);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
|||||||
#include "motor_control.h"
|
|
||||||
#include "pid.h"
|
|
||||||
#include "user_math.h"
|
|
||||||
#include "device\device.h"
|
|
||||||
#include "can_use.h"
|
|
||||||
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
|||||||
#ifndef _MOTOR_CONTROL_H_
|
|
||||||
#define _MOTOR_CONTROL_H_
|
|
||||||
|
|
||||||
#include "struct_typedef.h"
|
|
||||||
#include "pid.h"
|
|
||||||
|
|
||||||
/*大疆电机解算数据*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint16_t ecd;
|
|
||||||
int16_t speed_rpm;
|
|
||||||
int16_t given_current;
|
|
||||||
uint16_t temperate;
|
|
||||||
int16_t last_ecd;
|
|
||||||
int16_t round_cnt;
|
|
||||||
int16_t total_angle;
|
|
||||||
uint16_t offset_ecd;
|
|
||||||
uint32_t msg_cnt;
|
|
||||||
} DJmotor_measure_t;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,192 +0,0 @@
|
|||||||
/*
|
|
||||||
乐迪r12ds遥控器。
|
|
||||||
需要根据实际的遥控器通道修改解析的函数 该遥控器采用sbus 用的uart3
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* Includes ----------------------------------------------------------------- */
|
|
||||||
#include "r12ds.h"
|
|
||||||
#include "main.h"
|
|
||||||
#include "error_detect.h"
|
|
||||||
#include <string.h>
|
|
||||||
#include "cmd.h"
|
|
||||||
#include "user_math.h"
|
|
||||||
|
|
||||||
#ifdef r12ds_t
|
|
||||||
extern UART_HandleTypeDef huart3;
|
|
||||||
extern DMA_HandleTypeDef hdma_usart3_rx;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
osThreadId_t thread_alert;
|
|
||||||
|
|
||||||
int buf0ready =0; /*不起作用*/
|
|
||||||
int buf1ready =0;
|
|
||||||
|
|
||||||
/* Private function -------------------------------------------------------- */
|
|
||||||
static void R12DS_IdleCallback(void) {
|
|
||||||
static uint16_t this_time_rx_len = 0;
|
|
||||||
if( (hdma_usart3_rx.Instance->CR & DMA_SxCR_CT) == RESET)
|
|
||||||
{
|
|
||||||
//current memory buffer used is memory0
|
|
||||||
|
|
||||||
//disable dma to change dma register
|
|
||||||
__HAL_DMA_DISABLE(&hdma_usart3_rx);
|
|
||||||
|
|
||||||
//get received data length, length = set_data_length - remain_length
|
|
||||||
this_time_rx_len = SBUS_RX_BUF_NUM - hdma_usart3_rx.Instance->NDTR;
|
|
||||||
|
|
||||||
//reset set_data_length
|
|
||||||
hdma_usart3_rx.Instance->NDTR = SBUS_RX_BUF_NUM;
|
|
||||||
|
|
||||||
//change memory0 to memory1
|
|
||||||
hdma_usart3_rx.Instance->CR |= DMA_SxCR_CT;
|
|
||||||
|
|
||||||
//enable dma
|
|
||||||
__HAL_DMA_ENABLE(&hdma_usart3_rx);
|
|
||||||
|
|
||||||
//1 frame length is correct data
|
|
||||||
if(this_time_rx_len == RC_FRAME_LENGTH)
|
|
||||||
{
|
|
||||||
// osThreadFlagsSet(thread_alert,SIGNAL_R12DS_BUF0_REDY);
|
|
||||||
buf0ready = 1;
|
|
||||||
// detect_hook(R12DS_TOE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
__HAL_DMA_DISABLE(&hdma_usart3_rx);
|
|
||||||
|
|
||||||
this_time_rx_len = SBUS_RX_BUF_NUM - hdma_usart3_rx.Instance->NDTR;
|
|
||||||
|
|
||||||
hdma_usart3_rx.Instance->NDTR = SBUS_RX_BUF_NUM;
|
|
||||||
|
|
||||||
//change memory1 to memory0
|
|
||||||
DMA1_Stream1->CR &= ~(DMA_SxCR_CT);
|
|
||||||
|
|
||||||
__HAL_DMA_ENABLE(&hdma_usart3_rx);
|
|
||||||
|
|
||||||
if(this_time_rx_len == RC_FRAME_LENGTH)
|
|
||||||
{
|
|
||||||
// osThreadFlagsSet(thread_alert,SIGNAL_R12DS_BUF1_REDY);
|
|
||||||
buf1ready = 1;
|
|
||||||
// detect_hook(R12DS_TOE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Exported functions ------------------------------------------------------- */
|
|
||||||
|
|
||||||
|
|
||||||
int8_t R12ds_DMA_Init(uint8_t *rx1_buf, uint8_t *rx2_buf, uint16_t dma_buf_num)
|
|
||||||
{
|
|
||||||
if((thread_alert = osThreadGetId()) == NULL ) return DEVICE_ERR_NULL;
|
|
||||||
//enable the dma transfer for the receiver request
|
|
||||||
SET_BIT(huart3.Instance->CR3, USART_CR3_DMAR);
|
|
||||||
|
|
||||||
//enable idle interrupt
|
|
||||||
__HAL_UART_ENABLE_IT(&huart3, UART_IT_IDLE);
|
|
||||||
|
|
||||||
//disable dma, to change the dma register
|
|
||||||
__HAL_DMA_DISABLE(&hdma_usart3_rx);
|
|
||||||
|
|
||||||
//disable dma again but why?
|
|
||||||
//what's the condition?
|
|
||||||
while(hdma_usart3_rx.Instance->CR & DMA_SxCR_EN)
|
|
||||||
{
|
|
||||||
__HAL_DMA_DISABLE(&hdma_usart3_rx);
|
|
||||||
}
|
|
||||||
|
|
||||||
//??
|
|
||||||
hdma_usart3_rx.Instance->PAR = (uint32_t) & (USART3->DR);
|
|
||||||
|
|
||||||
//memory buffer 1
|
|
||||||
hdma_usart3_rx.Instance->M0AR = (uint32_t)(rx1_buf);
|
|
||||||
|
|
||||||
//momory buffer 2
|
|
||||||
hdma_usart3_rx.Instance->M1AR = (uint32_t)(rx2_buf);
|
|
||||||
|
|
||||||
//data length
|
|
||||||
hdma_usart3_rx.Instance->NDTR = dma_buf_num;
|
|
||||||
|
|
||||||
//enable double memory buffer
|
|
||||||
SET_BIT(hdma_usart3_rx.Instance->CR, DMA_SxCR_DBM);
|
|
||||||
|
|
||||||
|
|
||||||
//enable dma
|
|
||||||
__HAL_DMA_ENABLE(&hdma_usart3_rx);
|
|
||||||
|
|
||||||
BSP_UART_RegisterCallback(BSP_UART_REMOTE, BSP_UART_IDLE_LINE_CB,
|
|
||||||
R12DS_IdleCallback);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int8_t sbus_to_rc(volatile const uint8_t *sbus_buf, CMD_RC_t *rc_ctrl)
|
|
||||||
{
|
|
||||||
if (sbus_buf == NULL || rc_ctrl == NULL)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
rc_ctrl->ch_x = (sbus_buf[1] | (sbus_buf[2] << 8)) & 0x07ff; //Channel 1 x
|
|
||||||
rc_ctrl->ch_y = ((sbus_buf[2] >> 3) | (sbus_buf[3] << 5)) & 0x07ff; //Channel 2 mul
|
|
||||||
rc_ctrl->mul= ((sbus_buf[3] >> 6) | (sbus_buf[4] << 2) | //Channel 3 y
|
|
||||||
(sbus_buf[5] << 10)) &0x07ff;
|
|
||||||
rc_ctrl->ch_w = ((sbus_buf[5] >> 1) | (sbus_buf[6] << 7)) & 0x07ff; //Channel 4 w
|
|
||||||
|
|
||||||
rc_ctrl->key[0] = ((int16_t)sbus_buf[6] >> 4 | ((int16_t)sbus_buf[7] << 4 )) & 0x07FF; //Channel 5
|
|
||||||
rc_ctrl->key[1] = ((int16_t)sbus_buf[7] >> 7 | ((int16_t)sbus_buf[8] << 1 ) | (int16_t)sbus_buf[9] << 9 ) & 0x07FF; //Channel 6
|
|
||||||
rc_ctrl->key[2] = ((int16_t)sbus_buf[9] >> 2 | ((int16_t)sbus_buf[10] << 6 )) & 0x07FF;; //Channel 7
|
|
||||||
rc_ctrl->key[3] = ((int16_t)sbus_buf[10] >> 5 | ((int16_t)sbus_buf[11] << 3 )) & 0x07FF; //Channel 8
|
|
||||||
rc_ctrl->key[4] = ((int16_t)sbus_buf[12] << 0 | ((int16_t)sbus_buf[13] << 8 )) & 0x07FF; //Channel 9
|
|
||||||
rc_ctrl->key[5] = ((int16_t)sbus_buf[13] >> 3 | ((int16_t)sbus_buf[14] << 5 )) & 0x07FF; //Channel 10
|
|
||||||
rc_ctrl->key[6] = ((int16_t)sbus_buf[14] >> 6 | ((int16_t)sbus_buf[15] << 2 ) | (int16_t)sbus_buf[16] << 10 ) & 0x07FF; //Channel 11
|
|
||||||
rc_ctrl->key[7] = ((int16_t)sbus_buf[16] >> 1 | ((int16_t)sbus_buf[17] << 7 )) & 0x07FF; //Channel 12
|
|
||||||
|
|
||||||
rc_ctrl->ch_y -= RC_CH_VALUE_OFFSET;
|
|
||||||
rc_ctrl->ch_x -= RC_CH_VALUE_OFFSET;
|
|
||||||
rc_ctrl->mul -= RC_CH_VALUE_OFFSET;
|
|
||||||
rc_ctrl->ch_w -= RC_CH_VALUE_OFFSET;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
rc_ctrl->ch_y -= 4; //y(-694,693)
|
|
||||||
rc_ctrl->ch_x += 3; //x(-693,694)
|
|
||||||
rc_ctrl->mul = rc_ctrl->mul; //m(-518,843)
|
|
||||||
rc_ctrl->ch_w += 4; //w(-694,693)
|
|
||||||
|
|
||||||
rc_ctrl->key[2] = map_fp32(rc_ctrl->key[2],306,1694,1694,306);
|
|
||||||
rc_ctrl->key[3] = map_fp32(rc_ctrl->key[3],306,1694,1694,306);
|
|
||||||
rc_ctrl->ch_x = map_fp32(rc_ctrl->ch_x,700,-800,-700,700); //x
|
|
||||||
rc_ctrl->ch_y = map_fp32(rc_ctrl->ch_y,-900,796,700,-700); //y
|
|
||||||
rc_ctrl->mul = map_fp32(rc_ctrl->mul,-632,901,25,0); //m
|
|
||||||
rc_ctrl->ch_w = map_fp32(rc_ctrl->ch_w,-820,780,-700,700);
|
|
||||||
rc_ctrl->ch_w = 0.5f*(rc_ctrl->ch_w);
|
|
||||||
rc_ctrl->ch_x = -0.5f*(rc_ctrl->ch_x);
|
|
||||||
rc_ctrl->ch_y = 0.5f*(rc_ctrl->ch_y);
|
|
||||||
//
|
|
||||||
//̀死区(-5,5)
|
|
||||||
if(rc_ctrl->ch_y>-15&&rc_ctrl->ch_y<15) rc_ctrl->ch_y=0;
|
|
||||||
if(rc_ctrl->ch_x>-15&&rc_ctrl->ch_x<15) rc_ctrl->ch_x=0;
|
|
||||||
if(rc_ctrl->mul>=0&&rc_ctrl->mul<=3) rc_ctrl->mul=0;
|
|
||||||
if(rc_ctrl->ch_w>-15&&rc_ctrl->ch_w<15) rc_ctrl->ch_w=0;
|
|
||||||
|
|
||||||
|
|
||||||
if( (((int16_t)sbus_buf[16] >> 1 | ((int16_t)sbus_buf[17] << 7 )) & 0x07FF )<380) rc_ctrl->offline =1; //遥控器掉线
|
|
||||||
else rc_ctrl->offline =0;
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
|||||||
#ifndef _R12DS_H
|
|
||||||
#define _R12DS_H
|
|
||||||
|
|
||||||
#include <cmsis_os2.h>
|
|
||||||
#include "device.h"
|
|
||||||
#include "bsp_usart.h"
|
|
||||||
#include "cmd.h"
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef r12ds_t
|
|
||||||
|
|
||||||
#define RC_FRAME_LENGTH 25u
|
|
||||||
|
|
||||||
|
|
||||||
#define RC_CH_VALUE_OFFSET ((uint16_t)1024)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int8_t R12ds_DMA_Init(uint8_t *rx1_buf, uint8_t *rx2_buf, uint16_t dma_buf_num);
|
|
||||||
|
|
||||||
int8_t sbus_to_rc(volatile const uint8_t *sbus_buf,CMD_RC_t *rc_ctrl);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Includes ----------------------------------------------------------------- */
|
/* Includes ----------------------------------------------------------------- */
|
||||||
#include "dr16.h"
|
#include "rc.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -72,14 +72,14 @@ int8_t LD_ParseRaw( RC_ctrl_t *rc_ctrl)
|
|||||||
(cbuf[5] << 10)) &0x07ff;
|
(cbuf[5] << 10)) &0x07ff;
|
||||||
rc_ctrl->ch[3] = ((cbuf[5] >> 1) | (cbuf[6] << 7)) & 0x07ff; //!< Channel 3
|
rc_ctrl->ch[3] = ((cbuf[5] >> 1) | (cbuf[6] << 7)) & 0x07ff; //!< Channel 3
|
||||||
|
|
||||||
rc_ctrl->sw[0] = ((int16_t)cbuf[6] >> 4 | ((int16_t)cbuf[7] << 4 )) & 0x07FF; //!< Switch left
|
rc_ctrl->sw[0] = ((int16_t)cbuf[6] >> 4 | ((int16_t)cbuf[7] << 4 )) & 0x07FF;
|
||||||
rc_ctrl->sw[1] = ((int16_t)cbuf[7] >> 7 | ((int16_t)cbuf[8] << 1 ) | (int16_t)cbuf[9] << 9 ) & 0x07FF; //!< Switch right
|
rc_ctrl->sw[1] = ((int16_t)cbuf[7] >> 7 | ((int16_t)cbuf[8] << 1 ) | (int16_t)cbuf[9] << 9 ) & 0x07FF;
|
||||||
rc_ctrl->sw[2] = ((int16_t)cbuf[9] >> 2 | ((int16_t)cbuf[10] << 6 )) & 0x07FF;; //!< Mouse X axis
|
rc_ctrl->sw[2] = ((int16_t)cbuf[9] >> 2 | ((int16_t)cbuf[10] << 6 )) & 0x07FF;;
|
||||||
rc_ctrl->sw[3] = ((int16_t)cbuf[10] >> 5 | ((int16_t)cbuf[11] << 3 )) & 0x07FF; //!< Mouse Y axis
|
rc_ctrl->sw[3] = ((int16_t)cbuf[10] >> 5 | ((int16_t)cbuf[11] << 3 )) & 0x07FF;
|
||||||
rc_ctrl->sw[4] = ((int16_t)cbuf[12] << 0 | ((int16_t)cbuf[13] << 8 )) & 0x07FF; //!< Mouse Z axis
|
rc_ctrl->sw[4] = ((int16_t)cbuf[12] << 0 | ((int16_t)cbuf[13] << 8 )) & 0x07FF;
|
||||||
rc_ctrl->sw[5] = ((int16_t)cbuf[13] >> 3 | ((int16_t)cbuf[14] << 5 )) & 0x07FF; //!< Mouse Left Is Press ?
|
rc_ctrl->sw[5] = ((int16_t)cbuf[13] >> 3 | ((int16_t)cbuf[14] << 5 )) & 0x07FF;
|
||||||
rc_ctrl->sw[6] = ((int16_t)cbuf[14] >> 6 | ((int16_t)cbuf[15] << 2 ) | (int16_t)cbuf[16] << 10 ) & 0x07FF; //!< Mouse Right Is Press ?
|
rc_ctrl->sw[6] = ((int16_t)cbuf[14] >> 6 | ((int16_t)cbuf[15] << 2 ) | (int16_t)cbuf[16] << 10 ) & 0x07FF;
|
||||||
rc_ctrl->sw[7] = ((int16_t)cbuf[16] >> 1 | ((int16_t)cbuf[17] << 7 )) & 0x07FF; //!< KeyBoard value
|
rc_ctrl->sw[7] = ((int16_t)cbuf[16] >> 1 | ((int16_t)cbuf[17] << 7 )) & 0x07FF;
|
||||||
|
|
||||||
rc_ctrl->ch[0] -= RC_CH_VALUE_MID;
|
rc_ctrl->ch[0] -= RC_CH_VALUE_MID;
|
||||||
rc_ctrl->ch[1] -= RC_CH_VALUE_MID;
|
rc_ctrl->ch[1] -= RC_CH_VALUE_MID;
|
||||||
@ -114,10 +114,11 @@ int8_t LD_ParseRaw( RC_ctrl_t *rc_ctrl)
|
|||||||
rc_ctrl->map_ch[3]=expo_map(rc_ctrl->map_ch[3],0.7f);
|
rc_ctrl->map_ch[3]=expo_map(rc_ctrl->map_ch[3],0.7f);
|
||||||
|
|
||||||
//死区(-30,30)
|
//死区(-30,30)
|
||||||
if(rc_ctrl->map_ch[0]>-0.05&&rc_ctrl->map_ch[0]<0.05) rc_ctrl->map_ch[0]=0;
|
if(rc_ctrl->map_ch[0]>-0.05f&&rc_ctrl->map_ch[0]<0.05f) rc_ctrl->map_ch[0]=0;
|
||||||
if(rc_ctrl->map_ch[1]>-0.05&&rc_ctrl->map_ch[1]<0.05) rc_ctrl->map_ch[1]=0;
|
if(rc_ctrl->map_ch[1]>-0.05f&&rc_ctrl->map_ch[1]<0.05f) rc_ctrl->map_ch[1]=0;
|
||||||
if(rc_ctrl->map_ch[2]>-0.05&&rc_ctrl->map_ch[2]<0.05) rc_ctrl->map_ch[2]=0;
|
if(rc_ctrl->map_ch[2]>-0.05f&&rc_ctrl->map_ch[2]<0.05f) rc_ctrl->map_ch[2]=0;
|
||||||
if(rc_ctrl->map_ch[3]>-0.05&&rc_ctrl->map_ch[3]<0.05) rc_ctrl->map_ch[3]=0;
|
if(rc_ctrl->map_ch[3]>-0.05f&&rc_ctrl->map_ch[3]<0.05f) rc_ctrl->map_ch[3]=0;
|
||||||
|
return 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
/*dr16数据解析+校验 */
|
/*dr16数据解析+校验 */
|
@ -1,9 +1,9 @@
|
|||||||
#ifndef DR16_h
|
#ifndef RC_h
|
||||||
#define DR16_h
|
#define RC_h
|
||||||
|
|
||||||
/* Includes ----------------------------------------------------------------- */
|
/* Includes ----------------------------------------------------------------- */
|
||||||
#include <cmsis_os2.h>
|
#include <cmsis_os2.h>
|
||||||
|
#include "bsp_usart.h"
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "user_math.h"
|
#include "user_math.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
@ -34,9 +34,9 @@ typedef struct {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define SBUS_RX_BUF_NUM 25u
|
//#define SBUS_RX_BUF_NUM 25u
|
||||||
|
|
||||||
#define RC_FRAME_LENGTH 18u
|
//#define RC_FRAME_LENGTH 18u
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,185 +0,0 @@
|
|||||||
/**
|
|
||||||
****************************(C) COPYRIGHT 2019 DJI****************************
|
|
||||||
* @file remote_control.c/h
|
|
||||||
* @brief 遥控器处理,遥控器是通过类似SBUS的协议传输,利用DMA传输方式节约CPU
|
|
||||||
* 资源,利用串口空闲中断来拉起处理函数,同时提供一些掉线重启DMA,串口
|
|
||||||
* 的方式保证热插拔的稳定性。
|
|
||||||
* @note 该任务是通过串口中断启动,不是freeRTOS任务
|
|
||||||
* @history
|
|
||||||
* Version Date Author Modification
|
|
||||||
* V1.0.0 Dec-01-2019 RM 1. 完成
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
==============================================================================
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
@endverbatim
|
|
||||||
****************************(C) COPYRIGHT 2019 DJI****************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "remote_control.h"
|
|
||||||
#include "main.h"
|
|
||||||
|
|
||||||
|
|
||||||
extern UART_HandleTypeDef huart3;
|
|
||||||
extern DMA_HandleTypeDef hdma_usart3_rx;
|
|
||||||
|
|
||||||
static void sbus_to_rc(volatile const uint8_t *sbus_buf, RC_ctrl_t *rc_ctrl);
|
|
||||||
|
|
||||||
RC_ctrl_t rc_ctrl;
|
|
||||||
static uint8_t sbus_rx_buf[2][RC_FRAME_LENGTH];
|
|
||||||
uint8_t remote_ready = 0;//遥控器准备完成
|
|
||||||
|
|
||||||
void remote_control_init(void)
|
|
||||||
{
|
|
||||||
RC_init(sbus_rx_buf[0], sbus_rx_buf[1], RC_FRAME_LENGTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//串口中断
|
|
||||||
void USART3_IRQHandler(void)
|
|
||||||
{
|
|
||||||
//have received data ???
|
|
||||||
if(huart3.Instance->SR & UART_FLAG_RXNE)
|
|
||||||
{
|
|
||||||
__HAL_UART_CLEAR_FEFLAG(&huart3);
|
|
||||||
}
|
|
||||||
else if(USART3->SR & UART_FLAG_IDLE)
|
|
||||||
{
|
|
||||||
|
|
||||||
static uint16_t this_time_rx_len = 0;
|
|
||||||
__HAL_UART_CLEAR_PEFLAG(&huart3);
|
|
||||||
|
|
||||||
if( (hdma_usart3_rx.Instance->CR & DMA_SxCR_CT) == RESET)
|
|
||||||
{
|
|
||||||
//current memory buffer used is memory0
|
|
||||||
|
|
||||||
//disable dma to change dma register
|
|
||||||
__HAL_DMA_DISABLE(&hdma_usart3_rx);
|
|
||||||
|
|
||||||
//get received data length, length = set_data_length - remain_length
|
|
||||||
this_time_rx_len = SBUS_RX_BUF_NUM - hdma_usart3_rx.Instance->NDTR;
|
|
||||||
|
|
||||||
//reset set_data_length
|
|
||||||
hdma_usart3_rx.Instance->NDTR = SBUS_RX_BUF_NUM;
|
|
||||||
|
|
||||||
//change memory0 to memory1
|
|
||||||
hdma_usart3_rx.Instance->CR |= DMA_SxCR_CT;
|
|
||||||
|
|
||||||
//enable dma
|
|
||||||
__HAL_DMA_ENABLE(&hdma_usart3_rx);
|
|
||||||
|
|
||||||
//1 frame length is correct data
|
|
||||||
if(this_time_rx_len == RC_FRAME_LENGTH)
|
|
||||||
{
|
|
||||||
sbus_to_rc(sbus_rx_buf[0], &rc_ctrl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
__HAL_DMA_DISABLE(&hdma_usart3_rx);
|
|
||||||
|
|
||||||
this_time_rx_len = SBUS_RX_BUF_NUM - hdma_usart3_rx.Instance->NDTR;
|
|
||||||
|
|
||||||
hdma_usart3_rx.Instance->NDTR = SBUS_RX_BUF_NUM;
|
|
||||||
|
|
||||||
//change memory1 to memory0
|
|
||||||
DMA1_Stream1->CR &= ~(DMA_SxCR_CT);
|
|
||||||
|
|
||||||
__HAL_DMA_ENABLE(&hdma_usart3_rx);
|
|
||||||
|
|
||||||
if(this_time_rx_len == RC_FRAME_LENGTH)
|
|
||||||
{
|
|
||||||
sbus_to_rc(sbus_rx_buf[1], &rc_ctrl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sbus_to_rc(volatile const uint8_t *sbus_buf, RC_ctrl_t *rc_ctrl)
|
|
||||||
{
|
|
||||||
if (sbus_buf == NULL || rc_ctrl == NULL)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc_ctrl->ch[1] = (sbus_buf[1] | (sbus_buf[2] << 8)) & 0x07ff; //Channel 1
|
|
||||||
rc_ctrl->ch[2] = ((sbus_buf[2] >> 3) | (sbus_buf[3] << 5)) & 0x07ff; //Channel 2
|
|
||||||
rc_ctrl->ch[0] = ((sbus_buf[3] >> 6) | (sbus_buf[4] << 2) | //Channel 3
|
|
||||||
(sbus_buf[5] << 10)) &0x07ff;
|
|
||||||
rc_ctrl->ch[3] = ((sbus_buf[5] >> 1) | (sbus_buf[6] << 7)) & 0x07ff; //Channel 4
|
|
||||||
|
|
||||||
rc_ctrl->sw[0] = ((int16_t)sbus_buf[6] >> 4 | ((int16_t)sbus_buf[7] << 4 )) & 0x07FF; //Channel 5
|
|
||||||
rc_ctrl->sw[1] = ((int16_t)sbus_buf[7] >> 7 | ((int16_t)sbus_buf[8] << 1 ) | (int16_t)sbus_buf[9] << 9 ) & 0x07FF; //Channel 6
|
|
||||||
rc_ctrl->sw[2] = ((int16_t)sbus_buf[9] >> 2 | ((int16_t)sbus_buf[10] << 6 )) & 0x07FF;; //Channel 7
|
|
||||||
rc_ctrl->sw[3] = ((int16_t)sbus_buf[10] >> 5 | ((int16_t)sbus_buf[11] << 3 )) & 0x07FF; //Channel 8
|
|
||||||
rc_ctrl->sw[4] = ((int16_t)sbus_buf[12] << 0 | ((int16_t)sbus_buf[13] << 8 )) & 0x07FF; //Channel 9
|
|
||||||
rc_ctrl->sw[5] = ((int16_t)sbus_buf[13] >> 3 | ((int16_t)sbus_buf[14] << 5 )) & 0x07FF; //Channel 10
|
|
||||||
rc_ctrl->sw[6] = ((int16_t)sbus_buf[14] >> 6 | ((int16_t)sbus_buf[15] << 2 ) | (int16_t)sbus_buf[16] << 10 ) & 0x07FF; //Channel 11
|
|
||||||
rc_ctrl->sw[7] = ((int16_t)sbus_buf[16] >> 1 | ((int16_t)sbus_buf[17] << 7 )) & 0x07FF; //Channel 12
|
|
||||||
|
|
||||||
rc_ctrl->ch[0] -= RC_CH_VALUE_OFFSET;
|
|
||||||
rc_ctrl->ch[1] -= RC_CH_VALUE_OFFSET;
|
|
||||||
rc_ctrl->ch[2] -= RC_CH_VALUE_OFFSET;
|
|
||||||
rc_ctrl->ch[3] -= RC_CH_VALUE_OFFSET;
|
|
||||||
|
|
||||||
|
|
||||||
// //新遥控器
|
|
||||||
rc_ctrl->ch[0] += 20; //y(-694,693)
|
|
||||||
rc_ctrl->ch[1] += 20; //x(-693,694)
|
|
||||||
rc_ctrl->ch[2] = -rc_ctrl->ch[2]+144; //m(-518,843)
|
|
||||||
rc_ctrl->ch[3] += 4; //w(-694,693)
|
|
||||||
|
|
||||||
rc_ctrl->sw[2] = map(rc_ctrl->sw[2],306,1694,1694,306);
|
|
||||||
rc_ctrl->sw[3] = map(rc_ctrl->sw[3],306,1694,1694,306);
|
|
||||||
// rc_ctrl->ch[1] = map(rc_ctrl->ch[1],656,-656,-700,700); //x
|
|
||||||
rc_ctrl->ch[0] = map(rc_ctrl->ch[0],-800,796,700,-700); //y
|
|
||||||
rc_ctrl->ch[2] = map(rc_ctrl->ch[2],-632,901,25,0); //m
|
|
||||||
rc_ctrl->ch[3] = map(rc_ctrl->ch[3],-820,780,-700,700);
|
|
||||||
rc_ctrl->ch[3] = 0.5*(rc_ctrl->ch[3]);
|
|
||||||
rc_ctrl->ch[1] = 0.5*(rc_ctrl->ch[1]);
|
|
||||||
rc_ctrl->ch[0] = 0.5*(rc_ctrl->ch[0]);
|
|
||||||
//
|
|
||||||
//死区(-30,30)
|
|
||||||
if(rc_ctrl->ch[0]>-14&&rc_ctrl->ch[0]<10) rc_ctrl->ch[0]=0;
|
|
||||||
if(rc_ctrl->ch[1]>-30&&rc_ctrl->ch[1]<20) rc_ctrl->ch[1]=0;
|
|
||||||
if(rc_ctrl->ch[2]>=0&&rc_ctrl->ch[2]<=3) rc_ctrl->ch[2]=0;
|
|
||||||
if(rc_ctrl->ch[3]>-22&&rc_ctrl->ch[3]<22) rc_ctrl->ch[3]=0;
|
|
||||||
|
|
||||||
remote_ready = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int map(int x, int in_min, int in_max, int out_min, int out_max) //映射函数
|
|
||||||
{
|
|
||||||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
306 306
|
|
||||||
sw[] sw[7]
|
|
||||||
1694 1694
|
|
||||||
|
|
||||||
306 306
|
|
||||||
sw[6] sw[4]
|
|
||||||
1694 1694
|
|
||||||
|
|
||||||
306 306 306 306
|
|
||||||
sw[0] sw[2] sw[1]:306-1694 sw[5]:306-1694 sw[]1000 sw[3]
|
|
||||||
1694 1694 1694 1694
|
|
||||||
710
|
|
||||||
688 1425
|
|
||||||
| |
|
|
||||||
| |
|
|
||||||
54 -616------ch[3]770 -354---------ch[0] 339 0
|
|
||||||
| |
|
|
||||||
| |
|
|
||||||
ch[2] ch[1]
|
|
||||||
_699 38
|
|
||||||
*/
|
|
@ -1,42 +0,0 @@
|
|||||||
/**
|
|
||||||
****************************(C) COPYRIGHT 2016 DJI****************************
|
|
||||||
* @file remote_control.c/h
|
|
||||||
* @brief 遥控器处理,遥控器是通过类似SBUS的协议传输,利用DMA传输方式节约CPU
|
|
||||||
* 资源,利用串口空闲中断来拉起处理函数,同时提供一些掉线重启DMA,串口
|
|
||||||
* 的方式保证热插拔的稳定性。
|
|
||||||
* @note
|
|
||||||
* @history
|
|
||||||
* Version Date Author Modification
|
|
||||||
* V1.0.0 Dec-26-2018 RM 1. 完成
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
==============================================================================
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
@endverbatim
|
|
||||||
****************************(C) COPYRIGHT 2016 DJI****************************
|
|
||||||
*/
|
|
||||||
#ifndef REMOTE_CONTROL_H
|
|
||||||
#define REMOTE_CONTROL_H
|
|
||||||
#include "struct_typedef.h"
|
|
||||||
#include "bsp_rc.h"
|
|
||||||
|
|
||||||
#define SBUS_RX_BUF_NUM 50u
|
|
||||||
|
|
||||||
#define RC_FRAME_LENGTH 25u
|
|
||||||
|
|
||||||
#define RC_CH_VALUE_OFFSET ((uint16_t)1024)
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
int16_t ch[4];
|
|
||||||
int16_t sw[8];
|
|
||||||
|
|
||||||
}__attribute__((packed)) RC_ctrl_t;
|
|
||||||
|
|
||||||
extern void remote_control_init(void);
|
|
||||||
static void sbus_to_rc(volatile const uint8_t *sbus_buf, RC_ctrl_t *rc_ctrl);
|
|
||||||
int map(int x, int in_min, int in_max, int out_min, int out_max); //映射函数
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -51,7 +51,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "error_detect.h"
|
#include "error_detect.h"
|
||||||
#include "user_task.h"
|
#include "user_task.h"
|
||||||
#include "r12ds.h"
|
|
||||||
#include "nuc.h"
|
#include "nuc.h"
|
||||||
/**
|
/**
|
||||||
* @brief init error_list, assign offline_time, online_time, priority.
|
* @brief init error_list, assign offline_time, online_time, priority.
|
||||||
|
@ -35,10 +35,8 @@ void Task_Init(void *argument) {
|
|||||||
osThreadNew(Task_AttiEsti, NULL, &attr_atti_esti);
|
osThreadNew(Task_AttiEsti, NULL, &attr_atti_esti);
|
||||||
task_runtime.thread.chassis =
|
task_runtime.thread.chassis =
|
||||||
osThreadNew(Task_Chassis, NULL, &attr_chassis);
|
osThreadNew(Task_Chassis, NULL, &attr_chassis);
|
||||||
// task_runtime.thread.r12ds =
|
task_runtime.thread.rc =
|
||||||
// osThreadNew(Task_r12ds,NULL,&attr_r12ds);
|
osThreadNew(Task_rc,NULL,&attr_rc);
|
||||||
task_runtime.thread.dr16 =
|
|
||||||
osThreadNew(Task_dr16,NULL,&attr_dr16);
|
|
||||||
|
|
||||||
task_runtime.thread.can =
|
task_runtime.thread.can =
|
||||||
osThreadNew(Task_can,NULL,&attr_can);
|
osThreadNew(Task_can,NULL,&attr_can);
|
||||||
|
@ -1,82 +0,0 @@
|
|||||||
#include "r12ds.h"
|
|
||||||
#include "cmsis_os.h"
|
|
||||||
#include "user_task.h"
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef r12ds_t
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
|
|
||||||
CMD_RC_t cmd_rc;
|
|
||||||
|
|
||||||
uint8_t sbus_rx_buf[2][RC_FRAME_LENGTH];
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
static CMD_RC_t cmd_rc;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CMD_RC_t *R12ds_DataGet(){
|
|
||||||
return &cmd_rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void R12ds_HandleOffline(void) {
|
|
||||||
CMD_RC_t *rc;
|
|
||||||
rc = R12ds_DataGet();
|
|
||||||
memset(rc, 0, sizeof(rc->ch_x) + sizeof(rc->mul) + sizeof(rc->ch_y) + sizeof(rc->ch_w) + sizeof(rc->key));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void Task_r12ds(void *argument)
|
|
||||||
{
|
|
||||||
(void)argument;
|
|
||||||
|
|
||||||
|
|
||||||
const uint32_t delay_tick = osKernelGetTickFreq() / TASK_FREQ_R12DS;
|
|
||||||
#ifdef r12ds_t
|
|
||||||
|
|
||||||
R12ds_DMA_Init(sbus_rx_buf[0],sbus_rx_buf[1],50);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint32_t tick = osKernelGetTickCount();
|
|
||||||
|
|
||||||
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
|
|
||||||
#ifdef r12ds_t
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
|
|
||||||
task_runtime.stack_water_mark.r12ds =
|
|
||||||
osThreadGetStackSpace(osThreadGetId());
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
sbus_to_rc(sbus_rx_buf[0],&cmd_rc);
|
|
||||||
|
|
||||||
if(cmd_rc.offline ==1)
|
|
||||||
{
|
|
||||||
R12ds_HandleOffline();
|
|
||||||
}
|
|
||||||
|
|
||||||
osMessageQueueReset(task_runtime.msgq.cmd.raw.rc);
|
|
||||||
osMessageQueuePut(task_runtime.msgq.cmd.raw.rc,(&cmd_rc),0,0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
tick += delay_tick; /* 计算下一个唤醒时*/
|
|
||||||
|
|
||||||
osDelay(10);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
#ifndef _R12DS_TASK_H
|
|
||||||
#define _R12DS_TASK_H
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -5,7 +5,7 @@
|
|||||||
/* Includes ----------------------------------------------------------------- */
|
/* Includes ----------------------------------------------------------------- */
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "dr16.h"
|
#include "rc.h"
|
||||||
#include "user_task.h"
|
#include "user_task.h"
|
||||||
|
|
||||||
/* Private typedef ---------------------------------------------------------- */
|
/* Private typedef ---------------------------------------------------------- */
|
||||||
@ -31,15 +31,15 @@ static CMD_RC_t cmd_rc;
|
|||||||
*
|
*
|
||||||
* \param argument 未使用
|
* \param argument 未使用
|
||||||
*/
|
*/
|
||||||
void Task_dr16(void *argument) {
|
void Task_rc(void *argument) {
|
||||||
(void)argument; /* 未使用,消除警告 */
|
(void)argument; /* 未使用,消除警告 */
|
||||||
|
|
||||||
RC_SBUS_Init(); /* 初始化dr16 */
|
RC_SBUS_Init(); /* 初始化 */
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
/* */
|
/* */
|
||||||
task_runtime.stack_water_mark.dr16 = osThreadGetStackSpace(osThreadGetId());
|
task_runtime.stack_water_mark.rc = osThreadGetStackSpace(osThreadGetId());
|
||||||
#endif
|
#endif
|
||||||
/* 开启DMA */
|
/* 开启DMA */
|
||||||
RC_SBUS_StartDmaRecv();
|
RC_SBUS_StartDmaRecv();
|
@ -58,7 +58,7 @@ const osThreadAttr_t attr_error_detect = {
|
|||||||
.stack_size = 128 *4,
|
.stack_size = 128 *4,
|
||||||
};
|
};
|
||||||
|
|
||||||
const osThreadAttr_t attr_dr16 = {
|
const osThreadAttr_t attr_rc = {
|
||||||
.name = "dr16",
|
.name = "dr16",
|
||||||
.priority = osPriorityRealtime,
|
.priority = osPriorityRealtime,
|
||||||
.stack_size = 128 *4,
|
.stack_size = 128 *4,
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#define TASK_FREQ_NUC (500u)
|
#define TASK_FREQ_NUC (500u)
|
||||||
#define TASK_FREQ_CAN (1000u)
|
#define TASK_FREQ_CAN (1000u)
|
||||||
#define TASK_FREQ_R12DS (1000u)
|
#define TASK_FREQ_R12DS (1000u)
|
||||||
#define TASK_FREQ_DR16 (1000u)
|
#define TASK_FREQ_RC (1000u)
|
||||||
|
|
||||||
#define TASK_FREQ_ERROR_DTC (3u)
|
#define TASK_FREQ_ERROR_DTC (3u)
|
||||||
|
|
||||||
@ -40,8 +40,7 @@ typedef struct {
|
|||||||
osThreadId_t chassis;
|
osThreadId_t chassis;
|
||||||
osThreadId_t up;
|
osThreadId_t up;
|
||||||
|
|
||||||
osThreadId_t dr16;
|
osThreadId_t rc;
|
||||||
osThreadId_t r12ds;
|
|
||||||
osThreadId_t can;
|
osThreadId_t can;
|
||||||
osThreadId_t cmd;
|
osThreadId_t cmd;
|
||||||
osThreadId_t nuc;
|
osThreadId_t nuc;
|
||||||
@ -111,8 +110,7 @@ typedef struct {
|
|||||||
|
|
||||||
UBaseType_t can;
|
UBaseType_t can;
|
||||||
UBaseType_t atti_esti;
|
UBaseType_t atti_esti;
|
||||||
UBaseType_t dr16;
|
UBaseType_t rc;
|
||||||
UBaseType_t r12ds;
|
|
||||||
|
|
||||||
UBaseType_t cmd;
|
UBaseType_t cmd;
|
||||||
UBaseType_t nuc;
|
UBaseType_t nuc;
|
||||||
@ -124,8 +122,7 @@ typedef struct {
|
|||||||
float chassis;
|
float chassis;
|
||||||
float can;
|
float can;
|
||||||
float atti_esti;
|
float atti_esti;
|
||||||
float r12ds;
|
float rc;
|
||||||
float dr16;
|
|
||||||
float up;
|
float up;
|
||||||
|
|
||||||
float cmd;
|
float cmd;
|
||||||
@ -137,8 +134,7 @@ typedef struct {
|
|||||||
float chassis;
|
float chassis;
|
||||||
float can;
|
float can;
|
||||||
float atti_esti;
|
float atti_esti;
|
||||||
float r12ds;
|
float rc;
|
||||||
float dr16;
|
|
||||||
float up;
|
float up;
|
||||||
|
|
||||||
float cmd;
|
float cmd;
|
||||||
@ -166,7 +162,7 @@ extern const osThreadAttr_t attr_nuc;
|
|||||||
|
|
||||||
extern const osThreadAttr_t attr_error_detect;
|
extern const osThreadAttr_t attr_error_detect;
|
||||||
|
|
||||||
extern const osThreadAttr_t attr_dr16;
|
extern const osThreadAttr_t attr_rc;
|
||||||
|
|
||||||
//extern const osThreadAttr_t attr_r12ds;
|
//extern const osThreadAttr_t attr_r12ds;
|
||||||
|
|
||||||
@ -179,17 +175,13 @@ void Task_Chassis(void *argument);
|
|||||||
|
|
||||||
void Task_up(void *argument);
|
void Task_up(void *argument);
|
||||||
|
|
||||||
|
|
||||||
void Task_can(void *argument);
|
void Task_can(void *argument);
|
||||||
|
|
||||||
void Task_cmd(void *argument);
|
void Task_cmd(void *argument);
|
||||||
|
|
||||||
void Task_nuc(void *argument);
|
void Task_nuc(void *argument);
|
||||||
|
|
||||||
|
|
||||||
void Task_error_detect(void *argument);
|
void Task_error_detect(void *argument);
|
||||||
|
|
||||||
void Task_r12ds(void *argument);
|
void Task_rc(void *argument);
|
||||||
|
|
||||||
void Task_dr16(void *argument);
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user