Got ADS1299 working in syncronous mode.

This commit is contained in:
Nicolas Trimborn 2021-08-23 21:03:39 +02:00
parent 65e1957d2a
commit 1230e96c1f
14 changed files with 1171 additions and 150 deletions

3
.gitmodules vendored
View File

@ -4,3 +4,6 @@
[submodule "Examples/OpenBCI_Cyton_Library"] [submodule "Examples/OpenBCI_Cyton_Library"]
path = Examples/OpenBCI_Cyton_Library path = Examples/OpenBCI_Cyton_Library
url = https://github.com/OpenBCI/OpenBCI_Cyton_Library.git url = https://github.com/OpenBCI/OpenBCI_Cyton_Library.git
[submodule "Examples/ADS129X"]
path = Examples/ADS129X
url = https://github.com/ferdinandkeil/ADS129X.git

View File

@ -0,0 +1,867 @@
<?xml version="1.0" encoding="utf-8"?>
<EtherCATInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="EtherCATInfo.xsd" Version="1.8">
<Vendor>
<Id>#x000004D8</Id>
<Name>Microchip Technology Inc</Name>
</Vendor>
<Descriptions>
<Groups>
<Group>
<Type>LAN9252-2_motor_Master</Type>
<Name LcId="1033">LAN9252-2_motor_Master</Name>
<ImageData16x14>424DD8020000000000003600000028000000100000000E0000000100180000000000A2020000120B0000120B000000000000000000001306E31306E3190CE42B1FE62B1FE61306E31F13E5190CE42519E51306E31306E3190CE42F24E7190CE41306E31306E31306E31306E35F56EC645CED645CED4137E91F13E5473DE95F57EC3227E71306E3473DE95A51EC271BE61306E31306E31409CA524CC68E8AD74F48C1615CC82218D03E36BF716BCE746FCE453DC01307CE3931BA7D78D27671D1150CB21409CA1712801B1D1D1B1D1D1B1D1D1B1D1D120B891B1D1D1B1D1D1B1D1D1B1D1D120B891B1D1D1B1D1D1B1D1D1B1D1D1712801712807F8080D4D5D5D4D5D5383939120B89545656D4D5D5D4D5D5626464130C89292B2BD4D5D5D4D5D56264641915801712804647471B1D1DAAAAAAD4D5D5130E82383939292B2B717272D4D5D5151183D4D5D57F80801B1D1D7172721E1C81191580464747D4D5D5D4D5D51B1D1D19158A292B2BD4D5D5D4D5D5292B2B1B1B8AD4D5D56264641B1D1D1B1D1D2427821E1D81D4D5D54647476264643839391E208BD4D5D57F8080464747545656242A8BD4D5D59B9C9C292B2BAAAAAA2D3683252882464747D4D5D5D4D5D51B1D1D272D85292B2BD4D5D5D4D5D5292B2B2E37861B1D1DD4D5D5D4D5D5464747394484323BB52324812122822426822526824554C0323883292B822A2D83353C84424CBF3238843940842E32834853865D6EBB5262EB3E43E83334E74147E94349E9535FEB4D56EA5662EB484DEA545DEB636FED545AEA5A63EC6671ED8CA0F290A5F2748AEF6B7BEE5D68EC6874ED788AEF8397F17684EF7986EF8C9FF2818FF1818EF08E9DF18A97F18791F19BA9F3B0C0F691A4F291A2F28390F192A1F29CACF3A3B3F498A6F3A4B3F4AEBDF5B0BEF59EA8F3A3ADF4BBC7F7C4D1F8CAD7F8CED9F9B4C4F6B8C8F6ACB8F59AA3F3B6C1F6C5D2F8C2CDF8CCD7F9D2DDF9D5E0FAD2DAF9D5DCF9DFE7FBE2E9FBE5EBFBE8EEFB0000</ImageData16x14>
</Group>
</Groups>
<Devices>
<Device Physics="YY">
<Type ProductCode="#x00000002" RevisionNo="#x00000007">LAN9252-2_motor_Master</Type>
<Name LcId="1033"><![CDATA[MSRM 2_motor_Master Ethercat Slave]]></Name>
<Info>
<EtherCATController>
<DpramSize>4096</DpramSize>
<SmCount>4</SmCount>
<FmmuCount>3</FmmuCount>
</EtherCATController>
<Port>
<Type>MII</Type>
<PhysicalPhyAddr>0</PhysicalPhyAddr>
</Port>
<Port>
<Type>MII</Type>
<PhysicalPhyAddr>1</PhysicalPhyAddr>
</Port>
<IdentificationAdo>#x0012</IdentificationAdo>
</Info>
<GroupType>LAN9252-2_motor_Master</GroupType>
<Fmmu>Outputs</Fmmu>
<Fmmu>Inputs</Fmmu>
<Sm StartAddress="#x1100" ControlByte="#x04" Enable="1">Outputs</Sm>
<Sm StartAddress="#x1800" ControlByte="0" Enable="1">Inputs</Sm>
<RxPdo Fixed="1" Sm="0">
<Index>#x1a00</Index>
<Name>ECAT2MCU</Name>
<Entry>
<Index>#x3101</Index>
<SubIndex>1</SubIndex>
<BitLen>8</BitLen>
<Name>M1__control_mode</Name>
<DataType>BYTE</DataType>
</Entry>
<Entry>
<Index>#x3102</Index>
<SubIndex>1</SubIndex>
<BitLen>8</BitLen>
<Name>M1__control_set</Name>
<DataType>BYTE</DataType>
</Entry>
<Entry>
<Index>#x3103</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M1__desired_position</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3104</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M1__desired_speed</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3105</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M1__desired__current</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3106</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M1__Max_Pos</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3107</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M1__Max_velocity</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3108</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M1__Max_current</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3109</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M1__Spare</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x310A</Index>
<SubIndex>1</SubIndex>
<BitLen>8</BitLen>
<Name>M2__control_mode</Name>
<DataType>BYTE</DataType>
</Entry>
<Entry>
<Index>#x310B</Index>
<SubIndex>1</SubIndex>
<BitLen>8</BitLen>
<Name>M2__control_set</Name>
<DataType>BYTE</DataType>
</Entry>
<Entry>
<Index>#x310C</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M2__desired_position</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x310D</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M2__desired_speed</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x310E</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M2__desired__current</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x310F</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M2__Max_Pos</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3110</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M2__Max_velocity</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3111</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M2__Max_current</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3112</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M2__Spare</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3113</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>SPARE__1_RX</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3114</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>SPARE__2_RX</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3115</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>SPARE__3_RX</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3116</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>SPARE__4_RX</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3117</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>SPARE__5_RX</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3118</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>SPARE__6_RX</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3119</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>SPARE__7_RX</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x311A</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>SPARE__8_RX</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x311B</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>SPARE__9_RX</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x311C</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>SPARE__10_RX</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x311D</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>SPARE__11_RX</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x311E</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>SPARE__12_RX</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x311F</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>SPARE__13_RX</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3120</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>SPARE__14_RX</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3121</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>SPARE__15_RX</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3122</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>SPARE__16_RX</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3123</Index>
<SubIndex>1</SubIndex>
<BitLen>8</BitLen>
<Name>M3__control_mode</Name>
<DataType>BYTE</DataType>
</Entry>
<Entry>
<Index>#x3124</Index>
<SubIndex>1</SubIndex>
<BitLen>8</BitLen>
<Name>M3__control_set</Name>
<DataType>BYTE</DataType>
</Entry>
<Entry>
<Index>#x3125</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M3__desired_position</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3126</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M3__desired_speed</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3127</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M3__desired__current</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3128</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M3__Max_Pos</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3129</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M3__Max_velocity</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x312A</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M3__Max_current</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x312B</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M3__Spare</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x312C</Index>
<SubIndex>1</SubIndex>
<BitLen>8</BitLen>
<Name>M4__control_mode</Name>
<DataType>BYTE</DataType>
</Entry>
<Entry>
<Index>#x312D</Index>
<SubIndex>1</SubIndex>
<BitLen>8</BitLen>
<Name>M4__control_set</Name>
<DataType>BYTE</DataType>
</Entry>
<Entry>
<Index>#x312E</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M4__desired_position</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x312F</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M4__desired_speed</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3130</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M4__desired__current</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3131</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M4__Max_Pos</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3132</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M4__Max_velocity</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3133</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M4__Max_current</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3134</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M4__Spare</Name>
<DataType>INT</DataType>
</Entry>
</RxPdo>
<TxPdo Fixed="1" Sm="1">
<Index>#x1600</Index>
<Name>MCU2ECAT</Name>
<Entry>
<Index>#x3001</Index>
<SubIndex>1</SubIndex>
<BitLen>8</BitLen>
<Name>M1__status</Name>
<DataType>BYTE</DataType>
</Entry>
<Entry>
<Index>#x3002</Index>
<SubIndex>1</SubIndex>
<BitLen>8</BitLen>
<Name>M1__mode</Name>
<DataType>BYTE</DataType>
</Entry>
<Entry>
<Index>#x3003</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M1__Joint_rel_position</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3004</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M1__Joint_abs_position</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3005</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M1__Motor_speed</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3006</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M1__Motor_current_bus</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3007</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M1__Motor_currentPhA</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3008</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M1__Motor_currentPhB</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3009</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M1__Motor_currentPhC</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x300A</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M1__Motor_hallState</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x300B</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M1__Motor_dutyCycle</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x300C</Index>
<SubIndex>1</SubIndex>
<BitLen>8</BitLen>
<Name>M2__status</Name>
<DataType>BYTE</DataType>
</Entry>
<Entry>
<Index>#x300D</Index>
<SubIndex>1</SubIndex>
<BitLen>8</BitLen>
<Name>M2__mode</Name>
<DataType>BYTE</DataType>
</Entry>
<Entry>
<Index>#x300E</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M2__Joint__rel_position</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x300F</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M2__Joint_abs_position</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3010</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M2__Motor_speed</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3011</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M2__Motor_current_bus</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3012</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M2__Motor_currentPhA</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3013</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M2__Motor_currentPhB</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3014</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M2__Motor_currentPhC</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3015</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M2__Motor_hallState</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3016</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M2__Motor_dutyCycle</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3017</Index>
<SubIndex>1</SubIndex>
<BitLen>32</BitLen>
<Name>EMG__CH1</Name>
<DataType>DINT</DataType>
</Entry>
<Entry>
<Index>#x3018</Index>
<SubIndex>1</SubIndex>
<BitLen>32</BitLen>
<Name>EMG__CH2</Name>
<DataType>DINT</DataType>
</Entry>
<Entry>
<Index>#x3019</Index>
<SubIndex>1</SubIndex>
<BitLen>32</BitLen>
<Name>EMG__CH3</Name>
<DataType>DINT</DataType>
</Entry>
<Entry>
<Index>#x301A</Index>
<SubIndex>1</SubIndex>
<BitLen>32</BitLen>
<Name>EMG__CH4</Name>
<DataType>DINT</DataType>
</Entry>
<Entry>
<Index>#x301B</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>SPARE__1_TX</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x301C</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>SPARE__2_TX</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x301D</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>SPARE__3_TX</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x301E</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>SPARE__4_TX</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x301F</Index>
<SubIndex>1</SubIndex>
<BitLen>8</BitLen>
<Name>M3__status</Name>
<DataType>BYTE</DataType>
</Entry>
<Entry>
<Index>#x3020</Index>
<SubIndex>1</SubIndex>
<BitLen>8</BitLen>
<Name>M3__mode</Name>
<DataType>BYTE</DataType>
</Entry>
<Entry>
<Index>#x3021</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M3__Joint__rel_position</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3022</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M3__Joint_abs_position</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3023</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M3__Motor_speed</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3024</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M3__Motor_current_bus</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3025</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M3__Motor_currentPhA</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3026</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M3__Motor_currentPhB</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3027</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M3__Motor_currentPhC</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3028</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M3__Motor_hallState</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3029</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M3__Motor_dutyCycle</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x302A</Index>
<SubIndex>1</SubIndex>
<BitLen>8</BitLen>
<Name>M4__status</Name>
<DataType>BYTE</DataType>
</Entry>
<Entry>
<Index>#x302B</Index>
<SubIndex>1</SubIndex>
<BitLen>8</BitLen>
<Name>M4__mode</Name>
<DataType>BYTE</DataType>
</Entry>
<Entry>
<Index>#x302C</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M4__Joint__rel_position</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x302D</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M4__Joint_abs_position</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x302E</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M4__Motor_speed</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x302F</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M4__Motor_current_bus</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3030</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M4__Motor_currentPhA</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3031</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M4__Motor_currentPhB</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3032</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M4__Motor_currentPhC</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3033</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M4__Motor_hallState</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3034</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>M4__Motor_dutyCycle</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3035</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>IMU__q_x0</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3036</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>IMU__q_y0</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3037</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>IMU__q_z0</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3038</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>IMU__q_w0</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3039</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>FSR__CH1</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x303A</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>FSR__CH2</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x303B</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>FSR__CH3</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x303C</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>FSR__CH4</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x303D</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>FSR__CH5</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x303E</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>Pressure__CH1</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x303F</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>Pressure__CH2</Name>
<DataType>INT</DataType>
</Entry>
<Entry>
<Index>#x3040</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>Pressure__CH3</Name>
<DataType>INT</DataType>
</Entry>
</TxPdo>
<Eeprom>
<ByteSize>2048</ByteSize>
<ConfigData>803100CC1000F0FF</ConfigData>
</Eeprom>
</Device>
</Devices>
</Descriptions>
</EtherCATInfo>

View File

@ -2400,9 +2400,10 @@ pads:
SPI2_SS: SPI2_SS:
name: PA14 name: PA14
definition: Atmel:SAME51_Drivers:0.0.1::SAME51J19A-MF::pad::PA14 definition: Atmel:SAME51_Drivers:0.0.1::SAME51J19A-MF::pad::PA14
mode: Peripheral IO mode: Digital output
user_label: SPI2_SS user_label: SPI2_SS
configuration: null configuration:
pad_initial_level: High
SPI2_MISO: SPI2_MISO:
name: PA15 name: PA15
definition: Atmel:SAME51_Drivers:0.0.1::SAME51J19A-MF::pad::PA15 definition: Atmel:SAME51_Drivers:0.0.1::SAME51J19A-MF::pad::PA15

View File

@ -7,6 +7,41 @@
#include "ADS1299.h" #include "ADS1299.h"
/* Settings
* No daisy:
* 4 EMG channels channels at 1000.0 Hz.
* Gain 24, SRB2 Open, Normal electrode input
* Route all Channels_P to Bias derivation
* Route all Channels_P to Bias derivation
* Lead off functions off
Expected ADS Board Registers
* ADS_ID, 00, 3C, 0, 0, 1, 1, 1, 1, 1, 0
* CONFIG1, 01, 94, 1, 0, 0, 1, 0, 1, 0, 0
* CONFIG2, 02, C0, 1, 1, 0, 0, 0, 0, 0, 0
* CONFIG3, 03, EC, 1, 1, 1, 0, 1, 1, 0, 0
* LOFF, 04, 02, 0, 0, 0, 0, 0, 0, 1, 0
* CH1SET, 05, 68, 0, 1, 1, 0, 1, 0, 0, 0
* CH2SET, 06, 68, 0, 1, 1, 0, 1, 0, 0, 0
* CH3SET, 07, 68, 0, 1, 1, 0, 1, 0, 0, 0
* CH4SET, 08, 68, 0, 1, 1, 0, 1, 0, 0, 0
* CH5SET, 09, 68, 0, 1, 1, 0, 1, 0, 0, 0
* CH6SET, 0A, 68, 0, 1, 1, 0, 1, 0, 0, 0
* CH7SET, 0B, 68, 0, 1, 1, 0, 1, 0, 0, 0
* CH8SET, 0C, 68, 0, 1, 1, 0, 1, 0, 0, 0
* BIAS_SENSP, 0D, FF, 1, 1, 1, 1, 1, 1, 1, 1
* BIAS_SENSN, 0E, FF, 1, 1, 1, 1, 1, 1, 1, 1
* LOFF_SENSP, 0F, 00, 0, 0, 0, 0, 0, 0, 0, 0
* LOFF_SENSN, 10, 00, 0, 0, 0, 0, 0, 0, 0, 0
* LOFF_FLIP, 11, 00, 0, 0, 0, 0, 0, 0, 0, 0
* LOFF_STATP, 12, 00, 0, 0, 0, 0, 0, 0, 0, 0
* LOFF_STATN, 13, 00, 0, 0, 0, 0, 0, 0, 0, 0
* GPIO, 14, 0F, 0, 0, 0, 0, 1, 1, 1, 1
* MISC1, 15, 00, 0, 0, 0, 0, 0, 0, 0, 0
* MISC2, 16, 00, 0, 0, 0, 0, 0, 0, 0, 0
* CONFIG4, 17, 00, 0, 0, 0, 0, 0, 0, 0, 0
*/
void initialize_ads() void initialize_ads()
{ {
spi_m_sync_disable(ADS1299.SPI_descr); spi_m_sync_disable(ADS1299.SPI_descr);
@ -16,17 +51,41 @@ void initialize_ads()
/* Init SPI*/ /* Init SPI*/
spi_m_sync_enable(ADS1299.SPI_descr); spi_m_sync_enable(ADS1299.SPI_descr);
gpio_set_pin_level(ADS1299.SS_pin, true); gpio_set_pin_level(ADS1299.SS_pin, true);
delay_us(20);
/* Reset ADS1299 - Reset Active Low*/ /* Reset ADS1299 - Reset Active Low*/
gpio_set_pin_level(ADS1299.reset_pin, false); gpio_set_pin_level(ADS1299.reset_pin, false);
delay_us(5); delay_us(20);
gpio_set_pin_level(ADS1299.reset_pin, true); gpio_set_pin_level(ADS1299.reset_pin, true);
delay_us(20); delay_us(20);
ADS1299_RESET(); // all registers set to default
ADS1299_SDATAC(); // stop Read Data Continuous mode to communicate with ADS
ADS1299_RREGS(0x00, 0x17); // read ADS registers starting at 0x00 and ending at 0x17
/* Write Config Registers */
ADS1299_WREG(CONFIG1,0x94); // Set Config 1 Register
ADS1299_WREG(CONFIG2,0xC0); // Set Config 2 Register
ADS1299_WREG(CONFIG3,0xEC); // Set Config 3 Register
ADS1299_WREG(LOFF,0x02); // Set LOFF Register
for(uint8_t i=CH1SET; i<=CH4SET; i++) // set up to modify the 4 channel setting registers
{
ADS1299.regData[i] = 0x68; // the regData array mirrors the ADS1299 register addresses
}
ADS1299_WREGS(CH1SET,3); // write new channel settings
ADS1299_WREG(BIAS_SENSP,0xFF); // Set BIAS_SENSP Register
ADS1299_WREG(BIAS_SENSN,0xFF); // Set BIAS_SENSN Register
ADS1299_WREG(BIAS_SENSP,0xFF); // Set BIAS_SENSP Register
ADS1299_WREG(GPIO_REG,0x0F); // Set BIAS_SENSP Register
/* Remaining Registers left at 0x00 */
ADS1299_RREGS(0x00, 0x17); // read ADS registers to verify settings
ADS1299_RDATAC(); // enter Read Data Continuous mode
volatile int x = 0;
} }
uint8_t getDeviceID() uint8_t getDeviceID()
{ {
uint8_t data = RREG(0x00); uint8_t data = ADS1299_RREG(0x00);
return data; return data;
} }
@ -34,120 +93,179 @@ uint8_t getDeviceID()
// AS5048 Registers & Commands // AS5048 Registers & Commands
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
void WAKEUP() { void ADS1299_WAKEUP() {
gpio_set_pin_level(ADS1299.SS_pin, false); gpio_set_pin_level(ADS1299.SS_pin, false);
transfer_byte(ADS1299.SPI_descr, _WAKEUP); _transfer_byte(ADS1299.SPI_descr, _WAKEUP);
gpio_set_pin_level(ADS1299.SS_pin, true); gpio_set_pin_level(ADS1299.SS_pin, true);
delay_us(3); //must wait 4 tCLK cycles before sending another command (Datasheet, pg. 35) delay_us(3); //must wait 4 tCLK cycles before sending another command (Datasheet, pg. 35)
} }
void STANDBY() { // only allowed to send WAKEUP after sending STANDBY void ADS1299_STANDBY() { // only allowed to send WAKEUP after sending STANDBY
gpio_set_pin_level(ADS1299.SS_pin, false); gpio_set_pin_level(ADS1299.SS_pin, false);
transfer_byte(ADS1299.SPI_descr, _STANDBY); _transfer_byte(ADS1299.SPI_descr, _STANDBY);
gpio_set_pin_level(ADS1299.SS_pin, true); gpio_set_pin_level(ADS1299.SS_pin, true);
} }
void RESET() { // reset all the registers to default settings void ADS1299_RESET() { // reset all the registers to default settings
gpio_set_pin_level(ADS1299.SS_pin, false); gpio_set_pin_level(ADS1299.SS_pin, false);
transfer_byte(ADS1299.SPI_descr, _RESET); _transfer_byte(ADS1299.SPI_descr, _RESET);
delay_us(12); //must wait 18 tCLK cycles to execute this command (Datasheet, pg. 35) delay_us(12); //must wait 18 tCLK cycles to execute this command (Datasheet, pg. 35)
gpio_set_pin_level(ADS1299.SS_pin, true); gpio_set_pin_level(ADS1299.SS_pin, true);
} }
void START() { //start data conversion void ADS1299_START() { //start data conversion
gpio_set_pin_level(ADS1299.SS_pin, false); gpio_set_pin_level(ADS1299.SS_pin, false);
transfer_byte(ADS1299.SPI_descr, _START); _transfer_byte(ADS1299.SPI_descr, _START);
gpio_set_pin_level(ADS1299.SS_pin, true); gpio_set_pin_level(ADS1299.SS_pin, true);
} }
void STOP() { //stop data conversion void ADS1299_STOP() { //stop data conversion
gpio_set_pin_level(ADS1299.SS_pin, false); gpio_set_pin_level(ADS1299.SS_pin, false);
transfer_byte(ADS1299.SPI_descr, _STOP); _transfer_byte(ADS1299.SPI_descr, _STOP);
gpio_set_pin_level(ADS1299.SS_pin, true); gpio_set_pin_level(ADS1299.SS_pin, true);
} }
void RDATAC() { void ADS1299_RDATAC() {
gpio_set_pin_level(ADS1299.SS_pin, false); gpio_set_pin_level(ADS1299.SS_pin, false);
transfer_byte(ADS1299.SPI_descr, _RDATAC); _transfer_byte(ADS1299.SPI_descr, _RDATAC);
gpio_set_pin_level(ADS1299.SS_pin, true); gpio_set_pin_level(ADS1299.SS_pin, true);
delay_us(3); delay_us(3);
} }
void SDATAC() { void ADS1299_SDATAC() {
gpio_set_pin_level(ADS1299.SS_pin, false); gpio_set_pin_level(ADS1299.SS_pin, false);
transfer_byte(ADS1299.SPI_descr, _SDATAC); _transfer_byte(ADS1299.SPI_descr, _SDATAC);
gpio_set_pin_level(ADS1299.SS_pin, true); gpio_set_pin_level(ADS1299.SS_pin, true);
delay_us(3); //must wait 4 tCLK cycles after executing this command (Datasheet, pg. 37) delay_us(3); //must wait 4 tCLK cycles after executing this command (Datasheet, pg. 37)
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// SPI register Related Commands // SPI register Related Commands
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// reads ONE register at _address // reads ONE register at _address
uint8_t RREG(uint8_t _address) uint8_t ADS1299_RREG(uint8_t _address)
{ {
uint8_t opcode1 = _address + 0x20; // RREG expects 001rrrrr where rrrrr = _address uint8_t opcode1 = _address + 0x20; // RREG expects 001rrrrr where rrrrr = _address
gpio_set_pin_level(ADS1299.SS_pin, false); gpio_set_pin_level(ADS1299.SS_pin, false);
transfer_byte(ADS1299.SPI_descr, opcode1); _transfer_byte(ADS1299.SPI_descr, opcode1);
transfer_byte(ADS1299.SPI_descr, 0x00); _transfer_byte(ADS1299.SPI_descr, 0x00);
ADS1299.regData[_address] = transfer_byte(ADS1299.SPI_descr, 0x00); ADS1299.regData[_address] = _transfer_byte(ADS1299.SPI_descr, 0x00);
gpio_set_pin_level(ADS1299.SS_pin, true); gpio_set_pin_level(ADS1299.SS_pin, true);
return ADS1299.regData[_address]; return ADS1299.regData[_address];
} }
// Read more than one register starting at _address // Read more than one register starting at _address
void RREGS(uint8_t _address, uint8_t _numRegistersMinusOne) void ADS1299_RREGS(uint8_t _address, uint8_t _numRegistersMinusOne)
{ {
uint8_t opcode1 = _address + 0x20; // RREG expects 001rrrrr where rrrrr = _address uint8_t opcode1 = _address + 0x20; // RREG expects 001rrrrr where rrrrr = _address
gpio_set_pin_level(ADS1299.SS_pin, false); gpio_set_pin_level(ADS1299.SS_pin, false);
transfer_byte(ADS1299.SPI_descr, opcode1); _transfer_byte(ADS1299.SPI_descr, opcode1);
transfer_byte(ADS1299.SPI_descr, _numRegistersMinusOne); _transfer_byte(ADS1299.SPI_descr, _numRegistersMinusOne);
for(int i = 0; i <= _numRegistersMinusOne; i++){ for(int i = 0; i <= _numRegistersMinusOne; i++){ // add register uint8_t to mirror array
ADS1299.regData[_address + i] = transfer_byte(ADS1299.SPI_descr, 0x00); // add register uint8_t to mirror array ADS1299.regData[_address + i] = _transfer_byte(ADS1299.SPI_descr, 0x00);
} }
ADS1299.regData[_address] = transfer_byte(ADS1299.SPI_descr, 0x00); //ADS1299.regData[_address] = _transfer_byte(ADS1299.SPI_descr, 0x00);
gpio_set_pin_level(ADS1299.SS_pin, true); gpio_set_pin_level(ADS1299.SS_pin, true);
} }
void WREG(uint8_t _address, uint8_t _value) { // Write ONE register at _address void ADS1299_WREG(uint8_t _address, uint8_t _value) { // Write ONE register at _address
uint8_t opcode1 = _address + 0x40; // WREG expects 010rrrrr where rrrrr = _address uint8_t opcode1 = _address + 0x40; // WREG expects 010rrrrr where rrrrr = _address
gpio_set_pin_level(ADS1299.SS_pin, false); // open SPI gpio_set_pin_level(ADS1299.SS_pin, false); // open SPI
transfer_byte(ADS1299.SPI_descr, opcode1); // Send WREG command & address _transfer_byte(ADS1299.SPI_descr, opcode1); // Send WREG command & address
transfer_byte(ADS1299.SPI_descr, 0x00); // Send number of registers to read -1 _transfer_byte(ADS1299.SPI_descr, 0x00); // Send number of registers to read -1
transfer_byte(ADS1299.SPI_descr, _value); // Write the value to the register _transfer_byte(ADS1299.SPI_descr, _value); // Write the value to the register
gpio_set_pin_level(ADS1299.SS_pin, true); // close SPI gpio_set_pin_level(ADS1299.SS_pin, true); // close SPI
ADS1299.regData[_address] = _value; // update the mirror array ADS1299.regData[_address] = _value; // update the mirror array
} }
void WREGS(uint8_t _address, uint8_t _numRegistersMinusOne) { void ADS1299_WREGS(uint8_t _address, uint8_t _numRegistersMinusOne) {
uint8_t opcode1 = _address + 0x40; // WREG expects 010rrrrr where rrrrr = _address uint8_t opcode1 = _address + 0x40; // WREG expects 010rrrrr where rrrrr = _address
gpio_set_pin_level(ADS1299.SS_pin, false); // open SPI gpio_set_pin_level(ADS1299.SS_pin, false); // open SPI
transfer_byte(ADS1299.SPI_descr, opcode1); // Send WREG command & address _transfer_byte(ADS1299.SPI_descr, opcode1); // Send WREG command & address
transfer_byte(ADS1299.SPI_descr, _numRegistersMinusOne); // Send number of registers to read -1 _transfer_byte(ADS1299.SPI_descr, _numRegistersMinusOne); // Send number of registers to read -1
for (int i=_address; i <=(_address + _numRegistersMinusOne); i++){ for (int i=_address; i <=(_address + _numRegistersMinusOne); i++){
transfer_byte(ADS1299.SPI_descr, ADS1299.regData[i]); // Write to the registers _transfer_byte(ADS1299.SPI_descr, ADS1299.regData[i]); // Write to the registers
} }
gpio_set_pin_level(ADS1299.SS_pin, true); // close SPI gpio_set_pin_level(ADS1299.SS_pin, true); // close SPI
} }
void updateChannelData() //read data
void ADS1299_RDATA() { // use in Stop Read Continuous mode when DRDY goes low
uint8_t inByte;
ADS1299.stat_1 = 0; // clear the status registers
int nchan = 4; //assume 4 channel.
gpio_set_pin_level(ADS1299.SS_pin, false); // open SPI
_transfer_byte(ADS1299.SPI_descr, _RDATA);
for(int i=0; i<3; i++){ // read 3 byte status register (1100+LOFF_STATP+LOFF_STATN+GPIO[7:4])
inByte = _transfer_byte(ADS1299.SPI_descr, 0x00);
ADS1299.stat_1 = (ADS1299.stat_1<<8) | inByte;
}
for(int i = 0; i<nchan; i++){
for(int j=0; j<3; j++){ // read 24 bits of channel data from 1st ADS in 8 3 byte chunks
inByte = _transfer_byte(ADS1299.SPI_descr, 0x00);
ADS1299.channel_data[i] = (ADS1299.channel_data[i]<<8) | inByte;
}
}
for(int i=0; i<nchan; i++){ // convert 3 byte 2's compliment to 4 byte 2's compliment
if(bitRead(ADS1299.channel_data[i],23) == 1){
ADS1299.channel_data[i] |= 0xFF000000;
}else{
ADS1299.channel_data[i] &= 0x00FFFFFF;
}
}
}
//int32_t* ADS1299_UPDATECHANNELDATA()
//{
//uint8_t inByte;
//int nchan=4; //assume 8 channel. If needed, it automatically changes to 16 automatically in a later block.
//gpio_set_pin_level(ADS1299.SS_pin, false); // open SPI
//
//// READ CHANNEL DATA FROM FIRST ADS IN DAISY LINE
//for(int i=0; i<3; i++){ // read 3 byte status register from ADS 1 (1100+LOFF_STATP+LOFF_STATN+GPIO[7:4])
//inByte = _transfer_byte(ADS1299.SPI_descr,0x00);
//ADS1299.stat_1 = (ADS1299.stat_1<<8) | inByte;
//}
//
//for(int i = 0; i<8; i++){
//for(int j=0; j<3; j++){ // read 24 bits of channel data from 1st ADS in 8 3 byte chunks
//inByte = _transfer_byte(ADS1299.SPI_descr, 0x00);
//ADS1299.channel_data[i] = (ADS1299.channel_data[i]<<8) | inByte;
//}
//}
//
//gpio_set_pin_level(ADS1299.SS_pin, true); // close SPI
//
////reformat the numbers
//for(int i=0; i<nchan; i++){ // convert 3 byte 2's compliment to 4 byte 2's compliment
//if(bitRead(ADS1299.channel_data[i],23) == 1){
//ADS1299.channel_data[i] |= 0xFF000000;
//}else{
//ADS1299.channel_data[i] &= 0x00FFFFFF;
//}
//}
//return &ADS1299.channel_data;
//}
int32_t* ADS1299_UPDATECHANNELDATA()
{ {
uint8_t inByte; uint8_t inByte;
int nchan=4; //assume 8 channel. If needed, it automatically changes to 16 automatically in a later block. int nchan=4; //assume 8 channel. If needed, it automatically changes to 16 automatically in a later block.
gpio_set_pin_level(ADS1299.SS_pin, false); // open SPI gpio_set_pin_level(ADS1299.SS_pin, false); // open SPI
// READ CHANNEL DATA FROM FIRST ADS IN DAISY LINE // READ CHANNEL DATA FROM FIRST ADS IN DAISY LINE
for(int i=0; i<3; i++){ // read 3 byte status register from ADS 1 (1100+LOFF_STATP+LOFF_STATN+GPIO[7:4]) for(int i=0; i<3; i++){ // read 3 byte status register from ADS 1 (1100+LOFF_STATP+LOFF_STATN+GPIO[7:4])
inByte = transfer_byte(ADS1299.SPI_descr,0x00); inByte = _transfer_byte(ADS1299.SPI_descr,0x00);
ADS1299.stat_1 = (ADS1299.stat_1<<8) | inByte; ADS1299.stat_1 = (ADS1299.stat_1<<8) | inByte;
} }
for(int i = 0; i<8; i++){ for(int i = 0; i<8; i++){
for(int j=0; j<3; j++){ // read 24 bits of channel data from 1st ADS in 8 3 byte chunks for(int j=0; j<3; j++){ // read 24 bits of channel data from 1st ADS in 8 3 byte chunks
inByte = transfer_byte(ADS1299.SPI_descr, 0x00); inByte = _transfer_byte(ADS1299.SPI_descr, 0x00);
ADS1299.channel_data[i] = (ADS1299.channel_data[i]<<8) | inByte; _channel_data[i] = (_channel_data[i]<<8) | inByte;
} }
} }
@ -155,16 +273,16 @@ void updateChannelData()
//reformat the numbers //reformat the numbers
for(int i=0; i<nchan; i++){ // convert 3 byte 2's compliment to 4 byte 2's compliment for(int i=0; i<nchan; i++){ // convert 3 byte 2's compliment to 4 byte 2's compliment
if(bitRead(ADS1299.channel_data[i],23) == 1){ if(bitRead(_channel_data[i],23) == 1){
ADS1299.channel_data[i] |= 0xFF000000; _channel_data[i] |= 0xFF000000;
}else{ }else{
ADS1299.channel_data[i] &= 0x00FFFFFF; _channel_data[i] &= 0x00FFFFFF;
} }
} }
return &_channel_data;
} }
uint8_t transfer_byte(struct spi_m_sync_descriptor *spi, uint8_t command) uint8_t _transfer_byte(struct spi_m_sync_descriptor *spi, uint8_t command)
{ {
uint8_t in_buf[1], out_buf[1]; uint8_t in_buf[1], out_buf[1];
uint8_t wordRead; uint8_t wordRead;
@ -175,11 +293,11 @@ uint8_t transfer_byte(struct spi_m_sync_descriptor *spi, uint8_t command)
xfer.txbuf = out_buf; xfer.txbuf = out_buf;
xfer.size = 1; xfer.size = 1;
spi_m_sync_transfer(ADS1299.SPI_descr, &xfer); spi_m_sync_transfer(ADS1299.SPI_descr, &xfer);
wordRead = in_buf; wordRead = in_buf[0];
return (wordRead); return (wordRead);
} }
uint16_t transfer_word(struct spi_m_sync_descriptor *spi, uint16_t command) uint16_t _transfer_word(struct spi_m_sync_descriptor *spi, uint16_t command)
{ {
uint8_t in_buf[2], out_buf[2]; uint8_t in_buf[2], out_buf[2];
uint16_t wordRead; uint16_t wordRead;

View File

@ -52,53 +52,56 @@
#define MISC2 0x16 #define MISC2 0x16
#define CONFIG4 0x17 #define CONFIG4 0x17
volatile int32_t _channel_data[8];
/* Struct Definitions */ /* Struct Definitions */
struct SPI_ADS1299 { volatile struct SPI_ADS1299 {
struct spi_m_sync_descriptor *SPI_descr; volatile struct spi_m_sync_descriptor *SPI_descr;
uint8_t flags; volatile bool data_ReadyFlag;
uint32_t SS_pin; volatile uint32_t SS_pin;
uint32_t reset_pin; volatile uint32_t reset_pin;
uint8_t regData [24]; volatile uint8_t regData [24];
int16_t channel_data[16]; // Must Equal n_dev volatile int32_t* channel_data; // Must Equal n_dev
int16_t stat_1; volatile int16_t stat_1;
}; };
static struct SPI_ADS1299 ADS1299 = { static volatile struct SPI_ADS1299 ADS1299 = {
.SPI_descr = &SPI_2, .SPI_descr = &SPI_2,
.flags = 0, .data_ReadyFlag = false,
.SS_pin = SPI2_SS, .SS_pin = SPI2_SS,
.reset_pin = ADS_RESET, .reset_pin = ADS_RESET,
.regData = {0}, .regData = {0},
.channel_data = {0}, .channel_data = &_channel_data[0],
}; };
void initialize_ads(); void initialize_ads();
//ADS1299 SPI Command Definitions (Datasheet, p35) //ADS1299 SPI Command Definitions (Datasheet, p35)
//System Commands //System Commands
void WAKEUP(); void ADS1299_WAKEUP();
void STANDBY(); void ADS1299_STANDBY();
void RESET(); void ADS1299_RESET();
void START(); void ADS1299_START();
void STOP(); void ADS1299_STOP();
//Data Read Commands //Data Read Commands
void RDATAC(); void ADS1299_RDATAC();
void SDATAC(); void ADS1299_SDATAC();
void RDATA(); void ADS1299_RDATA();
//Register Read/Write Commands //Register Read/Write Commands
uint8_t getDeviceID(); uint8_t getDeviceID();
uint8_t RREG(uint8_t _address); uint8_t ADS1299_RREG(uint8_t _address);
void RREGS(uint8_t _address, uint8_t _numRegistersMinusOne); void ADS1299_RREGS(uint8_t _address, uint8_t _numRegistersMinusOne);
void printRegisterName(uint8_t _address); void printRegisterName(uint8_t _address);
void WREG(uint8_t _address, uint8_t _value); void ADS1299_WREG(uint8_t _address, uint8_t _value);
void WREGS(uint8_t _address, uint8_t _numRegistersMinusOne); void ADS1299_WREGS(uint8_t _address, uint8_t _numRegistersMinusOne);
void printHex(uint8_t _data); void printHex(uint8_t _data);
void updateChannelData(); int32_t* ADS1299_UPDATECHANNELDATA();
uint8_t transfer_byte(struct spi_m_sync_descriptor *spi, uint8_t command); uint8_t _transfer_byte(struct spi_m_sync_descriptor *spi, uint8_t command);
uint16_t transfer_word(struct spi_m_sync_descriptor *spi, uint16_t command); uint16_t _transfer_word(struct spi_m_sync_descriptor *spi, uint16_t command);
//SPI Transfer function //SPI Transfer function

View File

@ -11,6 +11,8 @@
#include "Ethercat_QSPI.h" #include "Ethercat_QSPI.h"
extern volatile int32_t _channel_data[8];
//Write To Ecat Total Bytes (XX bytes) //Write To Ecat Total Bytes (XX bytes)
/* Motor 1*/ /* Motor 1*/
static volatile uint8_t *M1_Status = (uint8_t *)&QSPI_tx_buffer[0]; static volatile uint8_t *M1_Status = (uint8_t *)&QSPI_tx_buffer[0];
@ -37,14 +39,10 @@ static volatile int16_t *M2_Motor_currentPhC = (((int16_t *)&QSPI_tx_buffer[8]
static volatile int16_t *M2_Motor__hallState = ((int16_t *)&QSPI_tx_buffer[9]); static volatile int16_t *M2_Motor__hallState = ((int16_t *)&QSPI_tx_buffer[9]);
static volatile int16_t *M2_Motor_dutyCycle = (((int16_t *)&QSPI_tx_buffer[9])+1); static volatile int16_t *M2_Motor_dutyCycle = (((int16_t *)&QSPI_tx_buffer[9])+1);
/* EMG */ /* EMG */
static volatile int16_t *EMG_CH1 = (((int16_t *)&QSPI_tx_buffer[10])); static volatile int32_t *EMG_CH1 = (((int32_t *)&QSPI_tx_buffer[10]));
static volatile int16_t *EMG_CH2 = (((int16_t *)&QSPI_tx_buffer[10])+1); static volatile int32_t *EMG_CH2 = (((int32_t *)&QSPI_tx_buffer[11]));
static volatile int16_t *EMG_CH3 = (((int16_t *)&QSPI_tx_buffer[11])); static volatile int32_t *EMG_CH3 = (((int32_t *)&QSPI_tx_buffer[12]));
static volatile int16_t *EMG_CH4 = (((int16_t *)&QSPI_tx_buffer[11])+1); static volatile int32_t *EMG_CH4 = (((int32_t *)&QSPI_tx_buffer[13]));
static volatile int16_t *EMG_CH5 = (((int16_t *)&QSPI_tx_buffer[12]));
static volatile int16_t *EMG_CH6 = (((int16_t *)&QSPI_tx_buffer[12])+1);
static volatile int16_t *EMG_CH7 = (((int16_t *)&QSPI_tx_buffer[13]));
static volatile int16_t *EMG_CH8 = (((int16_t *)&QSPI_tx_buffer[13])+1);
/* Reserved space */ /* Reserved space */
static volatile int16_t *Spare1_tx = (((int16_t *)&QSPI_tx_buffer[14])); static volatile int16_t *Spare1_tx = (((int16_t *)&QSPI_tx_buffer[14]));
@ -167,7 +165,7 @@ static void update_telemetry(void)
/* Motor 1 */ /* Motor 1 */
*M1_Status = Motor1.motor_state.currentstate; *M1_Status = Motor1.motor_state.currentstate;
*M1_Joint_rel_position = Motor1.motor_status.Num_Steps; *M1_Joint_rel_position = Motor1.motor_status.Num_Steps;
//*M1_Joint_abs_position = ((int16_t *)&QSPI_tx_buffer[1]); *M1_Joint_abs_position = Motor1.motor_status.abs_position;
//*M1_Motor_speed = (((int16_t *)&QSPI_tx_buffer[1])+1); //*M1_Motor_speed = (((int16_t *)&QSPI_tx_buffer[1])+1);
*M1_Motor_current_bus = convert_to_mA(Motor1.Iphase_pu.Bus); *M1_Motor_current_bus = convert_to_mA(Motor1.Iphase_pu.Bus);
*M1_Motor_currentPhA = convert_to_mA(Motor1.Iphase_pu.A); *M1_Motor_currentPhA = convert_to_mA(Motor1.Iphase_pu.A);
@ -180,7 +178,7 @@ static void update_telemetry(void)
/* Motor 2 */ /* Motor 2 */
*M2_Status = Motor2.motor_state.currentstate; *M2_Status = Motor2.motor_state.currentstate;
*M2_Joint_rel_position = Motor2.motor_status.Num_Steps; *M2_Joint_rel_position = Motor2.motor_status.Num_Steps;
//*M1_Joint_abs_position = ((int16_t *)&QSPI_tx_buffer[1]); *M2_Joint_abs_position = Motor2.motor_status.abs_position;
//*M1_Motor_speed = (((int16_t *)&QSPI_tx_buffer[1])+1); //*M1_Motor_speed = (((int16_t *)&QSPI_tx_buffer[1])+1);
*M2_Motor_current_bus = convert_to_mA( Motor2.Iphase_pu.Bus); *M2_Motor_current_bus = convert_to_mA( Motor2.Iphase_pu.Bus);
*M2_Motor_currentPhA = convert_to_mA( Motor2.Iphase_pu.A); *M2_Motor_currentPhA = convert_to_mA( Motor2.Iphase_pu.A);
@ -190,6 +188,15 @@ static void update_telemetry(void)
*M2_Motor_dutyCycle = Motor2.motor_status.duty_cycle; *M2_Motor_dutyCycle = Motor2.motor_status.duty_cycle;
*M2_Motor_speed = (int16_t)Motor2.motor_status.calc_rpm; *M2_Motor_speed = (int16_t)Motor2.motor_status.calc_rpm;
//*M2_Joint_abs_position = Motor2.motor_status.actualDirection; //*M2_Joint_abs_position = Motor2.motor_status.actualDirection;
*EMG_CH1 = _channel_data[0];
*EMG_CH2 = _channel_data[1];
*EMG_CH3 = _channel_data[2];
*EMG_CH4 = _channel_data[3];
//*EMG_CH1 = 1;
//*EMG_CH2 = 2;
//*EMG_CH3 = 3;
//*EMG_CH4 = 4;
} }
static void update_setpoints(void) static void update_setpoints(void)
@ -291,10 +298,7 @@ static inline void comms_check(void)
*EMG_CH2 = 24; *EMG_CH2 = 24;
*EMG_CH3 = -25; *EMG_CH3 = -25;
*EMG_CH4 = 26; *EMG_CH4 = 26;
*EMG_CH5 = -27;
*EMG_CH6 = 28;
*EMG_CH7 = -29;
*EMG_CH8 = 30;
/* Motor 3*/ /* Motor 3*/
*M3_Status = 1; *M3_Status = 1;

View File

@ -11,6 +11,8 @@
#include "Ethercat_QSPI.h" #include "Ethercat_QSPI.h"
extern volatile int32_t _channel_data[8];
//Write To Ecat Total Bytes (XX bytes) //Write To Ecat Total Bytes (XX bytes)
/* Motor 1*/ /* Motor 1*/
static volatile uint8_t *M1_Status = (uint8_t *)&QSPI_tx_buffer[0]; static volatile uint8_t *M1_Status = (uint8_t *)&QSPI_tx_buffer[0];
@ -37,14 +39,10 @@ static volatile int16_t *M2_Motor_currentPhC = (((int16_t *)&QSPI_tx_buffer[8]
static volatile int16_t *M2_Motor__hallState = ((int16_t *)&QSPI_tx_buffer[9]); static volatile int16_t *M2_Motor__hallState = ((int16_t *)&QSPI_tx_buffer[9]);
static volatile int16_t *M2_Motor_dutyCycle = (((int16_t *)&QSPI_tx_buffer[9])+1); static volatile int16_t *M2_Motor_dutyCycle = (((int16_t *)&QSPI_tx_buffer[9])+1);
/* EMG */ /* EMG */
static volatile int16_t *EMG_CH1 = (((int16_t *)&QSPI_tx_buffer[10])); static volatile int32_t *EMG_CH1 = (((int32_t *)&QSPI_tx_buffer[10]));
static volatile int16_t *EMG_CH2 = (((int16_t *)&QSPI_tx_buffer[10])+1); static volatile int32_t *EMG_CH2 = (((int32_t *)&QSPI_tx_buffer[11]));
static volatile int16_t *EMG_CH3 = (((int16_t *)&QSPI_tx_buffer[11])); static volatile int32_t *EMG_CH3 = (((int32_t *)&QSPI_tx_buffer[12]));
static volatile int16_t *EMG_CH4 = (((int16_t *)&QSPI_tx_buffer[11])+1); static volatile int32_t *EMG_CH4 = (((int32_t *)&QSPI_tx_buffer[13]));
static volatile int16_t *EMG_CH5 = (((int16_t *)&QSPI_tx_buffer[12]));
static volatile int16_t *EMG_CH6 = (((int16_t *)&QSPI_tx_buffer[12])+1);
static volatile int16_t *EMG_CH7 = (((int16_t *)&QSPI_tx_buffer[13]));
static volatile int16_t *EMG_CH8 = (((int16_t *)&QSPI_tx_buffer[13])+1);
/* Reserved space */ /* Reserved space */
static volatile int16_t *Spare1_tx = (((int16_t *)&QSPI_tx_buffer[14])); static volatile int16_t *Spare1_tx = (((int16_t *)&QSPI_tx_buffer[14]));
@ -167,7 +165,7 @@ static void update_telemetry(void)
/* Motor 1 */ /* Motor 1 */
*M1_Status = Motor1.motor_state.currentstate; *M1_Status = Motor1.motor_state.currentstate;
*M1_Joint_rel_position = Motor1.motor_status.Num_Steps; *M1_Joint_rel_position = Motor1.motor_status.Num_Steps;
//*M1_Joint_abs_position = ((int16_t *)&QSPI_tx_buffer[1]); *M1_Joint_abs_position = Motor1.motor_status.abs_position;
//*M1_Motor_speed = (((int16_t *)&QSPI_tx_buffer[1])+1); //*M1_Motor_speed = (((int16_t *)&QSPI_tx_buffer[1])+1);
*M1_Motor_current_bus = convert_to_mA(Motor1.Iphase_pu.Bus); *M1_Motor_current_bus = convert_to_mA(Motor1.Iphase_pu.Bus);
*M1_Motor_currentPhA = convert_to_mA(Motor1.Iphase_pu.A); *M1_Motor_currentPhA = convert_to_mA(Motor1.Iphase_pu.A);
@ -180,7 +178,7 @@ static void update_telemetry(void)
/* Motor 2 */ /* Motor 2 */
*M2_Status = Motor2.motor_state.currentstate; *M2_Status = Motor2.motor_state.currentstate;
*M2_Joint_rel_position = Motor2.motor_status.Num_Steps; *M2_Joint_rel_position = Motor2.motor_status.Num_Steps;
//*M1_Joint_abs_position = ((int16_t *)&QSPI_tx_buffer[1]); *M2_Joint_abs_position = Motor2.motor_status.abs_position;
//*M1_Motor_speed = (((int16_t *)&QSPI_tx_buffer[1])+1); //*M1_Motor_speed = (((int16_t *)&QSPI_tx_buffer[1])+1);
*M2_Motor_current_bus = convert_to_mA( Motor2.Iphase_pu.Bus); *M2_Motor_current_bus = convert_to_mA( Motor2.Iphase_pu.Bus);
*M2_Motor_currentPhA = convert_to_mA( Motor2.Iphase_pu.A); *M2_Motor_currentPhA = convert_to_mA( Motor2.Iphase_pu.A);
@ -190,6 +188,15 @@ static void update_telemetry(void)
*M2_Motor_dutyCycle = Motor2.motor_status.duty_cycle; *M2_Motor_dutyCycle = Motor2.motor_status.duty_cycle;
*M2_Motor_speed = (int16_t)Motor2.motor_status.calc_rpm; *M2_Motor_speed = (int16_t)Motor2.motor_status.calc_rpm;
//*M2_Joint_abs_position = Motor2.motor_status.actualDirection; //*M2_Joint_abs_position = Motor2.motor_status.actualDirection;
*EMG_CH1 = _channel_data[0];
*EMG_CH2 = _channel_data[1];
*EMG_CH3 = _channel_data[2];
*EMG_CH4 = _channel_data[3];
//*EMG_CH1 = 1;
//*EMG_CH2 = 2;
//*EMG_CH3 = 3;
//*EMG_CH4 = 4;
} }
static void update_setpoints(void) static void update_setpoints(void)
@ -291,10 +298,7 @@ static inline void comms_check(void)
*EMG_CH2 = 24; *EMG_CH2 = 24;
*EMG_CH3 = -25; *EMG_CH3 = -25;
*EMG_CH4 = 26; *EMG_CH4 = 26;
*EMG_CH5 = -27;
*EMG_CH6 = 28;
*EMG_CH7 = -29;
*EMG_CH8 = 30;
/* Motor 3*/ /* Motor 3*/
*M3_Status = 1; *M3_Status = 1;

View File

@ -150,7 +150,7 @@
<AcmeProjectActionInfo Action="File" Source="hri/hri_usb_e51.h" IsConfig="false" Hash="x6M7vYgNCS2oECqykr5+yw" /> <AcmeProjectActionInfo Action="File" Source="hri/hri_usb_e51.h" IsConfig="false" Hash="x6M7vYgNCS2oECqykr5+yw" />
<AcmeProjectActionInfo Action="File" Source="hri/hri_wdt_e51.h" IsConfig="false" Hash="o9Rg/hyuMzwOCphVc7uG1w" /> <AcmeProjectActionInfo Action="File" Source="hri/hri_wdt_e51.h" IsConfig="false" Hash="o9Rg/hyuMzwOCphVc7uG1w" />
<AcmeProjectActionInfo Action="File" Source="main.c" IsConfig="false" Hash="k0AH7j+BrmdFhBPzCCMptA" /> <AcmeProjectActionInfo Action="File" Source="main.c" IsConfig="false" Hash="k0AH7j+BrmdFhBPzCCMptA" />
<AcmeProjectActionInfo Action="File" Source="driver_init.c" IsConfig="false" Hash="x19qC0FjPq5Eh54u7ftL1g" /> <AcmeProjectActionInfo Action="File" Source="driver_init.c" IsConfig="false" Hash="Q3o1x3vWYELO1L6mRVKUIA" />
<AcmeProjectActionInfo Action="File" Source="driver_init.h" IsConfig="false" Hash="hkPygmC76Qup+RNNN/cLrA" /> <AcmeProjectActionInfo Action="File" Source="driver_init.h" IsConfig="false" Hash="hkPygmC76Qup+RNNN/cLrA" />
<AcmeProjectActionInfo Action="File" Source="atmel_start_pins.h" IsConfig="false" Hash="q332kmNEqTBha3F9F86pCg" /> <AcmeProjectActionInfo Action="File" Source="atmel_start_pins.h" IsConfig="false" Hash="q332kmNEqTBha3F9F86pCg" />
<AcmeProjectActionInfo Action="File" Source="examples/driver_examples.h" IsConfig="false" Hash="HwCfGc+NYMxlXMiyssgrQQ" /> <AcmeProjectActionInfo Action="File" Source="examples/driver_examples.h" IsConfig="false" Hash="HwCfGc+NYMxlXMiyssgrQQ" />
@ -417,7 +417,7 @@
<armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection> <armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>
<armgcc.compiler.optimization.DebugLevel>Maximum (-g3)</armgcc.compiler.optimization.DebugLevel> <armgcc.compiler.optimization.DebugLevel>Maximum (-g3)</armgcc.compiler.optimization.DebugLevel>
<armgcc.compiler.warnings.AllWarnings>True</armgcc.compiler.warnings.AllWarnings> <armgcc.compiler.warnings.AllWarnings>True</armgcc.compiler.warnings.AllWarnings>
<armgcc.compiler.miscellaneous.OtherFlags>-std=gnu99 -mfloat-abi=hard -mfpu=fpv4-sp-d16</armgcc.compiler.miscellaneous.OtherFlags> <armgcc.compiler.miscellaneous.OtherFlags>-std=gnu11 -mfloat-abi=hard -mfpu=fpv4-sp-d16</armgcc.compiler.miscellaneous.OtherFlags>
<armgcc.linker.general.UseNewlibNano>True</armgcc.linker.general.UseNewlibNano> <armgcc.linker.general.UseNewlibNano>True</armgcc.linker.general.UseNewlibNano>
<armgcc.linker.libraries.Libraries> <armgcc.linker.libraries.Libraries>
<ListValues> <ListValues>

View File

@ -104,6 +104,7 @@ void BldcInitStruct(BLDCMotor_t* const motor, BLDCMotor_param_t * const motor_pa
motor->motor_status.actualDirection = 0; motor->motor_status.actualDirection = 0;
motor->motor_status.duty_cycle = 0; motor->motor_status.duty_cycle = 0;
motor->motor_status.calc_rpm = 0; motor->motor_status.calc_rpm = 0;
motor->motor_status.abs_position = 0;
motor->motor_status.Num_Steps = 0; motor->motor_status.Num_Steps = 0;
motor->motor_status.cur_comm_step = 0; motor->motor_status.cur_comm_step = 0;
motor->motor_status.currentHallPattern = 1; motor->motor_status.currentHallPattern = 1;

View File

@ -62,6 +62,7 @@ volatile typedef struct
volatile uint8_t actualDirection; //! The actual direction of rotation. volatile uint8_t actualDirection; //! The actual direction of rotation.
volatile uint16_t duty_cycle; volatile uint16_t duty_cycle;
volatile int16_t calc_rpm; volatile int16_t calc_rpm;
volatile int16_t abs_position;
volatile int16_t Num_Steps; volatile int16_t Num_Steps;
/* Hall States */ /* Hall States */
//volatile uint8_t prevHallPattern; //volatile uint8_t prevHallPattern;

View File

@ -663,6 +663,16 @@ void system_init(void)
// GPIO on PA14 // GPIO on PA14
gpio_set_pin_level(SPI2_SS,
// <y> Initial level
// <id> pad_initial_level
// <false"> Low
// <true"> High
true);
// Set pin direction to output
gpio_set_pin_direction(SPI2_SS, GPIO_DIRECTION_OUT);
gpio_set_pin_function(SPI2_SS, GPIO_PIN_FUNCTION_OFF); gpio_set_pin_function(SPI2_SS, GPIO_PIN_FUNCTION_OFF);
// GPIO on PA25 // GPIO on PA25

View File

@ -60,7 +60,7 @@ void adc_sram_dma_callback(struct _dma_resource *adc_dma_res)
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// EtherCAT Cycle Timer - 1kHz // Speed Counter TC2 Overflow handler
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
void TC2_Handler(void) void TC2_Handler(void)
{ {
@ -71,7 +71,7 @@ void TC2_Handler(void)
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// // Speed Counter TC2 Overflow handler
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
void TC4_Handler(void) void TC4_Handler(void)
{ {
@ -81,7 +81,9 @@ void TC4_Handler(void)
} }
} }
// ----------------------------------------------------------------------
// BLDC Driver External Interrupt Handlers
// ----------------------------------------------------------------------
static void M1_RESET_BAR(void) static void M1_RESET_BAR(void)
{ {
volatile int x = 0; volatile int x = 0;
@ -92,7 +94,15 @@ static void M2_RESET_BAR(void)
volatile int x = 0; volatile int x = 0;
} }
// ----------------------------------------------------------------------
// ADS Data Ready Interrupt
// ----------------------------------------------------------------------
void ADS1299_dataReadyISR(void)
{
ADS1299.data_ReadyFlag = true;
//int32_t* temp = ADS1299_UPDATECHANNELDATA();
volatile int x = 1;
}

View File

@ -6,6 +6,7 @@
#include "bldc.h" #include "bldc.h"
#include "bldc_types.h" #include "bldc_types.h"
#include "EtherCAT_QSPI.h" #include "EtherCAT_QSPI.h"
#include "ADS1299.h"
#include "EtherCAT_SlaveDef.h" #include "EtherCAT_SlaveDef.h"
//#include "MSIF_master.h" //#include "MSIF_master.h"
#include "configuration.h" #include "configuration.h"
@ -13,7 +14,7 @@
#include "statemachine.h" #include "statemachine.h"
#include "angle_sensors.h" #include "angle_sensors.h"
#include "ADS1299.h"
void process_currents() void process_currents()
@ -79,10 +80,12 @@ void enable_NVIC_IRQ(void)
//NVIC_EnableIRQ(TC4_IRQn); // TC4: M2_Speed_Timer //NVIC_EnableIRQ(TC4_IRQn); // TC4: M2_Speed_Timer
NVIC_EnableIRQ(DMAC_0_IRQn); NVIC_EnableIRQ(DMAC_0_IRQn);
NVIC_EnableIRQ(DMAC_1_IRQn); NVIC_EnableIRQ(DMAC_1_IRQn);
NVIC_SetPriority(DMAC_0_IRQn, 2); NVIC_SetPriority(DMAC_0_IRQn, 1);
NVIC_SetPriority(ADC1_0_IRQn, 3); NVIC_SetPriority(ADC1_0_IRQn, 3);
NVIC_EnableIRQ(TCC0_0_IRQn); NVIC_EnableIRQ(TCC0_0_IRQn);
NVIC_EnableIRQ(TCC1_0_IRQn); NVIC_EnableIRQ(TCC1_0_IRQn);
NVIC_EnableIRQ(EIC_2_IRQn);
NVIC_SetPriority(EIC_2_IRQn, 3);
//NVIC_SetPriority(TCC0_0_IRQn, 3); //NVIC_SetPriority(TCC0_0_IRQn, 3);
//NVIC_EnableIRQ(EIC_5_IRQn); //NVIC_EnableIRQ(EIC_5_IRQn);
} }
@ -146,40 +149,38 @@ int main(void)
{ {
/* Initializes MCU, drivers and middleware */ /* Initializes MCU, drivers and middleware */
atmel_start_init(); atmel_start_init();
//initMotorParameters(); __disable_irq();
//configure_tcc_pwm();
//BldcInitStruct(&Motor1, &FH_22mm24BXTR); /* BLDC INIT */
//BldcInitStruct(&Motor2, &FH_32mm24BXTR);
//Motor1.readHall = &readHallSensorM1;
//Motor2.readHall = &readHallSensorM2;
//read_zero_current_offset_value(&Motor1, &Motor2);
//adc_sync_enable_channel(&ADC_1, 6);
//adc_init_dma();
//config_qspi();
//custom_logic_enable();
//enable_NVIC_IRQ();
//ECAT_STATE_MACHINE();
//One_ms_timer_init();
BldcInitStruct(&Motor1, &FH_22mm24BXTR); BldcInitStruct(&Motor1, &FH_22mm24BXTR);
BldcInitStruct(&Motor2, &FH_32mm24BXTR); BldcInitStruct(&Motor2, &FH_32mm24BXTR);
Motor1.readHall = &readHallSensorM1; Motor1.readHall = &readHallSensorM1;
Motor2.readHall = &readHallSensorM2; Motor2.readHall = &readHallSensorM2;
/* Current Offeset Calibration */
read_zero_current_offset_value(&Motor1, &Motor2); read_zero_current_offset_value(&Motor1, &Motor2);
/* Configure Hardware */
config_qspi(); config_qspi();
configure_tcc_pwm(); configure_tcc_pwm();
adc_sync_enable_channel(&ADC_1, 6); adc_sync_enable_channel(&ADC_1, 6);
/* SPI & DMA Configs */
boardToBoardTransferInit(); boardToBoardTransferInit();
init_spi_master_dma_descriptors(); init_spi_master_dma_descriptors();
adc_init_dma(); adc_init_dma();
ECAT_STATE_MACHINE(); ECAT_STATE_MACHINE();
One_ms_timer_init(); One_ms_timer_init();
custom_logic_enable(); custom_logic_enable();
//speed_timer_init();
angle_sensor_init(); angle_sensor_init();
initialize_ads(); initialize_ads();
/* External IRQ Config */
ext_irq_register(GPIO_PIN(ADS_DATA_RDY), ADS1299_dataReadyISR);
enable_NVIC_IRQ(); enable_NVIC_IRQ();
__enable_irq();
//ADS1299_START();
/* Replace with your application code */ /* Replace with your application code */
while (1) { while (1) {
@ -189,20 +190,15 @@ int main(void)
update_telemetry(); update_telemetry();
update_setpoints(); update_setpoints();
PORT->Group[1].OUTCLR.reg = (1<<GPIO_PIN(SPI1_CS)); PORT->Group[1].OUTCLR.reg = (1<<GPIO_PIN(SPI1_CS));
_dma_enable_transaction(DMAC_CHANNEL_CONF_SERCOM_1_RECEIVE, false); DMAC->Channel[0].CHCTRLA.reg |= DMAC_CHCTRLA_ENABLE;
_dma_enable_transaction(DMAC_CHANNEL_CONF_SERCOM_1_TRANSMIT, false); DMAC->Channel[1].CHCTRLA.reg |= DMAC_CHCTRLA_ENABLE;
volatile int x = 1; //_dma_enable_transaction(DMAC_CHANNEL_CONF_SERCOM_1_RECEIVE, false);
//_dma_enable_transaction(DMAC_CHANNEL_CONF_SERCOM_1_TRANSMIT, false);
// //int16_t* angles;
int16_t* angles; //angles = read_angle();
//int16_t* field; //Motor1.motor_status.abs_position = degrees(angles[0]);
//int16_t* temp; //Motor2.motor_status.abs_position = degrees(angles[1]);
angles = read_angle();
*M1_Joint_abs_position = degrees(angles[0]);
*M2_Joint_abs_position = degrees(angles[1]);
START();
*EMG_CH1 = getDeviceID();
////field = ang_sense_read(AS_CMD_MAGNITUDE); ////field = ang_sense_read(AS_CMD_MAGNITUDE);
//*Spare1_tx = (field[0] & AS_MASK); //*Spare1_tx = (field[0] & AS_MASK);
@ -210,10 +206,7 @@ int main(void)
//temp = ang_sense_read(AS_CMD_TEMP); //temp = ang_sense_read(AS_CMD_TEMP);
//*Spare3_tx = (int16_t)(((float)(temp[0] & AS_MASK) / 8.0) - 273.15); //*Spare3_tx = (int16_t)(((float)(temp[0] & AS_MASK) / 8.0) - 273.15);
//*Spare4_tx = (int16_t)(((float)(temp[1] & AS_MASK) / 8.0) - 273.15); //*Spare4_tx = (int16_t)(((float)(temp[1] & AS_MASK) / 8.0) - 273.15);
volatile int y = 0;
//spi_m_dma_transfer(&SPI_1_MSIF, (uint8_t*)Slave_1.tx_buffer, (uint8_t*)Slave_1.rx_buffer, MASTER_BUFFER_SIZE);
} }
if (Motor1.timerflags.current_loop_tic) { if (Motor1.timerflags.current_loop_tic) {
@ -221,6 +214,12 @@ int main(void)
exec_commutation(&Motor1); exec_commutation(&Motor1);
exec_commutation(&Motor2); exec_commutation(&Motor2);
} }
if (ADS1299.data_ReadyFlag){
ADS1299.data_ReadyFlag = false;
//ADS1299_UPDATECHANNELDATA();
}
if (run_ECAT) {ECAT_STATE_MACHINE();} if (run_ECAT) {ECAT_STATE_MACHINE();}
} }

View File

@ -239,7 +239,7 @@ int main(void)
//as5048a_init(&SPI_3, &AS_1); //as5048a_init(&SPI_3, &AS_1);
//ORIENTATION_SENSOR_0_init(); ORIENTATION_SENSOR_0_init();
angle_sensor_init(); angle_sensor_init();