From 21a00270e325f1dfd3e12608d8bf5d644cb2d58f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 08:59:17 +0100 Subject: [PATCH 01/62] Delete man directory --- man/gf2-amp.1.gz | Bin 555 -> 0 bytes man/gf2-amp50.1.gz | Bin 663 -> 0 bytes man/gf2-clear.1.gz | Bin 588 -> 0 bytes man/gf2-clkoff.1.gz | Bin 539 -> 0 bytes man/gf2-clkon.1.gz | Bin 565 -> 0 bytes man/gf2-dacoff.1.gz | Bin 594 -> 0 bytes man/gf2-dacon.1.gz | Bin 484 -> 0 bytes man/gf2-freq.1.gz | Bin 735 -> 0 bytes man/gf2-freq0.1.gz | Bin 711 -> 0 bytes man/gf2-freq1.1.gz | Bin 655 -> 0 bytes man/gf2-list.1.gz | Bin 500 -> 0 bytes man/gf2-lockotp.1.gz | Bin 585 -> 0 bytes man/gf2-phase.1.gz | Bin 699 -> 0 bytes man/gf2-phase0.1.gz | Bin 675 -> 0 bytes man/gf2-phase1.1.gz | Bin 617 -> 0 bytes man/gf2-reset.1.gz | Bin 539 -> 0 bytes man/gf2-selfreq0.1.gz | Bin 591 -> 0 bytes man/gf2-selfreq1.1.gz | Bin 593 -> 0 bytes man/gf2-selphase0.1.gz | Bin 588 -> 0 bytes man/gf2-selphase1.1.gz | Bin 589 -> 0 bytes man/gf2-sine.1.gz | Bin 420 -> 0 bytes man/gf2-start.1.gz | Bin 519 -> 0 bytes man/gf2-status.1.gz | Bin 536 -> 0 bytes man/gf2-stop.1.gz | Bin 568 -> 0 bytes man/gf2-tri.1.gz | Bin 416 -> 0 bytes 25 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 man/gf2-amp.1.gz delete mode 100644 man/gf2-amp50.1.gz delete mode 100644 man/gf2-clear.1.gz delete mode 100644 man/gf2-clkoff.1.gz delete mode 100644 man/gf2-clkon.1.gz delete mode 100644 man/gf2-dacoff.1.gz delete mode 100644 man/gf2-dacon.1.gz delete mode 100644 man/gf2-freq.1.gz delete mode 100644 man/gf2-freq0.1.gz delete mode 100644 man/gf2-freq1.1.gz delete mode 100644 man/gf2-list.1.gz delete mode 100644 man/gf2-lockotp.1.gz delete mode 100644 man/gf2-phase.1.gz delete mode 100644 man/gf2-phase0.1.gz delete mode 100644 man/gf2-phase1.1.gz delete mode 100644 man/gf2-reset.1.gz delete mode 100644 man/gf2-selfreq0.1.gz delete mode 100644 man/gf2-selfreq1.1.gz delete mode 100644 man/gf2-selphase0.1.gz delete mode 100644 man/gf2-selphase1.1.gz delete mode 100644 man/gf2-sine.1.gz delete mode 100644 man/gf2-start.1.gz delete mode 100644 man/gf2-status.1.gz delete mode 100644 man/gf2-stop.1.gz delete mode 100644 man/gf2-tri.1.gz diff --git a/man/gf2-amp.1.gz b/man/gf2-amp.1.gz deleted file mode 100644 index 1338d34a18d388f905259cd329238b52f6947886..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 555 zcmV+`0@VEr|tS9Eyz&y9zqsTjMbVEEyF(Gz|>M$%8XQ-JpCPMmKE#=OAqfbqW!lkiPhe z#69YwA1_EmnG{Hm!!;^hOT#*aK)R%@6gCk{&X{N@UH#N{O&bd6wKQN;{e-?9#x?Cq zrQx0J?6KVq?WI_p*oF`M9TRj5|2d}w8QAuoWsi9QqL>sbamKPYO@3Z=+_b7u#za~b z{6g>A{U{l*#Uat4A#hk?Ox{wBMF<<0Oi4xoy?35DrINn@+ERS&bwA0HV3Xo@g2}45 zn=hG=bwUGEmps}(za0!h7vWWHx|njG*0t1zD_5WIh8I}|lc|`W?O)#e(O`Uj(XBuk zl>P)gyQ=CzdqAaByCmDgW3ux2qX$MkG(I4sLp*R8r=DGG4#{Ri?)zxeheslMXLw`^ tX!@$V!1y%q58*yCKC)PmjdY5@b*ESEDoI}*?D;qLZwIC)rHjbO}p zb`P`3L&7%Yt_+3MjsS;E)$?oE zi+%B?&i5SINYFAmC&qJ@T5!HQeqvj;4rg6Ng8u2!fq-fwB3M> zp^o85AJA3G2)Y5UDs16u^ye2Vn=MNjose&hiH0^rp-b@Hl`s8^LdF)CEM3CqdBOd_Ylf#s;oP?sURJuTN&8__38lHT)y01JEJ=%%T+tZR17~J3En{qDVR9}p0BusqZrd;rz4I#uJ|%!7*a3R4;wZ5J z#||W=3)&tSdL$F3NR>-n=ZAXjH?%+2k!(v*+Y7-r%bPb#l+WS*?)qxBOyU%#EXwAv ziXReI7S~roA-C}P3XUI&gS()Gmqx=qYP8%N3l6=Px^!)B_Hng-%oZ7oZlI%JQM!On zkR|CNUap=VZjuzfwBff&HcJk8n~4XXJ*fG22VOg~H<3 zfLa{R5tI4L80sx|*jax4JgTZ{C4JcRj(2q(K~AcqCZ(GH+Z@Tejc08-sRwt^Vrz{y z!O;?o*a5c)sQI(PO+yvjm~rK|CY0MYxx00(7=XzDO*^FMLOYIToyPZS+8Y|8$q@EL7U`rqCWmTR^<v})UhF(<^ru`~a$u@~Bd?8W8;NTBPTzvFYhpJUT}22a!b;p6=Cayo@Ep=<_= z$#X)s#r;sIohb_VHiV6Ie66tQg=x^jOQYclHCpbC1$WS*v__lYKqw=2Ef0HLEMHj4 z2z`K_j?gTHufUQloy-@j=Z7SN?`{95ggs{IOP($lZ$?h?4t$CKi&02DNC&d2jrCl6 z@CGW>tw~>U-;QnMR(h_83BC>k_X9`GzXSX@)aA99le$&s13vbXsxlt2oda2WU|U<%ZxBy1ynFM!J_{A$H0wi zE3~LoTNCEvw&GIJxX#;?Kb9mgnX~1f{erxzZ^pNGa5{e&bx0`W_5#J7c4)&z{5B0F zXV_mB7JpoU(G?nZNJ-~Aj^;6p@6FU@+|4x_UBjNpqQjoap}JN*6~>o^H-zWPxMz{N dmya)J{UwU;cmYjs+glmW!)217~J3En{qJZ*DFz0CiH^ZW=KVefL+4cuFKv%40?Lw$kLAL@tX$Ld{RVcYc0XU0Br&KdLh2%aAA?}n4lvnli$&qgpE zJSVKk@9(5ulYwt{fJQ7eRu|zh80l3kKcPV@JXvrDBTGw$f&-~Zu4|U;bvk>=#u?)e z(2y~nj^Qh0Nje@(ri~!RHP=cN$_ot?{5E)?ysqYFd&Suv+bgYMi6CNQha5(<#~s=(lwzk$ z@xHKAWGhe(DkVpHW>BJY!X7}9S*dE0<1i!>2_5P~7d%B}u8#X%;w~t&qcujmY2!D~ zfwNZ%AccWQrSijnWH~Q<1j{HuXdUG@Jf{w4EZd@t43#$lF0#dxOxP^Z)^4_yYN2_( zwodY8Jcn#Pm@l#pOMWWvV6S{xy*v^|=fBWWlpRO9ItdqK6$6J9eX!=3kSi(Z6+{DQ zZH%3y4E8u=u$Yf#Da*trpoR$ri{|Y&!HugcJm2WLCh23b5lVAOo7WMK~kfzSEvfLfh!?Tke#7vnz_XvEzoPBeuK1fzTv30LH?p%w1z=Su&=qReG{T%GmTC@%5}(nYqnDxTRNy7s(TM+5)> D7Do&S diff --git a/man/gf2-dacoff.1.gz b/man/gf2-dacoff.1.gz deleted file mode 100644 index 6a89bfce4102c8aa1a886f8d8b88c6acc47a2b54..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 594 zcmV-Y0mayhe{0Y!cfceAVU?eu0bo53U! z**(msk8xC$SL2l|s4U^z7*@*3rN*WgX2BF*k%2ojXr(6$JGsS@Yz6)NIN$Ti0Fms3u$1BR+anzFo5&Y2M5bN_iN3M z?zj#oB8svN7EIGPBEc~wzs`hu*;vK)ZW>pm7H!05@s}irET87j*;y3-P#nNcH31!^ zIF6raiAQHihYfb2DA*MNDf(ay_ZS4n#_AO(3TQ3ah>9ZEcaiCHe!obgOx6K4JW#M` ze*YpkcWp(KwQg$#eXeS$wBQUc4)bMk4AX~fan}99QBvgY3m7JDD91+fDyZ@*_ow7IS!dyqi44vtqW<;Mz>RAi zT2`v{g!#O!xKvb_>h>}pOA?3|Y&mMb1g{P^(d`&6=TFm435DEVseRb&K#tRK$SZ03vAvbyOnw7gZS56@4x?Wbw-4Z4h{eHis# z61L25+quJE@S_bLLwN?CqLD#a1J7vCiC`U+MPtrlk z_&uB$86QBYHcLhiZ;Vd|@Ey`*I_M2YvzPm13O}pX$0U824kp=PJi6#6GakYUFQv;u zC401>OjQzY84EOlL$*@>c!D1A_r{_3xL|bfYyTaDSwInefH~4%*dcLrs_N$seOg2) zb@ar|;Sr@Ogg&r&(m*Dp#7)2jhmj3P(jw3o2}xTNCCg4}4MOk4p3I9i0_Hi&0CtP+ z!!$N$Wx>XJ%(^D- z(w+N&f||$!<AVV`B&E%b{E}qu^>qMb8yg`W&QD#rJ{(aVQ3@m%-=s2u6}kkx;2Y3wLAsuLK9KU4QOlI R!6|xX{{YdqvoDAR0094+VTAwy diff --git a/man/gf2-freq0.1.gz b/man/gf2-freq0.1.gz deleted file mode 100644 index 069267c50f5009d19ddcf40aa4d521b94265e91a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 711 zcmV;&0yzC2iwFp7){a^L17~J3EoO3MaWF110CiK_ZW=KVefL+4@{~wq1yTE6l5E1N z1nBM}C2ITNm|3v0Yj1slk{{}a^v60jmxV}0E95iwoH;%-PRbEHKHOYCz0;SD-8;52Yp$~7uj z^V(zNEnX(mS&=jr6`g(Z0g-=RqJY&f3GpKj9}e#YGUw7AQ&S(!~I z=jkNPf?MJLg@ny0VlPOl7~*E>8&ocVawY9vCN1!HYtUL;go9s4@4(dp8gCuEB7JUy z#Lp*lif>u`}k=79KR(`w_mazUHY4oM9s5JU*w zG=X>{>l(z0t7X_l*4<54QM~r9^$x6DDypVcy#-mFSwL(SYZO!&xFr=X3M@5SXs}+a zda%_V>`MDOTy?GAs7tqbw3ae=y-(OkZ*YyK_mMnW7)eidI^TH}{v)ka%R|dVjodK0 zVK3wxth7P$&q2et!HZyVAd`kvlRZJIP8cg%^0nF$6OENcBk9u0H?N_D1>J_32FEXwUKTW>N@Vc z4IOw#qr-FvZZTl8Q_#pHkfZZP(HVsYXSo72MjNJu@MI%B8Mishe&xY`YUfVDa9)n4 zIV*VMv4*ks2G!p`8ZK>&Bvn(#n9yIA4VQI7LvytkU!*Av$Hnv_K40FnmxHSw?AM?B zM-=;Tg5Gphok0~)Bw28Ax*4E4qTu8i7#vY8tviy`TD)o3scBbq_jA-ghaC|;M(mgl tlX=|U2L`8s4}^!vpktA$D^Gnj?i5j%PoVB(J0oe${sCGKbec2;000K?S8)IU diff --git a/man/gf2-freq1.1.gz b/man/gf2-freq1.1.gz deleted file mode 100644 index 215f79a6f4a796c1e8263c033b15cdd620b24b1d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 655 zcmV;A0&x8wiwFpG1&>+)17~J3EoO3MaWO720CiK#Zrd;ryz?s-IVFHY*g<-)lPIxJ z$95$dNYM7c&?}pWM5=tmb$+NH(jV(mb}Xwv4Ienm-Pze4iWd`jxWBr*&yuer7%`qt zU^aeC*t)#BEG_;V!S_pW=wlY#2Q9ra8Xi!i72a5gIRUlY!3Y{*MU5UUcmo2~>J2r# zi7H^rn?KLyi#*L4zkwq?<0-`E%Vc)@%y^cmmIHlqaj;h?~P5N>z($&*qr0)JIBeJgzvT9*AGnjj>*6AGK-Yk<r(PG zeq2lw#*0PICAb>$YnIb1I+aNC$2jeHUwxK5r3K{0xLD?AEcvC#*{$-M*w+gmT%7(L zt%=S^;V@zvMUq_{GW5Y}%F*~SmC%6J8q187!480)tKasjUqqapR=HO&UKW#i#&S^y ztYB(_Mg8ZufpgbJcv)9%Oq$Q@TBwSXVHXGSd6K|*n$OSLPe;_v`RHN*hx4c55y=XL zJwdOgEPGH#)RL@(JiUxiA5q+74|FXm<@}MPGV;~j1B pKc2~H;2*+|$f#pcx@%9qT7QbjgiwFq(Hj7#S17~J3Eo^CXbS^OfT~f<#+b|Hk>nj#MC4ep10eY|7DzO2_ z4on3|fnL_s(k4ui4oSszf2beQAM1*KDi?_}Yorj7(w4{(E#LxNSMNCDOe}l79+W1k3 z@5|{+IbF;cABW8xwPwkd@TW_8YQ*yPeSzSBCn4>{-`nE711CZMkZ% zMcQhHlmXpOY z6IeH7VCEVg=)b=X?m}X6Rhz^~_jO&PHaT~Ff66C{0>(43=%rVJ_3mzT--pxs%kYAv zA@nzB>y+w1+oB{=p}gH}p}ipG>AeGn9W=VA7$>(bUgPXGJe@8YcH!s(`3X?GCq zPH+pD!A_gb^djUnXd+9lv`R`}s1MQ?t7O2jIa%Lo_y2cSj*B@wKHT0cviq-Dv4&|B z=W|%imPxd$Zf~UKFPa+oc?01XQsKcVPC_eqM1_WtHV`T|*|M$8f2^`~p5{?}2R(@> zP9aY=>1?rjTHYm_HurOq-*3`&k!GvQ^zgMndxYxjx4ZPahQ{D4DiUhv(~QqHFk-5N zMq4Yk@(?-o#uQ;W2EJ!%hc)ea>rv@@vw{naqCZ6vO0 z*~Ym3w5yqrG1v9@)O?;KFk9r=Rr_DFx*1K!*Kj(2oOHw`GSj0MT~z~Afm)H0@&08% z)lp^e*8nC1nszEuSn95ty`OwYlOaw!G-#1J8H;l0atciQfeXQNdHqrcnxS2ffp X|HeJk?<*uD{5kp$O!D@GO#}b{<;EX` diff --git a/man/gf2-phase.1.gz b/man/gf2-phase.1.gz deleted file mode 100644 index 1b29524c2765435a060ee5f9dd07a9a0a3f0ef87..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 699 zcmV;s0z~~EiwFqkCXiYH17~J3EpTXIb7d|u0A*9bZks?5z3*3ya!Moz*^$y-OIi{m zIkshpl&bAvy$rDOvP+l6j{8Hs_8ZzC>i{;G_Ja1!&b&7>`|#p9JU!msuIGLfz>Im( z9G3obz_Rr2w#<2j@bwldbWIjK)>=4eG(4e3%bl^%FaW1P<1|9INv{+S`P$Ek(vxt=kzCI2qTnH>3CLSz}BaNIp`p|_iMZt9f z2dNZrb>K(ph3^nBO;I>z_GmAfGieJdGOfvPRwFZP#qKaq`9fJo})yJ<_K4W=EoDE-Lzu z{~VjKEvAO15L~IQW-~MZ9%E67LZ-)N2u{ngk}J@4vF)ZaW#dk+yw*p-tN*-SkkR7x zXb^b!-n(ZJy0Mp<=3l!!kx(x6Tz~IO`$(x9EBzGR#=#6qsEG{vqs5 hHn2#I!?okqT_Sqr3uuN$ot1QEe*t&@V_Q1~001(GTWou17~J3EpTXIb7e3tF#v5-%Wm6147~4G5IH4)BiIIVuhJ^9 z0LL~g1xV5Muvt^`BGRt952x-A_1bS}f2`cKBHL{*f`%eFLk^XcGq}H-Uaw|pk&R)( zl41sn^dVz)HNEb(+~OEMUxP&#^5D)Z;iOh@j|vTU+CWT#F?8JU79ARJ8aUK)hYEJQ z@fe#H9~aA2krynvg=24)2CckUc?VY3iZ`HDvjumVJ|S8L!f91E=H8+pzNQXmoH_^cK(#1zDcJ8l5+aaumL;lPf@Dv|(BZPphLt zcduvF&pa%h{5vQ}AIsTt%?jRnY+$avLG}BGhD#eGN!2znCiJ_y<+4fWLauu8MV3K2 zFP0bauj6fZIk_4^|9&$bQ1svgz38esgDRldWW&Yj#{kuUDl+N}jL*JGrF?>G*i*Cq+Yp;ZpTEPt}G~8(eAqisWx#1l;G~hIFsO1wXc;c$T-A6WRaXIM?|SdR%3ARjv}$)Ct7#fyu-Kv? zM#cwrM{|&D4O6(Gnap&zY_%Aei@K}sS&?JJ4k03|qjiMZd??Z6~XpA;Y3*pTv(7CziS@i=S zMkg2F6eM@$Vx6;scOF|O(g%rx^qBVc5leYq}ub*T8%qIwB!S*_d1=C^k)A6y+g#2aRdMW D4yH5F diff --git a/man/gf2-reset.1.gz b/man/gf2-reset.1.gz deleted file mode 100644 index fdf73352576917f21f23fdcf133d3859d9c3d7a3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 539 zcmV+$0_6Q4iwFql2#Q(&17~J3EplaZWppkv09{hej@mE~zWXUgoOUIMV5Q#6w%H{T z3#&LtU9~-U%>*nQJM|BgzEB^eFSd3dA?eNEc;@>VJ1G|M{PZx%Q<@eqBMDu=YW|Xv zUHLFEXwkus30w}L51zc@PG|+ssL(K{O*2B@R_j-qQIb4DH%XE_gYQ7oJex09o0rEl zho4RR*OY$Av)3Y9uZ9!CT8|dkRgvqeVrmOcgWDsNt@y4L9|LFJ3bg~_VppwCXn>!& z#DvUC7eK=_2BpD@onq3$Nk|Fr*s|a@fkl`*VxX(Eb#P)wEVZfHjvz^DW>|%R@HQVE z22HOHN}m)QnGD_&c+(#2UVFI(CQs~aL8zlXV4E~}V}`KCT+AEYw}E5W+6ZkTF;i#I zA-8GwU=u=Uja-!H%aBDQm;~jk_l68~9nCVCG;1EE-?9Q|F)ucBMAF~FMe}YSCmnM> z^q24ljSddOA}vO2J?CgcjvSpgD)cDq@+d%K!kcT(y}5|YH^pL|6Ur)&5|-KbbARE2;TGyPLOqA67L)(;>VOS(HPaYhl(e{72DNdMrZS d1jExA*GJ(Ydr;quIwQiFd;n%8U~S|B007on`^^9V diff --git a/man/gf2-selfreq0.1.gz b/man/gf2-selfreq0.1.gz deleted file mode 100644 index 6a019610bf8c479ef49b728bf3ea20d883fbcd51..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 591 zcmV-V0KR_eXb zh6R;{Z46RZZ4bswh=pTQe=JR3Xdk36Ry%wo>|T2Ff5!8lUuK+SHHC-CeV?ZDNtS*c zz>p+#3X9QWN_P2u-=fS7{u;oKK7=!J2T^-eyn+ER3$8$5+=&-#We&`+5*-@QdGsd} zufiRz-~kmH=CrB%(C5YSiOwiV#?Wp@l57Uwfu`APG+(SA$7u#X>x$1Q{glm~RNXq<)({s(fnLGlao?t+}aNNTl%qi{uNp0&FVq4$o5NvV$(D(z!qp{!%d z$qH;R;6)&DM??kgs9PK_OnS7i^+tqNR_qj$P7#vwu+m;83B`OEw3H<_{ zjZn-~jbYywB6qOIDwK5-c-Ee9rodag0H0~qwjCIfV7|p%D10-}>!fU8$+f{ElqQ7G z19Fj9CpwEpFbT?+n=n#gK_4PMlS#eCyY$;^1#~r9t?3;}e~YlTIM!I{nDaJn;SZWP zHsH)+)Yfy3)+Ugl^G1a`fz1}$%PoX2LSw?S(wuv9YBE}{rpt^_R(g~$*WRG|`>LU1 z>qwH9vW{{6aaS@S6RykdnUAI^jOKKCSN{gAJamTL9-Pk~23N%;GSgCfo#!`FMOB+@ z8E+?}R96+pTZ?8RH@V@}Mhfe$DXIBhy9Vx1gjwCH!L4kJ3|efQF7LPo8pHqq diff --git a/man/gf2-selfreq1.1.gz b/man/gf2-selfreq1.1.gz deleted file mode 100644 index 36a38e3cf864b1b4119233fdcbca3d90c74c2d62..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 593 zcmV-X0Vkj9h)jnnXi|A8ECkm`WEIUpx6m0E3JD_k9#7vt_%aQTjhNvXFMI_+a)p{!%d z$qsBV;B_EzTSNtJt4AC!OnS7i_C|zOR%{fLWRDPNE<;&NFxaxLw{2R94JrpWGx`P2 zpM+wj8w@A57L|i%>_XW^0*~4g&J=iy2jHHcFtr{BQWDJ9SP6x126~*74J?&5SclSt z5ZWRaRkx$FXatj>eDf4WDlF(W;xn1_Ydp)o6r62Zs8A_ zI5yzSV${}ij@Bknpz}tBJAuvC+RHVBFG6F&v(lVqFxTFo`unQk z-1d>AYGfbd`s1cyLMB`{7kfUMWiXx7FBGv7RL? z9m6Dw*$kG+a~kdQhmk{dEV#old>;V`6dvjVjDb7w1p*gdzTvfcnJ$9k=`)%u2Y#rWWB>&YP?%wvmr+mxv^N#TpUI0h(hM) z3ztJHxdI)^Ev-^IFvkjfFa0{-0NW&+7uJi?Uy{yLt+Sf++y_@}|2NudSp-X| zq+JjKor@tuAFQT-h|3iws2y+(Xe~V?BSf&5kmO}ETV)aBWk3ZB6D;b#e+=|pU5WEj z)iq&0?n^FJEKE7L^0739WWiRw`o;6|*q;oBaQ*%;Zj?~S?VUQ9Jnu+dsoG@6#eK7q zx>32spS5VzxYL_7HcC3*w3HDC<6F4;LR~fP%GSuD!`6u&Yd7^;nA{gyhf9SXMq@{J avv+p&74M{JA-$FK9sL7d4(v&21ONcAFc#SW diff --git a/man/gf2-selphase1.1.gz b/man/gf2-selphase1.1.gz deleted file mode 100644 index 95fedecf756d881d75a87a81de8e67b814b46c60..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 589 zcmV-T00ELpzZrVT)#_#(Sqnv^iEF7u# zI;|5>2_P?#8nr!amN8zj-lh8|l)g|OBrn#n0fU=EZ~kUH-}lqZCd)BA+}{p)K3$A6 zo~MwqgpXmCJ?3m(-VQzLZ6!RW@O=m*PzGoVkb>|KDg+^edc|XPE1ak?paWYr&Tt;b*0SDetkDFxTktP%{i2L; z`-9ogSE>xK!99%(5_l#GDGZAqPoxKOCd{f=Nf}wMuv7*wme_5`6GdqqRy3C|#u2~kr zQYvX5r9|%&C@@54=pW+pm5q7@!T>r)56May-614ambs7XC5x^e{R* bx|_SOYp-}A?HMvSMc?c%)}u7uXaoQNi>e!r diff --git a/man/gf2-sine.1.gz b/man/gf2-sine.1.gz deleted file mode 100644 index d39034797823ca9b506bd4f238f9a5cc41320cda..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 420 zcmV;V0bBkbiwFo<% z+c#HpuPwsk96W|j1Gmwtpvl4=T68jygID>24Y?KqL6S#LdM8b9BfgfK2T=%?-N3sW z%c=stf#6kc0Ui%mKCkg`351O6u|V@w=T>E@@ldyr{Vr=16(@!=d{bWQa-Mz%O(J+JcfEJN8j2^ge?M zLv%K2(pvn1qS=A8fXXuf=B8A3(Opi{<49IK8hI11W>jjp&J*W`ee(-ef1$xY?l{sB!o_fyIQD zgNxBV3@t-=317~J3Epv2Xa&#^+0Ckc}Zrd;rhW9+hz^eqX2|Gadby6i3 z;Mjqr01etM7hkfutX$?|Dj}7S{_E=h1T}U;QOdK}V93HIMqw}bb!#eJR-PL{U-wB4G%-(L1 z?6R{T)pGV`Bl#I1j4F@+8Na?}h#uaLRI4?O-N7^&&RD)fNeD{Tdm)_AU}E)-uD-V2 z)kvXvv)DoMH7$T1vv|!1EcvB^hl2{6(?)BcE#WshOH-32ZG*IrQlj@9G7Qlfsxb(D zW20UH-2k1VSGH0{cQTp27PDo>a#2OpFt^d6`TNJhjc+2ntaKBT_Vci!ayx|c`P2BSq(p8=DdZUQ?Ru@MIqdK#huU!9#ElSP8&F@+MD!wy?LTJCFw2n1|%(V_yII4 z^2KVsd%VpG_|@v~GWxB^pSJmC{oj=sXu;J8+#7?+bupl;maRT}>_2-XuotgF?V&`+ zgv62vRcX_(C`;j4d*Dogx7bB>NlwE-=~Dth4EV;Hqr?PGwcs^W27h~0{2iDo;aD?^ zaAbxx=+IbT27!edub9G}M{t_d%#^3dOVJ3|X4?b?O@O^ODS=fkh*j1m&9-G*PLK(U-}z9qAlIiNAx5Y59X&LNB4cDX4CWsOG(EA7LE{{7W( zWm_h#8rgDOf894>87bGzb=Qw(87x+GGiiUZ@aC)ebpqY@m)QkziOdYpL08oXs)$;X zlJVhTgzAFgq(@*jLi3A@6xLmiq~-_h`flx##%MN%y^%qSy^}>bPVI>KkmwD`kQr!% a>f^&A%^<+(zNa%He3K8TelC{S0{{Rg_y^+v diff --git a/man/gf2-stop.1.gz b/man/gf2-stop.1.gz deleted file mode 100644 index cde007d3056203c2ddef87ae213eec84364fe438..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 568 zcmV-80>}LyiwFpo*OFQQ17~J3Epv2la4sgnM+ zE8u6B{WTL`iu|$6*Q-f^_CBHqd5}}oG}3M%5QH5<)hpM%GKXaq(1EtE^rCH@(zNf( zX3P?JU0Z29ylG=#gMBG(p(Wl>*a5|`k6}pBRwkKO?=P*t%&bitt{aOi_{;e)TvhU((z zSDVb)b0SvK!Yevmy?;=h{FEVj*u1A)W0F;4p7w<^CibWjMeAc4K%z^3va#8;2791= zODPTS26&cz%S#aDvV0O}Ec>lH1CyJwm!b;(prh1wlJwYOAC*d8a40ZDXH$+v@X1co zjswuSv`nN_bO({;Q+c;8n2=3G1NRgi+JAou&V3i*Rb#rCqR(|Bwc%;<7sviYmcjB~ ztk1eFmd*ZraWRAA{nPw}ltJl6sGZ3K+7@*rTdBs6Ewm?8Is7#N^9fp2KfwZ++B#R68@P0qIU z*)%u}k5lj%S_NE1tAZvA*J#nnKn~vIAFRnW5D1c5+HEw_buQw5wZ0XFVEh6OW{jtd z2M~E#WXsj&<{~fQsS{u3;#XPRR>gWX)Td+*VTb?8;f#qrDqX*8y9Jqwrj-F3o8Ra_ zd!T*WR~p`hO!B*;0#RkvMod`#S10o~9d_-XL57(0HGH5W&=!>R*s_mGq4yk04AI%7 zu?T)g(L95+fX Date: Wed, 20 Jul 2022 08:59:51 +0100 Subject: [PATCH 02/62] Create newfile --- src/man/newfile | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/man/newfile diff --git a/src/man/newfile b/src/man/newfile new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/man/newfile @@ -0,0 +1 @@ + From 515cdeb1558864a29f1eca33931272db3553ee52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:01:26 +0100 Subject: [PATCH 03/62] Delete common.c --- src/common.c | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) delete mode 100644 src/common.c diff --git a/src/common.c b/src/common.c deleted file mode 100644 index 679936f..0000000 --- a/src/common.c +++ /dev/null @@ -1,48 +0,0 @@ -/* Common functions - Version 1.1 - Copyright (c) 2018-2019 Samuel Lourenço - - This library is free software: you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or (at your - option) any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include "common.h" - -bool isnumber(char *value) // Checks if a given string constitutes a valid number -{ - bool retval = true; - if (value[0] != '+' && value[0] != '-' && value[0] != '.' && (value[0] < '0' || value[0] > '9')) // Number is not valid if the first character is not a '+', '-', '.', nor a digit - retval = false; - else - { - bool dp_exists = false; - if (value[0] == '.') // If character is a decimal point - dp_exists = true; - size_t len = strlen(value); - for (size_t i = 1; i < len; ++i) - { - if ((value[i] != '.' || dp_exists) && (value[i] < '0' || value[i] > '9')) // Number is not valid if subsequent characters are not digits or if there is more than one decimal point - { - retval = false; - break; - } - if (value[i] == '.') // As before, if character is a decimal point - dp_exists = true; - } - } - return retval; -} From 3ec47665284c5bdcc603a5611c997674adf9711a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:01:33 +0100 Subject: [PATCH 04/62] Delete common.h --- src/common.h | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 src/common.h diff --git a/src/common.h b/src/common.h deleted file mode 100644 index 2cb904f..0000000 --- a/src/common.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Common functions - Version 1.1 - Copyright (c) 2018-2019 Samuel Lourenço - - This library is free software: you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or (at your - option) any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -#ifndef COMMON_H_ -#define COMMON_H_ - -// Includes -#include - -// Function prototypes -bool isnumber(char *value); - -#endif From f5b49d73c582a75778e41c0775716a48e4ead806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:01:46 +0100 Subject: [PATCH 05/62] Delete gf2-amp.c --- src/gf2-amp.c | 110 -------------------------------------------------- 1 file changed, 110 deletions(-) delete mode 100644 src/gf2-amp.c diff --git a/src/gf2-amp.c b/src/gf2-amp.c deleted file mode 100644 index 6902e0f..0000000 --- a/src/gf2-amp.c +++ /dev/null @@ -1,110 +0,0 @@ -/* GF2 Amp Command - Version 1.1 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include -#include -#include -#include "common.h" -#include "gf2-core.h" -#include "libusb-extra.h" - -// Defines -#define EXIT_USERERR 2 // Exit status value to indicate a command usage error - -int main(int argc, char **argv) -{ - err_level = EXIT_SUCCESS; // Note that this variable is declared externally! - if (argc < 2) // If the program was called without arguments - { - fprintf(stderr, "Error: Missing argument.\nUsage: gf2-amp AMPLITUDE(Vpp)\n"); - err_level = EXIT_USERERR; - } - else if (!isnumber(argv[1])) // If the argument string doesn't constitute a valid number - { - fprintf(stderr, "Error: Argument is not a valid number.\n"); - err_level = EXIT_USERERR; - } - else - { - float amplitude = (float)atof(argv[1]); // Convert the argument string into a floating point number - if (amplitude < 0 || amplitude > 8) // If the obtained amplitude value (in Vpp) after conversion is lesser than 0 or greater than 8 - { - fprintf(stderr, "Error: Amplitude should be between 0 and 8Vpp.\n"); - err_level = EXIT_USERERR; - } - else - { - libusb_context *context; - if (libusb_init(&context) != 0) // Initialize libusb. In case of failure - { - fprintf(stderr, "Error: Could not initialize libusb.\n"); - err_level = EXIT_FAILURE; - } - else // If libusb is initialized - { - libusb_device_handle *devhandle; - if (argc == 2) // If no serial number was specified - devhandle = libusb_open_device_with_vid_pid(context, 0x10C4, 0x8BF1); // Open a device and get the device handle - else // Serial number was specified as a second (optional) argument - devhandle = libusb_open_device_with_vid_pid_serial(context, 0x10C4, 0x8BF1, (unsigned char *)argv[2]); // Open the device having the specified serial number, and get the device handle - if (devhandle == NULL) // If the previous operation fails to get a device handle - { - fprintf(stderr, "Error: Could not find device.\n"); - err_level = EXIT_FAILURE; - } - else // If the device is successfully opened and a handle obtained - { - bool kernel_attached = false; - if (libusb_kernel_driver_active(devhandle, 0) != 0) // If a kernel driver is active on the interface - { - libusb_detach_kernel_driver(devhandle, 0); // Detach the kernel driver - kernel_attached = true; // Flag that the kernel driver was attached - } - if (libusb_claim_interface(devhandle, 0) != 0) // Claim the interface. In case of failure - { - fprintf(stderr, "Error: Device is currently unavailable.\n"); - err_level = EXIT_FAILURE; - } - else // If the interface is successfully claimed - { - configure_spi_mode(devhandle, 1, CPOL0, CPHA1); // Clock polarity regarding channel 1 is active high (CPOL = 0) and data is valid on each falling edge (CPHA = 1) - disable_spi_delays(devhandle, 1); // Disable all SPI delays for channel 1 - uint16_t amp_code = (uint16_t)(amplitude * 1023 / 8 + 0.5); - select_cs(devhandle, 1); // Enable the chip select corresponding to channel 1, and disable any others - set_amplitude(devhandle, amp_code); // Set the amplitude to the intended value (by sending a sequence of two bytes containing said value to the AD5310 DAC on channel 1) - usleep(100); // Wait 100us, in order to prevent possible errors while disabling the chip select (workaround) - disable_cs(devhandle, 1); // Disable the previously enabled chip select - if (err_level == 0) // If all goes well - printf("Amplitude set to %.3fVpp.\n", amp_code * 8.0 / 1023); - libusb_release_interface(devhandle, 0); // Release the interface - } - if (kernel_attached) // If a kernel driver was attached to the interface before - libusb_attach_kernel_driver(devhandle, 0); // Reattach the kernel driver - libusb_close(devhandle); // Close the device - } - libusb_exit(context); // Deinitialize libusb - } - } - } - return err_level; -} From 2b13eef09b885adf2b7628393fac1a316e9d355e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:01:53 +0100 Subject: [PATCH 06/62] Delete gf2-amp50.c --- src/gf2-amp50.c | 110 ------------------------------------------------ 1 file changed, 110 deletions(-) delete mode 100644 src/gf2-amp50.c diff --git a/src/gf2-amp50.c b/src/gf2-amp50.c deleted file mode 100644 index 167055a..0000000 --- a/src/gf2-amp50.c +++ /dev/null @@ -1,110 +0,0 @@ -/* GF2 Amp50 Command - Version 1.1 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include -#include -#include -#include "common.h" -#include "gf2-core.h" -#include "libusb-extra.h" - -// Defines -#define EXIT_USERERR 2 // Exit status value to indicate a command usage error - -int main(int argc, char **argv) -{ - err_level = EXIT_SUCCESS; // Note that this variable is declared externally! - if (argc < 2) // If the program was called without arguments - { - fprintf(stderr, "Error: Missing argument.\nUsage: gf2-amp50 AMPLITUDE(Vpp)\n"); - err_level = EXIT_USERERR; - } - else if (!isnumber(argv[1])) // If the argument string doesn't constitute a valid number - { - fprintf(stderr, "Error: Argument is not a valid number.\n"); - err_level = EXIT_USERERR; - } - else - { - float amplitude = (float)atof(argv[1]); // Convert the argument string into a floating point number - if (amplitude < 0 || amplitude > 4) // If the obtained amplitude value (in Vpp) after conversion is lesser than 0 or greater than 2.5 - { - fprintf(stderr, "Error: Amplitude should be between 0 and 4Vpp.\n"); - err_level = EXIT_USERERR; - } - else - { - libusb_context *context; - if (libusb_init(&context) != 0) // Initialize libusb. In case of failure - { - fprintf(stderr, "Error: Could not initialize libusb.\n"); - err_level = EXIT_FAILURE; - } - else // If libusb is initialized - { - libusb_device_handle *devhandle; - if (argc == 2) // If no serial number was specified - devhandle = libusb_open_device_with_vid_pid(context, 0x10C4, 0x8BF1); // Open a device and get the device handle - else // Serial number was specified as a second (optional) argument - devhandle = libusb_open_device_with_vid_pid_serial(context, 0x10C4, 0x8BF1, (unsigned char *)argv[2]); // Open the device having the specified serial number, and get the device handle - if (devhandle == NULL) // If the previous operation fails to get a device handle - { - fprintf(stderr, "Error: Could not find device.\n"); - err_level = EXIT_FAILURE; - } - else // If the device is successfully opened and a handle obtained - { - bool kernel_attached = false; - if (libusb_kernel_driver_active(devhandle, 0) != 0) // If a kernel driver is active on the interface - { - libusb_detach_kernel_driver(devhandle, 0); // Detach the kernel driver - kernel_attached = true; // Flag that the kernel driver was attached - } - if (libusb_claim_interface(devhandle, 0) != 0) // Claim the interface. In case of failure - { - fprintf(stderr, "Error: Device is currently unavailable.\n"); - err_level = EXIT_FAILURE; - } - else // If the interface is successfully claimed - { - configure_spi_mode(devhandle, 1, CPOL0, CPHA1); // Clock polarity regarding channel 1 is active high (CPOL = 0) and data is valid on each falling edge (CPHA = 1) - disable_spi_delays(devhandle, 1); // Disable all SPI delays for channel 1 - uint16_t amp_code = (uint16_t)(amplitude * 1023 / 4 + 0.5); - select_cs(devhandle, 1); // Enable the chip select corresponding to channel 1, and disable any others - set_amplitude(devhandle, amp_code); // Set the amplitude to the intended value (by sending a sequence of two bytes containing said value to the AD5310 DAC on channel 1) - usleep(100); // Wait 100us, in order to prevent possible errors while disabling the chip select (workaround) - disable_cs(devhandle, 1); // Disable the previously enabled chip select - if (err_level == 0) // If all goes well - printf("Amplitude set to %.3fVpp (%.3fVpp unterminated).\n", amp_code * 4.0 / 1023, amp_code * 8.0 / 1023); - libusb_release_interface(devhandle, 0); // Release the interface - } - if (kernel_attached) // If a kernel driver was attached to the interface before - libusb_attach_kernel_driver(devhandle, 0); // Reattach the kernel driver - libusb_close(devhandle); // Close the device - } - libusb_exit(context); // Deinitialize libusb - } - } - } - return err_level; -} From 41d3dd05a8dac7af7c8849d88340082b52b0a2f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:01:58 +0100 Subject: [PATCH 07/62] Delete gf2-clear.c --- src/gf2-clear.c | 97 ------------------------------------------------- 1 file changed, 97 deletions(-) delete mode 100644 src/gf2-clear.c diff --git a/src/gf2-clear.c b/src/gf2-clear.c deleted file mode 100644 index c9c52ad..0000000 --- a/src/gf2-clear.c +++ /dev/null @@ -1,97 +0,0 @@ -/* GF2 Clear Command - Version 1.1 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include -#include -#include -#include "gf2-core.h" -#include "libusb-extra.h" - -int main(int argc, char **argv) -{ - err_level = EXIT_SUCCESS; // Note that this variable is declared externally! - libusb_context *context; - if (libusb_init(&context) != 0) // Initialize libusb. In case of failure - { - fprintf(stderr, "Error: Could not initialize libusb.\n"); - err_level = EXIT_FAILURE; - } - else // If libusb is initialized - { - libusb_device_handle *devhandle; - if (argc < 2) // If the program was called without arguments - devhandle = libusb_open_device_with_vid_pid(context, 0x10C4, 0x8BF1); // Open a device and get the device handle - else // Serial number was specified as argument - devhandle = libusb_open_device_with_vid_pid_serial(context, 0x10C4, 0x8BF1, (unsigned char *)argv[1]); // Open the device having the specified serial number, and get the device handle - if (devhandle == NULL) // If the previous operation fails to get a device handle - { - fprintf(stderr, "Error: Could not find device.\n"); - err_level = EXIT_FAILURE; - } - else // If the device is successfully opened and a handle obtained - { - bool kernel_attached = false; - if (libusb_kernel_driver_active(devhandle, 0) != 0) // If a kernel driver is active on the interface - { - libusb_detach_kernel_driver(devhandle, 0); // Detach the kernel driver - kernel_attached = true; // Flag that the kernel driver was attached - } - if (libusb_claim_interface(devhandle, 0) != 0) // Claim the interface. In case of failure - { - fprintf(stderr, "Error: Device is currently unavailable.\n"); - err_level = EXIT_FAILURE; - } - else // If the interface is successfully claimed - { - configure_spi_mode(devhandle, 0, CPOL1, CPHA0); // Clock polarity regarding channel 0 is active low (CPOL = 1) and data is valid on each falling edge (CPHA = 0) - disable_spi_delays(devhandle, 0); // Disable all SPI delays for channel 0 - configure_spi_mode(devhandle, 1, CPOL0, CPHA1); // Clock polarity regarding channel 1 is active high (CPOL = 0) and data is valid on each falling edge (CPHA = 1) - disable_spi_delays(devhandle, 1); // Disable all SPI delays for channel 1 - set_gpio2(devhandle, false); // If not already, set GPIO.2 to a logical low in preparation for reset - select_cs(devhandle, 0); // Enable the chip select corresponding to channel 0, and disable any others - setup(devhandle); // Configure the AD9834 so that it acknowledges reset by pin - usleep(100); // Wait 100us, in order to prevent possible errors while setting GPIO.2 high (workaround) - set_gpio2(devhandle, true); // Set GPIO.2 to a logical high to enable reset - clear_registers(devhandle); // Clear all waveform generation registers (by sending a specific sequence of bytes to the AD9834 waveform generator on channel 0) - usleep(100); // Wait 100us, in order to prevent possible errors while switching the chip select (workaround) - select_cs(devhandle, 1); // Enable the chip select corresponding to channel 1, and disable the one corresponding to channel 0 (the previously selected channel) - set_amplitude(devhandle, 0); // Set the amplitude to zero (AD5310 DAC on channel 1) - usleep(100); // Wait 100us, in order to prevent possible errors while disabling the previouly enabled chip select (workaround) - disable_cs(devhandle, 1); // Disable the chip select corresponding to channel 1, which is the only one that is active to this point - set_gpio3(devhandle, false); // Set GPIO.3 to a logical low to enable the AD9834 internal DAC - set_gpio4(devhandle, false); // Set GPIO.4 to a logical low, so that the FREQ0 register defines the frequency of the AD9834 - set_gpio5(devhandle, false); // Set GPIO.5 to a logical low, so that the PHASE0 register defines the phase of the AD9834 - set_gpio6(devhandle, false); // Set GPIO.6 to a logical low to enable the synchronous clock generation (TLV3501 comparator) - set_gpio2(devhandle, false); // Set GPIO.2 to a logical low to disable reset (the waveform generator is now enabled) - if (err_level == 0) // If all goes well - printf("All settings cleared.\n"); - libusb_release_interface(devhandle, 0); // Release the interface - } - if (kernel_attached) // If a kernel driver was attached to the interface before - libusb_attach_kernel_driver(devhandle, 0); // Reattach the kernel driver - libusb_close(devhandle); // Close the device - } - libusb_exit(context); // Deinitialize libusb - } - return err_level; -} From e4ce21ee88ae55336433a1e95f4700017b7d99c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:02:05 +0100 Subject: [PATCH 08/62] Delete gf2-clkoff.c --- src/gf2-clkoff.c | 77 ------------------------------------------------ 1 file changed, 77 deletions(-) delete mode 100644 src/gf2-clkoff.c diff --git a/src/gf2-clkoff.c b/src/gf2-clkoff.c deleted file mode 100644 index 3b7d9df..0000000 --- a/src/gf2-clkoff.c +++ /dev/null @@ -1,77 +0,0 @@ -/* GF2 ClkOff Command - Version 1.1 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include -#include -#include "gf2-core.h" -#include "libusb-extra.h" - -int main(int argc, char **argv) -{ - err_level = EXIT_SUCCESS; // Note that this variable is declared externally! - libusb_context *context; - if (libusb_init(&context) != 0) // Initialize libusb. In case of failure - { - fprintf(stderr, "Error: Could not initialize libusb.\n"); - err_level = EXIT_FAILURE; - } - else // If libusb is initialized - { - libusb_device_handle *devhandle; - if (argc < 2) // If the program was called without arguments - devhandle = libusb_open_device_with_vid_pid(context, 0x10C4, 0x8BF1); // Open a device and get the device handle - else // Serial number was specified as argument - devhandle = libusb_open_device_with_vid_pid_serial(context, 0x10C4, 0x8BF1, (unsigned char *)argv[1]); // Open the device having the specified serial number, and get the device handle - if (devhandle == NULL) // If the previous operation fails to get a device handle - { - fprintf(stderr, "Error: Could not find device.\n"); - err_level = EXIT_FAILURE; - } - else // If the device is successfully opened and a handle obtained - { - bool kernel_attached = false; - if (libusb_kernel_driver_active(devhandle, 0) != 0) // If a kernel driver is active on the interface - { - libusb_detach_kernel_driver(devhandle, 0); // Detach the kernel driver - kernel_attached = true; // Flag that the kernel driver was attached - } - if (libusb_claim_interface(devhandle, 0) != 0) // Claim the interface. In case of failure - { - fprintf(stderr, "Error: Device is currently unavailable.\n"); - err_level = EXIT_FAILURE; - } - else // If the interface is successfully claimed - { - set_gpio6(devhandle, true); // Set GPIO.6 to a logical high to disable the synchronous clock generation (TLV3501 comparator) - if (err_level == 0) // If all goes well - printf("Synchronous clock disabled.\n"); - libusb_release_interface(devhandle, 0); // Release the interface - } - if (kernel_attached) // If a kernel driver was attached to the interface before - libusb_attach_kernel_driver(devhandle, 0); // Reattach the kernel driver - libusb_close(devhandle); // Close the device - } - libusb_exit(context); // Deinitialize libusb - } - return err_level; -} From 3caeb30b78cd6f8e50d206f21dd3e53a9dd0d649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:02:11 +0100 Subject: [PATCH 09/62] Delete gf2-clkon.c --- src/gf2-clkon.c | 77 ------------------------------------------------- 1 file changed, 77 deletions(-) delete mode 100644 src/gf2-clkon.c diff --git a/src/gf2-clkon.c b/src/gf2-clkon.c deleted file mode 100644 index 0cb4eed..0000000 --- a/src/gf2-clkon.c +++ /dev/null @@ -1,77 +0,0 @@ -/* GF2 ClkOn Command - Version 1.1 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include -#include -#include "gf2-core.h" -#include "libusb-extra.h" - -int main(int argc, char **argv) -{ - err_level = EXIT_SUCCESS; // Note that this variable is declared externally! - libusb_context *context; - if (libusb_init(&context) != 0) // Initialize libusb. In case of failure - { - fprintf(stderr, "Error: Could not initialize libusb.\n"); - err_level = EXIT_FAILURE; - } - else // If libusb is initialized - { - libusb_device_handle *devhandle; - if (argc < 2) // If the program was called without arguments - devhandle = libusb_open_device_with_vid_pid(context, 0x10C4, 0x8BF1); // Open a device and get the device handle - else // Serial number was specified as argument - devhandle = libusb_open_device_with_vid_pid_serial(context, 0x10C4, 0x8BF1, (unsigned char *)argv[1]); // Open the device having the specified serial number, and get the device handle - if (devhandle == NULL) // If the previous operation fails to get a device handle - { - fprintf(stderr, "Error: Could not find device.\n"); - err_level = EXIT_FAILURE; - } - else // If the device is successfully opened and a handle obtained - { - bool kernel_attached = false; - if (libusb_kernel_driver_active(devhandle, 0) != 0) // If a kernel driver is active on the interface - { - libusb_detach_kernel_driver(devhandle, 0); // Detach the kernel driver - kernel_attached = true; // Flag that the kernel driver was attached - } - if (libusb_claim_interface(devhandle, 0) != 0) // Claim the interface. In case of failure - { - fprintf(stderr, "Error: Device is currently unavailable.\n"); - err_level = EXIT_FAILURE; - } - else // If the interface is successfully claimed - { - set_gpio6(devhandle, false); // Set GPIO.6 to a logical low to enable the synchronous clock generation (TLV3501 comparator) - if (err_level == 0) // If all goes well - printf("Synchronous clock enabled.\n"); - libusb_release_interface(devhandle, 0); // Release the interface - } - if (kernel_attached) // If a kernel driver was attached to the interface before - libusb_attach_kernel_driver(devhandle, 0); // Reattach the kernel driver - libusb_close(devhandle); // Close the device - } - libusb_exit(context); // Deinitialize libusb - } - return err_level; -} From bad8c2558d8c42a6f6bfb4f150fb2c96735ce60e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:02:17 +0100 Subject: [PATCH 10/62] Delete gf2-core.c --- src/gf2-core.c | 364 ------------------------------------------------- 1 file changed, 364 deletions(-) delete mode 100644 src/gf2-core.c diff --git a/src/gf2-core.c b/src/gf2-core.c deleted file mode 100644 index 7726d60..0000000 --- a/src/gf2-core.c +++ /dev/null @@ -1,364 +0,0 @@ -/* GF2 core functions - Version 1.0 - Copyright (c) 2018-2019 Samuel Lourenço - - This library is free software: you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or (at your - option) any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include "gf2-core.h" - -// Defines -#define TR_TIMEOUT 100 // Transfer timeout in milliseconds - -// Global variables -int err_level; - -void clear_registers(libusb_device_handle *devhandle) // Clears all frequency and phase registers on the AD9834 waveform generator (channel 0 must be enabled) -{ - unsigned char write_command_buf[20] = { - 0x00, 0x00, // Reserved - 0x01, // Write command - 0x00, // Reserved - 0x0C, 0x00, 0x00, 0x00, // Twelve bytes to write - 0x40, 0x00, 0x40, 0x00, // FREQ0 register set to zero - 0x80, 0x00, 0x80, 0x00, // FREQ1 register set to zero - 0xC0, 0x00, // PHASE0 register set to zero - 0xE0, 0x00 // PHASE1 register set to zero - }; - int bytes_written; - if (libusb_bulk_transfer(devhandle, 0x01, write_command_buf, sizeof(write_command_buf), &bytes_written, TR_TIMEOUT) != 0) - { - fprintf(stderr, "Error: Failed bulk OUT transfer to endpoint 1 (address 0x01).\n"); - err_level = EXIT_FAILURE; - } -} - -void configure_spi_mode(libusb_device_handle *devhandle, uint8_t channel, bool cpol, bool cpha) // Configures the given SPI channel in respect to its clock polarity and phase -{ - unsigned char control_buf_out[2] = { - channel, // Selected channel - 0x20 * cpha + 0x10 * cpol + 0x08 // Control word (specified polarity and phase, push-pull mode, 12MHz) - }; - if (libusb_control_transfer(devhandle, 0x40, 0x31, 0x0000, 0x0000, control_buf_out, sizeof(control_buf_out), TR_TIMEOUT) != sizeof(control_buf_out)) - { - fprintf(stderr, "Error: Failed control transfer (0x40, 0x31).\n"); - err_level = EXIT_FAILURE; - } -} - -void disable_cs(libusb_device_handle *devhandle, uint8_t channel) // Disables the chip select corresponding to the target channel -{ - unsigned char control_buf_out[2] = { - channel, // Selected channel - 0x00 // Corresponding chip select disabled - }; - if (libusb_control_transfer(devhandle, 0x40, 0x25, 0x0000, 0x0000, control_buf_out, sizeof(control_buf_out), TR_TIMEOUT) != sizeof(control_buf_out)) - { - fprintf(stderr, "Error: Failed control transfer (0x40, 0x25).\n"); - err_level = EXIT_FAILURE; - } -} - -void disable_spi_delays(libusb_device_handle *devhandle, uint8_t channel) // Disables all SPI delays for a given channel -{ - unsigned char control_buf_out[8] = { - channel, // Selected channel - 0x00, // All SPI delays disabled, no CS toggle - 0x00, 0x00, // Inter-byte, - 0x00, 0x00, // post-assert and - 0x00, 0x00 // pre-deassert delays all set to 0us - }; - if (libusb_control_transfer(devhandle, 0x40, 0x33, 0x0000, 0x0000, control_buf_out, sizeof(control_buf_out), TR_TIMEOUT) != sizeof(control_buf_out)) - { - fprintf(stderr, "Error: Failed control transfer (0x40, 0x33).\n"); - err_level = EXIT_FAILURE; - } -} - -bool get_gpio2(libusb_device_handle *devhandle) // Gets the current value of the GPIO.2 pin on the CP2130 -{ - unsigned char control_buf_in[2]; - if (libusb_control_transfer(devhandle, 0xC0, 0x20, 0x0000, 0x0000, control_buf_in, sizeof(control_buf_in), TR_TIMEOUT) != sizeof(control_buf_in)) - { - fprintf(stderr, "Error: Failed control transfer (0xC0, 0x20).\n"); - err_level = EXIT_FAILURE; - } - return ((0x20 & control_buf_in[1]) != 0x00); // Returns one if bit 5 of byte 1, which corresponds to the GPIO.2 pin, is not set to zero -} - -bool get_gpio3(libusb_device_handle *devhandle) // Gets the current value of the GPIO.3 pin on the CP2130 -{ - unsigned char control_buf_in[2]; - if (libusb_control_transfer(devhandle, 0xC0, 0x20, 0x0000, 0x0000, control_buf_in, sizeof(control_buf_in), TR_TIMEOUT) != sizeof(control_buf_in)) - { - fprintf(stderr, "Error: Failed control transfer (0xC0, 0x20).\n"); - err_level = EXIT_FAILURE; - } - return ((0x40 & control_buf_in[1]) != 0x00); // Returns one if bit 6 of byte 1, which corresponds to the GPIO.3 pin, is not set to zero -} - -bool get_gpio4(libusb_device_handle *devhandle) // Gets the current value of the GPIO.4 pin on the CP2130 -{ - unsigned char control_buf_in[2]; - if (libusb_control_transfer(devhandle, 0xC0, 0x20, 0x0000, 0x0000, control_buf_in, sizeof(control_buf_in), TR_TIMEOUT) != sizeof(control_buf_in)) - { - fprintf(stderr, "Error: Failed control transfer (0xC0, 0x20).\n"); - err_level = EXIT_FAILURE; - } - return ((0x80 & control_buf_in[1]) != 0x00); // Returns one if bit 7 of byte 1, which corresponds to the GPIO.4 pin, is not set to zero -} - -bool get_gpio5(libusb_device_handle *devhandle) // Gets the current value of the GPIO.5 pin on the CP2130 -{ - unsigned char control_buf_in[2]; - if (libusb_control_transfer(devhandle, 0xC0, 0x20, 0x0000, 0x0000, control_buf_in, sizeof(control_buf_in), TR_TIMEOUT) != sizeof(control_buf_in)) - { - fprintf(stderr, "Error: Failed control transfer (0xC0, 0x20).\n"); - err_level = EXIT_FAILURE; - } - return ((0x01 & control_buf_in[0]) != 0x00); // Returns one if bit 0 of byte 0, which corresponds to the GPIO.5 pin, is not set to zero -} - -bool get_gpio6(libusb_device_handle *devhandle) // Gets the current value of the GPIO.6 pin on the CP2130 -{ - unsigned char control_buf_in[2]; - if (libusb_control_transfer(devhandle, 0xC0, 0x20, 0x0000, 0x0000, control_buf_in, sizeof(control_buf_in), TR_TIMEOUT) != sizeof(control_buf_in)) - { - fprintf(stderr, "Error: Failed control transfer (0xC0, 0x20).\n"); - err_level = EXIT_FAILURE; - } - return ((0x04 & control_buf_in[0]) != 0x00); // Returns one if bit 2 of byte 0, which corresponds to the GPIO.6 pin, is not set to zero -} - -bool is_otp_locked(libusb_device_handle *devhandle) // Checks if the OTP ROM of the CP2130 is locked -{ - unsigned char control_buf_in[2]; - if (libusb_control_transfer(devhandle, 0xC0, 0x6E, 0x0000, 0x0000, control_buf_in, sizeof(control_buf_in), TR_TIMEOUT) != sizeof(control_buf_in)) - { - fprintf(stderr, "Error: Failed control transfer (0xC0, 0x6E).\n"); - err_level = EXIT_FAILURE; - } - return (control_buf_in[0] == 0x00 && control_buf_in[1] == 0x00); // Returns one if both lock bytes are set to zero, that is, the OPT ROM is locked -} - -void lock_otp(libusb_device_handle *devhandle) // Locks the OTP ROM on the CP2130 -{ - unsigned char control_buf_out[2] = { - 0x00, 0x00 // Values to be written into the lock bytes, so that both are set to zero - }; - if (libusb_control_transfer(devhandle, 0x40, 0x6F, 0xA5F1, 0x0000, control_buf_out, sizeof(control_buf_out), TR_TIMEOUT) != sizeof(control_buf_out)) - { - fprintf(stderr, "Error: Failed control transfer (0x40, 0x6F).\n"); - err_level = EXIT_FAILURE; - } -} - -void reset(libusb_device_handle *devhandle) // Issues a reset to the CP2130, which in effect resets the entire device -{ - if (libusb_control_transfer(devhandle, 0x40, 0x10, 0x0000, 0x0000, NULL, 0, TR_TIMEOUT) != 0) - { - fprintf(stderr, "Error: Failed control transfer (0x40, 0x10).\n"); - err_level = EXIT_FAILURE; - } -} - -void select_cs(libusb_device_handle *devhandle, uint8_t channel) // Enables the chip select of the target channel, disabling any others -{ - unsigned char control_buf_out[2] = { - channel, // Selected channel - 0x02 // Only the corresponding chip select is enabled, all the others are disabled - }; - if (libusb_control_transfer(devhandle, 0x40, 0x25, 0x0000, 0x0000, control_buf_out, sizeof(control_buf_out), TR_TIMEOUT) != sizeof(control_buf_out)) - { - fprintf(stderr, "Error: Failed control transfer (0x40, 0x25).\n"); - err_level = EXIT_FAILURE; - } -} - -void setup(libusb_device_handle *devhandle) // Sets up the AD9834 waveform generator -{ - unsigned char write_command_buf[10] = { - 0x00, 0x00, // Reserved - 0x01, // Write command - 0x00, // Reserved - 0x02, 0x00, 0x00, 0x00, // Two bytes to write - 0x22, 0x00 // B28 = 1, PIN/SW = 1 - }; - int bytes_written; - if (libusb_bulk_transfer(devhandle, 0x01, write_command_buf, sizeof(write_command_buf), &bytes_written, TR_TIMEOUT) != 0) - { - fprintf(stderr, "Error: Failed bulk OUT transfer to endpoint 1 (address 0x01).\n"); - err_level = EXIT_FAILURE; - } -} - -void set_amplitude(libusb_device_handle *devhandle, uint16_t value) // Sets the register on the AD5310 DAC to a given value, in order to set the amplitude (channel 1 must be enabled) -{ - unsigned char write_command_buf[10] = { - 0x00, 0x00, // Reserved - 0x01, // Write command - 0x00, // Reserved - 0x02, 0x00, 0x00, 0x00, // Two bytes to write - 0x0F & (uint8_t)(value >> 6), // Amplitude set according to the given value - (uint8_t)(value << 2) - }; - int bytes_written; - if (libusb_bulk_transfer(devhandle, 0x01, write_command_buf, sizeof(write_command_buf), &bytes_written, TR_TIMEOUT) != 0) - { - fprintf(stderr, "Error: Failed bulk OUT transfer to endpoint 1 (address 0x01).\n"); - err_level = EXIT_FAILURE; - } -} - -void set_frequency(libusb_device_handle *devhandle, uint32_t value, bool sel) // Sets either FREQ0 or FREQ1 registers on the AD9834 waveform generator to the given value -{ - unsigned char write_command_buf[12] = { - 0x00, 0x00, // Reserved - 0x01, // Write command - 0x00, // Reserved - 0x04, 0x00, 0x00, 0x00, // Four bytes to write - (sel ? 0x80 : 0x40) + (0x3F & (uint8_t)(value >> 8)), // FREQ0 or FREQ1 register set to the given value, according to the boolean variable "sel" - (uint8_t)value, - (sel ? 0x80 : 0x40) + (0x3F & (uint8_t)(value >> 22)), - (uint8_t)(value >> 14) - }; - int bytes_written; - if (libusb_bulk_transfer(devhandle, 0x01, write_command_buf, sizeof(write_command_buf), &bytes_written, TR_TIMEOUT) != 0) - { - fprintf(stderr, "Error: Failed bulk OUT transfer to endpoint 1 (address 0x01).\n"); - err_level = EXIT_FAILURE; - } -} - -void set_gpio2(libusb_device_handle *devhandle, bool value) // Sets the GPIO.2 pin on the CP2130 to a given value -{ - unsigned char control_buf_out[4] = { - 0x00, 0xFF * value, // Set the value of GPIO.2 to the intended value - 0x00, 0x20 // Set the mask so that only GPIO.2 is changed - }; - if (libusb_control_transfer(devhandle, 0x40, 0x21, 0x0000, 0x0000, control_buf_out, sizeof(control_buf_out), TR_TIMEOUT) != sizeof(control_buf_out)) - { - fprintf(stderr, "Error: Failed control transfer (0x40, 0x21).\n"); - err_level = EXIT_FAILURE; - } -} - -void set_gpio3(libusb_device_handle *devhandle, bool value) // Sets the GPIO.3 pin on the CP2130 to a given value -{ - unsigned char control_buf_out[4] = { - 0x00, 0xFF * value, // Set the value of GPIO.3 to the intended value - 0x00, 0x40 // Set the mask so that only GPIO.3 is changed - }; - if (libusb_control_transfer(devhandle, 0x40, 0x21, 0x0000, 0x0000, control_buf_out, sizeof(control_buf_out), TR_TIMEOUT) != sizeof(control_buf_out)) - { - fprintf(stderr, "Error: Failed control transfer (0x40, 0x21).\n"); - err_level = EXIT_FAILURE; - } -} - -void set_gpio4(libusb_device_handle *devhandle, bool value) // Sets the GPIO.4 pin on the CP2130 to a given value -{ - unsigned char control_buf_out[4] = { - 0x00, 0xFF * value, // Set the value of GPIO.4 to the intended value - 0x00, 0x80 // Set the mask so that only GPIO.4 is changed - }; - if (libusb_control_transfer(devhandle, 0x40, 0x21, 0x0000, 0x0000, control_buf_out, sizeof(control_buf_out), TR_TIMEOUT) != sizeof(control_buf_out)) - { - fprintf(stderr, "Error: Failed control transfer (0x40, 0x21).\n"); - err_level = EXIT_FAILURE; - } -} - -void set_gpio5(libusb_device_handle *devhandle, bool value) // Sets the GPIO.5 pin on the CP2130 to a given value -{ - unsigned char control_buf_out[4] = { - 0xFF * value, 0x00, // Set the value of GPIO.5 to the intended value - 0x01, 0x00 // Set the mask so that only GPIO.5 is changed - }; - if (libusb_control_transfer(devhandle, 0x40, 0x21, 0x0000, 0x0000, control_buf_out, sizeof(control_buf_out), TR_TIMEOUT) != sizeof(control_buf_out)) - { - fprintf(stderr, "Error: Failed control transfer (0x40, 0x21).\n"); - err_level = EXIT_FAILURE; - } -} - -void set_gpio6(libusb_device_handle *devhandle, bool value) // Sets the GPIO.6 pin on the CP2130 to a given value -{ - unsigned char control_buf_out[4] = { - 0xFF * value, 0x00, // Set the value of GPIO.6 to the intended value - 0x04, 0x00 // Set the mask so that only GPIO.6 is changed - }; - if (libusb_control_transfer(devhandle, 0x40, 0x21, 0x0000, 0x0000, control_buf_out, sizeof(control_buf_out), TR_TIMEOUT) != sizeof(control_buf_out)) - { - fprintf(stderr, "Error: Failed control transfer (0x40, 0x21).\n"); - err_level = EXIT_FAILURE; - } -} - -void set_phase(libusb_device_handle *devhandle, uint16_t value, bool sel) // Sets either PHASE0 or PHASE1 registers on the AD9834 waveform generator to the given value -{ - unsigned char write_command_buf[10] = { - 0x00, 0x00, // Reserved - 0x01, // Write command - 0x00, // Reserved - 0x02, 0x00, 0x00, 0x00, // Two bytes to write - (sel ? 0xE0 : 0xC0) + (0x0F & (uint8_t)(value >> 8)), // PHASE0 or PHASE1 register set to the given value, according to the boolean variable "sel" - (uint8_t)value - }; - int bytes_written; - if (libusb_bulk_transfer(devhandle, 0x01, write_command_buf, sizeof(write_command_buf), &bytes_written, TR_TIMEOUT) != 0) - { - fprintf(stderr, "Error: Failed bulk OUT transfer to endpoint 1 (address 0x01).\n"); - err_level = EXIT_FAILURE; - } -} - -void set_sine_wave(libusb_device_handle *devhandle) // Configures the control register on the AD9834 waveform generator to generate a sine wave (channel 0 must be enabled) -{ - unsigned char write_command_buf[10] = { - 0x00, 0x00, // Reserved - 0x01, // Write command - 0x00, // Reserved - 0x02, 0x00, 0x00, 0x00, // Two bytes to write - 0x22, 0x00 // Sinusoidal waveform, B28 = 1, PIN/SW = 1 - }; - int bytes_written; - if (libusb_bulk_transfer(devhandle, 0x01, write_command_buf, sizeof(write_command_buf), &bytes_written, TR_TIMEOUT) != 0) - { - fprintf(stderr, "Error: Failed bulk OUT transfer to endpoint 1 (address 0x01).\n"); - err_level = EXIT_FAILURE; - } -} - -void set_triangle_wave(libusb_device_handle *devhandle) // Configures the control register on the AD9834 waveform generator in order to generate a triangle wave (channel 0 must be enabled) -{ - unsigned char write_command_buf[10] = { - 0x00, 0x00, // Reserved - 0x01, // Write command - 0x00, // Reserved - 0x02, 0x00, 0x00, 0x00, // Two bytes to write - 0x22, 0x02 // Triangular waveform, B28 = 1, PIN/SW = 1 - }; - int bytes_written; - if (libusb_bulk_transfer(devhandle, 0x01, write_command_buf, sizeof(write_command_buf), &bytes_written, TR_TIMEOUT) != 0) - { - fprintf(stderr, "Error: Failed bulk OUT transfer to endpoint 1 (address 0x01).\n"); - err_level = EXIT_FAILURE; - } -} From 5531df3f3c7ee6c7625ff1c743a04ed8b68853ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:02:22 +0100 Subject: [PATCH 11/62] Delete gf2-core.h --- src/gf2-core.h | 67 -------------------------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 src/gf2-core.h diff --git a/src/gf2-core.h b/src/gf2-core.h deleted file mode 100644 index 96f16c3..0000000 --- a/src/gf2-core.h +++ /dev/null @@ -1,67 +0,0 @@ -/* GF2 core functions - Version 1.0 - Copyright (c) 2018-2019 Samuel Lourenço - - This library is free software: you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or (at your - option) any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -#ifndef GF2_CORE_H_ -#define GF2_CORE_H_ - -// Includes -#include -#include - -// Defines -#define CPOL0 false // Boolean corresponding to CPOL = 0, applicable to configure_spi_mode() -#define CPOL1 true // Boolean corresponding to CPOL = 1, applicable to configure_spi_mode() -#define CPHA0 false // Boolean corresponding to CPHA = 0, applicable to configure_spi_mode() -#define CPHA1 true // Boolean corresponding to CPHA = 1, applicable to configure_spi_mode() -#define FREQ0 false // Boolean corresponding to the FREQ0 register, applicable to set_frequency() -#define FREQ1 true // Boolean corresponding to the FREQ1 register, applicable to set_frequency() -#define PHASE0 false // Boolean corresponding to the PHASE0 register, applicable to set_phase() -#define PHASE1 true // Boolean corresponding to the PHASE1 register, applicable to set_phase() - -// Global external variables -extern int err_level; - -// Function prototypes -void clear_registers(libusb_device_handle *devhandle); -void configure_spi_mode(libusb_device_handle *devhandle, uint8_t channel, bool cpol, bool cpha); -void disable_cs(libusb_device_handle *devhandle, uint8_t channel); -void disable_spi_delays(libusb_device_handle *devhandle, uint8_t channel); -bool get_gpio2(libusb_device_handle *devhandle); -bool get_gpio3(libusb_device_handle *devhandle); -bool get_gpio4(libusb_device_handle *devhandle); -bool get_gpio5(libusb_device_handle *devhandle); -bool get_gpio6(libusb_device_handle *devhandle); -bool is_otp_locked(libusb_device_handle *devhandle); -void lock_otp(libusb_device_handle *devhandle); -void reset(libusb_device_handle *devhandle); -void select_cs(libusb_device_handle *devhandle, uint8_t channel); -void setup(libusb_device_handle *devhandle); -void set_amplitude(libusb_device_handle *devhandle, uint16_t value); -void set_frequency(libusb_device_handle *devhandle, uint32_t value, bool sel); -void set_gpio2(libusb_device_handle *devhandle, bool value); -void set_gpio3(libusb_device_handle *devhandle, bool value); -void set_gpio4(libusb_device_handle *devhandle, bool value); -void set_gpio5(libusb_device_handle *devhandle, bool value); -void set_gpio6(libusb_device_handle *devhandle, bool value); -void set_phase(libusb_device_handle *devhandle, uint16_t value, bool sel); -void set_sine_wave(libusb_device_handle *devhandle); -void set_triangle_wave(libusb_device_handle *devhandle); - -#endif From 1109e405e2ee2390d98bec7b25478e91ae20f979 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:02:29 +0100 Subject: [PATCH 12/62] Delete gf2-dacoff.c --- src/gf2-dacoff.c | 84 ------------------------------------------------ 1 file changed, 84 deletions(-) delete mode 100644 src/gf2-dacoff.c diff --git a/src/gf2-dacoff.c b/src/gf2-dacoff.c deleted file mode 100644 index c99d541..0000000 --- a/src/gf2-dacoff.c +++ /dev/null @@ -1,84 +0,0 @@ -/* GF2 DACOff Command - Version 1.1 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include -#include -#include -#include "gf2-core.h" -#include "libusb-extra.h" - -int main(int argc, char **argv) -{ - err_level = EXIT_SUCCESS; // Note that this variable is declared externally! - libusb_context *context; - if (libusb_init(&context) != 0) // Initialize libusb. In case of failure - { - fprintf(stderr, "Error: Could not initialize libusb.\n"); - err_level = EXIT_FAILURE; - } - else // If libusb is initialized - { - libusb_device_handle *devhandle; - if (argc < 2) // If the program was called without arguments - devhandle = libusb_open_device_with_vid_pid(context, 0x10C4, 0x8BF1); // Open a device and get the device handle - else // Serial number was specified as argument - devhandle = libusb_open_device_with_vid_pid_serial(context, 0x10C4, 0x8BF1, (unsigned char *)argv[1]); // Open the device having the specified serial number, and get the device handle - if (devhandle == NULL) // If the previous operation fails to get a device handle - { - fprintf(stderr, "Error: Could not find device.\n"); - err_level = EXIT_FAILURE; - } - else // If the device is successfully opened and a handle obtained - { - bool kernel_attached = false; - if (libusb_kernel_driver_active(devhandle, 0) != 0) // If a kernel driver is active on the interface - { - libusb_detach_kernel_driver(devhandle, 0); // Detach the kernel driver - kernel_attached = true; // Flag that the kernel driver was attached - } - if (libusb_claim_interface(devhandle, 0) != 0) // Claim the interface. In case of failure - { - fprintf(stderr, "Error: Device is currently unavailable.\n"); - err_level = EXIT_FAILURE; - } - else // If the interface is successfully claimed - { - set_gpio3(devhandle, true); // Set GPIO.3 to a logical high in order to disable the AD9834 internal DAC - if (!get_gpio6(devhandle)) // If GPIO.6 is set to a logical low - { - set_gpio6(devhandle, true); // Set GPIO.6 to a logical high to disable the TLV3501 comparator - usleep(10000); // Wait 10ms, so that the comparator has time to settle - set_gpio6(devhandle, false); // Set GPIO.6 to a logical low to re-enable the comparator - } - if (err_level == 0) // If all goes well - printf("Waveform generator DAC disabled.\n"); - libusb_release_interface(devhandle, 0); // Release the interface - } - if (kernel_attached) // If a kernel driver was attached to the interface before - libusb_attach_kernel_driver(devhandle, 0); // Reattach the kernel driver - libusb_close(devhandle); // Close the device - } - libusb_exit(context); // Deinitialize libusb - } - return err_level; -} From e7dcbdfa56ad81628601a9585f8dd62175801b05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:02:38 +0100 Subject: [PATCH 13/62] Delete gf2-dacon.c --- src/gf2-dacon.c | 77 ------------------------------------------------- 1 file changed, 77 deletions(-) delete mode 100644 src/gf2-dacon.c diff --git a/src/gf2-dacon.c b/src/gf2-dacon.c deleted file mode 100644 index eda62b1..0000000 --- a/src/gf2-dacon.c +++ /dev/null @@ -1,77 +0,0 @@ -/* GF2 DACOn Command - Version 1.1 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include -#include -#include "gf2-core.h" -#include "libusb-extra.h" - -int main(int argc, char **argv) -{ - err_level = EXIT_SUCCESS; // Note that this variable is declared externally! - libusb_context *context; - if (libusb_init(&context) != 0) // Initialize libusb. In case of failure - { - fprintf(stderr, "Error: Could not initialize libusb.\n"); - err_level = EXIT_FAILURE; - } - else // If libusb is initialized - { - libusb_device_handle *devhandle; - if (argc < 2) // If the program was called without arguments - devhandle = libusb_open_device_with_vid_pid(context, 0x10C4, 0x8BF1); // Open a device and get the device handle - else // Serial number was specified as argument - devhandle = libusb_open_device_with_vid_pid_serial(context, 0x10C4, 0x8BF1, (unsigned char *)argv[1]); // Open the device having the specified serial number, and get the device handle - if (devhandle == NULL) // If the previous operation fails to get a device handle - { - fprintf(stderr, "Error: Could not find device.\n"); - err_level = EXIT_FAILURE; - } - else // If the device is successfully opened and a handle obtained - { - bool kernel_attached = false; - if (libusb_kernel_driver_active(devhandle, 0) != 0) // If a kernel driver is active on the interface - { - libusb_detach_kernel_driver(devhandle, 0); // Detach the kernel driver - kernel_attached = true; // Flag that the kernel driver was attached - } - if (libusb_claim_interface(devhandle, 0) != 0) // Claim the interface. In case of failure - { - fprintf(stderr, "Error: Device is currently unavailable.\n"); - err_level = EXIT_FAILURE; - } - else // If the interface is successfully claimed - { - set_gpio3(devhandle, false); // Set GPIO.3 to a logical low in order to enable the AD9834 internal DAC - if (err_level == 0) // If all goes well - printf("Waveform generator DAC enabled.\n"); - libusb_release_interface(devhandle, 0); // Release the interface - } - if (kernel_attached) // If a kernel driver was attached to the interface before - libusb_attach_kernel_driver(devhandle, 0); // Reattach the kernel driver - libusb_close(devhandle); // Close the device - } - libusb_exit(context); // Deinitialize libusb - } - return err_level; -} From b20a8bdf289e68d9f544f64a52abbd187f51f76c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:02:46 +0100 Subject: [PATCH 14/62] Delete gf2-freq.c --- src/gf2-freq.c | 111 ------------------------------------------------- 1 file changed, 111 deletions(-) delete mode 100644 src/gf2-freq.c diff --git a/src/gf2-freq.c b/src/gf2-freq.c deleted file mode 100644 index db8639d..0000000 --- a/src/gf2-freq.c +++ /dev/null @@ -1,111 +0,0 @@ -/* GF2 Freq Command - Version 1.1 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include -#include -#include -#include "common.h" -#include "gf2-core.h" -#include "libusb-extra.h" - -// Defines -#define EXIT_USERERR 2 // Exit status value to indicate a command usage error - -int main(int argc, char **argv) -{ - err_level = EXIT_SUCCESS; // Note that this variable is declared externally! - if (argc < 2) // If the program was called without arguments - { - fprintf(stderr, "Error: Missing argument.\nUsage: gf2-freq FREQUENCY(KHz)\n"); - err_level = EXIT_USERERR; - } - else if (!isnumber(argv[1])) // If the argument string doesn't constitute a valid number - { - fprintf(stderr, "Error: Argument is not a valid number.\n"); - err_level = EXIT_USERERR; - } - else - { - float frequency = (float)atof(argv[1]); // Convert the argument string into a floating point number - if (frequency < 0 || frequency > 40000) // If the obtained frequency value (in KHz) after conversion is lesser than 0 or greater than 25000 - { - fprintf(stderr, "Error: Frequency should be between 0 and 40000KHz.\n"); - err_level = EXIT_USERERR; - } - else - { - libusb_context *context; - if (libusb_init(&context) != 0) // Initialize libusb. In case of failure - { - fprintf(stderr, "Error: Could not initialize libusb.\n"); - err_level = EXIT_FAILURE; - } - else // If libusb is initialized - { - libusb_device_handle *devhandle; - if (argc == 2) // If no serial number was specified - devhandle = libusb_open_device_with_vid_pid(context, 0x10C4, 0x8BF1); // Open a device and get the device handle - else // Serial number was specified as a second (optional) argument - devhandle = libusb_open_device_with_vid_pid_serial(context, 0x10C4, 0x8BF1, (unsigned char *)argv[2]); // Open the device having the specified serial number, and get the device handle - if (devhandle == NULL) // If the previous operation fails to get a device handle - { - fprintf(stderr, "Error: Could not find device.\n"); - err_level = EXIT_FAILURE; - } - else // If the device is successfully opened and a handle obtained - { - bool kernel_attached = false; - if (libusb_kernel_driver_active(devhandle, 0) != 0) // If a kernel driver is active on the interface - { - libusb_detach_kernel_driver(devhandle, 0); // Detach the kernel driver - kernel_attached = true; // Flag that the kernel driver was attached - } - if (libusb_claim_interface(devhandle, 0) != 0) // Claim the interface. In case of failure - { - fprintf(stderr, "Error: Device is currently unavailable.\n"); - err_level = EXIT_FAILURE; - } - else // If the interface is successfully claimed - { - configure_spi_mode(devhandle, 0, CPOL1, CPHA0); // Clock polarity regarding channel 0 is active low (CPOL = 1) and data is valid on each falling edge (CPHA = 0) - disable_spi_delays(devhandle, 0); // Disable all SPI delays for channel 0 - uint32_t freq_code = (uint32_t)(frequency * 134217728 / 40000 + 0.5); - bool fsel = get_gpio4(devhandle); // Get the current value of the GPIO.4 pin, which corresponds to FSELECT on the AD9834 waveform generator - select_cs(devhandle, 0); // Enable the chip select corresponding to channel 0, and disable any others - set_frequency(devhandle, freq_code, fsel); // Set the selected freq register to the intended value (by sending a sequence of bytes to the AD9834 waveform generator on channel 0) - usleep(100); // Wait 100us, in order to prevent possible errors while disabling the chip select (workaround) - disable_cs(devhandle, 0); // Disable the previously enabled chip select - if (err_level == 0) // If all goes well - printf("Frequency (%d) set to %.4fKHz.\n",fsel , freq_code * 40000.0 / 134217728); - libusb_release_interface(devhandle, 0); // Release the interface - } - if (kernel_attached) // If a kernel driver was attached to the interface before - libusb_attach_kernel_driver(devhandle, 0); // Reattach the kernel driver - libusb_close(devhandle); // Close the device - } - libusb_exit(context); // Deinitialize libusb - } - } - } - return err_level; -} From 47b167cd2c6b5f3cc3875651ffb32053bedfb2e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:02:52 +0100 Subject: [PATCH 15/62] Delete gf2-freq0.c --- src/gf2-freq0.c | 110 ------------------------------------------------ 1 file changed, 110 deletions(-) delete mode 100644 src/gf2-freq0.c diff --git a/src/gf2-freq0.c b/src/gf2-freq0.c deleted file mode 100644 index 2094fc5..0000000 --- a/src/gf2-freq0.c +++ /dev/null @@ -1,110 +0,0 @@ -/* GF2 Freq0 Command - Version 1.1 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include -#include -#include -#include "common.h" -#include "gf2-core.h" -#include "libusb-extra.h" - -// Defines -#define EXIT_USERERR 2 // Exit status value to indicate a command usage error - -int main(int argc, char **argv) -{ - err_level = EXIT_SUCCESS; // Note that this variable is declared externally! - if (argc < 2) // If the program was called without arguments - { - fprintf(stderr, "Error: Missing argument.\nUsage: gf2-freq0 FREQUENCY(KHz)\n"); - err_level = EXIT_USERERR; - } - else if (!isnumber(argv[1])) // If the argument string doesn't constitute a valid number - { - fprintf(stderr, "Error: Argument is not a valid number.\n"); - err_level = EXIT_USERERR; - } - else - { - float frequency = (float)atof(argv[1]); // Convert the argument string into a floating point number - if (frequency < 0 || frequency > 40000) // If the obtained frequency value (in KHz) after conversion is lesser than 0 or greater than 25000 - { - fprintf(stderr, "Error: Frequency should be between 0 and 40000KHz.\n"); - err_level = EXIT_USERERR; - } - else - { - libusb_context *context; - if (libusb_init(&context) != 0) // Initialize libusb. In case of failure - { - fprintf(stderr, "Error: Could not initialize libusb.\n"); - err_level = EXIT_FAILURE; - } - else // If libusb is initialized - { - libusb_device_handle *devhandle; - if (argc == 2) // If no serial number was specified - devhandle = libusb_open_device_with_vid_pid(context, 0x10C4, 0x8BF1); // Open a device and get the device handle - else // Serial number was specified as a second (optional) argument - devhandle = libusb_open_device_with_vid_pid_serial(context, 0x10C4, 0x8BF1, (unsigned char *)argv[2]); // Open the device having the specified serial number, and get the device handle - if (devhandle == NULL) // If the previous operation fails to get a device handle - { - fprintf(stderr, "Error: Could not find device.\n"); - err_level = EXIT_FAILURE; - } - else // If the device is successfully opened and a handle obtained - { - bool kernel_attached = false; - if (libusb_kernel_driver_active(devhandle, 0) != 0) // If a kernel driver is active on the interface - { - libusb_detach_kernel_driver(devhandle, 0); // Detach the kernel driver - kernel_attached = true; // Flag that the kernel driver was attached - } - if (libusb_claim_interface(devhandle, 0) != 0) // Claim the interface. In case of failure - { - fprintf(stderr, "Error: Device is currently unavailable.\n"); - err_level = EXIT_FAILURE; - } - else // If the interface is successfully claimed - { - configure_spi_mode(devhandle, 0, CPOL1, CPHA0); // Clock polarity regarding channel 0 is active low (CPOL = 1) and data is valid on each falling edge (CPHA = 0) - disable_spi_delays(devhandle, 0); // Disable all SPI delays for channel 0 - uint32_t freq_code = (uint32_t)(frequency * 134217728 / 40000 + 0.5); - select_cs(devhandle, 0); // Enable the chip select corresponding to channel 0, and disable any others - set_frequency(devhandle, freq_code, FREQ0); // Set the FREQ0 register to the intended value (by sending a sequence of bytes to the AD9834 waveform generator on channel 0) - usleep(100); // Wait 100us, in order to prevent possible errors while disabling the chip select (workaround) - disable_cs(devhandle, 0); // Disable the previously enabled chip select - if (err_level == 0) // If all goes well - printf("Frequency 0 set to %.4fKHz.\n", freq_code * 40000.0 / 134217728); - libusb_release_interface(devhandle, 0); // Release the interface - } - if (kernel_attached) // If a kernel driver was attached to the interface before - libusb_attach_kernel_driver(devhandle, 0); // Reattach the kernel driver - libusb_close(devhandle); // Close the device - } - libusb_exit(context); // Deinitialize libusb - } - } - } - return err_level; -} From 785d39ce35c4252754bd027a48e858494bce417c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:02:58 +0100 Subject: [PATCH 16/62] Delete gf2-freq1.c --- src/gf2-freq1.c | 110 ------------------------------------------------ 1 file changed, 110 deletions(-) delete mode 100644 src/gf2-freq1.c diff --git a/src/gf2-freq1.c b/src/gf2-freq1.c deleted file mode 100644 index 9a9a6fb..0000000 --- a/src/gf2-freq1.c +++ /dev/null @@ -1,110 +0,0 @@ -/* GF2 Freq1 Command - Version 1.1 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include -#include -#include -#include "common.h" -#include "gf2-core.h" -#include "libusb-extra.h" - -// Defines -#define EXIT_USERERR 2 // Exit status value to indicate a command usage error - -int main(int argc, char **argv) -{ - err_level = EXIT_SUCCESS; // Note that this variable is declared externally! - if (argc < 2) // If the program was called without arguments - { - fprintf(stderr, "Error: Missing argument.\nUsage: gf2-freq1 FREQUENCY(KHz)\n"); - err_level = EXIT_USERERR; - } - else if (!isnumber(argv[1])) // If the argument string doesn't constitute a valid number - { - fprintf(stderr, "Error: Argument is not a valid number.\n"); - err_level = EXIT_USERERR; - } - else - { - float frequency = (float)atof(argv[1]); // Convert the argument string into a floating point number - if (frequency < 0 || frequency > 40000) // If the obtained frequency value (in KHz) after conversion is lesser than 0 or greater than 25000 - { - fprintf(stderr, "Error: Frequency should be between 0 and 40000KHz.\n"); - err_level = EXIT_USERERR; - } - else - { - libusb_context *context; - if (libusb_init(&context) != 0) // Initialize libusb. In case of failure - { - fprintf(stderr, "Error: Could not initialize libusb.\n"); - err_level = EXIT_FAILURE; - } - else // If libusb is initialized - { - libusb_device_handle *devhandle; - if (argc == 2) // If no serial number was specified - devhandle = libusb_open_device_with_vid_pid(context, 0x10C4, 0x8BF1); // Open a device and get the device handle - else // Serial number was specified as a second (optional) argument - devhandle = libusb_open_device_with_vid_pid_serial(context, 0x10C4, 0x8BF1, (unsigned char *)argv[2]); // Open the device having the specified serial number, and get the device handle - if (devhandle == NULL) // If the previous operation fails to get a device handle - { - fprintf(stderr, "Error: Could not find device.\n"); - err_level = EXIT_FAILURE; - } - else // If the device is successfully opened and a handle obtained - { - bool kernel_attached = false; - if (libusb_kernel_driver_active(devhandle, 0) != 0) // If a kernel driver is active on the interface - { - libusb_detach_kernel_driver(devhandle, 0); // Detach the kernel driver - kernel_attached = true; // Flag that the kernel driver was attached - } - if (libusb_claim_interface(devhandle, 0) != 0) // Claim the interface. In case of failure - { - fprintf(stderr, "Error: Device is currently unavailable.\n"); - err_level = EXIT_FAILURE; - } - else // If the interface is successfully claimed - { - configure_spi_mode(devhandle, 0, CPOL1, CPHA0); // Clock polarity regarding channel 0 is active low (CPOL = 1) and data is valid on each falling edge (CPHA = 0) - disable_spi_delays(devhandle, 0); // Disable all SPI delays for channel 0 - uint32_t freq_code = (uint32_t)(frequency * 134217728 / 40000 + 0.5); - select_cs(devhandle, 0); // Enable the chip select corresponding to channel 0, and disable any others - set_frequency(devhandle, freq_code, FREQ1); // Set the FREQ1 register to the intended value (by sending a sequence of bytes to the AD9834 waveform generator on channel 0) - usleep(100); // Wait 100us, in order to prevent possible errors while disabling the chip select (workaround) - disable_cs(devhandle, 0); // Disable the previously enabled chip select - if (err_level == 0) // If all goes well - printf("Frequency 1 set to %.4fKHz.\n", freq_code * 40000.0 / 134217728); - libusb_release_interface(devhandle, 0); // Release the interface - } - if (kernel_attached) // If a kernel driver was attached to the interface before - libusb_attach_kernel_driver(devhandle, 0); // Reattach the kernel driver - libusb_close(devhandle); // Close the device - } - libusb_exit(context); // Deinitialize libusb - } - } - } - return err_level; -} From f45045385fd5ead05eeff51d9c6d7ff00e45b9dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:03:04 +0100 Subject: [PATCH 17/62] Delete gf2-list.c --- src/gf2-list.c | 76 -------------------------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 src/gf2-list.c diff --git a/src/gf2-list.c b/src/gf2-list.c deleted file mode 100644 index 9f242f8..0000000 --- a/src/gf2-list.c +++ /dev/null @@ -1,76 +0,0 @@ -/* GF2 List Command - Version 1.1 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include - -int main(void) -{ - int err_level = EXIT_SUCCESS; - libusb_context *context; - if (libusb_init(&context) != 0) // Initialize libusb. In case of failure - { - fprintf(stderr, "Error: Could not initialize libusb.\n"); - err_level = EXIT_FAILURE; - } - else // If libusb is initialized - { - libusb_device **devs; - ssize_t devlist = libusb_get_device_list(context, &devs); // Get a device list - if (devlist < 0) // If the previous operation fails to get a device list - { - fprintf(stderr, "Error: Failed to retrieve a list of devices.\n"); - err_level = EXIT_FAILURE; - } - else - { - size_t counter = 0; - for (ssize_t i = 0; i < devlist; ++i) // Run through all listed devices - { - struct libusb_device_descriptor desc; - if (libusb_get_device_descriptor(devs[i], &desc) == 0 && desc.idVendor == 0x10C4 && desc.idProduct == 0x8BF1) // If the device descriptor is retrieved, and both VID and PID correspond to the GF2 Function Generator - { - libusb_device_handle *devhandle; - ++counter; // Increment the counter, since a suitable device was found - printf("%ld\t", counter); // Print the item number - if (libusb_open(devs[i], &devhandle) == 0) // Open the listed device. If successfull - { - unsigned char str_desc[256]; - libusb_get_string_descriptor_ascii(devhandle, desc.iSerialNumber, str_desc, sizeof(str_desc)); // Get the serial number string in ASCII format - printf("%s", str_desc); // Print the serial number string - libusb_close(devhandle); // Close the device - } - else // If not, the device is simply listed as unidentified (no error reported) - printf("Unidentified"); - if (counter == 1) // If the device is the first to be listed, then it must be the one that accepts commands by default (i.e., without having a serial number specified) - printf(" (default)"); - printf("\n"); // End of line for the list item - } - } - if (counter == 0) - printf("No devices found.\n"); - libusb_free_device_list(devs, 1); // Free device list - } - libusb_exit(context); // Deinitialize libusb - } - return err_level; -} From 114ca70f980434da718fc1c51cdb615d1e46e6c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:03:10 +0100 Subject: [PATCH 18/62] Delete gf2-lockotp.c --- src/gf2-lockotp.c | 98 ----------------------------------------------- 1 file changed, 98 deletions(-) delete mode 100644 src/gf2-lockotp.c diff --git a/src/gf2-lockotp.c b/src/gf2-lockotp.c deleted file mode 100644 index 53d5f52..0000000 --- a/src/gf2-lockotp.c +++ /dev/null @@ -1,98 +0,0 @@ -/* GF2 LockOTP Command - Version 1.1 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include -#include -#include "gf2-core.h" -#include "libusb-extra.h" - -// Defines -#define EXIT_USERERR 2 // Exit status value to indicate a command usage error - -int main(int argc, char **argv) -{ - err_level = EXIT_SUCCESS; // Note that this variable is declared externally! - if (argc < 2) // If the program was called without arguments - { - fprintf(stderr, "Error: Missing argument.\nUsage: gf2-lockotp SERIALNUMBER\n"); - err_level = EXIT_USERERR; - } - else - { - libusb_context *context; - if (libusb_init(&context) != 0) // Initialize libusb. In case of failure - { - fprintf(stderr, "Error: Could not initialize libusb.\n"); - err_level = EXIT_FAILURE; - } - else // If libusb is initialized - { - libusb_device_handle *devhandle = libusb_open_device_with_vid_pid_serial(context, 0x10C4, 0x8BF1, (unsigned char *)argv[1]); // Open the device having the specified serial number, and get the device handle - if (devhandle == NULL) // If the previous operation fails to get a device handle - { - fprintf(stderr, "Error: Could not find device.\n"); - err_level = EXIT_FAILURE; - } - else // If the device is successfully opened and a handle obtained - { - bool kernel_attached = false; - if (libusb_kernel_driver_active(devhandle, 0) != 0) // If a kernel driver is active on the interface - { - libusb_detach_kernel_driver(devhandle, 0); // Detach the kernel driver from the interface - kernel_attached = true; // Flag that the kernel driver was attached - } - if (libusb_claim_interface(devhandle, 0) != 0) // Claim the interface. In case of failure - { - fprintf(stderr, "Error: Device is currently unavailable.\n"); - err_level = EXIT_FAILURE; - } - else // If the interface is successfully claimed - { - if (is_otp_locked(devhandle) && err_level == 0) // Check if the OTP ROM is locked (err_level can change to 1 as a consequence of that verification, hence the need for "&& err_level == 0" in order to avoid misleading messages) - printf("Device OTP ROM is already locked.\n"); - else if (err_level == 0) // If all goes well - { - printf("Device OTP ROM contains unlocked fields, which can be overwritten.\n"); - printf("Do you wish to permanently lock all fields? [y/N] "); - char cin = getc(stdin); // Get character entered by user - if (cin == 'Y' || cin == 'y') // If user entered "Y" or "y" - { - lock_otp(devhandle); // Lock the OTP ROM - reset(devhandle); // Reset the device - if (err_level == 0) // If all goes well - printf("Device OTP ROM is now locked.\n"); // Notice that no verification is done after reset, since the device has to be allowed to re-enumerate before getting the updated register values - } - else // If user entered any other character - printf("Lock operation canceled.\n"); - } - libusb_release_interface(devhandle, 0); // Release the interface - } - if (kernel_attached) // If a kernel driver was attached to the interface before - libusb_attach_kernel_driver(devhandle, 0); // Reattach the kernel driver - libusb_close(devhandle); // Close the device - } - libusb_exit(context); // Deinitialize libusb - } - } - return err_level; -} From e2931293f0a9b4d46387987b5494434ad9325b23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:03:15 +0100 Subject: [PATCH 19/62] Delete gf2-phase.c --- src/gf2-phase.c | 104 ------------------------------------------------ 1 file changed, 104 deletions(-) delete mode 100644 src/gf2-phase.c diff --git a/src/gf2-phase.c b/src/gf2-phase.c deleted file mode 100644 index 61cbe39..0000000 --- a/src/gf2-phase.c +++ /dev/null @@ -1,104 +0,0 @@ -/* GF2 Phase Command - Version 1.1 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include -#include -#include -#include -#include "common.h" -#include "gf2-core.h" -#include "libusb-extra.h" - -// Defines -#define EXIT_USERERR 2 // Exit status value to indicate a command usage error - -int main(int argc, char **argv) -{ - err_level = EXIT_SUCCESS; // Note that this variable is declared externally! - if (argc < 2) // If the program was called without arguments - { - fprintf(stderr, "Error: Missing argument.\nUsage: gf2-phase0 PHASE(°)\n"); - err_level = EXIT_USERERR; - } - else if (!isnumber(argv[1])) // If the argument string doesn't constitute a valid number - { - fprintf(stderr, "Error: Argument is not a valid number.\n"); - err_level = EXIT_USERERR; - } - else - { - libusb_context *context; - if (libusb_init(&context) != 0) // Initialize libusb. In case of failure - { - fprintf(stderr, "Error: Could not initialize libusb.\n"); - err_level = EXIT_FAILURE; - } - else // If libusb is initialized - { - libusb_device_handle *devhandle; - if (argc == 2) // If no serial number was specified - devhandle = libusb_open_device_with_vid_pid(context, 0x10C4, 0x8BF1); // Open a device and get the device handle - else // Serial number was specified as a second (optional) argument - devhandle = libusb_open_device_with_vid_pid_serial(context, 0x10C4, 0x8BF1, (unsigned char *)argv[2]); // Open the device having the specified serial number, and get the device handle - if (devhandle == NULL) // If the previous operation fails to get a device handle - { - fprintf(stderr, "Error: Could not find device.\n"); - err_level = EXIT_FAILURE; - } - else // If the device is successfully opened and a handle obtained - { - bool kernel_attached = false; - if (libusb_kernel_driver_active(devhandle, 0) != 0) // If a kernel driver is active on the interface - { - libusb_detach_kernel_driver(devhandle, 0); // Detach the kernel driver - kernel_attached = true; // Flag that the kernel driver was attached - } - if (libusb_claim_interface(devhandle, 0) != 0) // Claim the interface. In case of failure - { - fprintf(stderr, "Error: Device is currently unavailable.\n"); - err_level = EXIT_FAILURE; - } - else // If the interface is successfully claimed - { - configure_spi_mode(devhandle, 0, CPOL1, CPHA0); // Clock polarity regarding channel 0 is active low (CPOL = 1) and data is valid on each falling edge (CPHA = 0) - disable_spi_delays(devhandle, 0); // Disable all SPI delays for channel 0 - float phase_mod = (float)fmod(atof(argv[1]), 360); // Convert the argument string into a floating point number, and then calculate the remainder of its division by 360 - uint16_t phase_code = (uint16_t)((phase_mod < 0 ? 360 + phase_mod : phase_mod) * 4096 / 360 + 0.5); - bool psel = get_gpio5(devhandle); // Get the current value of the GPIO.5 pin, which corresponds to PSELECT on the AD9834 waveform generator - select_cs(devhandle, 0); // Enable the chip select corresponding to channel 0, and disable any others - set_phase(devhandle, phase_code, psel); // Set the selected phase register to the intended value (by sending a sequence of bytes to the AD9834 waveform generator on channel 0) - usleep(100); // Wait 100us, in order to prevent possible errors while disabling the chip select (workaround) - disable_cs(devhandle, 0); // Disable the previously enabled chip select - if (err_level == 0) // If all goes well - printf("Phase (%d) set to %.2f°.\n", psel, phase_code * 360.0 / 4096); - libusb_release_interface(devhandle, 0); // Release the interface - } - if (kernel_attached) // If a kernel driver was attached to the interface before - libusb_attach_kernel_driver(devhandle, 0); // Reattach the kernel driver - libusb_close(devhandle); // Close the device - } - libusb_exit(context); // Deinitialize libusb - } - } - return err_level; -} From 193a091ef633b55a58cbf31ef2eeed2a77529169 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:03:21 +0100 Subject: [PATCH 20/62] Delete gf2-phase0.c --- src/gf2-phase0.c | 103 ----------------------------------------------- 1 file changed, 103 deletions(-) delete mode 100644 src/gf2-phase0.c diff --git a/src/gf2-phase0.c b/src/gf2-phase0.c deleted file mode 100644 index a442fe7..0000000 --- a/src/gf2-phase0.c +++ /dev/null @@ -1,103 +0,0 @@ -/* GF2 Phase0 Command - Version 1.1 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include -#include -#include -#include -#include "common.h" -#include "gf2-core.h" -#include "libusb-extra.h" - -// Defines -#define EXIT_USERERR 2 // Exit status value to indicate a command usage error - -int main(int argc, char **argv) -{ - err_level = EXIT_SUCCESS; // Note that this variable is declared externally! - if (argc < 2) // If the program was called without arguments - { - fprintf(stderr, "Error: Missing argument.\nUsage: gf2-phase0 PHASE(°)\n"); - err_level = EXIT_USERERR; - } - else if (!isnumber(argv[1])) // If the argument string doesn't constitute a valid number - { - fprintf(stderr, "Error: Argument is not a valid number.\n"); - err_level = EXIT_USERERR; - } - else - { - libusb_context *context; - if (libusb_init(&context) != 0) // Initialize libusb. In case of failure - { - fprintf(stderr, "Error: Could not initialize libusb.\n"); - err_level = EXIT_FAILURE; - } - else // If libusb is initialized - { - libusb_device_handle *devhandle; - if (argc == 2) // If no serial number was specified - devhandle = libusb_open_device_with_vid_pid(context, 0x10C4, 0x8BF1); // Open a device and get the device handle - else // Serial number was specified as a second (optional) argument - devhandle = libusb_open_device_with_vid_pid_serial(context, 0x10C4, 0x8BF1, (unsigned char *)argv[2]); // Open the device having the specified serial number, and get the device handle - if (devhandle == NULL) // If the previous operation fails to get a device handle - { - fprintf(stderr, "Error: Could not find device.\n"); - err_level = EXIT_FAILURE; - } - else // If the device is successfully opened and a handle obtained - { - bool kernel_attached = false; - if (libusb_kernel_driver_active(devhandle, 0) != 0) // If a kernel driver is active on the interface - { - libusb_detach_kernel_driver(devhandle, 0); // Detach the kernel driver - kernel_attached = true; // Flag that the kernel driver was attached - } - if (libusb_claim_interface(devhandle, 0) != 0) // Claim the interface. In case of failure - { - fprintf(stderr, "Error: Device is currently unavailable.\n"); - err_level = EXIT_FAILURE; - } - else // If the interface is successfully claimed - { - configure_spi_mode(devhandle, 0, CPOL1, CPHA0); // Clock polarity regarding channel 0 is active low (CPOL = 1) and data is valid on each falling edge (CPHA = 0) - disable_spi_delays(devhandle, 0); // Disable all SPI delays for channel 0 - float phase_mod = (float)fmod(atof(argv[1]), 360); // Convert the argument string into a floating point number, and then calculate the remainder of its division by 360 - uint16_t phase_code = (uint16_t)((phase_mod < 0 ? 360 + phase_mod : phase_mod) * 4096 / 360 + 0.5); - select_cs(devhandle, 0); // Enable the chip select corresponding to channel 0, and disable any others - set_phase(devhandle, phase_code, PHASE0); // Set the PHASE0 register to the intended value (by sending a sequence of bytes to the AD9834 waveform generator on channel 0) - usleep(100); // Wait 100us, in order to prevent possible errors while disabling the chip select (workaround) - disable_cs(devhandle, 0); // Disable the previously enabled chip select - if (err_level == 0) // If all goes well - printf("Phase 0 set to %.2f°.\n", phase_code * 360.0 / 4096); - libusb_release_interface(devhandle, 0); // Release the interface - } - if (kernel_attached) // If a kernel driver was attached to the interface before - libusb_attach_kernel_driver(devhandle, 0); // Reattach the kernel driver - libusb_close(devhandle); // Close the device - } - libusb_exit(context); // Deinitialize libusb - } - } - return err_level; -} From 50a9a28fba062c07d0063f2c261275718b58b8ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:03:27 +0100 Subject: [PATCH 21/62] Delete gf2-phase1.c --- src/gf2-phase1.c | 103 ----------------------------------------------- 1 file changed, 103 deletions(-) delete mode 100644 src/gf2-phase1.c diff --git a/src/gf2-phase1.c b/src/gf2-phase1.c deleted file mode 100644 index 5f7c345..0000000 --- a/src/gf2-phase1.c +++ /dev/null @@ -1,103 +0,0 @@ -/* GF2 Phase1 Command - Version 1.1 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include -#include -#include -#include -#include "common.h" -#include "gf2-core.h" -#include "libusb-extra.h" - -// Defines -#define EXIT_USERERR 2 // Exit status value to indicate a command usage error - -int main(int argc, char **argv) -{ - err_level = EXIT_SUCCESS; // Note that this variable is declared externally! - if (argc < 2) // If the program was called without arguments - { - fprintf(stderr, "Error: Missing argument.\nUsage: gf2-phase1 PHASE(°)\n"); - err_level = EXIT_USERERR; - } - else if (!isnumber(argv[1])) // If the argument string doesn't constitute a valid number - { - fprintf(stderr, "Error: Argument is not a valid number.\n"); - err_level = EXIT_USERERR; - } - else - { - libusb_context *context; - if (libusb_init(&context) != 0) // Initialize libusb. In case of failure - { - fprintf(stderr, "Error: Could not initialize libusb.\n"); - err_level = EXIT_FAILURE; - } - else // If libusb is initialized - { - libusb_device_handle *devhandle; - if (argc == 2) // If no serial number was specified - devhandle = libusb_open_device_with_vid_pid(context, 0x10C4, 0x8BF1); // Open a device and get the device handle - else // Serial number was specified as a second (optional) argument - devhandle = libusb_open_device_with_vid_pid_serial(context, 0x10C4, 0x8BF1, (unsigned char *)argv[2]); // Open the device having the specified serial number, and get the device handle - if (devhandle == NULL) // If the previous operation fails to get a device handle - { - fprintf(stderr, "Error: Could not find device.\n"); - err_level = EXIT_FAILURE; - } - else // If the device is successfully opened and a handle obtained - { - bool kernel_attached = false; - if (libusb_kernel_driver_active(devhandle, 0) != 0) // If a kernel driver is active on the interface - { - libusb_detach_kernel_driver(devhandle, 0); // Detach the kernel driver - kernel_attached = true; // Flag that the kernel driver was attached - } - if (libusb_claim_interface(devhandle, 0) != 0) // Claim the interface. In case of failure - { - fprintf(stderr, "Error: Device is currently unavailable.\n"); - err_level = EXIT_FAILURE; - } - else // If the interface is successfully claimed - { - configure_spi_mode(devhandle, 0, CPOL1, CPHA0); // Clock polarity regarding channel 0 is active low (CPOL = 1) and data is valid on each falling edge (CPHA = 0) - disable_spi_delays(devhandle, 0); // Disable all SPI delays for channel 0 - float phase_mod = (float)fmod(atof(argv[1]), 360); // Convert the argument string into a floating point number, and then calculate the remainder of its division by 360 - uint16_t phase_code = (uint16_t)((phase_mod < 0 ? 360 + phase_mod : phase_mod) * 4096 / 360 + 0.5); - select_cs(devhandle, 0); // Enable the chip select corresponding to channel 0, and disable any others - set_phase(devhandle, phase_code, PHASE1); // Set the PHASE1 register to the intended value (by sending a sequence of bytes to the AD9834 waveform generator on channel 0) - usleep(100); // Wait 100us, in order to prevent possible errors while disabling the chip select (workaround) - disable_cs(devhandle, 0); // Disable the previously enabled chip select - if (err_level == 0) // If all goes well - printf("Phase 1 set to %.2f°.\n", phase_code * 360.0 / 4096); - libusb_release_interface(devhandle, 0); // Release the interface - } - if (kernel_attached) // If a kernel driver was attached to the interface before - libusb_attach_kernel_driver(devhandle, 0); // Reattach the kernel driver - libusb_close(devhandle); // Close the device - } - libusb_exit(context); // Deinitialize libusb - } - } - return err_level; -} From c6895176d868e97bf0bef5488dedbb90dd62822b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:03:33 +0100 Subject: [PATCH 22/62] Delete gf2-reset.c --- src/gf2-reset.c | 77 ------------------------------------------------- 1 file changed, 77 deletions(-) delete mode 100644 src/gf2-reset.c diff --git a/src/gf2-reset.c b/src/gf2-reset.c deleted file mode 100644 index 8573b24..0000000 --- a/src/gf2-reset.c +++ /dev/null @@ -1,77 +0,0 @@ -/* GF2 Reset Command - Version 1.1 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include -#include -#include "gf2-core.h" -#include "libusb-extra.h" - -int main(int argc, char **argv) -{ - err_level = EXIT_SUCCESS; // Note that this variable is declared externally! - libusb_context *context; - if (libusb_init(&context) != 0) // Initialize libusb. In case of failure - { - fprintf(stderr, "Error: Could not initialize libusb.\n"); - err_level = EXIT_FAILURE; - } - else // If libusb is initialized - { - libusb_device_handle *devhandle; - if (argc < 2) // If the program was called without arguments - devhandle = libusb_open_device_with_vid_pid(context, 0x10C4, 0x8BF1); // Open a device and get the device handle - else // Serial number was specified as argument - devhandle = libusb_open_device_with_vid_pid_serial(context, 0x10C4, 0x8BF1, (unsigned char *)argv[1]); // Open the device having the specified serial number, and get the device handle - if (devhandle == NULL) // If the previous operation fails to get a device handle - { - fprintf(stderr, "Error: Could not find device.\n"); - err_level = EXIT_FAILURE; - } - else // If the device is successfully opened and a handle obtained - { - bool kernel_attached = false; - if (libusb_kernel_driver_active(devhandle, 0) != 0) // If a kernel driver is active on the interface - { - libusb_detach_kernel_driver(devhandle, 0); // Detach the kernel driver - kernel_attached = true; // Flag that the kernel driver was attached - } - if (libusb_claim_interface(devhandle, 0) != 0) // Claim the interface. In case of failure - { - fprintf(stderr, "Error: Device is currently unavailable.\n"); - err_level = EXIT_FAILURE; - } - else // If the interface is successfully claimed - { - reset(devhandle); // Reset the device - if (err_level == 0) // If all goes well - printf("Reset issued.\n"); - libusb_release_interface(devhandle, 0); // Release the interface - } - if (kernel_attached) // If a kernel driver was attached to the interface before - libusb_attach_kernel_driver(devhandle, 0); // Reattach the kernel driver - libusb_close(devhandle); // Close the device - } - libusb_exit(context); // Deinitialize libusb - } - return err_level; -} From 8767847fc377496f9892a42b436154220c6dcd1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:03:39 +0100 Subject: [PATCH 23/62] Delete gf2-selfreq0.c --- src/gf2-selfreq0.c | 77 ---------------------------------------------- 1 file changed, 77 deletions(-) delete mode 100644 src/gf2-selfreq0.c diff --git a/src/gf2-selfreq0.c b/src/gf2-selfreq0.c deleted file mode 100644 index b688cd6..0000000 --- a/src/gf2-selfreq0.c +++ /dev/null @@ -1,77 +0,0 @@ -/* GF2 SelFreq0 Command - Version 1.1 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include -#include -#include "gf2-core.h" -#include "libusb-extra.h" - -int main(int argc, char **argv) -{ - err_level = EXIT_SUCCESS; // Note that this variable is declared externally! - libusb_context *context; - if (libusb_init(&context) != 0) // Initialize libusb. In case of failure - { - fprintf(stderr, "Error: Could not initialize libusb.\n"); - err_level = EXIT_FAILURE; - } - else // If libusb is initialized - { - libusb_device_handle *devhandle; - if (argc < 2) // If the program was called without arguments - devhandle = libusb_open_device_with_vid_pid(context, 0x10C4, 0x8BF1); // Open a device and get the device handle - else // Serial number was specified as argument - devhandle = libusb_open_device_with_vid_pid_serial(context, 0x10C4, 0x8BF1, (unsigned char *)argv[1]); // Open the device having the specified serial number, and get the device handle - if (devhandle == NULL) // If the previous operation fails to get a device handle - { - fprintf(stderr, "Error: Could not find device.\n"); - err_level = EXIT_FAILURE; - } - else // If the device is successfully opened and a handle obtained - { - bool kernel_attached = false; - if (libusb_kernel_driver_active(devhandle, 0) != 0) // If a kernel driver is active on the interface - { - libusb_detach_kernel_driver(devhandle, 0); // Detach the kernel driver - kernel_attached = true; // Flag that the kernel driver was attached - } - if (libusb_claim_interface(devhandle, 0) != 0) // Claim the interface. In case of failure - { - fprintf(stderr, "Error: Device is currently unavailable.\n"); - err_level = EXIT_FAILURE; - } - else // If the interface is successfully claimed - { - set_gpio4(devhandle, false); - if (err_level == 0) // If all goes well - printf("Frequency 0 selected.\n"); - libusb_release_interface(devhandle, 0); // Release the interface - } - if (kernel_attached) // If a kernel driver was attached to the interface before - libusb_attach_kernel_driver(devhandle, 0); // Reattach the kernel driver - libusb_close(devhandle); // Close the device - } - libusb_exit(context); // Deinitialize libusb - } - return err_level; -} From 2e1ddfdb9d8dec9d027505672e53f10645ea2dd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:03:45 +0100 Subject: [PATCH 24/62] Delete gf2-selfreq1.c --- src/gf2-selfreq1.c | 77 ---------------------------------------------- 1 file changed, 77 deletions(-) delete mode 100644 src/gf2-selfreq1.c diff --git a/src/gf2-selfreq1.c b/src/gf2-selfreq1.c deleted file mode 100644 index 9bd1b8e..0000000 --- a/src/gf2-selfreq1.c +++ /dev/null @@ -1,77 +0,0 @@ -/* GF2 SelFreq1 Command - Version 1.1 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include -#include -#include "gf2-core.h" -#include "libusb-extra.h" - -int main(int argc, char **argv) -{ - err_level = EXIT_SUCCESS; // Note that this variable is declared externally! - libusb_context *context; - if (libusb_init(&context) != 0) // Initialize libusb. In case of failure - { - fprintf(stderr, "Error: Could not initialize libusb.\n"); - err_level = EXIT_FAILURE; - } - else // If libusb is initialized - { - libusb_device_handle *devhandle; - if (argc < 2) // If the program was called without arguments - devhandle = libusb_open_device_with_vid_pid(context, 0x10C4, 0x8BF1); // Open a device and get the device handle - else // Serial number was specified as argument - devhandle = libusb_open_device_with_vid_pid_serial(context, 0x10C4, 0x8BF1, (unsigned char *)argv[1]); // Open the device having the specified serial number, and get the device handle - if (devhandle == NULL) // If the previous operation fails to get a device handle - { - fprintf(stderr, "Error: Could not find device.\n"); - err_level = EXIT_FAILURE; - } - else // If the device is successfully opened and a handle obtained - { - bool kernel_attached = false; - if (libusb_kernel_driver_active(devhandle, 0) != 0) // If a kernel driver is active on the interface - { - libusb_detach_kernel_driver(devhandle, 0); // Detach the kernel driver - kernel_attached = true; // Flag that the kernel driver was attached - } - if (libusb_claim_interface(devhandle, 0) != 0) // Claim the interface. In case of failure - { - fprintf(stderr, "Error: Device is currently unavailable.\n"); - err_level = EXIT_FAILURE; - } - else // If the interface is successfully claimed - { - set_gpio4(devhandle, true); - if (err_level == 0) // If all goes well - printf("Frequency 1 selected.\n"); - libusb_release_interface(devhandle, 0); // Release the interface - } - if (kernel_attached) // If a kernel driver was attached to the interface before - libusb_attach_kernel_driver(devhandle, 0); // Reattach the kernel driver - libusb_close(devhandle); // Close the device - } - libusb_exit(context); // Deinitialize libusb - } - return err_level; -} From cab54924d5d25d6030323c82930a865ea262aedd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:03:50 +0100 Subject: [PATCH 25/62] Delete gf2-selphase0.c --- src/gf2-selphase0.c | 77 --------------------------------------------- 1 file changed, 77 deletions(-) delete mode 100644 src/gf2-selphase0.c diff --git a/src/gf2-selphase0.c b/src/gf2-selphase0.c deleted file mode 100644 index c14e53c..0000000 --- a/src/gf2-selphase0.c +++ /dev/null @@ -1,77 +0,0 @@ -/* GF2 SelPhase0 Command - Version 1.1 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include -#include -#include "gf2-core.h" -#include "libusb-extra.h" - -int main(int argc, char **argv) -{ - err_level = EXIT_SUCCESS; // Note that this variable is declared externally! - libusb_context *context; - if (libusb_init(&context) != 0) // Initialize libusb. In case of failure - { - fprintf(stderr, "Error: Could not initialize libusb.\n"); - err_level = EXIT_FAILURE; - } - else // If libusb is initialized - { - libusb_device_handle *devhandle; - if (argc < 2) // If the program was called without arguments - devhandle = libusb_open_device_with_vid_pid(context, 0x10C4, 0x8BF1); // Open a device and get the device handle - else // Serial number was specified as argument - devhandle = libusb_open_device_with_vid_pid_serial(context, 0x10C4, 0x8BF1, (unsigned char *)argv[1]); // Open the device having the specified serial number, and get the device handle - if (devhandle == NULL) // If the previous operation fails to get a device handle - { - fprintf(stderr, "Error: Could not find device.\n"); - err_level = EXIT_FAILURE; - } - else // If the device is successfully opened and a handle obtained - { - bool kernel_attached = false; - if (libusb_kernel_driver_active(devhandle, 0) != 0) // If a kernel driver is active on the interface - { - libusb_detach_kernel_driver(devhandle, 0); // Detach the kernel driver - kernel_attached = true; // Flag that the kernel driver was attached - } - if (libusb_claim_interface(devhandle, 0) != 0) // Claim the interface. In case of failure - { - fprintf(stderr, "Error: Device is currently unavailable.\n"); - err_level = EXIT_FAILURE; - } - else // If the interface is successfully claimed - { - set_gpio5(devhandle, false); - if (err_level == 0) // If all goes well - printf("Phase 0 selected.\n"); - libusb_release_interface(devhandle, 0); // Release the interface - } - if (kernel_attached) // If a kernel driver was attached to the interface before - libusb_attach_kernel_driver(devhandle, 0); // Reattach the kernel driver - libusb_close(devhandle); // Close the device - } - libusb_exit(context); // Deinitialize libusb - } - return err_level; -} From 150ab4f9bf7253e25091d3140144d526c6b09c1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:03:56 +0100 Subject: [PATCH 26/62] Delete gf2-selphase1.c --- src/gf2-selphase1.c | 77 --------------------------------------------- 1 file changed, 77 deletions(-) delete mode 100644 src/gf2-selphase1.c diff --git a/src/gf2-selphase1.c b/src/gf2-selphase1.c deleted file mode 100644 index 10c0126..0000000 --- a/src/gf2-selphase1.c +++ /dev/null @@ -1,77 +0,0 @@ -/* GF2 SelPhase1 Command - Version 1.1 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include -#include -#include "gf2-core.h" -#include "libusb-extra.h" - -int main(int argc, char **argv) -{ - err_level = EXIT_SUCCESS; // Note that this variable is declared externally! - libusb_context *context; - if (libusb_init(&context) != 0) // Initialize libusb. In case of failure - { - fprintf(stderr, "Error: Could not initialize libusb.\n"); - err_level = EXIT_FAILURE; - } - else // If libusb is initialized - { - libusb_device_handle *devhandle; - if (argc < 2) // If the program was called without arguments - devhandle = libusb_open_device_with_vid_pid(context, 0x10C4, 0x8BF1); // Open a device and get the device handle - else // Serial number was specified as argument - devhandle = libusb_open_device_with_vid_pid_serial(context, 0x10C4, 0x8BF1, (unsigned char *)argv[1]); // Open the device having the specified serial number, and get the device handle - if (devhandle == NULL) // If the previous operation fails to get a device handle - { - fprintf(stderr, "Error: Could not find device.\n"); - err_level = EXIT_FAILURE; - } - else // If the device is successfully opened and a handle obtained - { - bool kernel_attached = false; - if (libusb_kernel_driver_active(devhandle, 0) != 0) // If a kernel driver is active on the interface - { - libusb_detach_kernel_driver(devhandle, 0); // Detach the kernel driver - kernel_attached = true; // Flag that the kernel driver was attached - } - if (libusb_claim_interface(devhandle, 0) != 0) // Claim the interface. In case of failure - { - fprintf(stderr, "Error: Device is currently unavailable.\n"); - err_level = EXIT_FAILURE; - } - else // If the interface is successfully claimed - { - set_gpio5(devhandle, true); - if (err_level == 0) // If all goes well - printf("Phase 1 selected.\n"); - libusb_release_interface(devhandle, 0); // Release the interface - } - if (kernel_attached) // If a kernel driver was attached to the interface before - libusb_attach_kernel_driver(devhandle, 0); // Reattach the kernel driver - libusb_close(devhandle); // Close the device - } - libusb_exit(context); // Deinitialize libusb - } - return err_level; -} From ae2b35aaa5b0d28e9cb84acc386e774a9cbf5c73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:04:02 +0100 Subject: [PATCH 27/62] Delete gf2-sine.c --- src/gf2-sine.c | 83 -------------------------------------------------- 1 file changed, 83 deletions(-) delete mode 100644 src/gf2-sine.c diff --git a/src/gf2-sine.c b/src/gf2-sine.c deleted file mode 100644 index 4514b02..0000000 --- a/src/gf2-sine.c +++ /dev/null @@ -1,83 +0,0 @@ -/* GF2 Sine Command - Version 1.1 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include -#include -#include -#include "gf2-core.h" -#include "libusb-extra.h" - -int main(int argc, char **argv) -{ - err_level = EXIT_SUCCESS; // Note that this variable is declared externally! - libusb_context *context; - if (libusb_init(&context) != 0) // Initialize libusb. In case of failure - { - fprintf(stderr, "Error: Could not initialize libusb.\n"); - err_level = EXIT_FAILURE; - } - else // If libusb is initialized - { - libusb_device_handle *devhandle; - if (argc < 2) // If the program was called without arguments - devhandle = libusb_open_device_with_vid_pid(context, 0x10C4, 0x8BF1); // Open a device and get the device handle - else // Serial number was specified as argument - devhandle = libusb_open_device_with_vid_pid_serial(context, 0x10C4, 0x8BF1, (unsigned char *)argv[1]); // Open the device having the specified serial number, and get the device handle - if (devhandle == NULL) // If the previous operation fails to get a device handle - { - fprintf(stderr, "Error: Could not find device.\n"); - err_level = EXIT_FAILURE; - } - else // If the device is successfully opened and a handle obtained - { - bool kernel_attached = false; - if (libusb_kernel_driver_active(devhandle, 0) != 0) // If a kernel driver is active on the interface - { - libusb_detach_kernel_driver(devhandle, 0); // Detach the kernel driver - kernel_attached = true; // Flag that the kernel driver was attached - } - if (libusb_claim_interface(devhandle, 0) != 0) // Claim the interface. In case of failure - { - fprintf(stderr, "Error: Device is currently unavailable.\n"); - err_level = EXIT_FAILURE; - } - else // If the interface is successfully claimed - { - configure_spi_mode(devhandle, 0, CPOL1, CPHA0); // Clock polarity regarding channel 0 is active low (CPOL = 1) and data is valid on each falling edge (CPHA = 0) - disable_spi_delays(devhandle, 0); // Disable all SPI delays for channel 0 - select_cs(devhandle, 0); // Enable the chip select corresponding to channel 0, and disable any others - set_sine_wave(devhandle); // Set the waveform to sinusoidal (by sending a specific sequence of bytes to the AD9834 waveform generator on channel 0) - usleep(100); // Wait 100us, in order to prevent possible errors while disabling the chip select (workaround) - disable_cs(devhandle, 0); // Disable the previously enabled chip select - if (err_level == 0) // If all goes well - printf("Waveform set to sinusoidal.\n"); - libusb_release_interface(devhandle, 0); // Release the interface - } - if (kernel_attached) // If a kernel driver was attached to the interface before - libusb_attach_kernel_driver(devhandle, 0); // Reattach the kernel driver - libusb_close(devhandle); // Close the device - } - libusb_exit(context); // Deinitialize libusb - } - return err_level; -} From de2cab9b5a7352fbec8b2b48e26ac070b9255b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:04:08 +0100 Subject: [PATCH 28/62] Delete gf2-start.c --- src/gf2-start.c | 78 ------------------------------------------------- 1 file changed, 78 deletions(-) delete mode 100644 src/gf2-start.c diff --git a/src/gf2-start.c b/src/gf2-start.c deleted file mode 100644 index f974fbc..0000000 --- a/src/gf2-start.c +++ /dev/null @@ -1,78 +0,0 @@ -/* GF2 Start Command - Version 1.1 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include -#include -#include "gf2-core.h" -#include "libusb-extra.h" - -int main(int argc, char **argv) -{ - err_level = EXIT_SUCCESS; // Note that this variable is declared externally! - libusb_context *context; - if (libusb_init(&context) != 0) // Initialize libusb. In case of failure - { - fprintf(stderr, "Error: Could not initialize libusb.\n"); - err_level = EXIT_FAILURE; - } - else // If libusb is initialized - { - libusb_device_handle *devhandle; - if (argc < 2) // If the program was called without arguments - devhandle = libusb_open_device_with_vid_pid(context, 0x10C4, 0x8BF1); // Open a device and get the device handle - else // Serial number was specified as argument - devhandle = libusb_open_device_with_vid_pid_serial(context, 0x10C4, 0x8BF1, (unsigned char *)argv[1]); // Open the device having the specified serial number, and get the device handle - if (devhandle == NULL) // If the previous operation fails to get a device handle - { - fprintf(stderr, "Error: Could not find device.\n"); - err_level = EXIT_FAILURE; - } - else // If the device is successfully opened and a handle obtained - { - bool kernel_attached = false; - if (libusb_kernel_driver_active(devhandle, 0) != 0) // If a kernel driver is active on the interface - { - libusb_detach_kernel_driver(devhandle, 0); // Detach the kernel driver - kernel_attached = true; // Flag that the kernel driver was attached - } - if (libusb_claim_interface(devhandle, 0) != 0) // Claim the interface. In case of failure - { - fprintf(stderr, "Error: Device is currently unavailable.\n"); - err_level = EXIT_FAILURE; - } - else // If the interface is successfully claimed - { - set_gpio2(devhandle, true); // Set GPIO.2 to a logical high to enable reset, thus enforcing a restart if the waveform generator is already running - set_gpio2(devhandle, false); // Set GPIO.2 to a logical low in order to disable reset and (re)start the waveform generation - if (err_level == 0) // If all goes well - printf("Waveform generation started.\n"); - libusb_release_interface(devhandle, 0); // Release the interface - } - if (kernel_attached) // If a kernel driver was attached to the interface before - libusb_attach_kernel_driver(devhandle, 0); // Reattach the kernel driver - libusb_close(devhandle); // Close the device - } - libusb_exit(context); // Deinitialize libusb - } - return err_level; -} From 03bb7d34b708cfd78b96fbe5b433c0478dc44b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:04:13 +0100 Subject: [PATCH 29/62] Delete gf2-status.c --- src/gf2-status.c | 89 ------------------------------------------------ 1 file changed, 89 deletions(-) delete mode 100644 src/gf2-status.c diff --git a/src/gf2-status.c b/src/gf2-status.c deleted file mode 100644 index 196989b..0000000 --- a/src/gf2-status.c +++ /dev/null @@ -1,89 +0,0 @@ -/* GF2 Status Command - Version 1.1 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include -#include -#include "gf2-core.h" -#include "libusb-extra.h" - -int main(int argc, char **argv) -{ - err_level = EXIT_SUCCESS; // Note that this variable is declared externally! - libusb_context *context; - if (libusb_init(&context) != 0) // Initialize libusb. In case of failure - { - fprintf(stderr, "Error: Could not initialize libusb.\n"); - err_level = EXIT_FAILURE; - } - else // If libusb is initialized - { - libusb_device_handle *devhandle; - if (argc < 2) // If the program was called without arguments - devhandle = libusb_open_device_with_vid_pid(context, 0x10C4, 0x8BF1); // Open a device and get the device handle - else // Serial number was specified as argument - devhandle = libusb_open_device_with_vid_pid_serial(context, 0x10C4, 0x8BF1, (unsigned char *)argv[1]); // Open the device having the specified serial number, and get the device handle - if (devhandle == NULL) // If the previous operation fails to get a device handle - { - fprintf(stderr, "Error: Could not find device.\n"); - err_level = EXIT_FAILURE; - } - else // If the device is successfully opened and a handle obtained - { - bool kernel_attached = false; - if (libusb_kernel_driver_active(devhandle, 0) != 0) // If a kernel driver is active on the interface - { - libusb_detach_kernel_driver(devhandle, 0); // Detach the kernel driver - kernel_attached = true; // Flag that the kernel driver was attached - } - if (libusb_claim_interface(devhandle, 0) != 0) // Claim the interface. In case of failure - { - fprintf(stderr, "Error: Device is currently unavailable.\n"); - err_level = EXIT_FAILURE; - } - else // If the interface is successfully claimed - { - bool rst = get_gpio2(devhandle); // Get the current value of the GPIO.2 pin, which corresponds to RESET on the AD9834 waveform generator - bool slp = get_gpio3(devhandle); // Get the current value of the GPIO.3 pin, which corresponds to SLEEP on the AD9834 waveform generator - bool cmp = get_gpio6(devhandle); // Get the current value of the GPIO.6 pin, which corresponds to SHDN on the TLV3501 comparator - bool fsel = get_gpio4(devhandle); // Get the current value of the GPIO.4 pin, which corresponds to FSELECT on the AD9834 waveform generator - bool psel = get_gpio5(devhandle); // Get the current value of the GPIO.5 pin, which corresponds to PSELECT on the AD9834 waveform generator - if (err_level == 0) // If all goes well - { - printf("Status: %s\n", rst ? "Stopped" : "Running"); // Print waveform generation status - printf("Waveform generator DAC: %s\n", slp ? "Disabled" : "Enabled"); // Print waveform generator DAC status - printf("Synchronous clock: %s\n", cmp ? "Disabled" : "Enabled"); // Print synchronous clock status - printf("Analog output: %s\n", rst || slp ? "Inactive" : "Active"); // Print analog output status - printf("Digital output: %s\n", rst || slp || cmp ? "Inactive" : "Active"); // Print digital output status - printf("Active frequency parameter: Frequency %d\n", fsel); // Print selected frequency parameter - printf("Active phase parameter: Phase %d\n", psel); // Print selected phase parameter - } - libusb_release_interface(devhandle, 0); // Release the interface - } - if (kernel_attached) // If a kernel driver was attached to the interface before - libusb_attach_kernel_driver(devhandle, 0); // Reattach the kernel driver - libusb_close(devhandle); // Close the device - } - libusb_exit(context); // Deinitialize libusb - } - return err_level; -} From d858bb1e38d9038cc211dd250a63b7fcf0e9f78d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:04:20 +0100 Subject: [PATCH 30/62] Delete gf2-stop.c --- src/gf2-stop.c | 84 -------------------------------------------------- 1 file changed, 84 deletions(-) delete mode 100644 src/gf2-stop.c diff --git a/src/gf2-stop.c b/src/gf2-stop.c deleted file mode 100644 index 0c715bf..0000000 --- a/src/gf2-stop.c +++ /dev/null @@ -1,84 +0,0 @@ -/* GF2 Stop Command - Version 1.1 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include -#include -#include -#include "gf2-core.h" -#include "libusb-extra.h" - -int main(int argc, char **argv) -{ - err_level = EXIT_SUCCESS; // Note that this variable is declared externally! - libusb_context *context; - if (libusb_init(&context) != 0) // Initialize libusb. In case of failure - { - fprintf(stderr, "Error: Could not initialize libusb.\n"); - err_level = EXIT_FAILURE; - } - else // If libusb is initialized - { - libusb_device_handle *devhandle; - if (argc < 2) // If the program was called without arguments - devhandle = libusb_open_device_with_vid_pid(context, 0x10C4, 0x8BF1); // Open a device and get the device handle - else // Serial number was specified as argument - devhandle = libusb_open_device_with_vid_pid_serial(context, 0x10C4, 0x8BF1, (unsigned char *)argv[1]); // Open the device having the specified serial number, and get the device handle - if (devhandle == NULL) // If the previous operation fails to get a device handle - { - fprintf(stderr, "Error: Could not find device.\n"); - err_level = EXIT_FAILURE; - } - else // If the device is successfully opened and a handle obtained - { - bool kernel_attached = false; - if (libusb_kernel_driver_active(devhandle, 0) != 0) // If a kernel driver is active on the interface - { - libusb_detach_kernel_driver(devhandle, 0); // Detach the kernel driver - kernel_attached = true; // Flag that the kernel driver was attached - } - if (libusb_claim_interface(devhandle, 0) != 0) // Claim the interface. In case of failure - { - fprintf(stderr, "Error: Device is currently unavailable.\n"); - err_level = EXIT_FAILURE; - } - else // If the interface is successfully claimed - { - set_gpio2(devhandle, true); // Set GPIO.2 to a logical high to enable and hold reset, hence stopping the waveform generation - if (!get_gpio6(devhandle)) // If GPIO.6 is set to a logical low - { - set_gpio6(devhandle, true); // Set GPIO.6 to a logical high to disable the TLV3501 comparator - usleep(10000); // Wait 10ms, so that the comparator has time to settle - set_gpio6(devhandle, false); // Set GPIO.6 to a logical low to re-enable the comparator - } - if (err_level == 0) // If all goes well - printf("Waveform generation stopped.\n"); - libusb_release_interface(devhandle, 0); // Release the interface - } - if (kernel_attached) // If a kernel driver was attached to the interface before - libusb_attach_kernel_driver(devhandle, 0); // Reattach the kernel driver - libusb_close(devhandle); // Close the device - } - libusb_exit(context); // Deinitialize libusb - } - return err_level; -} From de5dc4afacdeace5f0f8f44bf2cb5628d4e8bcb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:04:26 +0100 Subject: [PATCH 31/62] Delete gf2-tri.c --- src/gf2-tri.c | 83 --------------------------------------------------- 1 file changed, 83 deletions(-) delete mode 100644 src/gf2-tri.c diff --git a/src/gf2-tri.c b/src/gf2-tri.c deleted file mode 100644 index 7ea3384..0000000 --- a/src/gf2-tri.c +++ /dev/null @@ -1,83 +0,0 @@ -/* GF2 Tri Command - Version 1.1 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see . - - - Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ - - -// Includes -#include -#include -#include -#include -#include -#include "gf2-core.h" -#include "libusb-extra.h" - -int main(int argc, char **argv) -{ - err_level = EXIT_SUCCESS; // Note that this variable is declared externally! - libusb_context *context; - if (libusb_init(&context) != 0) // Initialize libusb. In case of failure - { - fprintf(stderr, "Error: Could not initialize libusb.\n"); - err_level = EXIT_FAILURE; - } - else // If libusb is initialized - { - libusb_device_handle *devhandle; - if (argc < 2) // If the program was called without arguments - devhandle = libusb_open_device_with_vid_pid(context, 0x10C4, 0x8BF1); // Open a device and get the device handle - else // Serial number was specified as argument - devhandle = libusb_open_device_with_vid_pid_serial(context, 0x10C4, 0x8BF1, (unsigned char *)argv[1]); // Open the device having the specified serial number, and get the device handle - if (devhandle == NULL) // If the previous operation fails to get a device handle - { - fprintf(stderr, "Error: Could not find device.\n"); - err_level = EXIT_FAILURE; - } - else // If the device is successfully opened and a handle obtained - { - bool kernel_attached = false; - if (libusb_kernel_driver_active(devhandle, 0) != 0) // If a kernel driver is active on the interface - { - libusb_detach_kernel_driver(devhandle, 0); // Detach the kernel driver - kernel_attached = true; // Flag that the kernel driver was attached - } - if (libusb_claim_interface(devhandle, 0) != 0) // Claim the interface. In case of failure - { - fprintf(stderr, "Error: Device is currently unavailable.\n"); - err_level = EXIT_FAILURE; - } - else // If the interface is successfully claimed - { - configure_spi_mode(devhandle, 0, CPOL1, CPHA0); // Clock polarity regarding channel 0 is active low (CPOL = 1) and data is valid on each falling edge (CPHA = 0) - disable_spi_delays(devhandle, 0); // Disable all SPI delays for channel 0 - select_cs(devhandle, 0); // Enable the chip select corresponding to channel 0, and disable any others - set_triangle_wave(devhandle); // Set the waveform to triangular (by sending a specific sequence of bytes to the AD9834 waveform generator on channel 0) - usleep(100); // Wait 100us, in order to prevent possible errors while disabling the chip select (workaround) - disable_cs(devhandle, 0); // Disable the previously enabled chip select - if (err_level == 0) // If all goes well - printf("Waveform set to triangular.\n"); - libusb_release_interface(devhandle, 0); // Release the interface - } - if (kernel_attached) // If a kernel driver was attached to the interface before - libusb_attach_kernel_driver(devhandle, 0); // Reattach the kernel driver - libusb_close(devhandle); // Close the device - } - libusb_exit(context); // Deinitialize libusb - } - return err_level; -} From 10c6945d379fe8b605306a71f5b4662262d7f72f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:05:47 +0100 Subject: [PATCH 32/62] Add files via upload --- src/cp2130.cpp | 1110 ++++++++++++++++++++++++++++++++++++++++++++ src/cp2130.h | 413 ++++++++++++++++ src/error.cpp | 33 ++ src/error.h | 30 ++ src/gf2device.cpp | 371 +++++++++++++++ src/gf2device.h | 103 ++++ src/libusb-extra.c | 23 +- src/libusb-extra.h | 4 +- src/utils.cpp | 78 ++++ src/utils.h | 35 ++ 10 files changed, 2185 insertions(+), 15 deletions(-) create mode 100644 src/cp2130.cpp create mode 100644 src/cp2130.h create mode 100644 src/error.cpp create mode 100644 src/error.h create mode 100644 src/gf2device.cpp create mode 100644 src/gf2device.h create mode 100644 src/utils.cpp create mode 100644 src/utils.h diff --git a/src/cp2130.cpp b/src/cp2130.cpp new file mode 100644 index 0000000..0e2d1e7 --- /dev/null +++ b/src/cp2130.cpp @@ -0,0 +1,1110 @@ +/* CP2130 class - Version 1.2.3 + Copyright (c) 2021-2022 Samuel Lourenço + + This library is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include "cp2130.h" +extern "C" { +#include "libusb-extra.h" +} + +// Definitions +const unsigned int TR_TIMEOUT = 500; // Transfer timeout in milliseconds + +// Specific to getDescGeneric() and writeDescGeneric() (added in version 1.1.0) +const uint16_t DESC_TBLSIZE = 0x0040; // Descriptor table size, including preamble [64] +const size_t DESC_MAXIDX = DESC_TBLSIZE - 2; // Maximum usable index [62] +const size_t DESC_IDXINCR = DESC_TBLSIZE - 1; // Index increment or step between table preambles [63] + +// Private generic procedure used to get any descriptor (added as a refactor in version 1.1.0) +std::u16string CP2130::getDescGeneric(uint8_t command, int &errcnt, std::string &errstr) +{ + unsigned char controlBufferIn[DESC_TBLSIZE]; + controlTransfer(GET, command, 0x0000, 0x0000, controlBufferIn, DESC_TBLSIZE, errcnt, errstr); + std::u16string descriptor; + size_t length = controlBufferIn[0]; + size_t end = length > DESC_MAXIDX ? DESC_MAXIDX : length; + for (size_t i = 2; i < end; i += 2) { // Process first 30 characters (bytes 2-61 of the array) + if (controlBufferIn[i] != 0 || controlBufferIn[i + 1] != 0) { // Filter out null characters + descriptor += static_cast(controlBufferIn[i + 1] << 8 | controlBufferIn[i]); // UTF-16LE conversion as per the USB 2.0 specification + } + } + if ((command == GET_MANUFACTURING_STRING_1 || command == GET_PRODUCT_STRING_1) && length > DESC_MAXIDX) { + char16_t midchar = controlBufferIn[DESC_MAXIDX]; // Char in the middle (parted between two tables) + controlTransfer(GET, command + 2, 0x0000, 0x0000, controlBufferIn, DESC_TBLSIZE, errcnt, errstr); + midchar = static_cast(controlBufferIn[0] << 8 | midchar); // Reconstruct the char in the middle + if (midchar != 0x0000) { // Filter out the reconstructed char if the same is null + descriptor += midchar; + } + end = length - DESC_IDXINCR; + for (size_t i = 1; i < end; i += 2) { // Process remaining characters, up to 31 (bytes 1-62 of the array) + if (controlBufferIn[i] != 0 || controlBufferIn[i + 1] != 0) { // Again, filter out null characters + descriptor += static_cast(controlBufferIn[i + 1] << 8 | controlBufferIn[i]); // UTF-16LE conversion as per the USB 2.0 specification + } + } + } + return descriptor; +} + +// Private generic procedure used to write any descriptor (added as a refactor in version 1.1.0) +void CP2130::writeDescGeneric(const std::u16string &descriptor, uint8_t command, int &errcnt, std::string &errstr) +{ + size_t length = 2 * descriptor.size() + 2; + unsigned char controlBufferOut[DESC_TBLSIZE] = { // It is important to initialize the array in this manner, here, so that the remaining indexes are filled with zeros! + static_cast(length), // USB string descriptor length + 0x03 // USB string descriptor constant + }; + size_t ntables = command == SET_MANUFACTURING_STRING_1 || command == SET_PRODUCT_STRING_1 ? 2 : 1; // Number of tables to write + for (size_t i = 0; i < ntables; ++i) { + size_t start = i == 0 ? 2 : 0; + size_t offset = DESC_IDXINCR * i; + for (size_t j = start; j < DESC_IDXINCR; ++j) { + if (offset + j < length) { // Rewritten in version 1.1.1 in order to fix a possible bug + controlBufferOut[j] = static_cast(descriptor[(offset + j - 2) / 2] >> ((i + j) % 2 == 0 ? 0 : 8)); + } else { + controlBufferOut[j] = 0x00; + } + } + controlTransfer(SET, command + 2 * i, PROM_WRITE_KEY, 0x0000, controlBufferOut, DESC_TBLSIZE, errcnt, errstr); + } +} + +// "Equal to" operator for EventCounter +bool CP2130::EventCounter::operator ==(const CP2130::EventCounter &other) const +{ + return overflow == other.overflow && mode == other.mode && value == other.value; +} + +// "Not equal to" operator for EventCounter +bool CP2130::EventCounter::operator !=(const CP2130::EventCounter &other) const +{ + return !(operator ==(other)); +} + +// "Equal to" operator for PinConfig +bool CP2130::PinConfig::operator ==(const CP2130::PinConfig &other) const +{ + return gpio0 == other.gpio0 && gpio1 == other.gpio1 && gpio2 == other.gpio2 && gpio3 == other.gpio3 && gpio4 == other.gpio4 && gpio5 == other.gpio5 && gpio6 == other.gpio6 && gpio7 == other.gpio7 && gpio8 == other.gpio8 && gpio9 == other.gpio9 && gpio10 == other.gpio10 && sspndlvl == other.sspndlvl && sspndmode == other.sspndmode && wkupmask == other.wkupmask && wkupmatch == other.wkupmatch && divider == other.divider; +} + +// "Not equal to" operator for PinConfig +bool CP2130::PinConfig::operator !=(const CP2130::PinConfig &other) const +{ + return !(operator ==(other)); +} + +// "Equal to" operator for PROMConfig +bool CP2130::PROMConfig::operator ==(const CP2130::PROMConfig &other) const +{ + bool equal = true; + for (size_t i = 0; i < PROM_BLOCKS; ++i) { + for (size_t j = 0; j < PROM_BLOCK_SIZE; ++j) { + if (blocks[i][j] != other.blocks[i][j]) { + equal = false; + break; + } + } + if (!equal) { + break; + } + } + return equal; +} + +// "Not equal to" operator for PROMConfig +bool CP2130::PROMConfig::operator !=(const CP2130::PROMConfig &other) const +{ + return !(operator ==(other)); +} + +// Subscript operator for accessing PROMConfig as a single 512-byte block +uint8_t &CP2130::PROMConfig::operator [](size_t index) +{ + return blocks[index / PROM_BLOCK_SIZE][index % PROM_BLOCK_SIZE]; +} + +// Const version of the previous subscript operator +const uint8_t &CP2130::PROMConfig::operator [](size_t index) const // For correct error reporting and easy debugging, this operator returns a const reference instead of a value +{ + return blocks[index / PROM_BLOCK_SIZE][index % PROM_BLOCK_SIZE]; +} + +// "Equal to" operator for SiliconVersion +bool CP2130::SiliconVersion::operator ==(const CP2130::SiliconVersion &other) const +{ + return maj == other.maj && min == other.min; +} + +// "Not equal to" operator for SiliconVersion +bool CP2130::SiliconVersion::operator !=(const CP2130::SiliconVersion &other) const +{ + return !(operator ==(other)); +} + +// "Equal to" operator for SPIDelays +bool CP2130::SPIDelays::operator ==(const CP2130::SPIDelays &other) const +{ + return cstglen == other.cstglen && prdasten == other.prdasten && pstasten == other.pstasten && itbyten == other.itbyten && prdastdly == other.prdastdly && pstastdly == other.pstastdly && itbytdly == other.itbytdly; +} + +// "Not equal to" operator for SPIDelays +bool CP2130::SPIDelays::operator !=(const CP2130::SPIDelays &other) const +{ + return !(operator ==(other)); +} + +// "Equal to" operator for SPIMode +bool CP2130::SPIMode::operator ==(const CP2130::SPIMode &other) const +{ + return csmode == other.csmode && cfrq == other.cfrq && cpol == other.cpol && cpha == other.cpha; +} + +// "Not equal to" operator for SPIMode +bool CP2130::SPIMode::operator !=(const CP2130::SPIMode &other) const +{ + return !(operator ==(other)); +} + +// "Equal to" operator for USBConfig +bool CP2130::USBConfig::operator ==(const CP2130::USBConfig &other) const +{ + return vid == other.vid && pid == other.pid && majrel == other.majrel && minrel == other.minrel && maxpow == other.maxpow && powmode == other.powmode && trfprio == other.trfprio; +} + +// "Not equal to" operator for USBConfig +bool CP2130::USBConfig::operator !=(const CP2130::USBConfig &other) const +{ + return !(operator ==(other)); +} + +CP2130::CP2130() : + context_(nullptr), + handle_(nullptr), + disconnected_(false), + kernelWasAttached_(false) +{ +} + +CP2130::~CP2130() +{ + close(); // The destructor is used to close the device, and this is essential so the device can be freed when the parent object is destroyed +} + +// Diagnostic function used to verify if the device has been disconnected +bool CP2130::disconnected() const +{ + return disconnected_; // Returns true if the device has been disconnected, or false otherwise +} + +// Checks if the device is open +bool CP2130::isOpen() const +{ + return handle_ != nullptr; // Returns true if the device is open, or false otherwise +} + +// Safe bulk transfer +void CP2130::bulkTransfer(uint8_t endpointAddr, unsigned char *data, int length, int *transferred, int &errcnt, std::string &errstr) +{ + if (!isOpen()) { + ++errcnt; + errstr += "In bulkTransfer(): device is not open.\n"; // Program logic error + } else { + int result = libusb_bulk_transfer(handle_, endpointAddr, data, length, transferred, TR_TIMEOUT); + if (result != 0 || (transferred != nullptr && *transferred != length)) { // The number of transferred bytes is also verified, as long as a valid (non-null) pointer is passed via "transferred" + ++errcnt; + std::ostringstream stream; + if (endpointAddr < 0x80) { + stream << "Failed bulk OUT transfer to endpoint " + << (0x0f & endpointAddr) + << " (address 0x" + << std::hex << std::setfill ('0') << std::setw(2) << static_cast(endpointAddr) + << ")." << std::endl; + } else { + stream << "Failed bulk IN transfer from endpoint " + << (0x0f & endpointAddr) + << " (address 0x" + << std::hex << std::setfill ('0') << std::setw(2) << static_cast(endpointAddr) + << ")." << std::endl; + } + errstr += stream.str(); + if (result == LIBUSB_ERROR_NO_DEVICE || result == LIBUSB_ERROR_IO) { // Note that libusb_bulk_transfer() may return "LIBUSB_ERROR_IO" [-1] on device disconnect + disconnected_ = true; // This reports that the device has been disconnected + } + } + } +} + +// Closes the device safely, if open +void CP2130::close() +{ + if (isOpen()) { // This condition avoids a segmentation fault if the calling algorithm tries, for some reason, to close the same device twice (e.g., if the device is already closed when the destructor is called) + libusb_release_interface(handle_, 0); // Release the interface + if (kernelWasAttached_) { // If a kernel driver was attached to the interface before + libusb_attach_kernel_driver(handle_, 0); // Reattach the kernel driver + } + libusb_close(handle_); // Close the device + libusb_exit(context_); // Deinitialize libusb + handle_ = nullptr; // Required to mark the device as closed + } +} + +// Configures the pin mode and value for a given GPIO pin +// Note that this function can override the GPIO pin modes programmed in the OTP ROM configuration +void CP2130::configureGPIO(uint8_t pin, uint8_t mode, bool value, int &errcnt, std::string &errstr) +{ + if (pin > 10) { + ++errcnt; + errstr += "In configureGPIO(): Pin number must be between 0 and 10.\n"; // Program logic error + } else { + unsigned char controlBufferOut[SET_GPIO_MODE_AND_LEVEL_WLEN] = { + pin, // Selected GPIO pin + mode, // Pin mode (see the values applicable to PinConfig/getPinConfig()/writePinConfig()) + value // Output value (when applicable) + }; + controlTransfer(SET, SET_GPIO_MODE_AND_LEVEL, 0x0000, 0x0000, controlBufferOut, SET_GPIO_MODE_AND_LEVEL_WLEN, errcnt, errstr); + } +} + +// Configures delays for a given SPI channel +void CP2130::configureSPIDelays(uint8_t channel, const SPIDelays &delays, int &errcnt, std::string &errstr) +{ + if (channel > 10) { + ++errcnt; + errstr += "In configureSPIDelays(): SPI channel value must be between 0 and 10.\n"; // Program logic error + } else { + unsigned char controlBufferOut[SET_SPI_DELAY_WLEN] = { + channel, // Selected channel + static_cast(delays.cstglen << 3 | delays.prdasten << 2 | delays.pstasten << 1 | (delays.itbyten)), // SPI enable mask (chip select toggle, pre-deassert, post-assert and inter-byte delay enable bits) + static_cast(delays.itbytdly >> 8), static_cast(delays.itbytdly), // Inter-byte delay + static_cast(delays.pstastdly >> 8), static_cast(delays.pstastdly), // Post-assert delay + static_cast(delays.prdastdly >> 8), static_cast(delays.prdastdly) // Pre-deassert delay + }; + controlTransfer(SET, SET_SPI_DELAY, 0x0000, 0x0000, controlBufferOut, SET_SPI_DELAY_WLEN, errcnt, errstr); + } +} + +// Configures the given SPI channel in respect to its chip select mode, clock frequency, polarity and phase +void CP2130::configureSPIMode(uint8_t channel, const SPIMode &mode, int &errcnt, std::string &errstr) +{ + if (channel > 10) { + ++errcnt; + errstr += "In configureSPIMode(): SPI channel value must be between 0 and 10.\n"; // Program logic error + } else { + unsigned char controlBufferOut[SET_SPI_WORD_WLEN] = { + channel, // Selected channel + static_cast(mode.cpha << 5 | mode.cpol << 4 | mode.csmode << 3 | (0x07 & mode.cfrq)) // Control word (specified chip select mode, clock frequency, polarity and phase) + }; + controlTransfer(SET, SET_SPI_WORD, 0x0000, 0x0000, controlBufferOut, SET_SPI_WORD_WLEN, errcnt, errstr); + } +} + +// Safe control transfer +void CP2130::controlTransfer(uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, unsigned char *data, uint16_t wLength, int &errcnt, std::string &errstr) +{ + if (!isOpen()) { + ++errcnt; + errstr += "In controlTransfer(): device is not open.\n"; // Program logic error + } else { + int result = libusb_control_transfer(handle_, bmRequestType, bRequest, wValue, wIndex, data, wLength, TR_TIMEOUT); + if (result != wLength) { + ++errcnt; + std::ostringstream stream; + stream << "Failed control transfer (0x" + << std::hex << std::setfill ('0') << std::setw(2) << static_cast(bmRequestType) + << ", 0x" + << std::setw(2) << static_cast(bRequest) + << ")." << std::endl; + errstr += stream.str(); + if (result == LIBUSB_ERROR_NO_DEVICE || result == LIBUSB_ERROR_IO || result == LIBUSB_ERROR_PIPE) { // Note that libusb_control_transfer() may return "LIBUSB_ERROR_IO" [-1] or "LIBUSB_ERROR_PIPE" [-9] on device disconnect + disconnected_ = true; // This reports that the device has been disconnected + } + } + } +} + +// Disables the chip select of the target channel +void CP2130::disableCS(uint8_t channel, int &errcnt, std::string &errstr) +{ + if (channel > 10) { + ++errcnt; + errstr += "In disableCS(): SPI channel value must be between 0 and 10.\n"; // Program logic error + } else { + unsigned char controlBufferOut[SET_GPIO_CHIP_SELECT_WLEN] = { + channel, // Selected channel + 0x00 // Corresponding chip select disabled + }; + controlTransfer(SET, SET_GPIO_CHIP_SELECT, 0x0000, 0x0000, controlBufferOut, SET_GPIO_CHIP_SELECT_WLEN, errcnt, errstr); + } +} + +// Disables all SPI delays for a given channel +void CP2130::disableSPIDelays(uint8_t channel, int &errcnt, std::string &errstr) +{ + if (channel > 10) { + ++errcnt; + errstr += "In disableSPIDelays(): SPI channel value must be between 0 and 10.\n"; // Program logic error + } else { + unsigned char controlBufferOut[SET_SPI_DELAY_WLEN] = { + channel, // Selected channel + 0x00, // All SPI delays disabled, no CS toggle + 0x00, 0x00, // Inter-byte, + 0x00, 0x00, // post-assert and + 0x00, 0x00 // pre-deassert delays all set to 0us + }; + controlTransfer(SET, SET_SPI_DELAY, 0x0000, 0x0000, controlBufferOut, SET_SPI_DELAY_WLEN, errcnt, errstr); + } +} + +// Enables the chip select of the target channel +void CP2130::enableCS(uint8_t channel, int &errcnt, std::string &errstr) +{ + if (channel > 10) { + ++errcnt; + errstr += "In enableCS(): SPI channel value must be between 0 and 10.\n"; // Program logic error + } else { + unsigned char controlBufferOut[SET_GPIO_CHIP_SELECT_WLEN] = { + channel, // Selected channel + 0x01 // Corresponding chip select enabled + }; + controlTransfer(SET, SET_GPIO_CHIP_SELECT, 0x0000, 0x0000, controlBufferOut, SET_GPIO_CHIP_SELECT_WLEN, errcnt, errstr); + } +} + +// Returns the current clock divider value +uint8_t CP2130::getClockDivider(int &errcnt, std::string &errstr) +{ + unsigned char controlBufferIn[GET_CLOCK_DIVIDER_WLEN]; + controlTransfer(GET, GET_CLOCK_DIVIDER, 0x0000, 0x0000, controlBufferIn, GET_CLOCK_DIVIDER_WLEN, errcnt, errstr); + return controlBufferIn[0]; +} + +// Returns the chip select status for a given channel +bool CP2130::getCS(uint8_t channel, int &errcnt, std::string &errstr) +{ + bool cs; + if (channel > 10) { + ++errcnt; + errstr += "In getCS(): SPI channel value must be between 0 and 10.\n"; // Program logic error + cs = false; + } else { + unsigned char controlBufferIn[GET_GPIO_CHIP_SELECT_WLEN]; + controlTransfer(GET, GET_GPIO_CHIP_SELECT, 0x0000, 0x0000, controlBufferIn, GET_GPIO_CHIP_SELECT_WLEN, errcnt, errstr); + cs = (0x0001 << channel & (controlBufferIn[0] << 8 | controlBufferIn[1])) != 0x0000; + } + return cs; +} + +// Returns the address of the endpoint assuming the IN direction +uint8_t CP2130::getEndpointInAddr(int &errcnt, std::string &errstr) +{ + return getTransferPriority(errcnt, errstr) == PRIOWRITE ? 0x82 : 0x81; +} + +// Returns the address of the endpoint assuming the OUT direction +uint8_t CP2130::getEndpointOutAddr(int &errcnt, std::string &errstr) +{ + return getTransferPriority(errcnt, errstr) == PRIOWRITE ? 0x01 : 0x02; +} + +// Gets the event counter, including mode and value +CP2130::EventCounter CP2130::getEventCounter(int &errcnt, std::string &errstr) +{ + unsigned char controlBufferIn[GET_EVENT_COUNTER_WLEN]; + controlTransfer(GET, GET_EVENT_COUNTER, 0x0000, 0x0000, controlBufferIn, GET_EVENT_COUNTER_WLEN, errcnt, errstr); + CP2130::EventCounter evtcntr; + evtcntr.overflow = (0x80 & controlBufferIn[0]) != 0x00; // Event counter overflow bit corresponds to bit 7 of byte 0 + evtcntr.mode = static_cast(0x07 & controlBufferIn[0]); // GPIO.4/EVTCNTR pin mode corresponds to bits 2:0 of byte 0 + evtcntr.value = static_cast(controlBufferIn[1] << 8 | controlBufferIn[2]); // Event count value corresponds to bytes 1 and 2 (big-endian conversion) + return evtcntr; +} + +// Gets the full FIFO threshold +uint8_t CP2130::getFIFOThreshold(int &errcnt, std::string &errstr) +{ + unsigned char controlBufferIn[GET_FULL_THRESHOLD_WLEN]; + controlTransfer(GET, GET_FULL_THRESHOLD, 0x0000, 0x0000, controlBufferIn, GET_FULL_THRESHOLD_WLEN, errcnt, errstr); + return controlBufferIn[0]; +} + +// Returns the current value of the GPIO.0 pin on the CP2130 +bool CP2130::getGPIO0(int &errcnt, std::string &errstr) +{ + return (BMGPIO0 & getGPIOs(errcnt, errstr)) != 0x0000; +} + +// Returns the current value of the GPIO.1 pin on the CP2130 +bool CP2130::getGPIO1(int &errcnt, std::string &errstr) +{ + return (BMGPIO1 & getGPIOs(errcnt, errstr)) != 0x0000; +} + +// Returns the current value of the GPIO.2 pin on the CP2130 +bool CP2130::getGPIO2(int &errcnt, std::string &errstr) +{ + return (BMGPIO2 & getGPIOs(errcnt, errstr)) != 0x0000; +} + +// Returns the current value of the GPIO.3 pin on the CP2130 +bool CP2130::getGPIO3(int &errcnt, std::string &errstr) +{ + return (BMGPIO3 & getGPIOs(errcnt, errstr)) != 0x0000; +} + +// Returns the current value of the GPIO.4 pin on the CP2130 +bool CP2130::getGPIO4(int &errcnt, std::string &errstr) +{ + return (BMGPIO4 & getGPIOs(errcnt, errstr)) != 0x0000; +} + +// Returns the current value of the GPIO.5 pin on the CP2130 +bool CP2130::getGPIO5(int &errcnt, std::string &errstr) +{ + return (BMGPIO5 & getGPIOs(errcnt, errstr)) != 0x0000; +} + +// Returns the current value of the GPIO.6 pin on the CP2130 +bool CP2130::getGPIO6(int &errcnt, std::string &errstr) +{ + return (BMGPIO6 & getGPIOs(errcnt, errstr)) != 0x0000; +} + +// Returns the current value of the GPIO.7 pin on the CP2130 +bool CP2130::getGPIO7(int &errcnt, std::string &errstr) +{ + return (BMGPIO7 & getGPIOs(errcnt, errstr)) != 0x0000; +} + +// Returns the current value of the GPIO.8 pin on the CP2130 +bool CP2130::getGPIO8(int &errcnt, std::string &errstr) +{ + return (BMGPIO8 & getGPIOs(errcnt, errstr)) != 0x0000; +} + +// Returns the current value of the GPIO.9 pin on the CP2130 +bool CP2130::getGPIO9(int &errcnt, std::string &errstr) +{ + return (BMGPIO9 & getGPIOs(errcnt, errstr)) != 0x0000; +} + +// Returns the current value of the GPIO.10 pin on the CP2130 +bool CP2130::getGPIO10(int &errcnt, std::string &errstr) +{ + return (BMGPIO10 & getGPIOs(errcnt, errstr)) != 0x0000; +} + +// Returns the value of all GPIO pins on the CP2130, in bitmap format +uint16_t CP2130::getGPIOs(int &errcnt, std::string &errstr) +{ + unsigned char controlBufferIn[GET_GPIO_VALUES_WLEN]; + controlTransfer(GET, GET_GPIO_VALUES, 0x0000, 0x0000, controlBufferIn, GET_GPIO_VALUES_WLEN, errcnt, errstr); + return static_cast(BMGPIOS & (controlBufferIn[0] << 8 | controlBufferIn[1])); // Returns the value of every GPIO pin in bitmap format (big-endian conversion) +} + +// Returns the lock word from the CP2130 OTP ROM +uint16_t CP2130::getLockWord(int &errcnt, std::string &errstr) +{ + unsigned char controlBufferIn[GET_LOCK_BYTE_WLEN]; + controlTransfer(GET, GET_LOCK_BYTE, 0x0000, 0x0000, controlBufferIn, GET_LOCK_BYTE_WLEN, errcnt, errstr); + return static_cast(controlBufferIn[1] << 8 | controlBufferIn[0]); // Returns both lock bytes as a word (little-endian conversion) +} + +// Gets the manufacturer descriptor from the CP2130 OTP ROM +std::u16string CP2130::getManufacturerDesc(int &errcnt, std::string &errstr) +{ + return getDescGeneric(GET_MANUFACTURING_STRING_1, errcnt, errstr); +} + +// Gets the pin configuration from the CP2130 OTP ROM +CP2130::PinConfig CP2130::getPinConfig(int &errcnt, std::string &errstr) +{ + unsigned char controlBufferIn[GET_PIN_CONFIG_WLEN]; + controlTransfer(GET, GET_PIN_CONFIG, 0x0000, 0x0000, controlBufferIn, GET_PIN_CONFIG_WLEN, errcnt, errstr); + PinConfig config; + config.gpio0 = controlBufferIn[0]; // GPIO.0 pin config corresponds to byte 0 + config.gpio1 = controlBufferIn[1]; // GPIO.1 pin config corresponds to byte 1 + config.gpio2 = controlBufferIn[2]; // GPIO.2 pin config corresponds to byte 2 + config.gpio3 = controlBufferIn[3]; // GPIO.3 pin config corresponds to byte 3 + config.gpio4 = controlBufferIn[4]; // GPIO.4 pin config corresponds to byte 4 + config.gpio5 = controlBufferIn[5]; // GPIO.5 pin config corresponds to byte 5 + config.gpio6 = controlBufferIn[6]; // GPIO.6 pin config corresponds to byte 6 + config.gpio7 = controlBufferIn[7]; // GPIO.7 pin config corresponds to byte 7 + config.gpio8 = controlBufferIn[8]; // GPIO.8 pin config corresponds to byte 8 + config.gpio9 = controlBufferIn[9]; // GPIO.9 pin config corresponds to byte 9 + config.gpio10 = controlBufferIn[10]; // GPIO.10 pin config corresponds to byte 10 + config.sspndlvl = static_cast(controlBufferIn[11] << 8 | controlBufferIn[12]); // Suspend pin level bitmap corresponds to bytes 11 and 12 (big-endian conversion) + config.sspndmode = static_cast(controlBufferIn[13] << 8 | controlBufferIn[14]); // Suspend pin mode bitmap corresponds to bytes 13 and 14 (big-endian conversion) + config.wkupmask = static_cast(controlBufferIn[15] << 8 | controlBufferIn[16]); // Wakeup pin mask bitmap corresponds to bytes 15 and 16 (big-endian conversion) + config.wkupmatch = static_cast(controlBufferIn[17] << 8 | controlBufferIn[18]); // Wakeup pin match bitmap corresponds to bytes 17 and 18 (big-endian conversion) + config.divider = controlBufferIn[19]; // Clock divider corresponds to byte 19 + return config; +} + +// Gets the product descriptor from the CP2130 OTP ROM +std::u16string CP2130::getProductDesc(int &errcnt, std::string &errstr) +{ + return getDescGeneric(GET_PRODUCT_STRING_1, errcnt, errstr); +} + +// Gets the entire CP2130 OTP ROM content as a structure of eight 64-byte blocks +CP2130::PROMConfig CP2130::getPROMConfig(int &errcnt, std::string &errstr) +{ + PROMConfig config; + for (size_t i = 0; i < PROM_BLOCKS; ++i) { + unsigned char controlBufferIn[GET_PROM_CONFIG_WLEN]; + controlTransfer(GET, GET_PROM_CONFIG, 0x0000, static_cast(i), controlBufferIn, GET_PROM_CONFIG_WLEN, errcnt, errstr); + for (size_t j = 0; j < PROM_BLOCK_SIZE; ++j) { + config.blocks[i][j] = controlBufferIn[j]; + } + } + return config; +} + +// Gets the serial descriptor from the CP2130 OTP ROM +std::u16string CP2130::getSerialDesc(int &errcnt, std::string &errstr) +{ + return getDescGeneric(GET_SERIAL_STRING, errcnt, errstr); +} + +// Returns the CP2130 silicon, read-only version +CP2130::SiliconVersion CP2130::getSiliconVersion(int &errcnt, std::string &errstr) +{ + unsigned char controlBufferIn[GET_READONLY_VERSION_WLEN]; + controlTransfer(GET, GET_READONLY_VERSION, 0x0000, 0x0000, controlBufferIn, GET_READONLY_VERSION_WLEN, errcnt, errstr); + SiliconVersion version; + version.maj = controlBufferIn[0]; // Major read-only version corresponds to byte 0 + version.min = controlBufferIn[1]; // Minor read-only version corresponds to byte 1 + return version; +} + +// Returns the SPI delays for a given channel +CP2130::SPIDelays CP2130::getSPIDelays(uint8_t channel, int &errcnt, std::string &errstr) +{ + SPIDelays delays; + if (channel > 10) { + ++errcnt; + errstr += "In getSPIDelays(): SPI channel value must be between 0 and 10.\n"; // Program logic error + delays = {false, false, false, false, 0x0000, 0x0000, 0x0000}; + } else { + unsigned char controlBufferIn[GET_SPI_DELAY_WLEN]; + controlTransfer(GET, GET_SPI_DELAY, 0x0000, 0x0000, controlBufferIn, GET_SPI_DELAY_WLEN, errcnt, errstr); + delays.cstglen = (0x08 & controlBufferIn[1]) != 0x00; // CS toggle enable corresponds to bit 3 of byte 1 + delays.prdasten = (0x04 & controlBufferIn[1]) != 0x00; // Pre-deassert delay enable corresponds to bit 2 of byte 1 + delays.pstasten = (0x02 & controlBufferIn[1]) != 0x00; // Post-assert delay enable to bit 1 of byte 1 + delays.itbyten = (0x01 &controlBufferIn[1]) != 0x00; // Inter-byte delay enable corresponds to bit 0 of byte 1 + delays.itbytdly = static_cast(controlBufferIn[2] << 8 | controlBufferIn[3]); // Inter-byte delay corresponds to bytes 2 and 3 (big-endian conversion) + delays.pstastdly = static_cast(controlBufferIn[4] << 8 | controlBufferIn[5]); // Post-assert delay corresponds to bytes 4 and 5 (big-endian conversion) + delays.prdastdly = static_cast(controlBufferIn[6] << 8 | controlBufferIn[7]); // Pre-deassert delay corresponds to bytes 6 and 7 (big-endian conversion) + } + return delays; +} + +// Returns the SPI mode for a given channel +CP2130::SPIMode CP2130::getSPIMode(uint8_t channel, int &errcnt, std::string &errstr) +{ + SPIMode mode; + if (channel > 10) { + ++errcnt; + errstr += "In getSPIMode(): SPI channel value must be between 0 and 10.\n"; // Program logic error + mode = {false, 0x00, false, false}; + } else { + unsigned char controlBufferIn[GET_SPI_WORD_WLEN]; + controlTransfer(GET, GET_SPI_WORD, 0x0000, 0x0000, controlBufferIn, GET_SPI_WORD_WLEN, errcnt, errstr); + mode.csmode = (0x08 & controlBufferIn[channel]) != 0x00; // Chip select mode corresponds to bit 3 + mode.cfrq = static_cast(0x07 & controlBufferIn[channel]); // Clock frequency is set in the bits 2:0 + mode.cpha = (0x20 & controlBufferIn[channel]) != 0x00; // Clock phase corresponds to bit 5 + mode.cpol = (0x10 &controlBufferIn[channel]) != 0x00; // Clock polarity corresponds to bit 4 + } + return mode; +} + +// Returns the transfer priority from the CP2130 OTP ROM +uint8_t CP2130::getTransferPriority(int &errcnt, std::string &errstr) +{ + return getUSBConfig(errcnt, errstr).trfprio; // Refactored in version 1.1.0, because the overhead presented by this solution was found to be very slim +} + +// Gets the USB configuration, including VID, PID, major and minor release versions, from the CP2130 OTP ROM +CP2130::USBConfig CP2130::getUSBConfig(int &errcnt, std::string &errstr) +{ + unsigned char controlBufferIn[GET_USB_CONFIG_WLEN]; + controlTransfer(GET, GET_USB_CONFIG, 0x0000, 0x0000, controlBufferIn, GET_USB_CONFIG_WLEN, errcnt, errstr); + USBConfig config; + config.vid = static_cast(controlBufferIn[1] << 8 | controlBufferIn[0]); // VID corresponds to bytes 0 and 1 (little-endian conversion) + config.pid = static_cast(controlBufferIn[3] << 8 | controlBufferIn[2]); // PID corresponds to bytes 2 and 3 (little-endian conversion) + config.majrel = controlBufferIn[6]; // Major release version corresponds to byte 6 + config.minrel = controlBufferIn[7]; // Minor release version corresponds to byte 7 + config.maxpow = controlBufferIn[4]; // Maximum power consumption corresponds to byte 4 + config.powmode = controlBufferIn[5]; // Power mode corresponds to byte 5 + config.trfprio = controlBufferIn[8]; // Transfer priority corresponds to byte 8 + return config; +} + +// Returns true is the OTP ROM of the CP2130 was never written +bool CP2130::isOTPBlank(int &errcnt, std::string &errstr) +{ + return getLockWord(errcnt, errstr) == 0xffff; +} + +// Returns true is the OTP ROM of the CP2130 is locked +bool CP2130::isOTPLocked(int &errcnt, std::string &errstr) +{ + return (LWALL & getLockWord(errcnt, errstr)) == 0x0000; // Note that the reserved bits are ignored +} + +// Returns true if a ReadWithRTR command is currently active +bool CP2130::isRTRActive(int &errcnt, std::string &errstr) +{ + unsigned char controlBufferIn[GET_RTR_STATE_WLEN]; + controlTransfer(GET, GET_RTR_STATE, 0x0000, 0x0000, controlBufferIn, GET_RTR_STATE_WLEN, errcnt, errstr); + return controlBufferIn[0] == 0x01; +} + +// Locks the OTP ROM of the CP2130, preventing further changes +void CP2130::lockOTP(int &errcnt, std::string &errstr) +{ + writeLockWord(0x0000, errcnt, errstr); // Both lock bytes are set to zero +} + +// Opens the device having the given VID, PID and, optionally, the given serial number, and assigns its handle +// Since version 1.1.0, it is not required to specify a serial number +int CP2130::open(uint16_t vid, uint16_t pid, const std::string &serial) +{ + int retval; + if (isOpen()) { // Just in case the calling algorithm tries to open a device that was already sucessfully open, or tries to open different devices concurrently, all while using (or referencing to) the same object + retval = SUCCESS; + } else if (libusb_init(&context_) != 0) { // Initialize libusb. In case of failure + retval = ERROR_INIT; + } else { // If libusb is initialized + if (serial.empty()) { // Note that serial, by omission, is an empty string + handle_ = libusb_open_device_with_vid_pid(context_, vid, pid); // If no serial number is specified, this will open the first device found with matching VID and PID + } else { + char *serialcstr = new char[serial.size() + 1]; // Allocated dynamically since version 1.1.0 + std::strcpy(serialcstr, serial.c_str()); + handle_ = libusb_open_device_with_vid_pid_serial(context_, vid, pid, reinterpret_cast(serialcstr)); + delete[] serialcstr; + } + if (handle_ == nullptr) { // If the previous operation fails to get a device handle + libusb_exit(context_); // Deinitialize libusb + retval = ERROR_NOT_FOUND; + } else { // If the device is successfully opened and a handle obtained + if (libusb_kernel_driver_active(handle_, 0) == 1) { // If a kernel driver is active on the interface + libusb_detach_kernel_driver(handle_, 0); // Detach the kernel driver + kernelWasAttached_ = true; // Flag that the kernel driver was attached + } else { + kernelWasAttached_ = false; // The kernel driver was not attached + } + if (libusb_claim_interface(handle_, 0) != 0) { // Claim the interface. In case of failure + if (kernelWasAttached_) { // If a kernel driver was attached to the interface before + libusb_attach_kernel_driver(handle_, 0); // Reattach the kernel driver + } + libusb_close(handle_); // Close the device + libusb_exit(context_); // Deinitialize libusb + handle_ = nullptr; // Required to mark the device as closed + retval = ERROR_BUSY; + } else { + disconnected_ = false; // Note that this flag is never assumed to be true for a device that was never opened - See constructor for details! + retval = SUCCESS; + } + } + } + return retval; +} + +// Issues a reset to the CP2130 +void CP2130::reset(int &errcnt, std::string &errstr) +{ + controlTransfer(SET, RESET_DEVICE, 0x0000, 0x0000, nullptr, RESET_DEVICE_WLEN, errcnt, errstr); +} + +// Enables the chip select of the target channel, disabling any others +void CP2130::selectCS(uint8_t channel, int &errcnt, std::string &errstr) +{ + if (channel > 10) { + ++errcnt; + errstr += "In selectCS(): SPI channel value must be between 0 and 10.\n"; // Program logic error + } else { + unsigned char controlBufferOut[SET_GPIO_CHIP_SELECT_WLEN] = { + channel, // Selected channel + 0x02 // Only the corresponding chip select is enabled, all the others are disabled + }; + controlTransfer(SET, SET_GPIO_CHIP_SELECT, 0x0000, 0x0000, controlBufferOut, SET_GPIO_CHIP_SELECT_WLEN, errcnt, errstr); + } +} + +// Sets the clock divider value +void CP2130::setClockDivider(uint8_t value, int &errcnt, std::string &errstr) +{ + unsigned char controlBufferOut[SET_CLOCK_DIVIDER_WLEN] = { + value // Intended clock divider value (GPIO.5 clock frequency = 24 MHz / divider) + }; + controlTransfer(SET, SET_CLOCK_DIVIDER, 0x0000, 0x0000, controlBufferOut, SET_CLOCK_DIVIDER_WLEN, errcnt, errstr); +} + +// Sets the event counter +void CP2130::setEventCounter(const EventCounter &evcntr, int &errcnt, std::string &errstr) +{ + unsigned char controlBufferOut[SET_EVENT_COUNTER_WLEN] = { + static_cast(0x07 & evcntr.mode), // Set GPIO.4/EVTCNTR pin mode + static_cast(evcntr.value >> 8), static_cast(evcntr.value) // Set the event count value + }; + controlTransfer(SET, SET_EVENT_COUNTER, 0x0000, 0x0000, controlBufferOut, SET_EVENT_COUNTER_WLEN, errcnt, errstr); +} + +// Sets the full FIFO threshold +void CP2130::setFIFOThreshold(uint8_t threshold, int &errcnt, std::string &errstr) +{ + unsigned char controlBufferOut[SET_FULL_THRESHOLD_WLEN] = { + threshold // Intended FIFO threshold + }; + controlTransfer(SET, SET_FULL_THRESHOLD, 0x0000, 0x0000, controlBufferOut, SET_FULL_THRESHOLD_WLEN, errcnt, errstr); +} + +// Sets the GPIO.0 pin on the CP2130 to a given value +void CP2130::setGPIO0(bool value, int &errcnt, std::string &errstr) +{ + setGPIOs(BMGPIOS * value, BMGPIO0, errcnt, errstr); +} + +// Sets the GPIO.1 pin on the CP2130 to a given value +void CP2130::setGPIO1(bool value, int &errcnt, std::string &errstr) +{ + setGPIOs(BMGPIOS * value, BMGPIO1, errcnt, errstr); +} + +// Sets the GPIO.2 pin on the CP2130 to a given value +void CP2130::setGPIO2(bool value, int &errcnt, std::string &errstr) +{ + setGPIOs(BMGPIOS * value, BMGPIO2, errcnt, errstr); +} + +// Sets the GPIO.3 pin on the CP2130 to a given value +void CP2130::setGPIO3(bool value, int &errcnt, std::string &errstr) +{ + setGPIOs(BMGPIOS * value, BMGPIO3, errcnt, errstr); +} + +// Sets the GPIO.4 pin on the CP2130 to a given value +void CP2130::setGPIO4(bool value, int &errcnt, std::string &errstr) +{ + setGPIOs(BMGPIOS * value, BMGPIO4, errcnt, errstr); +} + +// Sets the GPIO.5 pin on the CP2130 to a given value +void CP2130::setGPIO5(bool value, int &errcnt, std::string &errstr) +{ + setGPIOs(BMGPIOS * value, BMGPIO5, errcnt, errstr); +} + +// Sets the GPIO.6 pin on the CP2130 to a given value +void CP2130::setGPIO6(bool value, int &errcnt, std::string &errstr) +{ + setGPIOs(BMGPIOS * value, BMGPIO6, errcnt, errstr); +} + +// Sets the GPIO.7 pin on the CP2130 to a given value +void CP2130::setGPIO7(bool value, int &errcnt, std::string &errstr) +{ + setGPIOs(BMGPIOS * value, BMGPIO7, errcnt, errstr); +} + +// Sets the GPIO.8 pin on the CP2130 to a given value +void CP2130::setGPIO8(bool value, int &errcnt, std::string &errstr) +{ + setGPIOs(BMGPIOS * value, BMGPIO8, errcnt, errstr); +} + +// Sets the GPIO.9 pin on the CP2130 to a given value +void CP2130::setGPIO9(bool value, int &errcnt, std::string &errstr) +{ + setGPIOs(BMGPIOS * value, BMGPIO9, errcnt, errstr); +} + +// Sets the GPIO.10 pin on the CP2130 to a given value +void CP2130::setGPIO10(bool value, int &errcnt, std::string &errstr) +{ + setGPIOs(BMGPIOS * value, BMGPIO10, errcnt, errstr); +} + +// Sets one or more GPIO pins on the CP2130 to the intended values, according to the values and mask bitmaps +void CP2130::setGPIOs(uint16_t bmValues, uint16_t bmMask, int &errcnt, std::string &errstr) +{ + unsigned char controlBufferOut[SET_GPIO_VALUES_WLEN] = { + static_cast((BMGPIOS & bmValues) >> 8), static_cast(BMGPIOS & bmValues), // GPIO values bitmap + static_cast((BMGPIOS & bmMask) >> 8), static_cast(BMGPIOS & bmMask) // Mask bitmap + }; + controlTransfer(SET, SET_GPIO_VALUES, 0x0000, 0x0000, controlBufferOut, SET_GPIO_VALUES_WLEN, errcnt, errstr); +} + +// Requests and reads the given number of bytes from the SPI bus, and then returns a vector +// This is the prefered method of reading from the bus, if both endpoint addresses are known +std::vector CP2130::spiRead(uint32_t bytesToRead, uint8_t endpointInAddr, uint8_t endpointOutAddr, int &errcnt, std::string &errstr) +{ + unsigned char readCommandBuffer[8] = { + 0x00, 0x00, // Reserved + CP2130::READ, // Read command + 0x00, // Reserved + static_cast(bytesToRead), + static_cast(bytesToRead >> 8), + static_cast(bytesToRead >> 16), + static_cast(bytesToRead >> 24) + }; +#if LIBUSB_API_VERSION >= 0x01000105 + bulkTransfer(endpointOutAddr, readCommandBuffer, static_cast(sizeof(readCommandBuffer)), nullptr, errcnt, errstr); +#else + int bytesWritten; + bulkTransfer(endpointOutAddr, readCommandBuffer, static_cast(sizeof(readCommandBuffer)), &bytesWritten, errcnt, errstr); +#endif + unsigned char *readInputBuffer = new unsigned char[bytesToRead]; // Allocated dynamically since version 1.1.0 + int bytesRead = 0; // Important! + bulkTransfer(endpointInAddr, readInputBuffer, static_cast(bytesToRead), &bytesRead, errcnt, errstr); + std::vector retdata(static_cast(bytesRead)); + for (int i = 0; i < bytesRead; ++i) { + retdata[i] = readInputBuffer[i]; + } + delete[] readInputBuffer; + return retdata; +} + +// This function is a shorthand version of the previous one (both endpoint addresses are automatically deduced, at the cost of decreased speed) +std::vector CP2130::spiRead(uint32_t bytesToRead, int &errcnt, std::string &errstr) +{ + return spiRead(bytesToRead, getEndpointInAddr(errcnt, errstr), getEndpointOutAddr(errcnt, errstr), errcnt, errstr); +} + +// Writes to the SPI bus, using the given vector +// This is the prefered method of writing to the bus, if the endpoint OUT address is known +void CP2130::spiWrite(const std::vector &data, uint8_t endpointOutAddr, int &errcnt, std::string &errstr) +{ + uint32_t bytesToWrite = static_cast(data.size()); + int bufSize = bytesToWrite + 8; + unsigned char *writeCommandBuffer = new unsigned char[bufSize] { // Allocated dynamically since version 1.1.0 + 0x00, 0x00, // Reserved + CP2130::WRITE, // Write command + 0x00, // Reserved + static_cast(bytesToWrite), + static_cast(bytesToWrite >> 8), + static_cast(bytesToWrite >> 16), + static_cast(bytesToWrite >> 24) + }; + for (size_t i = 0; i < bytesToWrite; ++i) { + writeCommandBuffer[i + 8] = data[i]; + } +#if LIBUSB_API_VERSION >= 0x01000105 + bulkTransfer(endpointOutAddr, writeCommandBuffer, bufSize, nullptr, errcnt, errstr); +#else + int bytesWritten; + bulkTransfer(endpointOutAddr, writeCommandBuffer, bufSize, &bytesWritten, errcnt, errstr); +#endif + delete[] writeCommandBuffer; +} + +// This function is a shorthand version of the previous one (the endpoint OUT address is automatically deduced at the cost of decreased speed) +void CP2130::spiWrite(const std::vector &data, int &errcnt, std::string &errstr) +{ + spiWrite(data, getEndpointOutAddr(errcnt, errstr), errcnt, errstr); +} + +// Writes to the SPI bus while reading back, returning a vector of the same size as the one given +// This is the prefered method of writing and reading, if both endpoint addresses are known +std::vector CP2130::spiWriteRead(const std::vector &data, uint8_t endpointInAddr, uint8_t endpointOutAddr, int &errcnt, std::string &errstr) +{ + size_t bytesToWriteRead = data.size(); + size_t bytesProcessed = 0; // Loop control variable implemented in version 1.2.3, to replace "bytesLeft" + std::vector retdata; + while (bytesProcessed < bytesToWriteRead) { + size_t bytesRemaining = bytesToWriteRead - bytesProcessed; // Equivalent to the variable "bytesLeft" found in version 1.2.2, except that it is no longer used for control + uint32_t payload = static_cast(bytesRemaining > 56 ? 56 : bytesRemaining); + int bufSize = payload + 8; + unsigned char *writeReadCommandBuffer = new unsigned char[bufSize] { + 0x00, 0x00, // Reserved + CP2130::WRITEREAD, // WriteRead command + 0x00, // Reserved + static_cast(payload), + static_cast(payload >> 8), + static_cast(payload >> 16), + static_cast(payload >> 24) + }; + for (size_t i = 0; i < payload; ++i) { + writeReadCommandBuffer[i + 8] = data[bytesProcessed + i]; + } +#if LIBUSB_API_VERSION >= 0x01000105 + bulkTransfer(endpointOutAddr, writeReadCommandBuffer, bufSize, nullptr, errcnt, errstr); +#else + int bytesWritten; + bulkTransfer(endpointOutAddr, writeReadCommandBuffer, bufSize, &bytesWritten, errcnt, errstr); +#endif + delete[] writeReadCommandBuffer; + unsigned char *writeReadInputBuffer = new unsigned char[payload]; + int bytesRead = 0; // Important! + bulkTransfer(endpointInAddr, writeReadInputBuffer, payload, &bytesRead, errcnt, errstr); + size_t prevretdataSize = retdata.size(); + retdata.resize(static_cast(prevretdataSize + bytesRead)); // Optimization implemented in version 1.2.2, and fixed in version 1.2.3 + for (int i = 0; i < bytesRead; ++i) { + retdata[prevretdataSize + i] = writeReadInputBuffer[i]; // Note that std::vector::push_back() is no longer used since version 1.2.2, because it is more efficient to resize the vector only once per iteration (see above), so that the values may be simply assigned (fixed in version 1.2.3) + } + delete[] writeReadInputBuffer; + bytesProcessed += payload; // Note that, since version 1.2.3, the loop control variable is added to (it is generaly a bad idea to subtract from a unsigned variable, because it can lead to a overflow that may go unchecked) + } + return retdata; +} + +// This function is a shorthand version of the previous one (both endpoint addresses are automatically deduced, at the cost of decreased speed) +std::vector CP2130::spiWriteRead(const std::vector &data, int &errcnt, std::string &errstr) +{ + return spiWriteRead(data, getEndpointInAddr(errcnt, errstr), getEndpointOutAddr(errcnt, errstr), errcnt, errstr); +} + +// Aborts the current ReadWithRTR command +void CP2130::stopRTR(int &errcnt, std::string &errstr) +{ + unsigned char controlBufferOut[SET_RTR_STOP_WLEN] = { + 0x01 // Abort current ReadWithRTR command + }; + controlTransfer(SET, SET_RTR_STOP, 0x0000, 0x0000, controlBufferOut, SET_RTR_STOP_WLEN, errcnt, errstr); +} + +// This procedure is used to lock fields in the CP2130 OTP ROM - Use with care! +void CP2130::writeLockWord(uint16_t word, int &errcnt, std::string &errstr) +{ + unsigned char controlBufferOut[SET_LOCK_BYTE_WLEN] = { + static_cast(word), static_cast(word >> 8) // Sets both lock bytes to the intended value + }; + controlTransfer(SET, SET_LOCK_BYTE, PROM_WRITE_KEY, 0x0000, controlBufferOut, SET_LOCK_BYTE_WLEN, errcnt, errstr); +} + +// Writes the manufacturer descriptor to the CP2130 OTP ROM +void CP2130::writeManufacturerDesc(const std::u16string &manufacturer, int &errcnt, std::string &errstr) +{ + if (manufacturer.size() > DESCMXL_MANUFACTURER) { + ++errcnt; + errstr += "In writeManufacturerDesc(): manufacturer descriptor string cannot be longer than 62 characters.\n"; // Program logic error + } else { + writeDescGeneric(manufacturer, SET_MANUFACTURING_STRING_1, errcnt, errstr); // Refactored in version 1.1.0 + } +} + +// Writes the pin configuration to the CP2130 OTP ROM +void CP2130::writePinConfig(const PinConfig &config, int &errcnt, std::string &errstr) +{ + unsigned char controlBufferOut[SET_PIN_CONFIG_WLEN] = { + config.gpio0, // GPIO.0 pin config + config.gpio1, // GPIO.1 pin config + config.gpio2, // GPIO.2 pin config + config.gpio3, // GPIO.3 pin config + config.gpio4, // GPIO.4 pin config + config.gpio5, // GPIO.5 pin config + config.gpio6, // GPIO.6 pin config + config.gpio7, // GPIO.7 pin config + config.gpio8, // GPIO.8 pin config + config.gpio9, // GPIO.9 pin config + config.gpio10, // GPIO.10 pin config + static_cast(0x7f & config.sspndlvl >> 8), static_cast(config.sspndlvl), // Suspend pin level bitmap + static_cast(config.sspndmode >> 8), static_cast(config.sspndmode), // Suspend pin mode bitmap + static_cast(0x7f & config.wkupmask >> 8), static_cast(config.wkupmask), // Wakeup pin mask bitmap + static_cast(0x7f & config.wkupmatch >> 8), static_cast(config.wkupmatch), // Wakeup pin match bitmap + config.divider // Clock divider + }; + controlTransfer(SET, SET_PIN_CONFIG, PROM_WRITE_KEY, 0x0000, controlBufferOut, SET_PIN_CONFIG_WLEN, errcnt, errstr); +} + +// Writes the product descriptor to the CP2130 OTP ROM +void CP2130::writeProductDesc(const std::u16string &product, int &errcnt, std::string &errstr) +{ + if (product.size() > DESCMXL_PRODUCT) { + ++errcnt; + errstr += "In writeProductDesc(): product descriptor string cannot be longer than 62 characters.\n"; // Program logic error + } else { + writeDescGeneric(product, SET_PRODUCT_STRING_1, errcnt, errstr); // Refactored in version 1.1.0 + } +} + +// Writes over the entire CP2130 OTP ROM +void CP2130::writePROMConfig(const PROMConfig &config, int &errcnt, std::string &errstr) +{ + for (size_t i = 0; i < PROM_BLOCKS; ++i) { + unsigned char controlBufferOut[SET_PROM_CONFIG_WLEN]; + for (size_t j = 0; j < PROM_BLOCK_SIZE; ++j) { + controlBufferOut[j] = config.blocks[i][j]; + } + controlTransfer(SET, SET_PROM_CONFIG, PROM_WRITE_KEY, static_cast(i), controlBufferOut, SET_PROM_CONFIG_WLEN, errcnt, errstr); + } +} + +// Writes the serial descriptor to the CP2130 OTP ROM +void CP2130::writeSerialDesc(const std::u16string &serial, int &errcnt, std::string &errstr) +{ + if (serial.size() > DESCMXL_SERIAL) { + ++errcnt; + errstr += "In writeSerialDesc(): serial descriptor string cannot be longer than 30 characters.\n"; // Program logic error + } else { + writeDescGeneric(serial, SET_SERIAL_STRING, errcnt, errstr); // Refactored in version 1.1.0 + } +} + +// Writes the USB configuration to the CP2130 OTP ROM +void CP2130::writeUSBConfig(const USBConfig &config, uint8_t mask, int &errcnt, std::string &errstr) +{ + unsigned char controlBufferOut[SET_USB_CONFIG_WLEN] = { + static_cast(config.vid), static_cast(config.vid >> 8), // VID + static_cast(config.pid), static_cast(config.pid >> 8), // PID + config.maxpow, // Maximum consumption current + config.powmode, // Power mode + config.majrel, config.minrel, // Major and minor release versions + config.trfprio, // Transfer priority + mask // Write mask (can be obtained using the return value of getLockWord(), after being bitwise ANDed with "LWUSBCFG" [0x009f] and the resulting value cast to uint8_t) + }; + controlTransfer(SET, SET_USB_CONFIG, PROM_WRITE_KEY, 0x0000, controlBufferOut, SET_USB_CONFIG_WLEN, errcnt, errstr); +} + +// Helper function to list devices +std::list CP2130::listDevices(uint16_t vid, uint16_t pid, int &errcnt, std::string &errstr) +{ + std::list devices; + libusb_context *context; + if (libusb_init(&context) != 0) { // Initialize libusb. In case of failure + ++errcnt; + errstr += "Could not initialize libusb.\n"; + } else { // If libusb is initialized + libusb_device **devs; + ssize_t devlist = libusb_get_device_list(context, &devs); // Get a device list + if (devlist < 0) { // If the previous operation fails to get a device list + ++errcnt; + errstr += "Failed to retrieve a list of devices.\n"; + } else { + for (ssize_t i = 0; i < devlist; ++i) { // Run through all listed devices + libusb_device_descriptor desc; + if (libusb_get_device_descriptor(devs[i], &desc) == 0 && desc.idVendor == vid && desc.idProduct == pid) { // If the device descriptor is retrieved, and both VID and PID correspond to the respective given values + libusb_device_handle *handle; + if (libusb_open(devs[i], &handle) == 0) { // Open the listed device. If successfull + unsigned char str_desc[256]; + libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, str_desc, static_cast(sizeof(str_desc))); // Get the serial number string in ASCII format + devices.push_back(reinterpret_cast(str_desc)); // Add the serial number string to the list + libusb_close(handle); // Close the device + } + } + } + libusb_free_device_list(devs, 1); // Free device list + } + libusb_exit(context); // Deinitialize libusb + } + return devices; +} diff --git a/src/cp2130.h b/src/cp2130.h new file mode 100644 index 0000000..fbc4b6c --- /dev/null +++ b/src/cp2130.h @@ -0,0 +1,413 @@ +/* CP2130 class - Version 1.2.3 + Copyright (c) 2021-2022 Samuel Lourenço + + This library is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +#ifndef CP2130_H +#define CP2130_H + +// Includes +#include +#include +#include +#include +#include + +class CP2130 +{ +private: + libusb_context *context_; + libusb_device_handle *handle_; + bool disconnected_, kernelWasAttached_; + + std::u16string getDescGeneric(uint8_t command, int &errcnt, std::string &errstr); + void writeDescGeneric(const std::u16string &descriptor, uint8_t command, int &errcnt, std::string &errstr); + +public: + // Class definitions + static const uint16_t VID = 0x10c4; // Default USB vendor ID + static const uint16_t PID = 0x87a0; // Default USB product ID + static const int SUCCESS = 0; // Returned by open() if successful + static const int ERROR_INIT = 1; // Returned by open() in case of a libusb initialization failure + static const int ERROR_NOT_FOUND = 2; // Returned by open() if the device was not found + static const int ERROR_BUSY = 3; // Returned by open() if the device is already in use + + // Descriptor specific definitions + static const size_t DESCMXL_MANUFACTURER = 62; // Maximum length of manufacturer descriptor + static const size_t DESCMXL_PRODUCT = 62; // Maximum length of product descriptor + static const size_t DESCMXL_SERIAL = 30; // Maximum length of serial descriptor + + // OTP ROM specific definitions + static const size_t PROM_BLOCKS = 8; // Number of blocks of the OTP ROM + static const size_t PROM_BLOCK_SIZE = 64; // Size of each block + static const size_t PROM_SIZE = PROM_BLOCKS * PROM_BLOCK_SIZE; // Total size of the OTP ROM + static const uint16_t PROM_WRITE_KEY = 0xa5f1; // OTP ROM write key + static const size_t PROMIDX_VID = 0; // 'VID' field index + static const size_t PROMSZE_VID = 2; // 'VID' field size + static const size_t PROMIDX_PID = 2; // 'PID' field index + static const size_t PROMSZE_PID = 2; // 'PID' field size + static const size_t PROMIDX_MAX_POWER = 4; // 'Max Power' field index + static const size_t PROMSZE_MAX_POWER = 1; // 'Max Power' field size + static const size_t PROMIDX_POWER_MODE = 5; // 'Power Mode' field index + static const size_t PROMSZE_POWER_MODE = 1; // 'Power Mode' field size + static const size_t PROMIDX_RELEASE_VERSION = 6; // 'Release Version' field index + static const size_t PROMSZE_RELEASE_VERSION = 2; // 'Release Version' field size + static const size_t PROMIDX_TRANSFER_PRIORITY = 8; // 'Transfer Priority' field index + static const size_t PROMSZE_TRANSFER_PRIORITY = 1; // 'Transfer Priority' field size + static const size_t PROMIDX_MANUFACTURING_STRING_1 = 9; // 'Manufacturing String 1' field index + static const size_t PROMSZE_MANUFACTURING_STRING_1 = 63; // 'Manufacturing String 1' field size + static const size_t PROMIDX_MANUFACTURING_STRING_2 = 72; // 'Manufacturing String 2' field index + static const size_t PROMSZE_MANUFACTURING_STRING_2 = 63; // 'Manufacturing String 2' field size + static const size_t PROMIDX_PRODUCT_STRING_1 = 135; // 'Product String 1' field index + static const size_t PROMSZE_PRODUCT_STRING_1 = 63; // 'Product String 1' field size + static const size_t PROMIDX_PRODUCT_STRING_2 = 198; // 'Product String 2' field index + static const size_t PROMSZE_PRODUCT_STRING_2 = 63; // 'Product String 2' field size + static const size_t PROMIDX_SERIAL_STRING = 261; // 'Serial String' field index + static const size_t PROMSZE_SERIAL_STRING = 62; // 'Serial String' field size + static const size_t PROMIDX_PIN_CONFIG = 324; // 'Pin Config' field index + static const size_t PROMSZE_PIN_CONFIG = 20; // 'Pin Config' field size + static const size_t PROMIDX_CUSTOMIZED_FIELDS = 344; // Customized fields index + static const size_t PROMSZE_CUSTOMIZED_FIELDS = 2; // Customized fields size + static const size_t PROMIDX_LOCK_BYTE = 346; // 'Lock Byte' field index + static const size_t PROMSZE_LOCK_BYTE = 2; // 'Lock Byte' field size + + // The following values are applicable to bulkTransfer() + static const uint8_t READ = 0x00; // Read command + static const uint8_t WRITE = 0x01; // Write command + static const uint8_t WRITEREAD = 0x02; // WriteRead command + static const uint8_t READWITHRTR = 0x04; // ReadWithRTR command + + // The following values are applicable to controlTransfer() + static const uint8_t GET = 0xc0; // Device-to-Host vendor request + static const uint8_t SET = 0x40; // Host-to-Device vendor request + static const uint8_t RESET_DEVICE = 0x10; // Reset_Device command + static const uint16_t RESET_DEVICE_WLEN = 0x0000; // Reset_Device data stage length + static const uint8_t GET_READONLY_VERSION = 0x11; // Get_ReadOnly_Version command + static const uint16_t GET_READONLY_VERSION_WLEN = 0x0002; // Get_ReadOnly_Version data stage length + static const uint8_t GET_GPIO_VALUES = 0x20; // Get_GPIO_Values command + static const uint16_t GET_GPIO_VALUES_WLEN = 0x0002; // Get_GPIO_Values data stage length + static const uint8_t SET_GPIO_VALUES = 0x21; // Set_GPIO_Values command + static const uint16_t SET_GPIO_VALUES_WLEN = 0x0004; // Set_GPIO_Values data stage length + static const uint8_t GET_GPIO_MODE_AND_LEVEL = 0x22; // Get_GPIO_Mode_And_Level command + static const uint16_t GET_GPIO_MODE_AND_LEVEL_WLEN = 0x0004; // Get_GPIO_Mode_And_Level data stage length + static const uint8_t SET_GPIO_MODE_AND_LEVEL = 0x23; // Set_GPIO_Mode_And_Level command + static const uint16_t SET_GPIO_MODE_AND_LEVEL_WLEN = 0x0003; // Set_GPIO_Mode_And_Level data stage length + static const uint8_t GET_GPIO_CHIP_SELECT = 0x24; // Get_GPIO_Chip_Select command + static const uint16_t GET_GPIO_CHIP_SELECT_WLEN = 0x0004; // Get_GPIO_Chip_Select data stage length + static const uint8_t SET_GPIO_CHIP_SELECT = 0x25; // Set_GPIO_Chip_Select command + static const uint16_t SET_GPIO_CHIP_SELECT_WLEN = 0x0002; // Set_GPIO_Chip_Select data stage length + static const uint8_t GET_SPI_WORD = 0x30; // Get_SPI_Word command + static const uint16_t GET_SPI_WORD_WLEN = 0x000b; // Get_SPI_Word data stage length + static const uint8_t SET_SPI_WORD = 0x31; // Set_SPI_Word command + static const uint16_t SET_SPI_WORD_WLEN = 0x0002; // Set_SPI_Word data stage length + static const uint8_t GET_SPI_DELAY = 0x32; // Get_SPI_Delay command + static const uint16_t GET_SPI_DELAY_WLEN = 0x0008; // Get_SPI_Delay data stage length + static const uint8_t SET_SPI_DELAY = 0x33; // Set_SPI_Delay command + static const uint16_t SET_SPI_DELAY_WLEN = 0x0008; // Set_SPI_Delay data stage length + static const uint8_t GET_FULL_THRESHOLD = 0x34; // Get_Full_Threshold command + static const uint16_t GET_FULL_THRESHOLD_WLEN = 0x0001; // Get_Full_Threshold data stage length + static const uint8_t SET_FULL_THRESHOLD = 0x35; // Set_Full_Threshold command + static const uint16_t SET_FULL_THRESHOLD_WLEN = 0x0001; // Set_Full_Threshold data stage length + static const uint8_t GET_RTR_STATE = 0x36; // Get_RTR_State command + static const uint16_t GET_RTR_STATE_WLEN = 0x0001; // Get_RTR_State data stage length + static const uint8_t SET_RTR_STOP = 0x37; // Set_RTR_Stop command + static const uint16_t SET_RTR_STOP_WLEN = 0x0001; // Set_RTR_Stop data stage length + static const uint8_t GET_EVENT_COUNTER = 0x44; // Get_Event_Counter command + static const uint16_t GET_EVENT_COUNTER_WLEN = 0x0003; // Get_Event_Counter data stage length + static const uint8_t SET_EVENT_COUNTER = 0x45; // Set_Event_Counter command + static const uint16_t SET_EVENT_COUNTER_WLEN = 0x0003; // Set_Event_Counter data stage length + static const uint8_t GET_CLOCK_DIVIDER = 0x46; // Get_Clock_Divider command + static const uint16_t GET_CLOCK_DIVIDER_WLEN = 0x0001; // Get_Clock_Divider data stage length + static const uint8_t SET_CLOCK_DIVIDER = 0x47; // Set_Clock_Divider command + static const uint16_t SET_CLOCK_DIVIDER_WLEN = 0x0001; // Set_Clock_Divider data stage length + static const uint8_t GET_USB_CONFIG = 0x60; // Get_USB_Config command + static const uint16_t GET_USB_CONFIG_WLEN = 0x0009; // Get_USB_Config data stage length + static const uint8_t SET_USB_CONFIG = 0x61; // Set_USB_Config command + static const uint16_t SET_USB_CONFIG_WLEN = 0x000a; // Set_USB_Config data stage length + static const uint8_t GET_MANUFACTURING_STRING_1 = 0x62; // Get_Manufacturing_String_1 command + static const uint16_t GET_MANUFACTURING_STRING_1_WLEN = 0x0040; // Get_Manufacturing_String_1 data stage length + static const uint8_t SET_MANUFACTURING_STRING_1 = 0x63; // Set_Manufacturing_String_1 command + static const uint16_t SET_MANUFACTURING_STRING_1_WLEN = 0x0040; // Set_Manufacturing_String_1 data stage length + static const uint8_t GET_MANUFACTURING_STRING_2 = 0x64; // Get_Manufacturing_String_2 command + static const uint16_t GET_MANUFACTURING_STRING_2_WLEN = 0x0040; // Get_Manufacturing_String_2 data stage length + static const uint8_t SET_MANUFACTURING_STRING_2 = 0x65; // Set_Manufacturing_String_2 command + static const uint16_t SET_MANUFACTURING_STRING_2_WLEN = 0x0040; // Set_Manufacturing_String_2 data stage length + static const uint8_t GET_PRODUCT_STRING_1 = 0x66; // Get_Product_String_1 command + static const uint16_t GET_PRODUCT_STRING_1_WLEN = 0x0040; // Get_Product_String_1 data stage length + static const uint8_t SET_PRODUCT_STRING_1 = 0x67; // Set_Product_String_1 command + static const uint16_t SET_PRODUCT_STRING_1_WLEN = 0x0040; // Set_Product_String_1 data stage length + static const uint8_t GET_PRODUCT_STRING_2 = 0x68; // Get_Product_String_2 command + static const uint16_t GET_PRODUCT_STRING_2_WLEN = 0x0040; // Get_Product_String_2 data stage length + static const uint8_t SET_PRODUCT_STRING_2 = 0x69; // Set_Product_String_2 command + static const uint16_t SET_PRODUCT_STRING_2_WLEN = 0x0040; // Set_Product_String_2 data stage length + static const uint8_t GET_SERIAL_STRING = 0x6a; // Get_Serial_String command + static const uint16_t GET_SERIAL_STRING_WLEN = 0x0040; // Get_Serial_String data stage length + static const uint8_t SET_SERIAL_STRING = 0x6b; // Set_Serial_String command + static const uint16_t SET_SERIAL_STRING_WLEN = 0x0040; // Set_Serial_String data stage length + static const uint8_t GET_PIN_CONFIG = 0x6c; // Get_Pin_Config command + static const uint16_t GET_PIN_CONFIG_WLEN = 0x0014; // Get_Pin_Config data stage length + static const uint8_t SET_PIN_CONFIG = 0x6d; // Set_Pin_Config command + static const uint16_t SET_PIN_CONFIG_WLEN = 0x0014; // Set_Pin_Config data stage length + static const uint8_t GET_LOCK_BYTE = 0x6e; // Get_Lock_Byte command + static const uint16_t GET_LOCK_BYTE_WLEN = 0x0002; // Get_Lock_Byte data stage length + static const uint8_t SET_LOCK_BYTE = 0x6f; // Set_Lock_Byte command + static const uint16_t SET_LOCK_BYTE_WLEN = 0x0002; // Set_Lock_Byte data stage length + static const uint8_t GET_PROM_CONFIG = 0x70; // Get_PROM_Config command + static const uint16_t GET_PROM_CONFIG_WLEN = 0x0040; // Get_PROM_Config data stage length + static const uint8_t SET_PROM_CONFIG = 0x71; // Set_PROM_Config command + static const uint16_t SET_PROM_CONFIG_WLEN = 0x0040; // Set_PROM_Config data stage length + + // The following masks are applicable to the value returned by getLockWord() + static const uint16_t LWVID = 0x0001; // Mask for the vendor ID lock bit + static const uint16_t LWPID = 0x0002; // Mask for the product ID lock bit + static const uint16_t LWMAXPOW = 0x0004; // Mask for the max power lock bit + static const uint16_t LWPOWMODE = 0x0008; // Mask for the power mode lock bit + static const uint16_t LWREL = 0x0010; // Mask for the release version lock bit + static const uint16_t LWMANUF = 0x0060; // Mask for the manufacturer descriptor lock bits + static const uint16_t LWTRFPRIO = 0x0080; // Mask for the transfer priority lock bit + static const uint16_t LWUSBCFG = 0x009f; // Mask for the USB config lock bits + static const uint16_t LWPROD = 0x0300; // Mask for the product descriptor lock bits + static const uint16_t LWSER = 0x0400; // Mask for the serial descriptor lock bit + static const uint16_t LWPINCFG = 0x0800; // Mask for the pin config lock bit + static const uint16_t LWALL = 0x0fff; // Mask for all but the reserved lock bits + + // The following values are applicable to SPIMode/configureSPIMode()/getSPIMode() + static const bool CSMODEOD = false; // Boolean corresponding to chip select open-drain mode + static const bool CSMODEPP = true; // Boolean corresponding to chip select push-pull mode + static const uint8_t CFRQ12M = 0x00; // Value corresponding to a clock frequency of 12MHz + static const uint8_t CFRQ6M = 0x01; // Value corresponding to a clock frequency of 6MHz + static const uint8_t CFRQ3M = 0x02; // Value corresponding to a clock frequency of 3MHz + static const uint8_t CFRQ1500K = 0x03; // Value corresponding to a clock frequency of 1.5MHz + static const uint8_t CFRQ750K = 0x04; // Value corresponding to a clock frequency of 750KHz + static const uint8_t CFRQ375K = 0x05; // Value corresponding to a clock frequency of 375KHz + static const uint8_t CFRQ1875= 0x06; // Value corresponding to a clock frequency of 187.5KHz + static const uint8_t CFRQ938 = 0x07; // Value corresponding to a clock frequency of 93.8KHz + static const bool CPOL0 = false; // Boolean corresponding to CPOL = 0 (clock is active high and idles low) + static const bool CPOL1 = true; // Boolean corresponding to CPOL = 1 (clock is active low and idles high) + static const bool CPHA0 = false; // Boolean corresponding to CPHA = 0 (data is valid on the leading edge of the clock) + static const bool CPHA1 = true; // Boolean corresponding to CPHA = 1 (data is valid on the trailing edge of the clock) + + // The following values are applicable to PinConfig/getPinConfig()/writePinConfig() + static const uint8_t PCIN = 0x00; // GPIO as input - Also applicable to configureGPIO() + static const uint8_t PCOUTOD = 0x01; // GPIO as open-drain output - Also applicable to configureGPIO() + static const uint8_t PCOUTPP = 0x02; // GPIO as push-pull output - Also applicable to configureGPIO() + static const uint8_t PCCS = 0x03; // GPIO as chip select + static const uint8_t PCNRTR = 0x04; // GPIO as !RTR input, only applicable to GPIO.3 + static const uint8_t PCRTR = 0x05; // GPIO as RTR input, only applicable to GPIO.3 + static const uint8_t PCEVTCNTRRE = 0x04; // GPIO as EVTCNTR rising edge input, only applicable to GPIO.4 - Also applicable to getEventCounter()/setEventCounter() + static const uint8_t PCEVTCNTRFE = 0x05; // GPIO as EVTCNTR falling edge input, only applicable to GPIO.4 - Also applicable to getEventCounter()/setEventCounter() + static const uint8_t PCEVTCNTRNP = 0x06; // GPIO as EVTCNTR negative pulse input, only applicable to GPIO.4 - Also applicable to getEventCounter()/setEventCounter() + static const uint8_t PCEVTCNTRPP = 0x07; // GPIO as EVTCNTR positive pulse input, only applicable to GPIO.4 - Also applicable to getEventCounter()/setEventCounter() + static const uint8_t PCCLKOUT = 0x04; // GPIO as CLKOUT push-pull output, only applicable to GPIO.5 + static const uint8_t PCSPIACT = 0x04; // GPIO as SPIACT push-pull output, only applicable to GPIO.8 + static const uint8_t PCSSPND = 0x04; // GPIO as SUSPEND push-pull output, only applicable to GPIO.9 + static const uint8_t PCNSSPND = 0x04; // GPIO as !SUSPEND push-pull output, only applicable to GPIO.10 + static const uint16_t BMSCK = 0x0001; // Bitmap for the SCK pin + static const uint16_t BMMISO = 0x0002; // Bitmap for the MISO pin + static const uint16_t BMMOSI = 0x0004; // Bitmap for the MOSI pin + static const uint16_t BMGPIO0 = 0x0008; // Bitmap for the GPIO.0 pin - Also applicable to getGPIOs()/setGPIOs() + static const uint16_t BMGPIO1 = 0x0010; // Bitmap for the GPIO.1 pin - Also applicable to getGPIOs()/setGPIOs() + static const uint16_t BMGPIO2 = 0x0020; // Bitmap for the GPIO.2 pin - Also applicable to getGPIOs()/setGPIOs() + static const uint16_t BMGPIO3 = 0x0040; // Bitmap for the GPIO.3 pin - Also applicable to getGPIOs()/setGPIOs() + static const uint16_t BMGPIO4 = 0x0080; // Bitmap for the GPIO.4 pin - Also applicable to getGPIOs()/setGPIOs() + static const uint16_t BMGPIO5 = 0x0100; // Bitmap for the GPIO.5 pin - Also applicable to getGPIOs()/setGPIOs() + static const uint16_t BMVPP = 0x0200; // Bitmap for the VPP pin + static const uint16_t BMGPIO6 = 0x0400; // Bitmap for the GPIO.6 pin - Also applicable to getGPIOs()/setGPIOs() + static const uint16_t BMGPIO7 = 0x0800; // Bitmap for the GPIO.7 pin - Also applicable to getGPIOs()/setGPIOs() + static const uint16_t BMGPIO8 = 0x1000; // Bitmap for the GPIO.8 pin - Also applicable to getGPIOs()/setGPIOs() + static const uint16_t BMGPIO9 = 0x2000; // Bitmap for the GPIO.9 pin - Also applicable to getGPIOs()/setGPIOs() + static const uint16_t BMGPIO10 = 0x4000; // Bitmap for the GPIO.10 pin - Also applicable to getGPIOs()/setGPIOs() + static const uint16_t BMGPIOS = 0x7df8; // Bitmap for all GPIO pins + static const uint16_t BMENABLE = 0x8000; // Bitmap for suspend mode and level enable, only applicable to PinConfig.sspndmode (suspend pin mode bitmap) + + // The following values are applicable to USBConfig/getUSBConfig()/writeUSBConfig() + static const uint8_t PMBUSREGEN = 0x00; // Value corresponding to USB bus-powered mode with voltage regulator enabled + static const uint8_t PMBUSREGDIS = 0x01; // Value corresponding to USB bus-powered mode with voltage regulator disabled + static const uint8_t PMSELFREGEN = 0x02; // Value corresponding to USB self-powered mode with voltage regulator enabled + static const uint8_t PRIOREAD = 0x00; // Value corresponding to data transfer with high priority read + static const uint8_t PRIOWRITE = 0x01; // Value corresponding to data transfer with high priority write + + struct EventCounter { + bool overflow; // Overflow flag + uint8_t mode; // GPIO.4/EVTCNTR pin mode (see the values applicable to PinConfig/getPinConfig()/writePinConfig()) + uint16_t value; // Count value (big-endian) + + bool operator ==(const EventCounter &other) const; + bool operator !=(const EventCounter &other) const; + }; + + struct PinConfig { + uint8_t gpio0; // GPIO.0 pin config + uint8_t gpio1; // GPIO.1 pin config + uint8_t gpio2; // GPIO.2 pin config + uint8_t gpio3; // GPIO.3 pin config + uint8_t gpio4; // GPIO.4 pin config + uint8_t gpio5; // GPIO.5 pin config + uint8_t gpio6; // GPIO.6 pin config + uint8_t gpio7; // GPIO.7 pin config + uint8_t gpio8; // GPIO.8 pin config + uint8_t gpio9; // GPIO.9 pin config + uint8_t gpio10; // GPIO.10 pin config + uint16_t sspndlvl; // Suspend pin level bitmap (big-endian - see Silicon Labs AN792 for details) + uint16_t sspndmode; // Suspend pin mode bitmap (big-endian - see Silicon Labs AN792 for details) + uint16_t wkupmask; // Wakeup pin mask bitmap (big-endian - see Silicon Labs AN792 for details) + uint16_t wkupmatch; // Wakeup pin match bitmap (big-endian - see Silicon Labs AN792 for details) + uint8_t divider; // GPIO.5/!CS5/CLKOUT OTP ROM clock divider value (see Silicon Labs AN792 for details) + + bool operator ==(const PinConfig &other) const; + bool operator !=(const PinConfig &other) const; + }; + + struct PROMConfig { + uint8_t blocks[PROM_BLOCKS][PROM_BLOCK_SIZE]; // OTP ROM blocks + + bool operator ==(const PROMConfig &other) const; + bool operator !=(const PROMConfig &other) const; + uint8_t &operator [](size_t index); + const uint8_t &operator [](size_t index) const; + }; + + struct SiliconVersion { + uint8_t maj; // Major read-only version + uint8_t min; // Minor read-only version + + bool operator ==(const SiliconVersion &other) const; + bool operator !=(const SiliconVersion &other) const; + }; + + struct SPIDelays { + bool cstglen; // CS toggle enable + bool prdasten; // Pre-deassert delay enable + bool pstasten; // Post-assert delay enable + bool itbyten; // Inter-byte delay enable + uint16_t prdastdly; // Pre-deassert delay (10us units, big-endian) + uint16_t pstastdly; // Post-assert delay (10us units, big-endian) + uint16_t itbytdly; // Inter-byte delay (10us units, big-endian) + + bool operator ==(const SPIDelays &other) const; + bool operator !=(const SPIDelays &other) const; + }; + + struct SPIMode { + bool csmode; // Chip select mode (false for open drain, true for push-pull) + uint8_t cfrq; // Clock frequency + bool cpol; // Clock polarity + bool cpha; // Clock phase + + bool operator ==(const SPIMode &other) const; + bool operator !=(const SPIMode &other) const; + }; + + struct USBConfig { + uint16_t vid; // Vendor ID (little-endian) + uint16_t pid; // Product ID (little-endian) + uint8_t majrel; // Major release version + uint8_t minrel; // Minor release version + uint8_t maxpow; // Maximum consumption current (raw value in 2mA units) + uint8_t powmode; // Power mode + uint8_t trfprio; // Transfer priority + + bool operator ==(const USBConfig &other) const; + bool operator !=(const USBConfig &other) const; + }; + + CP2130(); + ~CP2130(); + + bool disconnected() const; + bool isOpen() const; + + void bulkTransfer(uint8_t endpointAddr, unsigned char *data, int length, int *transferred, int &errcnt, std::string &errstr); + void close(); + void configureGPIO(uint8_t pin, uint8_t mode, bool value, int &errcnt, std::string &errstr); + void configureSPIDelays(uint8_t channel, const SPIDelays &delays, int &errcnt, std::string &errstr); + void configureSPIMode(uint8_t channel, const SPIMode &mode, int &errcnt, std::string &errstr); + void controlTransfer(uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, unsigned char *data, uint16_t wLength, int &errcnt, std::string &errstr); + void disableCS(uint8_t channel, int &errcnt, std::string &errstr); + void disableSPIDelays(uint8_t channel, int &errcnt, std::string &errstr); + void enableCS(uint8_t channel, int &errcnt, std::string &errstr); + uint8_t getClockDivider(int &errcnt, std::string &errstr); + bool getCS(uint8_t channel, int &errcnt, std::string &errstr); + uint8_t getEndpointInAddr(int &errcnt, std::string &errstr); + uint8_t getEndpointOutAddr(int &errcnt, std::string &errstr); + EventCounter getEventCounter(int &errcnt, std::string &errstr); + uint8_t getFIFOThreshold(int &errcnt, std::string &errstr); + bool getGPIO0(int &errcnt, std::string &errstr); + bool getGPIO1(int &errcnt, std::string &errstr); + bool getGPIO2(int &errcnt, std::string &errstr); + bool getGPIO3(int &errcnt, std::string &errstr); + bool getGPIO4(int &errcnt, std::string &errstr); + bool getGPIO5(int &errcnt, std::string &errstr); + bool getGPIO6(int &errcnt, std::string &errstr); + bool getGPIO7(int &errcnt, std::string &errstr); + bool getGPIO8(int &errcnt, std::string &errstr); + bool getGPIO9(int &errcnt, std::string &errstr); + bool getGPIO10(int &errcnt, std::string &errstr); + uint16_t getGPIOs(int &errcnt, std::string &errstr); + uint16_t getLockWord(int &errcnt, std::string &errstr); + std::u16string getManufacturerDesc(int &errcnt, std::string &errstr); + PinConfig getPinConfig(int &errcnt, std::string &errstr); + std::u16string getProductDesc(int &errcnt, std::string &errstr); + PROMConfig getPROMConfig(int &errcnt, std::string &errstr); + std::u16string getSerialDesc(int &errcnt, std::string &errstr); + SiliconVersion getSiliconVersion(int &errcnt, std::string &errstr); + SPIDelays getSPIDelays(uint8_t channel, int &errcnt, std::string &errstr); + SPIMode getSPIMode(uint8_t channel, int &errcnt, std::string &errstr); + uint8_t getTransferPriority(int &errcnt, std::string &errstr); + USBConfig getUSBConfig(int &errcnt, std::string &errstr); + bool isOTPBlank(int &errcnt, std::string &errstr); + bool isOTPLocked(int &errcnt, std::string &errstr); + bool isRTRActive(int &errcnt, std::string &errstr); + void lockOTP(int &errcnt, std::string &errstr); + int open(uint16_t vid, uint16_t pid, const std::string &serial = std::string()); + void reset(int &errcnt, std::string &errstr); + void selectCS(uint8_t channel, int &errcnt, std::string &errstr); + void setClockDivider(uint8_t value, int &errcnt, std::string &errstr); + void setEventCounter(const EventCounter &evcntr, int &errcnt, std::string &errstr); + void setFIFOThreshold(uint8_t threshold, int &errcnt, std::string &errstr); + void setGPIO0(bool value, int &errcnt, std::string &errstr); + void setGPIO1(bool value, int &errcnt, std::string &errstr); + void setGPIO2(bool value, int &errcnt, std::string &errstr); + void setGPIO3(bool value, int &errcnt, std::string &errstr); + void setGPIO4(bool value, int &errcnt, std::string &errstr); + void setGPIO5(bool value, int &errcnt, std::string &errstr); + void setGPIO6(bool value, int &errcnt, std::string &errstr); + void setGPIO7(bool value, int &errcnt, std::string &errstr); + void setGPIO8(bool value, int &errcnt, std::string &errstr); + void setGPIO9(bool value, int &errcnt, std::string &errstr); + void setGPIO10(bool value, int &errcnt, std::string &errstr); + void setGPIOs(uint16_t bmValues, uint16_t bmMask, int &errcnt, std::string &errstr); + std::vector spiRead(uint32_t bytesToRead, uint8_t endpointInAddr, uint8_t endpointOutAddr, int &errcnt, std::string &errstr); + std::vector spiRead(uint32_t bytesToRead, int &errcnt, std::string &errstr); + void spiWrite(const std::vector &data, uint8_t endpointOutAddr, int &errcnt, std::string &errstr); + void spiWrite(const std::vector &data, int &errcnt, std::string &errstr); + std::vector spiWriteRead(const std::vector &data, uint8_t endpointInAddr, uint8_t endpointOutAddr, int &errcnt, std::string &errstr); + std::vector spiWriteRead(const std::vector &data, int &errcnt, std::string &errstr); + void stopRTR(int &errcnt, std::string &errstr); + void writeLockWord(uint16_t word, int &errcnt, std::string &errstr); + void writeManufacturerDesc(const std::u16string &manufacturer, int &errcnt, std::string &errstr); + void writePinConfig(const PinConfig &config, int &errcnt, std::string &errstr); + void writeProductDesc(const std::u16string &product, int &errcnt, std::string &errstr); + void writePROMConfig(const PROMConfig &config, int &errcnt, std::string &errstr); + void writeSerialDesc(const std::u16string &serial, int &errcnt, std::string &errstr); + void writeUSBConfig(const USBConfig &config, uint8_t mask, int &errcnt, std::string &errstr); + + static std::list listDevices(uint16_t vid, uint16_t pid, int &errcnt, std::string &errstr); +}; + +#endif // CP2130_H diff --git a/src/error.cpp b/src/error.cpp new file mode 100644 index 0000000..2043d26 --- /dev/null +++ b/src/error.cpp @@ -0,0 +1,33 @@ +/* Error handling functions - Version 1.0.0 + Copyright (c) 2022 Samuel Lourenço + + This library is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include "error.h" + +// Prints errors in separated lines (each error should be terminated with a newline character) +void printErrors(const std::string &errstr) +{ + size_t lnend, lnstart = 0; + while ((lnend = errstr.find('\n', lnstart)) != std::string::npos) { + std::cerr << "Error: " << errstr.substr(lnstart, lnend - lnstart + 1); // This includes the newline character + lnstart = lnend + 1; + } +} diff --git a/src/error.h b/src/error.h new file mode 100644 index 0000000..540b0ce --- /dev/null +++ b/src/error.h @@ -0,0 +1,30 @@ +/* Error handling functions - Version 1.0.0 + Copyright (c) 2022 Samuel Lourenço + + This library is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +#ifndef ERROR_H +#define ERROR_H + +// Includes +#include + +// Function prototypes +void printErrors(const std::string &errstr); + +#endif // ERROR_H diff --git a/src/gf2device.cpp b/src/gf2device.cpp new file mode 100644 index 0000000..0e6fe93 --- /dev/null +++ b/src/gf2device.cpp @@ -0,0 +1,371 @@ +/* GF2 device class - Version 1.0.0 + Requires CP2130 class version 1.1.0 or later + Copyright (c) 2022 Samuel Lourenço + + This library is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include +#include "gf2device.h" + +// Definitions +const uint8_t EPOUT = 0x01; // Address of endpoint assuming the OUT direction +const uint8_t FREQ0 = 0x40; // Mask for the FREQ0 register +const uint8_t FREQ1 = 0x80; // Mask for the FREQ1 register +const uint8_t PHASE0 = 0xc0; // Mask for the PHASE0 register +const uint8_t PHASE1 = 0xe0; // Mask for the PHASE1 register + +// Amplitude conversion constant +const uint AQUANTUM = 1023; // Quantum related to the 10-bit resolution of the AD5310 DAC + +// Frequency conversion constants +const uint FQUANTUM = 268435456; // Quantum related to the 28-bit frequency resolution of the AD9834 waveform generator +const float MCLK = 80000; // 80MHz clock + +// Phase conversion constant +const uint PQUANTUM = 4096; // Quantum related to the 12-bit phase resolution of the AD9834 waveform generator + +GF2Device::GF2Device() : + cp2130_() +{ +} + +// Diagnostic function used to verify if the device has been disconnected +bool GF2Device::disconnected() const +{ + return cp2130_.disconnected(); +} + +// Checks if the device is open +bool GF2Device::isOpen() const +{ + return cp2130_.isOpen(); +} + +// Sets the frequency, phase and amplitude of the generated signal to zero, and sets its waveform to sinusoidal +void GF2Device::clear(int &errcnt, std::string &errstr) +{ + setWaveGenEnabled(true, errcnt, errstr); // This ensures that the RST signal is low prior to resetting the AD9834 waveform generator, since it requires an high to low transition on its RESET pin for the reset to be sampled and acknowledged + cp2130_.selectCS(0, errcnt, errstr); // Enable the chip select corresponding to channel 0, and disable any others + std::vector setupAD9834 = { + 0x22, 0x00 // B28 = 1, PIN/SW = 1, MODE = 0 (sinusoidal waveform) + }; + cp2130_.spiWrite(setupAD9834, EPOUT, errcnt, errstr); // Configure the AD9834 (channel 0) so that it acknowledges reset by pin + usleep(100); // Wait 100us, in order to prevent possible errors, since the following operation sets GPIO.2 high (workaround) + setWaveGenEnabled(false, errcnt, errstr); // Disable and reset the AD9834 + std::vector clearAD9834 = { + FREQ0, 0x00, FREQ0, 0x00, // FREQ0 register set to zero + FREQ1, 0x00, FREQ1, 0x00, // FREQ1 register set to zero + PHASE0, 0x00, // PHASE0 register set to zero + PHASE1, 0x00 // PHASE1 register set to zero + }; + cp2130_.spiWrite(clearAD9834, EPOUT, errcnt, errstr); // Clear all of the AD9834 frequency and phase registers in order to set both generation parameters to zero + usleep(100); // Wait 100us, in order to prevent possible errors while switching the chip select (workaround) + cp2130_.selectCS(1, errcnt, errstr); // Enable the chip select corresponding to channel 1, and disable the one corresponding to channel 0 (the previously selected channel) + std::vector clearAD5310 = { + 0x00, 0x00 // AD5310 register set to zero + }; + cp2130_.spiWrite(clearAD5310, EPOUT, errcnt, errstr); // Clear the AD5310 register in order to set the amplitude to zero + usleep(100); // Wait 100us, in order to prevent possible errors while disabling the chip select (workaround) + cp2130_.disableCS(1, errcnt, errstr); // Disable the chip select corresponding to channel 1, which is the only one that is active to this point + setDACEnabled(true, errcnt, errstr); // Enable the DAC that is internal to the AD9834 + selectFrequency(FSEL0, errcnt, errstr); // The FREQ0 register defines the frequency of the AD9834 + selectPhase(PSEL0, errcnt, errstr); // The PHASE0 register defines the phase of the AD9834 + setClockEnabled(true, errcnt, errstr); // Enable the synchronous clock + setWaveGenEnabled(true, errcnt, errstr); // Re-enable the AD9834 +} + +// Closes the device safely, if open +void GF2Device::close() +{ + cp2130_.close(); +} + +// Returns the silicon version of the CP2130 bridge +CP2130::SiliconVersion GF2Device::getCP2130SiliconVersion(int &errcnt, std::string &errstr) +{ + return cp2130_.getSiliconVersion(errcnt, errstr); +} + +// Returns the current frequency selection +bool GF2Device::getFrequencySelection(int &errcnt, std::string &errstr) +{ + return cp2130_.getGPIO4(errcnt, errstr); // GPIO.4 corresponds to the FSEL signal (FSELECT pin on the AD9834 waveform generator) +} + +// Returns the hardware revision of the device +std::string GF2Device::getHardwareRevision(int &errcnt, std::string &errstr) +{ + return hardwareRevision(getUSBConfig(errcnt, errstr)); +} + +// Gets the manufacturer descriptor from the device +std::u16string GF2Device::getManufacturerDesc(int &errcnt, std::string &errstr) +{ + return cp2130_.getManufacturerDesc(errcnt, errstr); +} + +// Returns the current phase selection +bool GF2Device::getPhaseSelection(int &errcnt, std::string &errstr) +{ + return cp2130_.getGPIO5(errcnt, errstr); // GPIO.5 corresponds to the PSEL signal (PSELECT pin on the AD9834 waveform generator) +} + +// Gets the product descriptor from the device +std::u16string GF2Device::getProductDesc(int &errcnt, std::string &errstr) +{ + return cp2130_.getProductDesc(errcnt, errstr); +} + +// Gets the serial descriptor from the device +std::u16string GF2Device::getSerialDesc(int &errcnt, std::string &errstr) +{ + return cp2130_.getSerialDesc(errcnt, errstr); +} + +// Gets the USB configuration of the device +CP2130::USBConfig GF2Device::getUSBConfig(int &errcnt, std::string &errstr) +{ + return cp2130_.getUSBConfig(errcnt, errstr); +} + +// Checks if the synchronous clock is enabled +bool GF2Device::isClockEnabled(int &errcnt, std::string &errstr) +{ + return !cp2130_.getGPIO6(errcnt, errstr); // GPIO.6 corresponds to the !CMPEN signal (SHDN pin on the TLV3501 comparator) +} + +// Checks if the DAC internal to the AD9834 waveform generator is enabled +bool GF2Device::isDACEnabled(int &errcnt, std::string &errstr) +{ + return !cp2130_.getGPIO3(errcnt, errstr); // GPIO.3 corresponds to the SLP signal (SLEEP pin on the AD9834 waveform generator) +} + +// Checks if the AD9834 waveform generator is enabled +bool GF2Device::isWaveGenEnabled(int &errcnt, std::string &errstr) +{ + return !cp2130_.getGPIO2(errcnt, errstr); // GPIO.2 corresponds to the RST signal (RESET pin on the AD9834 waveform generator) +} + +// Opens a device and assigns its handle +int GF2Device::open(const std::string &serial) +{ + return cp2130_.open(VID, PID, serial); +} + +// Issues a reset to the CP2130, which in effect resets the entire device +void GF2Device::reset(int &errcnt, std::string &errstr) +{ + cp2130_.reset(errcnt, errstr); +} + +// Selects the active frequency +void GF2Device::selectFrequency(bool fsel, int &errcnt, std::string &errstr) +{ + cp2130_.setGPIO4(fsel, errcnt, errstr); // GPIO.4 corresponds to the FSEL signal (FSELECT pin on the AD9834 waveform generator) +} + +// Selects the active phase +void GF2Device::selectPhase(bool psel, int &errcnt, std::string &errstr) +{ + cp2130_.setGPIO5(psel, errcnt, errstr); // GPIO.5 corresponds to the PSEL signal (PSELECT pin on the AD9834 waveform generator) +} + +// Sets the amplitude of the generated signal to the given value (in Vpp) +void GF2Device::setAmplitude(float amplitude, int &errcnt, std::string &errstr) +{ + if (amplitude < AMPLITUDE_MIN || amplitude > AMPLITUDE_MAX) { + ++errcnt; + errstr += "In setAmplitude(): Amplitude must be between 0 and 8.\n"; // Program logic error + } else { + cp2130_.selectCS(1, errcnt, errstr); // Enable the chip select corresponding to channel 1, and disable any others + uint16_t amplitudeCode = static_cast(amplitude * AQUANTUM / AMPLITUDE_MAX + 0.5); + std::vector setAmplitude = { + static_cast(0x0f & amplitudeCode >> 6), // Amplitude + static_cast(amplitudeCode << 2) + }; + cp2130_.spiWrite(setAmplitude, EPOUT, errcnt, errstr); // Set the amplitude of the output signal (AD5310 on channel 1)selectPhase + usleep(100); // Wait 100us, in order to prevent possible errors while disabling the chip select (workaround) + cp2130_.disableCS(1, errcnt, errstr); // Disable the previously enabled chip select + } +} + +// Enables or disables the synchronous clock +void GF2Device::setClockEnabled(bool value, int &errcnt, std::string &errstr) +{ + cp2130_.setGPIO6(!value, errcnt, errstr); // GPIO.6 corresponds to the !CMPEN signal (SHDN pin on the TLV3501 comparator) +} + +// Enables or disables the DAC internal to the AD9834 waveform generator +void GF2Device::setDACEnabled(bool value, int &errcnt, std::string &errstr) +{ + cp2130_.setGPIO3(!value, errcnt, errstr); // GPIO.3 corresponds to the SLP signal (SLEEP pin on the AD9834 waveform generator) +} + +// Sets the frequency, selected by the boolean variable "fsel", to the given value (in KHz) +void GF2Device::setFrequency(bool fsel, float frequency, int &errcnt, std::string &errstr) +{ + if (frequency < FREQUENCY_MIN || frequency > FREQUENCY_MAX) { + ++errcnt; + errstr += "In setFrequency(): Frequency must be between 0 and 40000.\n"; // Program logic error + } else { + cp2130_.selectCS(0, errcnt, errstr); // Enable the chip select corresponding to channel 0, and disable any others + uint32_t frequencyCode = static_cast(frequency * FQUANTUM / MCLK + 0.5); + std::vector setFrequency = { + static_cast((fsel ? FREQ1 : FREQ0) | (0x3f & frequencyCode >> 8)), // FREQ0 or FREQ1 register set to the given value, according to the boolean variable "fsel" + static_cast(frequencyCode), + static_cast((fsel ? FREQ1 : FREQ0) | (0x3f & frequencyCode >> 22)), + static_cast(frequencyCode >> 14) + }; + cp2130_.spiWrite(setFrequency, EPOUT, errcnt, errstr); // Set the selected frequency by updating the above registers (AD9834 on channel 0) + usleep(100); // Wait 100us, in order to prevent possible errors while disabling the chip select (workaround) + cp2130_.disableCS(0, errcnt, errstr); // Disable the previously enabled chip select + } +} + +// Sets the phase, selected by the boolean variable "psel", to the given value (in degrees) +void GF2Device::setPhase(bool psel, float phase, int &errcnt, std::string &errstr) +{ + cp2130_.selectCS(0, errcnt, errstr); // Enable the chip select corresponding to channel 0, and disable any others + float phaseMod = std::fmod(phase, 360); // Calculate the remainder of the division between the phase and 360 + uint16_t phaseCode = static_cast((phaseMod + (phaseMod < 0 ? 360 : 0)) * PQUANTUM / 360 + 0.5); + std::vector setPhase = { + static_cast((psel ? PHASE1 : PHASE0) | (0x0f & phaseCode >> 8)), // PHASE0 or PHASE1 register set to the given value, according to the boolean variable "psel" + static_cast(phaseCode) + }; + cp2130_.spiWrite(setPhase, EPOUT, errcnt, errstr); // Set the selected phase by updating the above registers (AD9834 on channel 0) + usleep(100); // Wait 100us, in order to prevent possible errors while disabling the chip select (workaround) + cp2130_.disableCS(0, errcnt, errstr); // Disable the previously enabled chip select +} + +// Sets the waveform of the generated signal to sinusoidal +void GF2Device::setSineWave(int &errcnt, std::string &errstr) +{ + cp2130_.selectCS(0, errcnt, errstr); // Enable the chip select corresponding to channel 0, and disable any others + std::vector setSineWave = { + 0x22, 0x00 // B28 = 1, PIN/SW = 1, MODE = 0 (sinusoidal waveform) + }; + cp2130_.spiWrite(setSineWave, EPOUT, errcnt, errstr); // Set the waveform to sinusoidal (AD9834 on channel 0) + usleep(100); // Wait 100us, in order to prevent possible errors while disabling the chip select (workaround) + cp2130_.disableCS(0, errcnt, errstr); // Disable the previously enabled chip select +} + +// Sets the waveform of the generated signal to triangular +void GF2Device::setTriangleWave(int &errcnt, std::string &errstr) +{ + cp2130_.selectCS(0, errcnt, errstr); // Enable the chip select corresponding to channel 0, and disable any others + std::vector setTriangleWave = { + 0x22, 0x02 // B28 = 1, PIN/SW = 1, MODE = 1 (triangular waveform) + }; + cp2130_.spiWrite(setTriangleWave, EPOUT, errcnt, errstr); // Set the waveform to triangular (AD9834 on channel 0) + usleep(100); // Wait 100us, in order to prevent possible errors while disabling the chip select (workaround) + cp2130_.disableCS(0, errcnt, errstr); // Disable the previously enabled chip select +} + +// Sets up channel 0 for communication with the AD9834 waveform generator +void GF2Device::setupChannel0(int &errcnt, std::string &errstr) +{ + CP2130::SPIMode mode; + mode.csmode = CP2130::CSMODEPP; // Chip select pin mode regarding channel 0 is push-pull + mode.cfrq = CP2130::CFRQ12M; // SPI clock frequency set to 12MHz + mode.cpol = CP2130::CPOL1; // SPI clock polarity is active low (CPOL = 1) + mode.cpha = CP2130::CPHA0; // SPI data is valid on each falling edge (CPHA = 0) + cp2130_.configureSPIMode(0, mode, errcnt, errstr); // Configure SPI mode for channel 0, using the above settings + cp2130_.disableSPIDelays(0, errcnt, errstr); // Disable all SPI delays for channel 0 +} + +// Sets up channel 1 for communication with the AD5310 DAC +void GF2Device::setupChannel1(int &errcnt, std::string &errstr) +{ + CP2130::SPIMode mode; + mode.csmode = CP2130::CSMODEPP; // Chip select pin mode regarding channel 1 is push-pull + mode.cfrq = CP2130::CFRQ12M; // SPI clock frequency set to 12MHz + mode.cpol = CP2130::CPOL0; // SPI clock polarity is active high (CPOL = 0) + mode.cpha = CP2130::CPHA1; // SPI data is valid on each falling edge (CPHA = 1) + cp2130_.configureSPIMode(1, mode, errcnt, errstr); // Configure SPI mode for channel 1, using the above settings + cp2130_.disableSPIDelays(1, errcnt, errstr); // Disable all SPI delays for channel 1 +} + +// Enables or disables the AD9834 waveform generator +void GF2Device::setWaveGenEnabled(bool value, int &errcnt, std::string &errstr) +{ + cp2130_.setGPIO2(!value, errcnt, errstr); // GPIO.2 corresponds to the RST signal (RESET pin on the AD9834 waveform generator) +} + +// Starts (or restarts) the waveform generation +void GF2Device::start(int &errcnt, std::string &errstr) +{ + setWaveGenEnabled(false, errcnt, errstr); // Disable and reset the AD9834 waveform generator (required to enforce a restart if the waveform generator is already running) + setWaveGenEnabled(true, errcnt, errstr); // and then re-enable it order to (re)start the waveform generation +} + +// Stops the waveform generation +void GF2Device::stop(int &errcnt, std::string &errstr) +{ + setWaveGenEnabled(false, errcnt, errstr); + if (isClockEnabled(errcnt, errstr)) { + setClockEnabled(false, errcnt, errstr); // Disable the TLV3501 comparator + usleep(10000); // Wait 10ms, so that the comparator has time to settle + setClockEnabled(true, errcnt, errstr); // Re-enable the comparator + } +} + +// Helper function that returns the expected amplitude from a given amplitude value +// Note that the function is only valid for values between "AMPLITUDE_MIN" [0] and "AMPLITUDE_MAX" [8] +float GF2Device::expectedAmplitude(float amplitude) +{ + return std::round(amplitude * AQUANTUM / AMPLITUDE_MAX) * AMPLITUDE_MAX / AQUANTUM; +} + +// Helper function that returns the expected frequency from a given frequency value +// Note that the function is only valid for values between "FREQUENCY_MIN" [0] and "FREQUENCY_MAX" [40000] +float GF2Device::expectedFrequency(float frequency) +{ + return std::round(frequency * FQUANTUM / MCLK) * MCLK / FQUANTUM; +} + +// Helper function that returns the expected phase from a given phase value +float GF2Device::expectedPhase(float phase) +{ + float phaseMod = std::fmod(phase, 360); // Calculate the remainder of the division between the phase and 360 + return std::round((phaseMod + (phaseMod < 0 ? 360 : 0)) * PQUANTUM / 360) * 360 / PQUANTUM; +} + +// Helper function that returns the hardware revision from a given USB configuration +std::string GF2Device::hardwareRevision(const CP2130::USBConfig &config) +{ + std::string revision; + if (config.majrel > 1 && config.majrel <= 27) { + revision += static_cast(config.majrel + 'A' - 2); // Append major revision letter (a major release number value of 2 corresponds to the letter "A" and so on) + } + if (config.majrel == 1 || config.minrel != 0) { + std::ostringstream stream; + stream << static_cast(config.minrel); + revision += stream.str(); // Append minor revision number + } + return revision; +} + +// Helper function to list devices +std::list GF2Device::listDevices(int &errcnt, std::string &errstr) +{ + return CP2130::listDevices(VID, PID, errcnt, errstr); +} diff --git a/src/gf2device.h b/src/gf2device.h new file mode 100644 index 0000000..8728c41 --- /dev/null +++ b/src/gf2device.h @@ -0,0 +1,103 @@ +/* GF2 device class - Version 1.0.0 + Requires CP2130 class version 1.1.0 or later + Copyright (c) 2022 Samuel Lourenço + + This library is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +#ifndef GF2DEVICE_H +#define GF2DEVICE_H + +// Includes +#include +#include +#include +#include "cp2130.h" + +class GF2Device +{ +private: + CP2130 cp2130_; + +public: + // Class definitions + static const uint16_t VID = 0x10c4; // USB vendor ID + static const uint16_t PID = 0x8bf1; // USB product ID + static const int SUCCESS = CP2130::SUCCESS; // Returned by open() if successful + static const int ERROR_INIT = CP2130::ERROR_INIT; // Returned by open() in case of a libusb initialization failure + static const int ERROR_NOT_FOUND = CP2130::ERROR_NOT_FOUND; // Returned by open() if the device was not found + static const int ERROR_BUSY = CP2130::ERROR_BUSY; // Returned by open() if the device is already in use + + // Limits applicable to setAmplitude() + static constexpr float AMPLITUDE_MIN = 0; // Minimum amplitude + static constexpr float AMPLITUDE_MAX = 8; // Maximum amplitude + + // Frequency selection options applicable to selectFrequency() and setFrequency() + static const bool FSEL0 = false; // Boolean corresponding to frequency 0 selection + static const bool FSEL1 = true; // Boolean corresponding to frequency 1 selection + + // Limits applicable to setFrequency() + static constexpr float FREQUENCY_MIN = 0; // Minimum frequency + static constexpr float FREQUENCY_MAX = 40000; // Maximum frequency + + // Phase selection options applicable to selectPhase() and setPhase() + static const bool PSEL0 = false; // Boolean corresponding to phase 0 selection + static const bool PSEL1 = true; // Boolean corresponding to phase 1 selection + + GF2Device(); + + bool disconnected() const; + bool isOpen() const; + + void clear(int &errcnt, std::string &errstr); + void close(); + CP2130::SiliconVersion getCP2130SiliconVersion(int &errcnt, std::string &errstr); + bool getFrequencySelection(int &errcnt, std::string &errstr); + std::string getHardwareRevision(int &errcnt, std::string &errstr); + std::u16string getManufacturerDesc(int &errcnt, std::string &errstr); + bool getPhaseSelection(int &errcnt, std::string &errstr); + std::u16string getProductDesc(int &errcnt, std::string &errstr); + std::u16string getSerialDesc(int &errcnt, std::string &errstr); + CP2130::USBConfig getUSBConfig(int &errcnt, std::string &errstr); + bool isClockEnabled(int &errcnt, std::string &errstr); + bool isDACEnabled(int &errcnt, std::string &errstr); + bool isWaveGenEnabled(int &errcnt, std::string &errstr); + int open(const std::string &serial = std::string()); + void reset(int &errcnt, std::string &errstr); + void selectFrequency(bool fsel, int &errcnt, std::string &errstr); + void selectPhase(bool psel, int &errcnt, std::string &errstr); + void setAmplitude(float amplitude, int &errcnt, std::string &errstr); + void setClockEnabled(bool value, int &errcnt, std::string &errstr); + void setDACEnabled(bool value, int &errcnt, std::string &errstr); + void setFrequency(bool fsel, float frequency, int &errcnt, std::string &errstr); + void setPhase(bool psel, float phase, int &errcnt, std::string &errstr); + void setSineWave(int &errcnt, std::string &errstr); + void setTriangleWave(int &errcnt, std::string &errstr); + void setupChannel0(int &errcnt, std::string &errstr); + void setupChannel1(int &errcnt, std::string &errstr); + void setWaveGenEnabled(bool value, int &errcnt, std::string &errstr); + void start(int &errcnt, std::string &errstr); + void stop(int &errcnt, std::string &errstr); + + static float expectedAmplitude(float amplitude); + static float expectedFrequency(float frequency); + static float expectedPhase(float phase); + static std::string hardwareRevision(const CP2130::USBConfig &config); + static std::list listDevices(int &errcnt, std::string &errstr); +}; + +#endif // GF2DEVICE_H diff --git a/src/libusb-extra.c b/src/libusb-extra.c index 534f1bc..900f8e9 100644 --- a/src/libusb-extra.c +++ b/src/libusb-extra.c @@ -1,5 +1,5 @@ -/* Extra functions for libusb - Version 1.1 - Copyright (c) 2018 Samuel Lourenço +/* Extra functions for libusb - Version 1.0.3 + Copyright (c) 2018-2021 Samuel Lourenço This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -22,25 +22,22 @@ #include #include "libusb-extra.h" -libusb_device_handle *libusb_open_device_with_vid_pid_serial(libusb_context *context, uint16_t vid, uint16_t pid, unsigned char *serial) // Opens the device with matching VID, PID and serial number +// Opens the device with matching VID, PID and serial number +libusb_device_handle *libusb_open_device_with_vid_pid_serial(libusb_context *context, uint16_t vid, uint16_t pid, unsigned char *serial) { libusb_device **devs; libusb_device_handle *devhandle = NULL; - if (libusb_get_device_list(context, &devs) >= 0) // If the device list is retrieved - { + if (libusb_get_device_list(context, &devs) >= 0) { // If the device list is retrieved libusb_device *dev; size_t devcounter = 0; - while ((dev = devs[devcounter++]) != NULL) // Walk through all the devices - { + while ((dev = devs[devcounter++]) != NULL) { // Walk through all the devices struct libusb_device_descriptor desc; - if (libusb_get_device_descriptor(dev, &desc) == 0 && desc.idVendor == vid && desc.idProduct == pid && libusb_open(dev, &devhandle) == 0) // If the device descriptor is retrieved, both PID and VID match, and if the device is successfully opened - { + if (libusb_get_device_descriptor(dev, &desc) == 0 && desc.idVendor == vid && desc.idProduct == pid && libusb_open(dev, &devhandle) == 0) { // If the device descriptor is retrieved, both PID and VID match, and if the device is successfully opened unsigned char str_desc[256]; - libusb_get_string_descriptor_ascii(devhandle, desc.iSerialNumber, str_desc, sizeof(str_desc)); // Get the serial number string in ASCII format - if (strcmp((char *)str_desc, (char *)serial) == 0) // If the serial number match + libusb_get_string_descriptor_ascii(devhandle, desc.iSerialNumber, str_desc, (int)sizeof(str_desc)); // Get the serial number string in ASCII format + if (strcmp((char *)str_desc, (char *)serial) == 0) { // If the serial number match break; - else - { + } else { libusb_close(devhandle); // Close the device, since it is not the one with the corresponding serial number devhandle = NULL; // Set device handle value to null pointer } diff --git a/src/libusb-extra.h b/src/libusb-extra.h index abe69ff..704bda4 100644 --- a/src/libusb-extra.h +++ b/src/libusb-extra.h @@ -1,5 +1,5 @@ -/* Extra functions for libusb - Version 1.1 - Copyright (c) 2018 Samuel Lourenço +/* Extra functions for libusb - Version 1.0.3 + Copyright (c) 2018-2021 Samuel Lourenço This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/src/utils.cpp b/src/utils.cpp new file mode 100644 index 0000000..caca238 --- /dev/null +++ b/src/utils.cpp @@ -0,0 +1,78 @@ +/* Utility functions - Version 1.0.0 + Copyright (c) 2022 Samuel Lourenço + + This library is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include "utils.h" + +// Checks if a given C string constitutes a valid integer +bool Utils::isInteger(char *value) +{ + bool retval = true; + if (value[0] != '+' && value[0] != '-' && (value[0] < '0' || value[0] > '9')) { // Number is not valid if the first character is not a '+', '-', nor a digit + retval = false; + } else { + size_t len = strlen(value); + for (size_t i = 1; i < len; ++i) { + if (value[i] < '0' || value[i] > '9') { // Number is not valid if subsequent characters are not digits + retval = false; + break; + } + } + } + return retval; +} + +// Checks if a given string constitutes a valid integer +bool Utils::isInteger(std::string value) +{ + return isInteger(value.c_str()); +} + +// Checks if a given C string constitutes a valid number +bool Utils::isNumber(char *value) +{ + bool retval = true; + if (value[0] != '+' && value[0] != '-' && value[0] != '.' && (value[0] < '0' || value[0] > '9')) { // Number is not valid if the first character is not a '+', '-', '.', nor a digit + retval = false; + } else { + bool dp_exists = false; + if (value[0] == '.') { // If character is a decimal point + dp_exists = true; + } + size_t len = strlen(value); + for (size_t i = 1; i < len; ++i) { + if ((value[i] != '.' || dp_exists) && (value[i] < '0' || value[i] > '9')) { // Number is not valid if subsequent characters are not digits or if there is more than one decimal point + retval = false; + break; + } + if (value[i] == '.') { // As before, if character is a decimal point + dp_exists = true; + } + } + } + return retval; +} + +// Checks if a given string constitutes a valid number +bool Utils::isNumber(std::string value) +{ + return isNumber(value.c_str()); +} diff --git a/src/utils.h b/src/utils.h new file mode 100644 index 0000000..e02dfd7 --- /dev/null +++ b/src/utils.h @@ -0,0 +1,35 @@ +/* Utility functions - Version 1.0.0 + Copyright (c) 2022 Samuel Lourenço + + This library is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +#ifndef UTILS_H +#define UTILS_H + +// Includes +#include + +namespace Utils +{ +bool isInteger(char *value); +bool isInteger(std::string value); +bool isNumber(char *value); +bool isNumber(std::string value); +} + +#endif // UTILS_H From a02173fe73a47d28c08beb50fd707647bee5b09a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:11:31 +0100 Subject: [PATCH 33/62] Add files via upload --- src/man/gf2-amp.1 | 29 +++++++++++++++++++++++++++++ src/man/gf2-amp50.1 | 33 +++++++++++++++++++++++++++++++++ src/man/gf2-clear.1 | 27 +++++++++++++++++++++++++++ src/man/gf2-clkoff.1 | 27 +++++++++++++++++++++++++++ src/man/gf2-clkon.1 | 29 +++++++++++++++++++++++++++++ src/man/gf2-dacoff.1 | 30 ++++++++++++++++++++++++++++++ src/man/gf2-dacon.1 | 25 +++++++++++++++++++++++++ src/man/gf2-freq.1 | 41 +++++++++++++++++++++++++++++++++++++++++ src/man/gf2-freq0.1 | 35 +++++++++++++++++++++++++++++++++++ src/man/gf2-freq1.1 | 32 ++++++++++++++++++++++++++++++++ src/man/gf2-list.1 | 22 ++++++++++++++++++++++ src/man/gf2-lockotp.1 | 27 +++++++++++++++++++++++++++ src/man/gf2-phase.1 | 40 ++++++++++++++++++++++++++++++++++++++++ src/man/gf2-phase0.1 | 34 ++++++++++++++++++++++++++++++++++ src/man/gf2-phase1.1 | 31 +++++++++++++++++++++++++++++++ src/man/gf2-reset.1 | 26 ++++++++++++++++++++++++++ src/man/gf2-selfreq0.1 | 33 +++++++++++++++++++++++++++++++++ src/man/gf2-selfreq1.1 | 33 +++++++++++++++++++++++++++++++++ src/man/gf2-selphase0.1 | 33 +++++++++++++++++++++++++++++++++ src/man/gf2-selphase1.1 | 33 +++++++++++++++++++++++++++++++++ src/man/gf2-sine.1 | 22 ++++++++++++++++++++++ src/man/gf2-start.1 | 28 ++++++++++++++++++++++++++++ src/man/gf2-status.1 | 27 +++++++++++++++++++++++++++ src/man/gf2-stop.1 | 29 +++++++++++++++++++++++++++++ src/man/gf2-tri.1 | 22 ++++++++++++++++++++++ 25 files changed, 748 insertions(+) create mode 100644 src/man/gf2-amp.1 create mode 100644 src/man/gf2-amp50.1 create mode 100644 src/man/gf2-clear.1 create mode 100644 src/man/gf2-clkoff.1 create mode 100644 src/man/gf2-clkon.1 create mode 100644 src/man/gf2-dacoff.1 create mode 100644 src/man/gf2-dacon.1 create mode 100644 src/man/gf2-freq.1 create mode 100644 src/man/gf2-freq0.1 create mode 100644 src/man/gf2-freq1.1 create mode 100644 src/man/gf2-list.1 create mode 100644 src/man/gf2-lockotp.1 create mode 100644 src/man/gf2-phase.1 create mode 100644 src/man/gf2-phase0.1 create mode 100644 src/man/gf2-phase1.1 create mode 100644 src/man/gf2-reset.1 create mode 100644 src/man/gf2-selfreq0.1 create mode 100644 src/man/gf2-selfreq1.1 create mode 100644 src/man/gf2-selphase0.1 create mode 100644 src/man/gf2-selphase1.1 create mode 100644 src/man/gf2-sine.1 create mode 100644 src/man/gf2-start.1 create mode 100644 src/man/gf2-status.1 create mode 100644 src/man/gf2-stop.1 create mode 100644 src/man/gf2-tri.1 diff --git a/src/man/gf2-amp.1 b/src/man/gf2-amp.1 new file mode 100644 index 0000000..c3f9376 --- /dev/null +++ b/src/man/gf2-amp.1 @@ -0,0 +1,29 @@ +.TH GF2-AMP 1 +.SH NAME +gf2-amp \- set GF2 Function Generator amplitude to a given value +.SH SYNOPSIS +.B gf2-amp +.I AMPLITUDE +.RI [ SERIALNUMBER ] +.SH DESCRIPTION +.B gf2-amp +sets the amplitude to the value given in the argument. This value is expressed +in Vpp (or Volts peak-to-peak) and must be between 0 and 8, inclusive. Decimal +values are accepted. + +Specifying a serial number is optional. +.SH EXAMPLE +.TP +.B gf2-amp 6.4 +Set the amplitude to 6.4Vpp. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur, or two in case of bad input. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), gf2-dacoff(1), +gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), gf2-list(1), +gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), +gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), +gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) diff --git a/src/man/gf2-amp50.1 b/src/man/gf2-amp50.1 new file mode 100644 index 0000000..f15d741 --- /dev/null +++ b/src/man/gf2-amp50.1 @@ -0,0 +1,33 @@ +.TH GF2-AMP50 1 +.SH NAME +gf2-amp50 \- set GF2 Function Generator amplitude to a given value +.SH SYNOPSIS +.B gf2-amp50 +.I AMPLITUDE +.RI [ SERIALNUMBER ] +.SH DESCRIPTION +.B gf2-amp50 +sets the amplitude to the value given in the argument. This value is expressed +in Vpp (or Volts peak-to-peak) and must be between 0 and 4, inclusive. Decimal +values are accepted. Notice that the analog output must be terminated with 50Ω +for accuracy. The actual amplitude value will be the double of the intended +value if the output is unterminated. In that case, you should use +.B gf2-amp +instead. + +Specifying a serial number is optional. +.SH EXAMPLE +.TP +.B gf2-amp50 3.2 +Set the amplitude to 3.2Vpp. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur, or two in case of bad input. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), gf2-dacoff(1), +gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), gf2-list(1), +gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), +gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), +gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) diff --git a/src/man/gf2-clear.1 b/src/man/gf2-clear.1 new file mode 100644 index 0000000..98c1e58 --- /dev/null +++ b/src/man/gf2-clear.1 @@ -0,0 +1,27 @@ +.TH GF2-CLEAR 1 +.SH NAME +gf2-clear \- clear GF2 Function Generator settings +.SH SYNOPSIS +.B gf2-clear +.RI [ SERIALNUMBER ] +.SH DESCRIPTION +.B gf2-clear +clears all waveform generation parameters and all registers, so that the +function generator is set to a known state. Waveform is set to sinusoidal, +with frequency set to 0Hz, phase set to 0° and amplitude set to 0Vpp. The +internal waveform generator DAC and the synchronous clock are enabled. Thus, +although the waveform generation is fully enabled, no signals will be +generated. + +Specifying a serial number is optional. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp(1), gf2-amp50(1), gf2-clkoff(1), gf2-clkon(1), gf2-dacoff(1), +gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), gf2-list(1), +gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), +gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), +gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) diff --git a/src/man/gf2-clkoff.1 b/src/man/gf2-clkoff.1 new file mode 100644 index 0000000..2e43b51 --- /dev/null +++ b/src/man/gf2-clkoff.1 @@ -0,0 +1,27 @@ +.TH GF2-CLKOFF 1 +.SH NAME +gf2-clkoff \- disable GF2 Function Generator synchronous clock +.SH SYNOPSIS +.B gf2-clkoff +.RI [ SERIALNUMBER ] +.SH DESCRIPTION +.B gf2-clkoff +disables the synchronous clock. It is important to mention that the digital +output of the function generator will be inactive after invoking this command. +To re-enable the synchronous clock, invoke +.BR gf2-clkon . +You can verify the synchronous clock status by calling +.BR gf2-status . + +Specifying a serial number is optional. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkon(1), gf2-dacoff(1), +gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), gf2-list(1), +gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), +gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), +gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) diff --git a/src/man/gf2-clkon.1 b/src/man/gf2-clkon.1 new file mode 100644 index 0000000..c4e037a --- /dev/null +++ b/src/man/gf2-clkon.1 @@ -0,0 +1,29 @@ +.TH GF2-CLKON 1 +.SH NAME +gf2-clkon \- enable GF2 Function Generator synchronous clock +.SH SYNOPSIS +.B gf2-clkon +.RI [ SERIALNUMBER ] +.SH DESCRIPTION +.B gf2-clkon +enables the synchronous clock. Note that +.B gf2-clkon +alone does not guarantee that the digital output of the function generator +will be active. However, having the synchronous clock enabled is one of the +necessary conditions. Conversely, to disable the synchronous clock, invoke +.BR gf2-clkoff . +You can verify the synchronous clock status by calling +.BR gf2-status . + +Specifying a serial number is optional. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-dacoff(1), +gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), gf2-list(1), +gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), +gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), +gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) diff --git a/src/man/gf2-dacoff.1 b/src/man/gf2-dacoff.1 new file mode 100644 index 0000000..ebcc065 --- /dev/null +++ b/src/man/gf2-dacoff.1 @@ -0,0 +1,30 @@ +.TH GF2-DACOFF 1 +.SH NAME +gf2-dacoff \- disable GF2 Function Generator waveform generator DAC +.SH SYNOPSIS +.B gf2-dacoff +.RI [ SERIALNUMBER ] +.SH DESCRIPTION +.B gf2-dacoff +disables the internal waveform generator DAC. Consequently, both analog and +digital outputs of the function generator will be inactive after invoking this +command. It is not guaranteed, though, that the digital output will idle low +(unless you invoke +.B gf2-clkoff +too). To re-enable the waveform generator DAC, invoke +.BR gf2-dacon . +You can verify the waveform generator DAC status by calling +.BR gf2-status . + +Specifying a serial number is optional. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), +gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), gf2-list(1), +gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), +gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), +gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) diff --git a/src/man/gf2-dacon.1 b/src/man/gf2-dacon.1 new file mode 100644 index 0000000..01148e1 --- /dev/null +++ b/src/man/gf2-dacon.1 @@ -0,0 +1,25 @@ +.TH GF2-DACON 1 +.SH NAME +gf2-dacon \- enable GF2 Function Generator waveform generator DAC +.SH SYNOPSIS +.B gf2-dacon +.RI [ SERIALNUMBER ] +.SH DESCRIPTION +.B gf2-dacon +enables the internal waveform generator DAC. Conversely, to disable it, invoke +.BR gf2-dacoff . +You can verify the waveform generator DAC status by calling +.BR gf2-status . + +Specifying a serial number is optional. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), +gf2-dacoff(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), gf2-list(1), +gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), +gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), +gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) diff --git a/src/man/gf2-freq.1 b/src/man/gf2-freq.1 new file mode 100644 index 0000000..5b5e131 --- /dev/null +++ b/src/man/gf2-freq.1 @@ -0,0 +1,41 @@ +.TH GF2-FREQ 1 +.SH NAME +gf2-freq \- set GF2 Function Generator frequency to a given value +.SH SYNOPSIS +.B gf2-freq +.I FREQUENCY +.RI [ SERIALNUMBER ] +.SH DESCRIPTION +.B gf2-freq +sets the frequency to the value given in the argument. This value is expressed +in KHz and must be between 0 and 40000, inclusive. Decimal values are +accepted. Note that this command will always take effect over the frequency of +the output signal, because it changes the currently selected frequency +parameter (i.e., frequency 0 or frequency 1). If you care about which +frequency parameter is being changed, you should use +.B gf2-freq0 +or +.B gf2-freq1 +instead, or pre-select the active frequency parameter by invoking +.B gf2-selfreq0 +or +.B gf2-selfreq1 +before calling +.BR gf2-freq . + +Specifying a serial number is optional. +.SH EXAMPLE +.TP +.B gf2-freq 15.3 +Set the frequency to 15.3KHz. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur, or two in case of bad input. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), +gf2-dacoff(1), gf2-dacon(1), gf2-freq0(1), gf2-freq1(1), gf2-list(1), +gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), +gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), +gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) diff --git a/src/man/gf2-freq0.1 b/src/man/gf2-freq0.1 new file mode 100644 index 0000000..7c97cbe --- /dev/null +++ b/src/man/gf2-freq0.1 @@ -0,0 +1,35 @@ +.TH GF2-FREQ0 1 +.SH NAME +gf2-freq0 \- set GF2 Function Generator frequency 0 parameter to a given value +.SH SYNOPSIS +.B gf2-freq0 +.I FREQUENCY +.RI [ SERIALNUMBER ] +.SH DESCRIPTION +.B gf2-freq0 +sets the frequency 0 parameter to the value given in the argument. This value +is expressed in KHz and must be between 0 and 40000, inclusive. Decimal values +are accepted. It is important to note that this command will change the +frequency of the output signal only if frequency 0 is selected as active. To +do such, you should invoke +.BR gf2-selfreq0 . +However, frequency 0 is the active frequency parameter after invoking +.B gf2-clear +and, therefore, it may not be required to do so. + +Specifying a serial number is optional. +.SH EXAMPLE +.TP +.B gf2-freq0 10.2 +Set frequency 0 to 10.2KHz. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur, or two in case of bad input. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), +gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq1(1), gf2-list(1), +gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), +gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), +gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) diff --git a/src/man/gf2-freq1.1 b/src/man/gf2-freq1.1 new file mode 100644 index 0000000..4927f26 --- /dev/null +++ b/src/man/gf2-freq1.1 @@ -0,0 +1,32 @@ +.TH GF2-FREQ1 1 +.SH NAME +gf2-freq1 \- set GF2 Function Generator frequency 1 parameter to a given value +.SH SYNOPSIS +.B gf2-freq1 +.I FREQUENCY +.RI [ SERIALNUMBER ] +.SH DESCRIPTION +.B gf2-freq1 +sets the frequency 1 parameter to the value given in the argument. This value +is expressed in KHz and must be between 0 and 40000, inclusive. Decimal values +are accepted. It is important to note that this command will change the +frequency of the output signal only if frequency 1 is selected as active. To +do such, you should invoke +.BR gf2-selfreq1 . + +Specifying a serial number is optional. +.SH EXAMPLE +.TP +.B gf2-freq1 20.4 +Set frequency 1 to 20.4KHz. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur, or two in case of bad input. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), +gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-list(1), +gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), +gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), +gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) diff --git a/src/man/gf2-list.1 b/src/man/gf2-list.1 new file mode 100644 index 0000000..256b31a --- /dev/null +++ b/src/man/gf2-list.1 @@ -0,0 +1,22 @@ +.TH GF2-LIST 1 +.SH NAME +gf2-list \- list connected GF2 Function Generator devices +.SH SYNOPSIS +.B gf2-list +.SH DESCRIPTION +.B gf2-list +lists all function generator devices that are currently connected. Note that +the first device on the list is always the one addressed by default. Hence, +when applicable, a command invoked without any serial number specified will +always take effect on that device. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), +gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), +gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), +gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), +gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) diff --git a/src/man/gf2-lockotp.1 b/src/man/gf2-lockotp.1 new file mode 100644 index 0000000..2d16102 --- /dev/null +++ b/src/man/gf2-lockotp.1 @@ -0,0 +1,27 @@ +.TH GF2-LOCKOTP 1 +.SH NAME +gf2-lockotp \- lock GF2 Function Generator OTP ROM +.SH SYNOPSIS +.B gf2-lockotp +.I SERIALNUMBER +.SH DESCRIPTION +.B gf2-lockotp +locks the function generator OTP ROM, preventing further (and possibly +unwanted) changes. It is important to lock all fields on the OTP ROM, since +any changes to untouched fields will be irreversible and can impair the +device. Note that you must specify the serial number of the target device. +.SH EXAMPLE +.TP +.B gf2-lockotp GF2-00VJ3PHW +Lock the OTP ROM of device with serial number GF2-00VJ3PHW. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur, or two in case of bad input. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), +gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), +gf2-list(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), +gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), +gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) diff --git a/src/man/gf2-phase.1 b/src/man/gf2-phase.1 new file mode 100644 index 0000000..820d33d --- /dev/null +++ b/src/man/gf2-phase.1 @@ -0,0 +1,40 @@ +.TH GF2-PHASE 1 +.SH NAME +gf2-phase \- set GF2 Function Generator phase to a given value +.SH SYNOPSIS +.B gf2-phase +.I PHASE +.RI [ SERIALNUMBER ] +.SH DESCRIPTION +.B gf2-phase +sets the phase to the value given in the argument. This value is expressed in +degrees. Any value is accepted. Note that this command will always take effect +over the phase of the output signal, because it changes the currently selected +phase parameter (i.e., phase 0 or phase 1). If you care about which phase +parameter is being changed, you should use +.B gf2-phase0 +or +.B gf2-phase1 +instead, or pre-select the active phase parameter by invoking +.B gf2-selphase0 +or +.B gf2-selphase1 +before calling +.BR gf2-phase . + +Specifying a serial number is optional. +.SH EXAMPLE +.TP +.B gf2-phase 67.5 +Set the phase to 67.5°. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur, or two in case of bad input. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), +gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), +gf2-list(1), gf2-lockotp(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), +gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), +gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) diff --git a/src/man/gf2-phase0.1 b/src/man/gf2-phase0.1 new file mode 100644 index 0000000..7ad3050 --- /dev/null +++ b/src/man/gf2-phase0.1 @@ -0,0 +1,34 @@ +.TH GF2-PHASE0 1 +.SH NAME +gf2-phase0 \- set GF2 Function Generator phase 0 parameter to a given value +.SH SYNOPSIS +.B gf2-phase0 +.I PHASE +.RI [ SERIALNUMBER ] +.SH DESCRIPTION +.B gf2-phase0 +sets the phase 0 parameter to the value given in the argument. This value is +expressed in degrees. Any value is accepted. It is important to note that this +command will change the phase of the output signal only if phase 0 is selected +as active. To do such, you should invoke +.BR gf2-selphase0 . +However, phase 0 is the active phase parameter after invoking +.B gf2-clear +and, therefore, it may not be required to do so. + +Specifying a serial number is optional. +.SH EXAMPLE +.TP +.B gf2-phase0 22.5 +Set phase 0 to 22.5°. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur, or two in case of bad input. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), +gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), +gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase1(1), gf2-reset(1), +gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), +gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) diff --git a/src/man/gf2-phase1.1 b/src/man/gf2-phase1.1 new file mode 100644 index 0000000..891cbe1 --- /dev/null +++ b/src/man/gf2-phase1.1 @@ -0,0 +1,31 @@ +.TH GF2-PHASE1 1 +.SH NAME +gf2-phase1 \- set GF2 Function Generator phase 1 parameter to a given value +.SH SYNOPSIS +.B gf2-phase1 +.I PHASE +.RI [ SERIALNUMBER ] +.SH DESCRIPTION +.B gf2-phase1 +sets the phase 1 parameter to the value given in the argument. This value is +expressed in degrees. Any value is accepted. It is important to note that this +command will change the phase of the output signal only if phase 1 is selected +as active. To do such, you should invoke +.BR gf2-selphase1 . + +Specifying a serial number is optional. +.SH EXAMPLE +.TP +.B gf2-phase1 112.5 +Set phase 1 to 112.5°. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur, or two in case of bad input. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), +gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), +gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-reset(1), +gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), +gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) diff --git a/src/man/gf2-reset.1 b/src/man/gf2-reset.1 new file mode 100644 index 0000000..7bccf8f --- /dev/null +++ b/src/man/gf2-reset.1 @@ -0,0 +1,26 @@ +.TH GF2-RESET 1 +.SH NAME +gf2-reset \- reset GF2 Function Generator +.SH SYNOPSIS +.B gf2-reset +.RI [ SERIALNUMBER ] +.SH DESCRIPTION +.B gf2-reset +issues a reset command to the function generator, causing it to power cycle. +After reset, no signals will be generated. However, most waveform generation +parameters will be set to unknown values. You should always invoke +.B gf2-clear +after issuing a reset and prior to any other commands. + +Specifying a serial number is optional. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), +gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), +gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), +gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), +gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) diff --git a/src/man/gf2-selfreq0.1 b/src/man/gf2-selfreq0.1 new file mode 100644 index 0000000..ad228da --- /dev/null +++ b/src/man/gf2-selfreq0.1 @@ -0,0 +1,33 @@ +.TH GF2-SELFREQ0 1 +.SH NAME +gf2-selfreq0 \- select frequency 0 as the active frequency parameter of GF2 +Function Generator +.SH SYNOPSIS +.B gf2-selfreq0 +.RI [ SERIALNUMBER ] +.SH DESCRIPTION +.B gf2-selfreq0 +selects the frequency 0 parameter to be the active frequency parameter of the +function generator. Along with +.BR gf2-selfreq1 , +.B gf2-selfreq0 +allows you to instantly switch between two frequency values during signal +generation, being a way to implement BFSK (binary frequency-shift keying). You +can use +.B gf2-freq0 +and +.B gf2-freq1 +to define the frequency parameters beforehand. + +Specifying a serial number is optional. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), +gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), +gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), +gf2-reset(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), +gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) diff --git a/src/man/gf2-selfreq1.1 b/src/man/gf2-selfreq1.1 new file mode 100644 index 0000000..6e696b4 --- /dev/null +++ b/src/man/gf2-selfreq1.1 @@ -0,0 +1,33 @@ +.TH GF2-SELFREQ1 1 +.SH NAME +gf2-selfreq1 \- select frequency 1 as the active frequency parameter of GF2 +Function Generator +.SH SYNOPSIS +.B gf2-selfreq1 +.RI [ SERIALNUMBER ] +.SH DESCRIPTION +.B gf2-selfreq1 +selects the frequency 1 parameter to be the active frequency parameter of the +function generator. Along with +.BR gf2-selfreq0 , +.B gf2-selfreq1 +allows you to instantly switch between two frequency values during signal +generation, being a way to implement BFSK (binary frequency-shift keying). You +can use +.B gf2-freq0 +and +.B gf2-freq1 +to define the frequency parameters beforehand. + +Specifying a serial number is optional. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), +gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), +gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), +gf2-reset(1), gf2-selfreq0(1), gf2-selphase0(1), gf2-selphase1(1), +gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) diff --git a/src/man/gf2-selphase0.1 b/src/man/gf2-selphase0.1 new file mode 100644 index 0000000..70d0954 --- /dev/null +++ b/src/man/gf2-selphase0.1 @@ -0,0 +1,33 @@ +.TH GF2-SELPHASE0 1 +.SH NAME +gf2-selphase0 \- select phase 0 as the active phase parameter of GF2 Function +Generator +.SH SYNOPSIS +.B gf2-selphase0 +.RI [ SERIALNUMBER ] +.SH DESCRIPTION +.B gf2-selphase0 +selects the phase 0 parameter to be the active phase parameter of the function +generator. Along with +.BR gf2-selphase1 , +.B gf2-selphase0 +allows you to instantly switch between two phase values during signal +generation, being a way to implement BPSK (binary phase-shift keying). You can +use +.B gf2-phase0 +and +.B gf2-phase1 +to define the phase parameters beforehand. + +Specifying a serial number is optional. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), +gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), +gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), +gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase1(1), gf2-sine(1), +gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) diff --git a/src/man/gf2-selphase1.1 b/src/man/gf2-selphase1.1 new file mode 100644 index 0000000..3283a06 --- /dev/null +++ b/src/man/gf2-selphase1.1 @@ -0,0 +1,33 @@ +.TH GF2-SELPHASE1 1 +.SH NAME +gf2-selphase1 \- select phase 1 as the active phase parameter of GF2 Function +Generator +.SH SYNOPSIS +.B gf2-selphase1 +.RI [ SERIALNUMBER ] +.SH DESCRIPTION +.B gf2-selphase1 +selects the phase 1 parameter to be the active phase parameter of the function +generator. Along with +.BR gf2-selphase0 , +.B gf2-selphase1 +allows you to instantly switch between two phase values during signal +generation, being a way to implement BPSK (binary phase-shift keying). You can +use +.B gf2-phase0 +and +.B gf2-phase1 +to define the phase parameters beforehand. + +Specifying a serial number is optional. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), +gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), +gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), +gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-sine(1), +gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) diff --git a/src/man/gf2-sine.1 b/src/man/gf2-sine.1 new file mode 100644 index 0000000..f1164dc --- /dev/null +++ b/src/man/gf2-sine.1 @@ -0,0 +1,22 @@ +.TH GF2-SINE 1 +.SH NAME +gf2-sine \- set GF2 Function Generator waveform to sinusoidal +.SH SYNOPSIS +.B gf2-sine +.RI [ SERIALNUMBER ] +.SH DESCRIPTION +.B gf2-sine +sets the waveform to sinusoidal. + +Specifying a serial number is optional. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), +gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), +gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), +gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), +gf2-selphase1(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) diff --git a/src/man/gf2-start.1 b/src/man/gf2-start.1 new file mode 100644 index 0000000..6289a14 --- /dev/null +++ b/src/man/gf2-start.1 @@ -0,0 +1,28 @@ +.TH GF2-START 1 +.SH NAME +gf2-start \- start GF2 Function Generator +.SH SYNOPSIS +.B gf2-start +.RI [ SERIALNUMBER ] +.SH DESCRIPTION +.B gf2-start +issues a start command to the function generator. If it is already running, +.B gf2-start +will cause the waveform generation to restart. Conversely, to stop the +function generator, invoke +.BR gf2-stop . +You can verify the function generator status by calling +.BR gf2-status . + +Specifying a serial number is optional. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), +gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), +gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), +gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), +gf2-selphase1(1), gf2-sine(1), gf2-status(1), gf2-stop(1), gf2-tri(1) diff --git a/src/man/gf2-status.1 b/src/man/gf2-status.1 new file mode 100644 index 0000000..86ff6e5 --- /dev/null +++ b/src/man/gf2-status.1 @@ -0,0 +1,27 @@ +.TH GF2-STATUS 1 +.SH NAME +gf2-status \- show GF2 Function Generator status +.SH SYNOPSIS +.B gf2-status +.RI [ SERIALNUMBER ] +.SH DESCRIPTION +.B gf2-status +shows the current status of the function generator, giving detailed +information. You can use +.B gf2status +to know, for example, which frequency and phase parameters are active. Due to +hardware limitations, information about frequency, phase or amplitude is not +shown. + +Specifying a serial number is optional. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), +gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), +gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), +gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), +gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-stop(1), gf2-tri(1) diff --git a/src/man/gf2-stop.1 b/src/man/gf2-stop.1 new file mode 100644 index 0000000..75169c3 --- /dev/null +++ b/src/man/gf2-stop.1 @@ -0,0 +1,29 @@ +.TH GF2-STOP 1 +.SH NAME +gf2-stop \- stop GF2 Function Generator +.SH SYNOPSIS +.B gf2-stop +.RI [ SERIALNUMBER ] +.SH DESCRIPTION +.B gf2-stop +issues a stop command to the function generator. After invoking this command, +no signals will be generated and both outputs will be inactive. It is not +guaranteed, though, that the digital output will idle low (unless you invoke +.B gf2-clkoff +too). To restart the function generator, invoke +.BR gf2-start . +You can verify the function generator status by calling +.BR gf2-status . + +Specifying a serial number is optional. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), +gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), +gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), +gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), +gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), gf2-tri(1) diff --git a/src/man/gf2-tri.1 b/src/man/gf2-tri.1 new file mode 100644 index 0000000..f934998 --- /dev/null +++ b/src/man/gf2-tri.1 @@ -0,0 +1,22 @@ +.TH GF2-TRI 1 +.SH NAME +gf2-tri \- set GF2 Function Generator waveform to triangular +.SH SYNOPSIS +.B gf2-tri +.RI [ SERIALNUMBER ] +.SH DESCRIPTION +.B gf2-tri +sets the waveform to triangular. + +Specifying a serial number is optional. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), +gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), +gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), +gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), +gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1) From fbbe2dd472de9765677c4bdfea48ac26bac03f1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:11:44 +0100 Subject: [PATCH 34/62] Delete newfile --- src/man/newfile | 1 - 1 file changed, 1 deletion(-) delete mode 100644 src/man/newfile diff --git a/src/man/newfile b/src/man/newfile deleted file mode 100644 index 8b13789..0000000 --- a/src/man/newfile +++ /dev/null @@ -1 +0,0 @@ - From 0ce820ca0935d30a01164886e3f8485b01c20adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Thu, 21 Jul 2022 08:29:21 +0100 Subject: [PATCH 35/62] Add files via upload --- src/Makefile | 23 +++++++++-------- src/gf2-reset.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 12 deletions(-) create mode 100644 src/gf2-reset.cpp diff --git a/src/Makefile b/src/Makefile index 080a67b..20123d2 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,5 +1,5 @@ # Makefile for all GF2 commands, Debian Linux (GCC) -# Copyright (c) 2018-2019 Samuel Lourenço +# Copyright (c) 2018-2022 Samuel Lourenço # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free @@ -19,27 +19,26 @@ CC = gcc -CFLAGS = -O2 -std=gnu99 -Wall -pedantic +CFLAGS = -O2 -std=c11 -Wall -pedantic +CXX = g++ +CXXFLAGS = -O2 -std=c++11 -Wall -pedantic LDFLAGS = -s -LDLIBS = -lm -lusb-1.0 -OBJECTS = common.o gf2-core.o libusb-extra.o -TARGETS = gf2-amp gf2-amp50 gf2-clear gf2-clkoff gf2-clkon gf2-dacoff gf2-dacon gf2-freq gf2-freq0 gf2-freq1 gf2-list gf2-lockotp gf2-phase gf2-phase0 gf2-phase1 gf2-reset gf2-selfreq0 gf2-selfreq1 gf2-selphase0 gf2-selphase1 gf2-sine gf2-start gf2-status gf2-stop gf2-tri +LDLIBS = -lusb-1.0 +OBJECTS = cp2130.o error.o gf2device.o libusb-extra.o +TARGETS = gf2-reset .PHONY: all clean install uninstall all: $(TARGETS) $(TARGETS): % : %.o $(OBJECTS) - $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ + $(CXX) $(LDFLAGS) $^ $(LDLIBS) -o $@ %.o: %.c $(CC) $(CFLAGS) -c $< +%.o: %.cpp + $(CXX) $(CXXFLAGS) -c $< + clean: $(RM) *.o $(TARGETS) - -install: - mv -f $(TARGETS) /usr/local/bin/. - -uninstall: - cd /usr/local/bin && $(RM) $(TARGETS) diff --git a/src/gf2-reset.cpp b/src/gf2-reset.cpp new file mode 100644 index 0000000..d4ae2e2 --- /dev/null +++ b/src/gf2-reset.cpp @@ -0,0 +1,63 @@ +/* GF2 Reset Command - Version 2.0 for Debian Linux + Copyright (c) 2018-2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include "error.h" +#include "gf2device.h" + +int main(int argc, char **argv) +{ + int err, errlvl = EXIT_SUCCESS; + GF2Device device; + if (argc < 2) { // If the program was called without arguments + err = device.open(); // Open a device and get the device handle + } else { // Serial number was specified as argument + err = device.open(argv[1]); // Open the device having the specified serial number, and get the device handle + } + if (err == GF2Device::SUCCESS) { // Device was successfully opened + int errcnt = 0; + std::string errstr; + device.reset(errcnt, errstr); // Reset the target device + if (errcnt > 0) { // In case of error + if (device.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } else { // Operation successful + std::cout << "Reset issued." << std::endl; + } + device.close(); + } else { // Failed to open device + if (err == GF2Device::ERROR_INIT) { // Failed to initialize libusb + std::cerr << "Error: Could not initialize libusb\n"; + } else if (err == GF2Device::ERROR_NOT_FOUND) { // Failed to find device + std::cerr << "Error: Could not find device.\n"; + } else if (err == GF2Device::ERROR_BUSY) { // Failed to claim interface + std::cerr << "Error: Device is currently unavailable.\n"; + } + errlvl = EXIT_FAILURE; + } + return errlvl; +} From 1892334501d4439726482c78844906f1d91ee049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Thu, 21 Jul 2022 09:16:52 +0100 Subject: [PATCH 36/62] Add files via upload --- src/Makefile | 2 +- src/gf2-clear.cpp | 65 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 src/gf2-clear.cpp diff --git a/src/Makefile b/src/Makefile index 20123d2..b535b5b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -25,7 +25,7 @@ CXXFLAGS = -O2 -std=c++11 -Wall -pedantic LDFLAGS = -s LDLIBS = -lusb-1.0 OBJECTS = cp2130.o error.o gf2device.o libusb-extra.o -TARGETS = gf2-reset +TARGETS = gf2-clear gf2-reset .PHONY: all clean install uninstall diff --git a/src/gf2-clear.cpp b/src/gf2-clear.cpp new file mode 100644 index 0000000..f401f40 --- /dev/null +++ b/src/gf2-clear.cpp @@ -0,0 +1,65 @@ +/* GF2 Clear Command - Version 2.0 for Debian Linux + Copyright (c) 2018-2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include "error.h" +#include "gf2device.h" + +int main(int argc, char **argv) +{ + int err, errlvl = EXIT_SUCCESS; + GF2Device device; + if (argc < 2) { // If the program was called without arguments + err = device.open(); // Open a device and get the device handle + } else { // Serial number was specified as argument + err = device.open(argv[1]); // Open the device having the specified serial number, and get the device handle + } + if (err == GF2Device::SUCCESS) { // Device was successfully opened + int errcnt = 0; + std::string errstr; + device.setupChannel0(errcnt, errstr); // Setup channel 0 + device.setupChannel1(errcnt, errstr); // Setup channel 1 + device.clear(errcnt, errstr); // Clear all waveform generation parameters + if (errcnt > 0) { // In case of error + if (device.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } else { // Operation successful + std::cout << "All settings cleared." << std::endl; + } + device.close(); + } else { // Failed to open device + if (err == GF2Device::ERROR_INIT) { // Failed to initialize libusb + std::cerr << "Error: Could not initialize libusb\n"; + } else if (err == GF2Device::ERROR_NOT_FOUND) { // Failed to find device + std::cerr << "Error: Could not find device.\n"; + } else if (err == GF2Device::ERROR_BUSY) { // Failed to claim interface + std::cerr << "Error: Device is currently unavailable.\n"; + } + errlvl = EXIT_FAILURE; + } + return errlvl; +} From 0582f8c6b56bb772607af21edcdd3d46930050c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Thu, 21 Jul 2022 21:15:31 +0100 Subject: [PATCH 37/62] Add files via upload --- src/Makefile | 2 +- src/gf2-list.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/gf2-list.cpp diff --git a/src/Makefile b/src/Makefile index b535b5b..c4465e6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -25,7 +25,7 @@ CXXFLAGS = -O2 -std=c++11 -Wall -pedantic LDFLAGS = -s LDLIBS = -lusb-1.0 OBJECTS = cp2130.o error.o gf2device.o libusb-extra.o -TARGETS = gf2-clear gf2-reset +TARGETS = gf2-clear gf2-list gf2-reset .PHONY: all clean install uninstall diff --git a/src/gf2-list.cpp b/src/gf2-list.cpp new file mode 100644 index 0000000..e367eec --- /dev/null +++ b/src/gf2-list.cpp @@ -0,0 +1,51 @@ +/* GF2 List Command - Version 2.0 for Debian Linux + Copyright (c) 2018-2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include +#include "error.h" +#include "gf2device.h" + +int main() +{ + int errcnt = 0, errlvl = EXIT_SUCCESS; + std::string errstr; + std::list deviceList = GF2Device::listDevices(errcnt, errstr); // Get a device list + if (errcnt > 0) { // In case of error + printErrors(errstr); + errlvl = EXIT_FAILURE; + } else if (deviceList.empty()) { // If list is empty + std::cout << "No devices found." << std::endl; + } else { + size_t counter = 0; // Device counter + for (std::string device : deviceList) { // Traverse device list + ++counter; + std::cout << counter << "\t" << device; // Print device order and serial numbers + if (counter == 1) { // The first device on the list is always the preferred one + std::cout << " (default)"; + } + std::cout << std::endl; + } + } + return errlvl; +} From 704a72bc121242ca1d3e9fd5b5148131fcd83e40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Thu, 21 Jul 2022 21:59:47 +0100 Subject: [PATCH 38/62] Add files via upload --- src/Makefile | 2 +- src/gf2-info.cpp | 75 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 src/gf2-info.cpp diff --git a/src/Makefile b/src/Makefile index c4465e6..e990974 100644 --- a/src/Makefile +++ b/src/Makefile @@ -25,7 +25,7 @@ CXXFLAGS = -O2 -std=c++11 -Wall -pedantic LDFLAGS = -s LDLIBS = -lusb-1.0 OBJECTS = cp2130.o error.o gf2device.o libusb-extra.o -TARGETS = gf2-clear gf2-list gf2-reset +TARGETS = gf2-clear gf2-info gf2-list gf2-reset .PHONY: all clean install uninstall diff --git a/src/gf2-info.cpp b/src/gf2-info.cpp new file mode 100644 index 0000000..16095a7 --- /dev/null +++ b/src/gf2-info.cpp @@ -0,0 +1,75 @@ +/* GF2 Info Command - Version 1.0 for Debian Linux + Copyright (c) 2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include +#include +#include +#include "cp2130.h" +#include "error.h" +#include "gf2device.h" + +int main(int argc, char **argv) +{ + int err, errlvl = EXIT_SUCCESS; + GF2Device device; + if (argc < 2) { // If the program was called without arguments + err = device.open(); // Open a device and get the device handle + } else { // Serial number was specified as argument + err = device.open(argv[1]); // Open the device having the specified serial number, and get the device handle + } + if (err == GF2Device::SUCCESS) { // Device was successfully opened + int errcnt = 0; + std::string errstr; + std::u16string manufacturer = device.getManufacturerDesc(errcnt, errstr); // Manufacturer descriptor + std::u16string product = device.getProductDesc(errcnt, errstr); // Product descriptor + std::u16string serial = device.getSerialDesc(errcnt, errstr); // Serial number descriptor + CP2130::USBConfig config = device.getUSBConfig(errcnt, errstr); // USB configuration + if (errcnt > 0) { // In case of error + if (device.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } else { // Operation successful + std::wstring_convert, char16_t> converter; + std::cout << "Manufacturer: " << converter.to_bytes(manufacturer) << std::endl; // Print manufacturer string + std::cout << "Product: " << converter.to_bytes(product) << std::endl; // Print product string + std::cout << "Serial number: " << converter.to_bytes(serial) << std::endl; // Print serial number string + std::cout << "Hardware revision: " << GF2Device::hardwareRevision(config) << " [0x" << std::hex << std::setfill ('0') << std::setw(4) << (config.majrel << 8 | config.minrel) << std::dec << "]" << std::endl; // Print hardware revision + std::cout << "Maximum power consumption: " << 2 * config.maxpow << "mA [0x" << std::hex << std::setw(2) << static_cast(config.maxpow) << "]" << std::endl; // Print maximum power consumption + } + device.close(); + } else { // Failed to open device + if (err == GF2Device::ERROR_INIT) { // Failed to initialize libusb + std::cerr << "Error: Could not initialize libusb\n"; + } else if (err == GF2Device::ERROR_NOT_FOUND) { // Failed to find device + std::cerr << "Error: Could not find device.\n"; + } else if (err == GF2Device::ERROR_BUSY) { // Failed to claim interface + std::cerr << "Error: Device is currently unavailable.\n"; + } + errlvl = EXIT_FAILURE; + } + return errlvl; +} From e596df07571aa1c6c8d4b9ceaa3e636f89fc52bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Thu, 21 Jul 2022 23:15:53 +0100 Subject: [PATCH 39/62] Add files via upload --- src/Makefile | 2 +- src/gf2-lockotp.cpp | 88 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 src/gf2-lockotp.cpp diff --git a/src/Makefile b/src/Makefile index e990974..6a4a4ac 100644 --- a/src/Makefile +++ b/src/Makefile @@ -25,7 +25,7 @@ CXXFLAGS = -O2 -std=c++11 -Wall -pedantic LDFLAGS = -s LDLIBS = -lusb-1.0 OBJECTS = cp2130.o error.o gf2device.o libusb-extra.o -TARGETS = gf2-clear gf2-info gf2-list gf2-reset +TARGETS = gf2-clear gf2-info gf2-list gf2-lockotp gf2-reset .PHONY: all clean install uninstall diff --git a/src/gf2-lockotp.cpp b/src/gf2-lockotp.cpp new file mode 100644 index 0000000..a22dde8 --- /dev/null +++ b/src/gf2-lockotp.cpp @@ -0,0 +1,88 @@ +/* GF2 LockOTP Command - Version 2.0 for Debian Linux + Copyright (c) 2018-2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include "cp2130.h" +#include "error.h" +#include "gf2device.h" + +// Definitions +static const int EXIT_USERERR = 2; // Exit status value to indicate a command usage error + +int main(int argc, char **argv) +{ + int errlvl = EXIT_SUCCESS; + if (argc < 2) { // If the program was called without arguments + std::cerr << "Error: Missing argument.\nUsage: gf2-lockotp SERIALNUMBER\n"; + errlvl = EXIT_USERERR; + } else { + CP2130 cp2130; + int err = cp2130.open(GF2Device::VID, GF2Device::PID, argv[1]); + if (err == GF2Device::SUCCESS) { // Open the device having the specified serial number, and get the device handle. If successful + int errcnt = 0; + std::string errstr; + if (cp2130.isOTPLocked(errcnt, errstr) && errcnt == 0) { // Check if the OTP ROM is locked (errcnt can increment as a consequence of that verification, hence the need for "&& errcnt == 0" in order to avoid misleading messages) + std::cout << "Device OTP ROM is already locked." << std::endl; + } else if (errcnt == 0) { // If OTP is not locked + std::cout << "Device OTP ROM contains unlocked fields, which can be overwritten." << std::endl; + std::cout << "Do you wish to permanently lock all fields? [y/N] "; + char cin; + std::cin.get(cin); // Get character entered by user + if (cin == 'Y' || cin == 'y') { // If user entered "Y" or "y" + cp2130.lockOTP(errcnt, errstr); // Lock the OTP ROM + cp2130.reset(errcnt, errstr); // Reset the device + if (errcnt > 0) { // In case of error + if (cp2130.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } else { // Operation successful + std::cout << "Device OTP ROM is now locked." << std::endl; // Notice that no verification is done after reset, since the device has to be allowed to re-enumerate before getting the updated register values + } + } else { // If user entered any other character + std::cout << "Lock operation canceled." << std::endl; + } + } else { + if (cp2130.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } + cp2130.close(); + } else { // Failed to open device + if (err == GF2Device::ERROR_INIT) { // Failed to initialize libusb + std::cerr << "Error: Could not initialize libusb\n"; + } else if (err == GF2Device::ERROR_NOT_FOUND) { // Failed to find device + std::cerr << "Error: Could not find device.\n"; + } else if (err == GF2Device::ERROR_BUSY) { // Failed to claim interface + std::cerr << "Error: Device is currently unavailable.\n"; + } + errlvl = EXIT_FAILURE; + } + return errlvl; + } +} From 6d6051bdc69e4d6ab5e0288b5bdc97d6acf7111a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Fri, 22 Jul 2022 00:42:51 +0100 Subject: [PATCH 40/62] Add files via upload --- src/Makefile | 2 +- src/gf2-status.cpp | 73 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 src/gf2-status.cpp diff --git a/src/Makefile b/src/Makefile index 6a4a4ac..406fe14 100644 --- a/src/Makefile +++ b/src/Makefile @@ -25,7 +25,7 @@ CXXFLAGS = -O2 -std=c++11 -Wall -pedantic LDFLAGS = -s LDLIBS = -lusb-1.0 OBJECTS = cp2130.o error.o gf2device.o libusb-extra.o -TARGETS = gf2-clear gf2-info gf2-list gf2-lockotp gf2-reset +TARGETS = gf2-clear gf2-info gf2-list gf2-lockotp gf2-reset gf2-status .PHONY: all clean install uninstall diff --git a/src/gf2-status.cpp b/src/gf2-status.cpp new file mode 100644 index 0000000..0417fc2 --- /dev/null +++ b/src/gf2-status.cpp @@ -0,0 +1,73 @@ +/* GF2 Status Command - Version 2.0 for Debian Linux + Copyright (c) 2018-2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include "error.h" +#include "gf2device.h" + +int main(int argc, char **argv) +{ + int err, errlvl = EXIT_SUCCESS; + GF2Device device; + if (argc < 2) { // If the program was called without arguments + err = device.open(); // Open a device and get the device handle + } else { // Serial number was specified as argument + err = device.open(argv[1]); // Open the device having the specified serial number, and get the device handle + } + if (err == GF2Device::SUCCESS) { // Device was successfully opened + int errcnt = 0; + std::string errstr; + bool gen = device.isWaveGenEnabled(errcnt, errstr); // AD9834 waveform generator status + bool dac = device.isDACEnabled(errcnt, errstr); // AD9834 internal DAC status + bool clk = device.isClockEnabled(errcnt, errstr); // Synchronous clock status + bool fsel = device.getFrequencySelection(errcnt, errstr); // Frequency selection + bool psel = device.getPhaseSelection(errcnt, errstr); // Phase selection + if (errcnt > 0) { // In case of error + if (device.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } else { // Operation successful + std::cout << "Status: " << (gen ? "Running" : "Stopped") << std::endl; // Print waveform generation status + std::cout << "Waveform generator DAC: " << (dac ? "Enabled" : "Disabled") << std::endl; // Print waveform generator DAC status + std::cout << "Synchronous clock: " << (clk ? "Enabled" : "Disabled") << std::endl; // Print synchronous clock status + std::cout << "Analog output: " << (gen && dac ? "Active" : "Inactive") << std::endl; // Print analog output status + std::cout << "Digital output: " << (gen && dac && clk ? "Active" : "Inactive") << std::endl; // Print digital output status + std::cout << "Active frequency parameter: Frequency " << fsel << std::endl; // Print selected frequency parameter + std::cout << "Active phase parameter: Phase " << psel << std::endl; // Print selected phase parameter + } + device.close(); + } else { // Failed to open device + if (err == GF2Device::ERROR_INIT) { // Failed to initialize libusb + std::cerr << "Error: Could not initialize libusb\n"; + } else if (err == GF2Device::ERROR_NOT_FOUND) { // Failed to find device + std::cerr << "Error: Could not find device.\n"; + } else if (err == GF2Device::ERROR_BUSY) { // Failed to claim interface + std::cerr << "Error: Device is currently unavailable.\n"; + } + errlvl = EXIT_FAILURE; + } + return errlvl; +} From f8ac707b492dad2d22c8edb42c82cead8205c02a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Fri, 22 Jul 2022 08:49:19 +0100 Subject: [PATCH 41/62] Add files via upload --- src/Makefile | 2 +- src/gf2-start.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 src/gf2-start.cpp diff --git a/src/Makefile b/src/Makefile index 406fe14..99ddea3 100644 --- a/src/Makefile +++ b/src/Makefile @@ -25,7 +25,7 @@ CXXFLAGS = -O2 -std=c++11 -Wall -pedantic LDFLAGS = -s LDLIBS = -lusb-1.0 OBJECTS = cp2130.o error.o gf2device.o libusb-extra.o -TARGETS = gf2-clear gf2-info gf2-list gf2-lockotp gf2-reset gf2-status +TARGETS = gf2-clear gf2-info gf2-list gf2-lockotp gf2-reset gf2-start gf2-status .PHONY: all clean install uninstall diff --git a/src/gf2-start.cpp b/src/gf2-start.cpp new file mode 100644 index 0000000..e545bb7 --- /dev/null +++ b/src/gf2-start.cpp @@ -0,0 +1,63 @@ +/* GF2 Start Command - Version 2.0 for Debian Linux + Copyright (c) 2018-2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include "error.h" +#include "gf2device.h" + +int main(int argc, char **argv) +{ + int err, errlvl = EXIT_SUCCESS; + GF2Device device; + if (argc < 2) { // If the program was called without arguments + err = device.open(); // Open a device and get the device handle + } else { // Serial number was specified as argument + err = device.open(argv[1]); // Open the device having the specified serial number, and get the device handle + } + if (err == GF2Device::SUCCESS) { // Device was successfully opened + int errcnt = 0; + std::string errstr; + device.start(errcnt, errstr); // Start (or restart) the waveform generation + if (errcnt > 0) { // In case of error + if (device.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } else { // Operation successful + std::cout << "Waveform generation started." << std::endl; + } + device.close(); + } else { // Failed to open device + if (err == GF2Device::ERROR_INIT) { // Failed to initialize libusb + std::cerr << "Error: Could not initialize libusb\n"; + } else if (err == GF2Device::ERROR_NOT_FOUND) { // Failed to find device + std::cerr << "Error: Could not find device.\n"; + } else if (err == GF2Device::ERROR_BUSY) { // Failed to claim interface + std::cerr << "Error: Device is currently unavailable.\n"; + } + errlvl = EXIT_FAILURE; + } + return errlvl; +} From 36b73a0d0feaf1f68d710dbbdb38fcdd879817b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Fri, 22 Jul 2022 09:10:59 +0100 Subject: [PATCH 42/62] Add files via upload --- src/gf2-stop.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/gf2-stop.cpp diff --git a/src/gf2-stop.cpp b/src/gf2-stop.cpp new file mode 100644 index 0000000..31546cf --- /dev/null +++ b/src/gf2-stop.cpp @@ -0,0 +1,63 @@ +/* GF2 Stop Command - Version 2.0 for Debian Linux + Copyright (c) 2018-2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include "error.h" +#include "gf2device.h" + +int main(int argc, char **argv) +{ + int err, errlvl = EXIT_SUCCESS; + GF2Device device; + if (argc < 2) { // If the program was called without arguments + err = device.open(); // Open a device and get the device handle + } else { // Serial number was specified as argument + err = device.open(argv[1]); // Open the device having the specified serial number, and get the device handle + } + if (err == GF2Device::SUCCESS) { // Device was successfully opened + int errcnt = 0; + std::string errstr; + device.stop(errcnt, errstr); // Stop the waveform generation + if (errcnt > 0) { // In case of error + if (device.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } else { // Operation successful + std::cout << "Waveform generation stopped." << std::endl; + } + device.close(); + } else { // Failed to open device + if (err == GF2Device::ERROR_INIT) { // Failed to initialize libusb + std::cerr << "Error: Could not initialize libusb\n"; + } else if (err == GF2Device::ERROR_NOT_FOUND) { // Failed to find device + std::cerr << "Error: Could not find device.\n"; + } else if (err == GF2Device::ERROR_BUSY) { // Failed to claim interface + std::cerr << "Error: Device is currently unavailable.\n"; + } + errlvl = EXIT_FAILURE; + } + return errlvl; +} From c5fb18f5f3aef9fa79f6e870bf2462ac548c2f50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Fri, 22 Jul 2022 09:11:27 +0100 Subject: [PATCH 43/62] Add files via upload --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 99ddea3..be450b1 100644 --- a/src/Makefile +++ b/src/Makefile @@ -25,7 +25,7 @@ CXXFLAGS = -O2 -std=c++11 -Wall -pedantic LDFLAGS = -s LDLIBS = -lusb-1.0 OBJECTS = cp2130.o error.o gf2device.o libusb-extra.o -TARGETS = gf2-clear gf2-info gf2-list gf2-lockotp gf2-reset gf2-start gf2-status +TARGETS = gf2-clear gf2-info gf2-list gf2-lockotp gf2-reset gf2-start gf2-status gf2-stop .PHONY: all clean install uninstall From 0f54397d13bb80eeb85afef8f55589de515ccd8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Fri, 22 Jul 2022 18:33:48 +0100 Subject: [PATCH 44/62] Add files via upload --- src/Makefile | 2 +- src/gf2-selfreq0.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++++ src/gf2-selfreq1.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 src/gf2-selfreq0.cpp create mode 100644 src/gf2-selfreq1.cpp diff --git a/src/Makefile b/src/Makefile index be450b1..20b2bf8 100644 --- a/src/Makefile +++ b/src/Makefile @@ -25,7 +25,7 @@ CXXFLAGS = -O2 -std=c++11 -Wall -pedantic LDFLAGS = -s LDLIBS = -lusb-1.0 OBJECTS = cp2130.o error.o gf2device.o libusb-extra.o -TARGETS = gf2-clear gf2-info gf2-list gf2-lockotp gf2-reset gf2-start gf2-status gf2-stop +TARGETS = gf2-clear gf2-info gf2-list gf2-lockotp gf2-reset gf2-selfreq0 gf2-selfreq1 gf2-start gf2-status gf2-stop .PHONY: all clean install uninstall diff --git a/src/gf2-selfreq0.cpp b/src/gf2-selfreq0.cpp new file mode 100644 index 0000000..c47de48 --- /dev/null +++ b/src/gf2-selfreq0.cpp @@ -0,0 +1,63 @@ +/* GF2 SelFreq0 Command - Version 2.0 for Debian Linux + Copyright (c) 2018-2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include "error.h" +#include "gf2device.h" + +int main(int argc, char **argv) +{ + int err, errlvl = EXIT_SUCCESS; + GF2Device device; + if (argc < 2) { // If the program was called without arguments + err = device.open(); // Open a device and get the device handle + } else { // Serial number was specified as argument + err = device.open(argv[1]); // Open the device having the specified serial number, and get the device handle + } + if (err == GF2Device::SUCCESS) { // Device was successfully opened + int errcnt = 0; + std::string errstr; + device.selectFrequency(GF2Device::FSEL0, errcnt, errstr); // Select frequency 0 as active + if (errcnt > 0) { // In case of error + if (device.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } else { // Operation successful + std::cout << "Frequency 0 selected." << std::endl; + } + device.close(); + } else { // Failed to open device + if (err == GF2Device::ERROR_INIT) { // Failed to initialize libusb + std::cerr << "Error: Could not initialize libusb\n"; + } else if (err == GF2Device::ERROR_NOT_FOUND) { // Failed to find device + std::cerr << "Error: Could not find device.\n"; + } else if (err == GF2Device::ERROR_BUSY) { // Failed to claim interface + std::cerr << "Error: Device is currently unavailable.\n"; + } + errlvl = EXIT_FAILURE; + } + return errlvl; +} diff --git a/src/gf2-selfreq1.cpp b/src/gf2-selfreq1.cpp new file mode 100644 index 0000000..20ff1e0 --- /dev/null +++ b/src/gf2-selfreq1.cpp @@ -0,0 +1,63 @@ +/* GF2 SelFreq1 Command - Version 2.0 for Debian Linux + Copyright (c) 2018-2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include "error.h" +#include "gf2device.h" + +int main(int argc, char **argv) +{ + int err, errlvl = EXIT_SUCCESS; + GF2Device device; + if (argc < 2) { // If the program was called without arguments + err = device.open(); // Open a device and get the device handle + } else { // Serial number was specified as argument + err = device.open(argv[1]); // Open the device having the specified serial number, and get the device handle + } + if (err == GF2Device::SUCCESS) { // Device was successfully opened + int errcnt = 0; + std::string errstr; + device.selectFrequency(GF2Device::FSEL1, errcnt, errstr); // Select frequency 1 as active + if (errcnt > 0) { // In case of error + if (device.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } else { // Operation successful + std::cout << "Frequency 1 selected." << std::endl; + } + device.close(); + } else { // Failed to open device + if (err == GF2Device::ERROR_INIT) { // Failed to initialize libusb + std::cerr << "Error: Could not initialize libusb\n"; + } else if (err == GF2Device::ERROR_NOT_FOUND) { // Failed to find device + std::cerr << "Error: Could not find device.\n"; + } else if (err == GF2Device::ERROR_BUSY) { // Failed to claim interface + std::cerr << "Error: Device is currently unavailable.\n"; + } + errlvl = EXIT_FAILURE; + } + return errlvl; +} From 29d73ebb83ce9f16753c9581a887266b50c34e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Fri, 22 Jul 2022 19:09:36 +0100 Subject: [PATCH 45/62] Add files via upload --- src/Makefile | 2 +- src/gf2-selphase0.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++ src/gf2-selphase1.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 src/gf2-selphase0.cpp create mode 100644 src/gf2-selphase1.cpp diff --git a/src/Makefile b/src/Makefile index 20b2bf8..e5fe57f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -25,7 +25,7 @@ CXXFLAGS = -O2 -std=c++11 -Wall -pedantic LDFLAGS = -s LDLIBS = -lusb-1.0 OBJECTS = cp2130.o error.o gf2device.o libusb-extra.o -TARGETS = gf2-clear gf2-info gf2-list gf2-lockotp gf2-reset gf2-selfreq0 gf2-selfreq1 gf2-start gf2-status gf2-stop +TARGETS = gf2-clear gf2-info gf2-list gf2-lockotp gf2-reset gf2-selfreq0 gf2-selfreq1 gf2-selphase0 gf2-selphase1 gf2-start gf2-status gf2-stop .PHONY: all clean install uninstall diff --git a/src/gf2-selphase0.cpp b/src/gf2-selphase0.cpp new file mode 100644 index 0000000..22d2598 --- /dev/null +++ b/src/gf2-selphase0.cpp @@ -0,0 +1,63 @@ +/* GF2 SelPhase0 Command - Version 2.0 for Debian Linux + Copyright (c) 2018-2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include "error.h" +#include "gf2device.h" + +int main(int argc, char **argv) +{ + int err, errlvl = EXIT_SUCCESS; + GF2Device device; + if (argc < 2) { // If the program was called without arguments + err = device.open(); // Open a device and get the device handle + } else { // Serial number was specified as argument + err = device.open(argv[1]); // Open the device having the specified serial number, and get the device handle + } + if (err == GF2Device::SUCCESS) { // Device was successfully opened + int errcnt = 0; + std::string errstr; + device.selectPhase(GF2Device::PSEL0, errcnt, errstr); // Select phase 0 as active + if (errcnt > 0) { // In case of error + if (device.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } else { // Operation successful + std::cout << "Phase 0 selected." << std::endl; + } + device.close(); + } else { // Failed to open device + if (err == GF2Device::ERROR_INIT) { // Failed to initialize libusb + std::cerr << "Error: Could not initialize libusb\n"; + } else if (err == GF2Device::ERROR_NOT_FOUND) { // Failed to find device + std::cerr << "Error: Could not find device.\n"; + } else if (err == GF2Device::ERROR_BUSY) { // Failed to claim interface + std::cerr << "Error: Device is currently unavailable.\n"; + } + errlvl = EXIT_FAILURE; + } + return errlvl; +} diff --git a/src/gf2-selphase1.cpp b/src/gf2-selphase1.cpp new file mode 100644 index 0000000..4e1dfb9 --- /dev/null +++ b/src/gf2-selphase1.cpp @@ -0,0 +1,63 @@ +/* GF2 SelPhase1 Command - Version 2.0 for Debian Linux + Copyright (c) 2018-2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include "error.h" +#include "gf2device.h" + +int main(int argc, char **argv) +{ + int err, errlvl = EXIT_SUCCESS; + GF2Device device; + if (argc < 2) { // If the program was called without arguments + err = device.open(); // Open a device and get the device handle + } else { // Serial number was specified as argument + err = device.open(argv[1]); // Open the device having the specified serial number, and get the device handle + } + if (err == GF2Device::SUCCESS) { // Device was successfully opened + int errcnt = 0; + std::string errstr; + device.selectPhase(GF2Device::PSEL1, errcnt, errstr); // Select phase 1 as active + if (errcnt > 0) { // In case of error + if (device.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } else { // Operation successful + std::cout << "Phase 1 selected." << std::endl; + } + device.close(); + } else { // Failed to open device + if (err == GF2Device::ERROR_INIT) { // Failed to initialize libusb + std::cerr << "Error: Could not initialize libusb\n"; + } else if (err == GF2Device::ERROR_NOT_FOUND) { // Failed to find device + std::cerr << "Error: Could not find device.\n"; + } else if (err == GF2Device::ERROR_BUSY) { // Failed to claim interface + std::cerr << "Error: Device is currently unavailable.\n"; + } + errlvl = EXIT_FAILURE; + } + return errlvl; +} From d90b17c294140ed838c96fd7fe04a8755d2282ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Fri, 22 Jul 2022 21:45:39 +0100 Subject: [PATCH 46/62] Add files via upload --- src/Makefile | 4 +-- src/gf2-amp.cpp | 83 ++++++++++++++++++++++++++++++++++++++++++++++ src/gf2-amp50.cpp | 84 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 169 insertions(+), 2 deletions(-) create mode 100644 src/gf2-amp.cpp create mode 100644 src/gf2-amp50.cpp diff --git a/src/Makefile b/src/Makefile index e5fe57f..269c086 100644 --- a/src/Makefile +++ b/src/Makefile @@ -24,8 +24,8 @@ CXX = g++ CXXFLAGS = -O2 -std=c++11 -Wall -pedantic LDFLAGS = -s LDLIBS = -lusb-1.0 -OBJECTS = cp2130.o error.o gf2device.o libusb-extra.o -TARGETS = gf2-clear gf2-info gf2-list gf2-lockotp gf2-reset gf2-selfreq0 gf2-selfreq1 gf2-selphase0 gf2-selphase1 gf2-start gf2-status gf2-stop +OBJECTS = cp2130.o error.o gf2device.o libusb-extra.o utils.o +TARGETS = gf2-amp gf2-amp50 gf2-clear gf2-info gf2-list gf2-lockotp gf2-reset gf2-selfreq0 gf2-selfreq1 gf2-selphase0 gf2-selphase1 gf2-start gf2-status gf2-stop .PHONY: all clean install uninstall diff --git a/src/gf2-amp.cpp b/src/gf2-amp.cpp new file mode 100644 index 0000000..ba43800 --- /dev/null +++ b/src/gf2-amp.cpp @@ -0,0 +1,83 @@ +/* GF2 Amp Command - Version 2.0 for Debian Linux + Copyright (c) 2018-2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include +#include "error.h" +#include "gf2device.h" +#include "utils.h" + +// Global variables +int EXIT_USERERR = 2; // Exit status value to indicate a command usage error + +int main(int argc, char **argv) +{ + int err, errlvl = EXIT_SUCCESS; + if (argc < 2) { // If the program was called without arguments + std::cerr << "Error: Missing argument.\nUsage: gf2-amp AMPLITUDE(Vpp)\n"; + errlvl = EXIT_USERERR; + } else if (!Utils::isNumber(argv[1])) { // If the argument string doesn't constitute a valid number + std::cerr << "Error: Argument is not a valid number.\n"; + errlvl = EXIT_USERERR; + } else { // Serial number was specified as argument + float amplitude = std::atof(argv[1]); // Convert the argument string into a floating point number + if (amplitude < GF2Device::AMPLITUDE_MIN || amplitude > GF2Device::AMPLITUDE_MAX) { // If the obtained amplitude value (in Vpp) after conversion is lesser than "AMPLITUDE_MIN" [0] or greater than "AMPLITUDE_MAX" [8] + std::cerr << "Error: Amplitude should be between 0 and 8Vpp.\n"; + errlvl = EXIT_USERERR; + } else { + GF2Device device; + if (argc < 3) { // If no serial number was specified + err = device.open(); // Open a device and get the device handle + } else { // Serial number was specified as a second (optional) argument + err = device.open(argv[2]); // Open the device having the specified serial number, and get the device handle + } + if (err == GF2Device::SUCCESS) { // Device was successfully opened + int errcnt = 0; + std::string errstr; + device.setupChannel1(errcnt, errstr); // Setup channel 1 + device.setAmplitude(amplitude, errcnt, errstr); // Set the amplitude of the generated signal to the given value + if (errcnt > 0) { // In case of error + if (device.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } else { // Operation successful + std::cout << "Amplitude set to " << std::fixed << std::setprecision(2) << GF2Device::expectedAmplitude(amplitude) << "Vpp." << std::endl; // Print the set amplitude + } + device.close(); + } else { // Failed to open device + if (err == GF2Device::ERROR_INIT) { // Failed to initialize libusb + std::cerr << "Error: Could not initialize libusb\n"; + } else if (err == GF2Device::ERROR_NOT_FOUND) { // Failed to find device + std::cerr << "Error: Could not find device.\n"; + } else if (err == GF2Device::ERROR_BUSY) { // Failed to claim interface + std::cerr << "Error: Device is currently unavailable.\n"; + } + errlvl = EXIT_FAILURE; + } + } + } + return errlvl; +} diff --git a/src/gf2-amp50.cpp b/src/gf2-amp50.cpp new file mode 100644 index 0000000..684bf0e --- /dev/null +++ b/src/gf2-amp50.cpp @@ -0,0 +1,84 @@ +/* GF2 Amp50 Command - Version 2.0 for Debian Linux + Copyright (c) 2018-2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include +#include "error.h" +#include "gf2device.h" +#include "utils.h" + +// Global variables +int EXIT_USERERR = 2; // Exit status value to indicate a command usage error + +int main(int argc, char **argv) +{ + int err, errlvl = EXIT_SUCCESS; + if (argc < 2) { // If the program was called without arguments + std::cerr << "Error: Missing argument.\nUsage: gf2-amp50 AMPLITUDE(Vpp)\n"; + errlvl = EXIT_USERERR; + } else if (!Utils::isNumber(argv[1])) { // If the argument string doesn't constitute a valid number + std::cerr << "Error: Argument is not a valid number.\n"; + errlvl = EXIT_USERERR; + } else { // Serial number was specified as argument + float amplitude = 2 * std::atof(argv[1]); // Convert the argument string into a floating point number, and multiply it by 2 in order to compensate the effect of the 50Ω load + if (amplitude < GF2Device::AMPLITUDE_MIN || amplitude > GF2Device::AMPLITUDE_MAX) { // If the obtained amplitude value (in Vpp) after conversion is lesser than "AMPLITUDE_MIN" [0] or greater than "AMPLITUDE_MAX" [8] + std::cerr << "Error: Amplitude should be between 0 and 4Vpp.\n"; + errlvl = EXIT_USERERR; + } else { + GF2Device device; + if (argc < 3) { // If no serial number was specified + err = device.open(); // Open a device and get the device handle + } else { // Serial number was specified as a second (optional) argument + err = device.open(argv[2]); // Open the device having the specified serial number, and get the device handle + } + if (err == GF2Device::SUCCESS) { // Device was successfully opened + int errcnt = 0; + std::string errstr; + device.setupChannel1(errcnt, errstr); // Setup channel 1 + device.setAmplitude(amplitude, errcnt, errstr); // Set the amplitude of the generated signal to the given value + if (errcnt > 0) { // In case of error + if (device.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } else { // Operation successful + float finalAmplitude = GF2Device::expectedAmplitude(amplitude); + std::cout << "Amplitude set to " << std::fixed << std::setprecision(2) << finalAmplitude / 2 << "Vpp (" << finalAmplitude << "Vpp unterminated)." << std::endl; // Print the set amplitude + } + device.close(); + } else { // Failed to open device + if (err == GF2Device::ERROR_INIT) { // Failed to initialize libusb + std::cerr << "Error: Could not initialize libusb\n"; + } else if (err == GF2Device::ERROR_NOT_FOUND) { // Failed to find device + std::cerr << "Error: Could not find device.\n"; + } else if (err == GF2Device::ERROR_BUSY) { // Failed to claim interface + std::cerr << "Error: Device is currently unavailable.\n"; + } + errlvl = EXIT_FAILURE; + } + } + } + return errlvl; +} From 1d8b55f87d5ed50214e580d68717618ed7d5ecc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Fri, 22 Jul 2022 23:18:39 +0100 Subject: [PATCH 47/62] Add files via upload --- src/gf2-amp.cpp | 2 +- src/gf2-amp50.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gf2-amp.cpp b/src/gf2-amp.cpp index ba43800..45f65ca 100644 --- a/src/gf2-amp.cpp +++ b/src/gf2-amp.cpp @@ -50,7 +50,7 @@ int main(int argc, char **argv) err = device.open(); // Open a device and get the device handle } else { // Serial number was specified as a second (optional) argument err = device.open(argv[2]); // Open the device having the specified serial number, and get the device handle - } + } if (err == GF2Device::SUCCESS) { // Device was successfully opened int errcnt = 0; std::string errstr; diff --git a/src/gf2-amp50.cpp b/src/gf2-amp50.cpp index 684bf0e..89af89d 100644 --- a/src/gf2-amp50.cpp +++ b/src/gf2-amp50.cpp @@ -50,7 +50,7 @@ int main(int argc, char **argv) err = device.open(); // Open a device and get the device handle } else { // Serial number was specified as a second (optional) argument err = device.open(argv[2]); // Open the device having the specified serial number, and get the device handle - } + } if (err == GF2Device::SUCCESS) { // Device was successfully opened int errcnt = 0; std::string errstr; From 071758e1f09dada2d0b1dc8e4cf3f8daedc7ac35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Fri, 22 Jul 2022 23:44:57 +0100 Subject: [PATCH 48/62] Add files via upload --- src/Makefile | 2 +- src/gf2-freq0.cpp | 83 +++++++++++++++++++++++++++++++++++++++++++++++ src/gf2-freq1.cpp | 83 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 src/gf2-freq0.cpp create mode 100644 src/gf2-freq1.cpp diff --git a/src/Makefile b/src/Makefile index 269c086..07df652 100644 --- a/src/Makefile +++ b/src/Makefile @@ -25,7 +25,7 @@ CXXFLAGS = -O2 -std=c++11 -Wall -pedantic LDFLAGS = -s LDLIBS = -lusb-1.0 OBJECTS = cp2130.o error.o gf2device.o libusb-extra.o utils.o -TARGETS = gf2-amp gf2-amp50 gf2-clear gf2-info gf2-list gf2-lockotp gf2-reset gf2-selfreq0 gf2-selfreq1 gf2-selphase0 gf2-selphase1 gf2-start gf2-status gf2-stop +TARGETS = gf2-amp gf2-amp50 gf2-clear gf2-freq0 gf2-freq1 gf2-info gf2-list gf2-lockotp gf2-reset gf2-selfreq0 gf2-selfreq1 gf2-selphase0 gf2-selphase1 gf2-start gf2-status gf2-stop .PHONY: all clean install uninstall diff --git a/src/gf2-freq0.cpp b/src/gf2-freq0.cpp new file mode 100644 index 0000000..4c92c73 --- /dev/null +++ b/src/gf2-freq0.cpp @@ -0,0 +1,83 @@ +/* GF2 Freq0 Command - Version 2.0 for Debian Linux + Copyright (c) 2018-2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include +#include "error.h" +#include "gf2device.h" +#include "utils.h" + +// Global variables +int EXIT_USERERR = 2; // Exit status value to indicate a command usage error + +int main(int argc, char **argv) +{ + int err, errlvl = EXIT_SUCCESS; + if (argc < 2) { // If the program was called without arguments + std::cerr << "Error: Missing argument.\nUsage: gf2-freq0 FREQUENCY(KHz)\n"; + errlvl = EXIT_USERERR; + } else if (!Utils::isNumber(argv[1])) { // If the argument string doesn't constitute a valid number + std::cerr << "Error: Argument is not a valid number.\n"; + errlvl = EXIT_USERERR; + } else { // Serial number was specified as argument + float frequency = std::atof(argv[1]); // Convert the argument string into a floating point number + if (frequency < GF2Device::FREQUENCY_MIN || frequency > GF2Device::FREQUENCY_MAX) { // If the obtained frequency value (in KHz) after conversion is lesser than "FREQUENCY_MIN" [0] or greater than "FREQUENCY_MAX" [40000] + std::cerr << "Error: Frequency should be between 0 and 40000KHz.\n"; + errlvl = EXIT_USERERR; + } else { + GF2Device device; + if (argc < 3) { // If no serial number was specified + err = device.open(); // Open a device and get the device handle + } else { // Serial number was specified as a second (optional) argument + err = device.open(argv[2]); // Open the device having the specified serial number, and get the device handle + } + if (err == GF2Device::SUCCESS) { // Device was successfully opened + int errcnt = 0; + std::string errstr; + device.setupChannel0(errcnt, errstr); // Setup channel 0 + device.setFrequency(GF2Device::FSEL0, frequency, errcnt, errstr); // Set frequency 0 to the given value + if (errcnt > 0) { // In case of error + if (device.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } else { // Operation successful + std::cout << "Frequency 0 set to " << std::fixed << std::setprecision(4) << GF2Device::expectedFrequency(frequency) << "KHz." << std::endl; // Print the set frequency + } + device.close(); + } else { // Failed to open device + if (err == GF2Device::ERROR_INIT) { // Failed to initialize libusb + std::cerr << "Error: Could not initialize libusb\n"; + } else if (err == GF2Device::ERROR_NOT_FOUND) { // Failed to find device + std::cerr << "Error: Could not find device.\n"; + } else if (err == GF2Device::ERROR_BUSY) { // Failed to claim interface + std::cerr << "Error: Device is currently unavailable.\n"; + } + errlvl = EXIT_FAILURE; + } + } + } + return errlvl; +} diff --git a/src/gf2-freq1.cpp b/src/gf2-freq1.cpp new file mode 100644 index 0000000..7b1c2b1 --- /dev/null +++ b/src/gf2-freq1.cpp @@ -0,0 +1,83 @@ +/* GF2 Freq1 Command - Version 2.0 for Debian Linux + Copyright (c) 2018-2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include +#include "error.h" +#include "gf2device.h" +#include "utils.h" + +// Global variables +int EXIT_USERERR = 2; // Exit status value to indicate a command usage error + +int main(int argc, char **argv) +{ + int err, errlvl = EXIT_SUCCESS; + if (argc < 2) { // If the program was called without arguments + std::cerr << "Error: Missing argument.\nUsage: gf2-freq1 FREQUENCY(KHz)\n"; + errlvl = EXIT_USERERR; + } else if (!Utils::isNumber(argv[1])) { // If the argument string doesn't constitute a valid number + std::cerr << "Error: Argument is not a valid number.\n"; + errlvl = EXIT_USERERR; + } else { // Serial number was specified as argument + float frequency = std::atof(argv[1]); // Convert the argument string into a floating point number + if (frequency < GF2Device::FREQUENCY_MIN || frequency > GF2Device::FREQUENCY_MAX) { // If the obtained frequency value (in KHz) after conversion is lesser than "FREQUENCY_MIN" [0] or greater than "FREQUENCY_MAX" [40000] + std::cerr << "Error: Frequency should be between 0 and 40000KHz.\n"; + errlvl = EXIT_USERERR; + } else { + GF2Device device; + if (argc < 3) { // If no serial number was specified + err = device.open(); // Open a device and get the device handle + } else { // Serial number was specified as a second (optional) argument + err = device.open(argv[2]); // Open the device having the specified serial number, and get the device handle + } + if (err == GF2Device::SUCCESS) { // Device was successfully opened + int errcnt = 0; + std::string errstr; + device.setupChannel0(errcnt, errstr); // Setup channel 0 + device.setFrequency(GF2Device::FSEL1, frequency, errcnt, errstr); // Set frequency 1 to the given value + if (errcnt > 0) { // In case of error + if (device.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } else { // Operation successful + std::cout << "Frequency 1 set to " << std::fixed << std::setprecision(4) << GF2Device::expectedFrequency(frequency) << "KHz." << std::endl; // Print the set frequency + } + device.close(); + } else { // Failed to open device + if (err == GF2Device::ERROR_INIT) { // Failed to initialize libusb + std::cerr << "Error: Could not initialize libusb\n"; + } else if (err == GF2Device::ERROR_NOT_FOUND) { // Failed to find device + std::cerr << "Error: Could not find device.\n"; + } else if (err == GF2Device::ERROR_BUSY) { // Failed to claim interface + std::cerr << "Error: Device is currently unavailable.\n"; + } + errlvl = EXIT_FAILURE; + } + } + } + return errlvl; +} From 1ba857d1c408fa90cc8cd42390761b27480499d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Sat, 23 Jul 2022 00:34:38 +0100 Subject: [PATCH 49/62] Add files via upload --- src/Makefile | 2 +- src/gf2-freq.cpp | 84 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 src/gf2-freq.cpp diff --git a/src/Makefile b/src/Makefile index 07df652..3ffc711 100644 --- a/src/Makefile +++ b/src/Makefile @@ -25,7 +25,7 @@ CXXFLAGS = -O2 -std=c++11 -Wall -pedantic LDFLAGS = -s LDLIBS = -lusb-1.0 OBJECTS = cp2130.o error.o gf2device.o libusb-extra.o utils.o -TARGETS = gf2-amp gf2-amp50 gf2-clear gf2-freq0 gf2-freq1 gf2-info gf2-list gf2-lockotp gf2-reset gf2-selfreq0 gf2-selfreq1 gf2-selphase0 gf2-selphase1 gf2-start gf2-status gf2-stop +TARGETS = gf2-amp gf2-amp50 gf2-clear gf2-freq gf2-freq0 gf2-freq1 gf2-info gf2-list gf2-lockotp gf2-reset gf2-selfreq0 gf2-selfreq1 gf2-selphase0 gf2-selphase1 gf2-start gf2-status gf2-stop .PHONY: all clean install uninstall diff --git a/src/gf2-freq.cpp b/src/gf2-freq.cpp new file mode 100644 index 0000000..b86a9d7 --- /dev/null +++ b/src/gf2-freq.cpp @@ -0,0 +1,84 @@ +/* GF2 Freq Command - Version 2.0 for Debian Linux + Copyright (c) 2018-2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include +#include "error.h" +#include "gf2device.h" +#include "utils.h" + +// Global variables +int EXIT_USERERR = 2; // Exit status value to indicate a command usage error + +int main(int argc, char **argv) +{ + int err, errlvl = EXIT_SUCCESS; + if (argc < 2) { // If the program was called without arguments + std::cerr << "Error: Missing argument.\nUsage: gf2-freq FREQUENCY(KHz)\n"; + errlvl = EXIT_USERERR; + } else if (!Utils::isNumber(argv[1])) { // If the argument string doesn't constitute a valid number + std::cerr << "Error: Argument is not a valid number.\n"; + errlvl = EXIT_USERERR; + } else { // Serial number was specified as argument + float frequency = std::atof(argv[1]); // Convert the argument string into a floating point number + if (frequency < GF2Device::FREQUENCY_MIN || frequency > GF2Device::FREQUENCY_MAX) { // If the obtained frequency value (in KHz) after conversion is lesser than "FREQUENCY_MIN" [0] or greater than "FREQUENCY_MAX" [40000] + std::cerr << "Error: Frequency should be between 0 and 40000KHz.\n"; + errlvl = EXIT_USERERR; + } else { + GF2Device device; + if (argc < 3) { // If no serial number was specified + err = device.open(); // Open a device and get the device handle + } else { // Serial number was specified as a second (optional) argument + err = device.open(argv[2]); // Open the device having the specified serial number, and get the device handle + } + if (err == GF2Device::SUCCESS) { // Device was successfully opened + int errcnt = 0; + std::string errstr; + bool fsel = device.getFrequencySelection(errcnt, errstr); // Get the current frequency selection + device.setupChannel0(errcnt, errstr); // Setup channel 0 + device.setFrequency(fsel, frequency, errcnt, errstr); // Set the active frequency (frequency 0 or frequency 1, whichever is selected) to the given value + if (errcnt > 0) { // In case of error + if (device.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } else { // Operation successful + std::cout << "Frequency (" << fsel << ") set to " << std::fixed << std::setprecision(4) << GF2Device::expectedFrequency(frequency) << "KHz." << std::endl; // Print the set frequency + } + device.close(); + } else { // Failed to open device + if (err == GF2Device::ERROR_INIT) { // Failed to initialize libusb + std::cerr << "Error: Could not initialize libusb\n"; + } else if (err == GF2Device::ERROR_NOT_FOUND) { // Failed to find device + std::cerr << "Error: Could not find device.\n"; + } else if (err == GF2Device::ERROR_BUSY) { // Failed to claim interface + std::cerr << "Error: Device is currently unavailable.\n"; + } + errlvl = EXIT_FAILURE; + } + } + } + return errlvl; +} From 5c74e03da4842b64c4b89239fb174c6ddc295f08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Sat, 23 Jul 2022 12:22:18 +0100 Subject: [PATCH 50/62] Add files via upload --- src/Makefile | 2 +- src/gf2-phase0.cpp | 78 ++++++++++++++++++++++++++++++++++++++++++++++ src/gf2-phase1.cpp | 78 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 src/gf2-phase0.cpp create mode 100644 src/gf2-phase1.cpp diff --git a/src/Makefile b/src/Makefile index 3ffc711..9ace86a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -25,7 +25,7 @@ CXXFLAGS = -O2 -std=c++11 -Wall -pedantic LDFLAGS = -s LDLIBS = -lusb-1.0 OBJECTS = cp2130.o error.o gf2device.o libusb-extra.o utils.o -TARGETS = gf2-amp gf2-amp50 gf2-clear gf2-freq gf2-freq0 gf2-freq1 gf2-info gf2-list gf2-lockotp gf2-reset gf2-selfreq0 gf2-selfreq1 gf2-selphase0 gf2-selphase1 gf2-start gf2-status gf2-stop +TARGETS = gf2-amp gf2-amp50 gf2-clear gf2-freq gf2-freq0 gf2-freq1 gf2-info gf2-list gf2-lockotp gf2-phase0 gf2-phase1 gf2-reset gf2-selfreq0 gf2-selfreq1 gf2-selphase0 gf2-selphase1 gf2-start gf2-status gf2-stop .PHONY: all clean install uninstall diff --git a/src/gf2-phase0.cpp b/src/gf2-phase0.cpp new file mode 100644 index 0000000..06b3c43 --- /dev/null +++ b/src/gf2-phase0.cpp @@ -0,0 +1,78 @@ +/* GF2 Phase0 Command - Version 2.0 for Debian Linux + Copyright (c) 2018-2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include +#include "error.h" +#include "gf2device.h" +#include "utils.h" + +// Global variables +int EXIT_USERERR = 2; // Exit status value to indicate a command usage error + +int main(int argc, char **argv) +{ + int err, errlvl = EXIT_SUCCESS; + if (argc < 2) { // If the program was called without arguments + std::cerr << "Error: Missing argument.\nUsage: gf2-phase0 PHASE(°)\n"; + errlvl = EXIT_USERERR; + } else if (!Utils::isNumber(argv[1])) { // If the argument string doesn't constitute a valid number + std::cerr << "Error: Argument is not a valid number.\n"; + errlvl = EXIT_USERERR; + } else { // Serial number was specified as argument + float phase = std::atof(argv[1]); // Convert the argument string into a floating point number + GF2Device device; + if (argc < 3) { // If no serial number was specified + err = device.open(); // Open a device and get the device handle + } else { // Serial number was specified as a second (optional) argument + err = device.open(argv[2]); // Open the device having the specified serial number, and get the device handle + } + if (err == GF2Device::SUCCESS) { // Device was successfully opened + int errcnt = 0; + std::string errstr; + device.setupChannel0(errcnt, errstr); // Setup channel 0 + device.setPhase(GF2Device::PSEL0, phase, errcnt, errstr); // Set phase 0 to the given value + if (errcnt > 0) { // In case of error + if (device.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } else { // Operation successful + std::cout << "Phase 0 set to " << std::fixed << std::setprecision(2) << GF2Device::expectedPhase(phase) << "°." << std::endl; // Print the set phase + } + device.close(); + } else { // Failed to open device + if (err == GF2Device::ERROR_INIT) { // Failed to initialize libusb + std::cerr << "Error: Could not initialize libusb\n"; + } else if (err == GF2Device::ERROR_NOT_FOUND) { // Failed to find device + std::cerr << "Error: Could not find device.\n"; + } else if (err == GF2Device::ERROR_BUSY) { // Failed to claim interface + std::cerr << "Error: Device is currently unavailable.\n"; + } + errlvl = EXIT_FAILURE; + } + } + return errlvl; +} diff --git a/src/gf2-phase1.cpp b/src/gf2-phase1.cpp new file mode 100644 index 0000000..eebabfa --- /dev/null +++ b/src/gf2-phase1.cpp @@ -0,0 +1,78 @@ +/* GF2 Phase1 Command - Version 2.0 for Debian Linux + Copyright (c) 2018-2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include +#include "error.h" +#include "gf2device.h" +#include "utils.h" + +// Global variables +int EXIT_USERERR = 2; // Exit status value to indicate a command usage error + +int main(int argc, char **argv) +{ + int err, errlvl = EXIT_SUCCESS; + if (argc < 2) { // If the program was called without arguments + std::cerr << "Error: Missing argument.\nUsage: gf2-phase1 PHASE(°)\n"; + errlvl = EXIT_USERERR; + } else if (!Utils::isNumber(argv[1])) { // If the argument string doesn't constitute a valid number + std::cerr << "Error: Argument is not a valid number.\n"; + errlvl = EXIT_USERERR; + } else { // Serial number was specified as argument + float phase = std::atof(argv[1]); // Convert the argument string into a floating point number + GF2Device device; + if (argc < 3) { // If no serial number was specified + err = device.open(); // Open a device and get the device handle + } else { // Serial number was specified as a second (optional) argument + err = device.open(argv[2]); // Open the device having the specified serial number, and get the device handle + } + if (err == GF2Device::SUCCESS) { // Device was successfully opened + int errcnt = 0; + std::string errstr; + device.setupChannel0(errcnt, errstr); // Setup channel 0 + device.setPhase(GF2Device::PSEL1, phase, errcnt, errstr); // Set phase 1 to the given value + if (errcnt > 0) { // In case of error + if (device.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } else { // Operation successful + std::cout << "Phase 1 set to " << std::fixed << std::setprecision(2) << GF2Device::expectedPhase(phase) << "°." << std::endl; // Print the set phase + } + device.close(); + } else { // Failed to open device + if (err == GF2Device::ERROR_INIT) { // Failed to initialize libusb + std::cerr << "Error: Could not initialize libusb\n"; + } else if (err == GF2Device::ERROR_NOT_FOUND) { // Failed to find device + std::cerr << "Error: Could not find device.\n"; + } else if (err == GF2Device::ERROR_BUSY) { // Failed to claim interface + std::cerr << "Error: Device is currently unavailable.\n"; + } + errlvl = EXIT_FAILURE; + } + } + return errlvl; +} From a6019ef785d821c0b3e7c1a70358dd3132ea97f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Sat, 23 Jul 2022 12:58:47 +0100 Subject: [PATCH 51/62] Add files via upload --- src/Makefile | 2 +- src/gf2-phase.cpp | 79 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 src/gf2-phase.cpp diff --git a/src/Makefile b/src/Makefile index 9ace86a..9e8f38e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -25,7 +25,7 @@ CXXFLAGS = -O2 -std=c++11 -Wall -pedantic LDFLAGS = -s LDLIBS = -lusb-1.0 OBJECTS = cp2130.o error.o gf2device.o libusb-extra.o utils.o -TARGETS = gf2-amp gf2-amp50 gf2-clear gf2-freq gf2-freq0 gf2-freq1 gf2-info gf2-list gf2-lockotp gf2-phase0 gf2-phase1 gf2-reset gf2-selfreq0 gf2-selfreq1 gf2-selphase0 gf2-selphase1 gf2-start gf2-status gf2-stop +TARGETS = gf2-amp gf2-amp50 gf2-clear gf2-freq gf2-freq0 gf2-freq1 gf2-info gf2-list gf2-lockotp gf2-phase gf2-phase0 gf2-phase1 gf2-reset gf2-selfreq0 gf2-selfreq1 gf2-selphase0 gf2-selphase1 gf2-start gf2-status gf2-stop .PHONY: all clean install uninstall diff --git a/src/gf2-phase.cpp b/src/gf2-phase.cpp new file mode 100644 index 0000000..f044b69 --- /dev/null +++ b/src/gf2-phase.cpp @@ -0,0 +1,79 @@ +/* GF2 Phase Command - Version 2.0 for Debian Linux + Copyright (c) 2018-2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include +#include "error.h" +#include "gf2device.h" +#include "utils.h" + +// Global variables +int EXIT_USERERR = 2; // Exit status value to indicate a command usage error + +int main(int argc, char **argv) +{ + int err, errlvl = EXIT_SUCCESS; + if (argc < 2) { // If the program was called without arguments + std::cerr << "Error: Missing argument.\nUsage: gf2-phase PHASE(°)\n"; + errlvl = EXIT_USERERR; + } else if (!Utils::isNumber(argv[1])) { // If the argument string doesn't constitute a valid number + std::cerr << "Error: Argument is not a valid number.\n"; + errlvl = EXIT_USERERR; + } else { // Serial number was specified as argument + float phase = std::atof(argv[1]); // Convert the argument string into a floating point number + GF2Device device; + if (argc < 3) { // If no serial number was specified + err = device.open(); // Open a device and get the device handle + } else { // Serial number was specified as a second (optional) argument + err = device.open(argv[2]); // Open the device having the specified serial number, and get the device handle + } + if (err == GF2Device::SUCCESS) { // Device was successfully opened + int errcnt = 0; + std::string errstr; + bool psel = device.getPhaseSelection(errcnt, errstr); // Get the current phase selection + device.setupChannel0(errcnt, errstr); // Setup channel 0 + device.setPhase(psel, phase, errcnt, errstr); // Set the active phase (phase 0 or phase 1, whichever is selected) to the given value + if (errcnt > 0) { // In case of error + if (device.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } else { // Operation successful + std::cout << "Phase (" << psel << ") set to " << std::fixed << std::setprecision(2) << GF2Device::expectedPhase(phase) << "°." << std::endl; // Print the set phase + } + device.close(); + } else { // Failed to open device + if (err == GF2Device::ERROR_INIT) { // Failed to initialize libusb + std::cerr << "Error: Could not initialize libusb\n"; + } else if (err == GF2Device::ERROR_NOT_FOUND) { // Failed to find device + std::cerr << "Error: Could not find device.\n"; + } else if (err == GF2Device::ERROR_BUSY) { // Failed to claim interface + std::cerr << "Error: Device is currently unavailable.\n"; + } + errlvl = EXIT_FAILURE; + } + } + return errlvl; +} From f8f519595ef325ddbfe58dc47bde97b783ebb633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Sat, 23 Jul 2022 20:30:47 +0100 Subject: [PATCH 52/62] Add files via upload --- src/Makefile | 2 +- src/gf2-dacoff.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++++++ src/gf2-dacon.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 src/gf2-dacoff.cpp create mode 100644 src/gf2-dacon.cpp diff --git a/src/Makefile b/src/Makefile index 9e8f38e..fa074c7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -25,7 +25,7 @@ CXXFLAGS = -O2 -std=c++11 -Wall -pedantic LDFLAGS = -s LDLIBS = -lusb-1.0 OBJECTS = cp2130.o error.o gf2device.o libusb-extra.o utils.o -TARGETS = gf2-amp gf2-amp50 gf2-clear gf2-freq gf2-freq0 gf2-freq1 gf2-info gf2-list gf2-lockotp gf2-phase gf2-phase0 gf2-phase1 gf2-reset gf2-selfreq0 gf2-selfreq1 gf2-selphase0 gf2-selphase1 gf2-start gf2-status gf2-stop +TARGETS = gf2-amp gf2-amp50 gf2-clear gf2-dacoff gf2-dacon gf2-freq gf2-freq0 gf2-freq1 gf2-info gf2-list gf2-lockotp gf2-phase gf2-phase0 gf2-phase1 gf2-reset gf2-selfreq0 gf2-selfreq1 gf2-selphase0 gf2-selphase1 gf2-start gf2-status gf2-stop .PHONY: all clean install uninstall diff --git a/src/gf2-dacoff.cpp b/src/gf2-dacoff.cpp new file mode 100644 index 0000000..5c79590 --- /dev/null +++ b/src/gf2-dacoff.cpp @@ -0,0 +1,63 @@ +/* GF2 DACOff Command - Version 2.0 for Debian Linux + Copyright (c) 2018-2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include "error.h" +#include "gf2device.h" + +int main(int argc, char **argv) +{ + int err, errlvl = EXIT_SUCCESS; + GF2Device device; + if (argc < 2) { // If the program was called without arguments + err = device.open(); // Open a device and get the device handle + } else { // Serial number was specified as argument + err = device.open(argv[1]); // Open the device having the specified serial number, and get the device handle + } + if (err == GF2Device::SUCCESS) { // Device was successfully opened + int errcnt = 0; + std::string errstr; + device.setDACEnabled(false, errcnt, errstr); // Disable the DAC that is internal to the AD9834 waveform generator + if (errcnt > 0) { // In case of error + if (device.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } else { // Operation successful + std::cout << "Waveform generator DAC disabled." << std::endl; + } + device.close(); + } else { // Failed to open device + if (err == GF2Device::ERROR_INIT) { // Failed to initialize libusb + std::cerr << "Error: Could not initialize libusb\n"; + } else if (err == GF2Device::ERROR_NOT_FOUND) { // Failed to find device + std::cerr << "Error: Could not find device.\n"; + } else if (err == GF2Device::ERROR_BUSY) { // Failed to claim interface + std::cerr << "Error: Device is currently unavailable.\n"; + } + errlvl = EXIT_FAILURE; + } + return errlvl; +} diff --git a/src/gf2-dacon.cpp b/src/gf2-dacon.cpp new file mode 100644 index 0000000..942065b --- /dev/null +++ b/src/gf2-dacon.cpp @@ -0,0 +1,63 @@ +/* GF2 DACOn Command - Version 2.0 for Debian Linux + Copyright (c) 2018-2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include "error.h" +#include "gf2device.h" + +int main(int argc, char **argv) +{ + int err, errlvl = EXIT_SUCCESS; + GF2Device device; + if (argc < 2) { // If the program was called without arguments + err = device.open(); // Open a device and get the device handle + } else { // Serial number was specified as argument + err = device.open(argv[1]); // Open the device having the specified serial number, and get the device handle + } + if (err == GF2Device::SUCCESS) { // Device was successfully opened + int errcnt = 0; + std::string errstr; + device.setDACEnabled(true, errcnt, errstr); // Enable the DAC that is internal to the AD9834 waveform generator + if (errcnt > 0) { // In case of error + if (device.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } else { // Operation successful + std::cout << "Waveform generator DAC enabled." << std::endl; + } + device.close(); + } else { // Failed to open device + if (err == GF2Device::ERROR_INIT) { // Failed to initialize libusb + std::cerr << "Error: Could not initialize libusb\n"; + } else if (err == GF2Device::ERROR_NOT_FOUND) { // Failed to find device + std::cerr << "Error: Could not find device.\n"; + } else if (err == GF2Device::ERROR_BUSY) { // Failed to claim interface + std::cerr << "Error: Device is currently unavailable.\n"; + } + errlvl = EXIT_FAILURE; + } + return errlvl; +} From e8785cd545298b4da10ebc3bf06e1a005e237352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Sat, 23 Jul 2022 21:25:49 +0100 Subject: [PATCH 53/62] Add files via upload --- src/Makefile | 2 +- src/gf2-clkoff.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++++++ src/gf2-clkon.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 src/gf2-clkoff.cpp create mode 100644 src/gf2-clkon.cpp diff --git a/src/Makefile b/src/Makefile index fa074c7..037b5bf 100644 --- a/src/Makefile +++ b/src/Makefile @@ -25,7 +25,7 @@ CXXFLAGS = -O2 -std=c++11 -Wall -pedantic LDFLAGS = -s LDLIBS = -lusb-1.0 OBJECTS = cp2130.o error.o gf2device.o libusb-extra.o utils.o -TARGETS = gf2-amp gf2-amp50 gf2-clear gf2-dacoff gf2-dacon gf2-freq gf2-freq0 gf2-freq1 gf2-info gf2-list gf2-lockotp gf2-phase gf2-phase0 gf2-phase1 gf2-reset gf2-selfreq0 gf2-selfreq1 gf2-selphase0 gf2-selphase1 gf2-start gf2-status gf2-stop +TARGETS = gf2-amp gf2-amp50 gf2-clear gf2-clkoff gf2-clkon gf2-dacoff gf2-dacon gf2-freq gf2-freq0 gf2-freq1 gf2-info gf2-list gf2-lockotp gf2-phase gf2-phase0 gf2-phase1 gf2-reset gf2-selfreq0 gf2-selfreq1 gf2-selphase0 gf2-selphase1 gf2-start gf2-status gf2-stop .PHONY: all clean install uninstall diff --git a/src/gf2-clkoff.cpp b/src/gf2-clkoff.cpp new file mode 100644 index 0000000..e69cbce --- /dev/null +++ b/src/gf2-clkoff.cpp @@ -0,0 +1,63 @@ +/* GF2 ClkOff Command - Version 2.0 for Debian Linux + Copyright (c) 2018-2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include "error.h" +#include "gf2device.h" + +int main(int argc, char **argv) +{ + int err, errlvl = EXIT_SUCCESS; + GF2Device device; + if (argc < 2) { // If the program was called without arguments + err = device.open(); // Open a device and get the device handle + } else { // Serial number was specified as argument + err = device.open(argv[1]); // Open the device having the specified serial number, and get the device handle + } + if (err == GF2Device::SUCCESS) { // Device was successfully opened + int errcnt = 0; + std::string errstr; + device.setClockEnabled(false, errcnt, errstr); // Disable the synchronous clock + if (errcnt > 0) { // In case of error + if (device.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } else { // Operation successful + std::cout << "Synchronous clock disabled." << std::endl; + } + device.close(); + } else { // Failed to open device + if (err == GF2Device::ERROR_INIT) { // Failed to initialize libusb + std::cerr << "Error: Could not initialize libusb\n"; + } else if (err == GF2Device::ERROR_NOT_FOUND) { // Failed to find device + std::cerr << "Error: Could not find device.\n"; + } else if (err == GF2Device::ERROR_BUSY) { // Failed to claim interface + std::cerr << "Error: Device is currently unavailable.\n"; + } + errlvl = EXIT_FAILURE; + } + return errlvl; +} diff --git a/src/gf2-clkon.cpp b/src/gf2-clkon.cpp new file mode 100644 index 0000000..d7bd44c --- /dev/null +++ b/src/gf2-clkon.cpp @@ -0,0 +1,63 @@ +/* GF2 ClkOn Command - Version 2.0 for Debian Linux + Copyright (c) 2018-2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include "error.h" +#include "gf2device.h" + +int main(int argc, char **argv) +{ + int err, errlvl = EXIT_SUCCESS; + GF2Device device; + if (argc < 2) { // If the program was called without arguments + err = device.open(); // Open a device and get the device handle + } else { // Serial number was specified as argument + err = device.open(argv[1]); // Open the device having the specified serial number, and get the device handle + } + if (err == GF2Device::SUCCESS) { // Device was successfully opened + int errcnt = 0; + std::string errstr; + device.setClockEnabled(true, errcnt, errstr); // Enable the synchronous clock + if (errcnt > 0) { // In case of error + if (device.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } else { // Operation successful + std::cout << "Synchronous clock enabled." << std::endl; + } + device.close(); + } else { // Failed to open device + if (err == GF2Device::ERROR_INIT) { // Failed to initialize libusb + std::cerr << "Error: Could not initialize libusb\n"; + } else if (err == GF2Device::ERROR_NOT_FOUND) { // Failed to find device + std::cerr << "Error: Could not find device.\n"; + } else if (err == GF2Device::ERROR_BUSY) { // Failed to claim interface + std::cerr << "Error: Device is currently unavailable.\n"; + } + errlvl = EXIT_FAILURE; + } + return errlvl; +} From a32e6c653c8c8fb57775b338e317c6014fad35b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Sat, 23 Jul 2022 22:07:10 +0100 Subject: [PATCH 54/62] Add files via upload --- src/Makefile | 2 +- src/gf2-sine.cpp | 64 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 src/gf2-sine.cpp diff --git a/src/Makefile b/src/Makefile index 037b5bf..be7fa66 100644 --- a/src/Makefile +++ b/src/Makefile @@ -25,7 +25,7 @@ CXXFLAGS = -O2 -std=c++11 -Wall -pedantic LDFLAGS = -s LDLIBS = -lusb-1.0 OBJECTS = cp2130.o error.o gf2device.o libusb-extra.o utils.o -TARGETS = gf2-amp gf2-amp50 gf2-clear gf2-clkoff gf2-clkon gf2-dacoff gf2-dacon gf2-freq gf2-freq0 gf2-freq1 gf2-info gf2-list gf2-lockotp gf2-phase gf2-phase0 gf2-phase1 gf2-reset gf2-selfreq0 gf2-selfreq1 gf2-selphase0 gf2-selphase1 gf2-start gf2-status gf2-stop +TARGETS = gf2-amp gf2-amp50 gf2-clear gf2-clkoff gf2-clkon gf2-dacoff gf2-dacon gf2-freq gf2-freq0 gf2-freq1 gf2-info gf2-list gf2-lockotp gf2-phase gf2-phase0 gf2-phase1 gf2-reset gf2-selfreq0 gf2-selfreq1 gf2-selphase0 gf2-selphase1 gf2-sine gf2-start gf2-status gf2-stop .PHONY: all clean install uninstall diff --git a/src/gf2-sine.cpp b/src/gf2-sine.cpp new file mode 100644 index 0000000..14cda00 --- /dev/null +++ b/src/gf2-sine.cpp @@ -0,0 +1,64 @@ +/* GF2 Sine Command - Version 2.0 for Debian Linux + Copyright (c) 2018-2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include "error.h" +#include "gf2device.h" + +int main(int argc, char **argv) +{ + int err, errlvl = EXIT_SUCCESS; + GF2Device device; + if (argc < 2) { // If the program was called without arguments + err = device.open(); // Open a device and get the device handle + } else { // Serial number was specified as argument + err = device.open(argv[1]); // Open the device having the specified serial number, and get the device handle + } + if (err == GF2Device::SUCCESS) { // Device was successfully opened + int errcnt = 0; + std::string errstr; + device.setupChannel0(errcnt, errstr); // Setup channel 0 + device.setSineWave(errcnt, errstr); // Set the waveform of the generated signal to sinusoidal + if (errcnt > 0) { // In case of error + if (device.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } else { // Operation successful + std::cout << "Waveform set to sinusoidal." << std::endl; + } + device.close(); + } else { // Failed to open device + if (err == GF2Device::ERROR_INIT) { // Failed to initialize libusb + std::cerr << "Error: Could not initialize libusb\n"; + } else if (err == GF2Device::ERROR_NOT_FOUND) { // Failed to find device + std::cerr << "Error: Could not find device.\n"; + } else if (err == GF2Device::ERROR_BUSY) { // Failed to claim interface + std::cerr << "Error: Device is currently unavailable.\n"; + } + errlvl = EXIT_FAILURE; + } + return errlvl; +} From ed1024363a409148309477f907bc372b6babee3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Sat, 23 Jul 2022 23:07:26 +0100 Subject: [PATCH 55/62] Add files via upload --- src/Makefile | 2 +- src/gf2-tri.cpp | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 src/gf2-tri.cpp diff --git a/src/Makefile b/src/Makefile index be7fa66..90b3b1e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -25,7 +25,7 @@ CXXFLAGS = -O2 -std=c++11 -Wall -pedantic LDFLAGS = -s LDLIBS = -lusb-1.0 OBJECTS = cp2130.o error.o gf2device.o libusb-extra.o utils.o -TARGETS = gf2-amp gf2-amp50 gf2-clear gf2-clkoff gf2-clkon gf2-dacoff gf2-dacon gf2-freq gf2-freq0 gf2-freq1 gf2-info gf2-list gf2-lockotp gf2-phase gf2-phase0 gf2-phase1 gf2-reset gf2-selfreq0 gf2-selfreq1 gf2-selphase0 gf2-selphase1 gf2-sine gf2-start gf2-status gf2-stop +TARGETS = gf2-amp gf2-amp50 gf2-clear gf2-clkoff gf2-clkon gf2-dacoff gf2-dacon gf2-freq gf2-freq0 gf2-freq1 gf2-info gf2-list gf2-lockotp gf2-phase gf2-phase0 gf2-phase1 gf2-reset gf2-selfreq0 gf2-selfreq1 gf2-selphase0 gf2-selphase1 gf2-sine gf2-start gf2-status gf2-stop gf2-tri .PHONY: all clean install uninstall diff --git a/src/gf2-tri.cpp b/src/gf2-tri.cpp new file mode 100644 index 0000000..5d0d3c4 --- /dev/null +++ b/src/gf2-tri.cpp @@ -0,0 +1,64 @@ +/* GF2 Tri Command - Version 2.0 for Debian Linux + Copyright (c) 2018-2022 Samuel Lourenço + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + + Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com */ + + +// Includes +#include +#include +#include +#include "error.h" +#include "gf2device.h" + +int main(int argc, char **argv) +{ + int err, errlvl = EXIT_SUCCESS; + GF2Device device; + if (argc < 2) { // If the program was called without arguments + err = device.open(); // Open a device and get the device handle + } else { // Serial number was specified as argument + err = device.open(argv[1]); // Open the device having the specified serial number, and get the device handle + } + if (err == GF2Device::SUCCESS) { // Device was successfully opened + int errcnt = 0; + std::string errstr; + device.setupChannel0(errcnt, errstr); // Setup channel 0 + device.setTriangleWave(errcnt, errstr); // Set the waveform of the generated signal to triangular + if (errcnt > 0) { // In case of error + if (device.disconnected()) { // If the device disconnected + std::cerr << "Error: Device disconnected.\n"; + } else { + printErrors(errstr); + } + errlvl = EXIT_FAILURE; + } else { // Operation successful + std::cout << "Waveform set to triangular." << std::endl; + } + device.close(); + } else { // Failed to open device + if (err == GF2Device::ERROR_INIT) { // Failed to initialize libusb + std::cerr << "Error: Could not initialize libusb\n"; + } else if (err == GF2Device::ERROR_NOT_FOUND) { // Failed to find device + std::cerr << "Error: Could not find device.\n"; + } else if (err == GF2Device::ERROR_BUSY) { // Failed to claim interface + std::cerr << "Error: Device is currently unavailable.\n"; + } + errlvl = EXIT_FAILURE; + } + return errlvl; +} From 1e54b88b2173e5ffca3bc62b03252f74b8b29ae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Sun, 24 Jul 2022 12:35:57 +0100 Subject: [PATCH 56/62] Add files via upload --- src/man/gf2-amp.1 | 9 +++++---- src/man/gf2-amp50.1 | 9 +++++---- src/man/gf2-clear.1 | 9 +++++---- src/man/gf2-clkoff.1 | 9 +++++---- src/man/gf2-clkon.1 | 9 +++++---- src/man/gf2-dacoff.1 | 9 +++++---- src/man/gf2-dacon.1 | 9 +++++---- src/man/gf2-freq.1 | 9 +++++---- src/man/gf2-freq0.1 | 9 +++++---- src/man/gf2-freq1.1 | 9 +++++---- src/man/gf2-info.1 | 25 +++++++++++++++++++++++++ src/man/gf2-list.1 | 7 ++++--- src/man/gf2-lockotp.1 | 7 ++++--- src/man/gf2-phase.1 | 7 ++++--- src/man/gf2-phase0.1 | 7 ++++--- src/man/gf2-phase1.1 | 7 ++++--- src/man/gf2-reset.1 | 7 ++++--- src/man/gf2-selfreq0.1 | 7 ++++--- src/man/gf2-selfreq1.1 | 7 ++++--- src/man/gf2-selphase0.1 | 7 ++++--- src/man/gf2-selphase1.1 | 7 ++++--- src/man/gf2-sine.1 | 7 ++++--- src/man/gf2-start.1 | 7 ++++--- src/man/gf2-status.1 | 7 ++++--- src/man/gf2-stop.1 | 7 ++++--- src/man/gf2-tri.1 | 7 ++++--- 26 files changed, 135 insertions(+), 85 deletions(-) create mode 100644 src/man/gf2-info.1 diff --git a/src/man/gf2-amp.1 b/src/man/gf2-amp.1 index c3f9376..554a4d2 100644 --- a/src/man/gf2-amp.1 +++ b/src/man/gf2-amp.1 @@ -23,7 +23,8 @@ occur, or two in case of bad input. Samuel Lourenço (samuel.fmlourenco@gmail.com). .SH "SEE ALSO" gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), gf2-dacoff(1), -gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), gf2-list(1), -gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), -gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), -gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) +gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), gf2-info(1), +gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), +gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), +gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), +gf2-tri(1) diff --git a/src/man/gf2-amp50.1 b/src/man/gf2-amp50.1 index f15d741..df15405 100644 --- a/src/man/gf2-amp50.1 +++ b/src/man/gf2-amp50.1 @@ -27,7 +27,8 @@ occur, or two in case of bad input. Samuel Lourenço (samuel.fmlourenco@gmail.com). .SH "SEE ALSO" gf2-amp(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), gf2-dacoff(1), -gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), gf2-list(1), -gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), -gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), -gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) +gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), gf2-info(1), +gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), +gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), +gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), +gf2-tri(1) diff --git a/src/man/gf2-clear.1 b/src/man/gf2-clear.1 index 98c1e58..a30cfcc 100644 --- a/src/man/gf2-clear.1 +++ b/src/man/gf2-clear.1 @@ -21,7 +21,8 @@ occur. Samuel Lourenço (samuel.fmlourenco@gmail.com). .SH "SEE ALSO" gf2-amp(1), gf2-amp50(1), gf2-clkoff(1), gf2-clkon(1), gf2-dacoff(1), -gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), gf2-list(1), -gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), -gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), -gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) +gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), gf2-info(1), +gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), +gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), +gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), +gf2-tri(1) diff --git a/src/man/gf2-clkoff.1 b/src/man/gf2-clkoff.1 index 2e43b51..78fd5f3 100644 --- a/src/man/gf2-clkoff.1 +++ b/src/man/gf2-clkoff.1 @@ -21,7 +21,8 @@ occur. Samuel Lourenço (samuel.fmlourenco@gmail.com). .SH "SEE ALSO" gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkon(1), gf2-dacoff(1), -gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), gf2-list(1), -gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), -gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), -gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) +gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), gf2-info(1), +gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), +gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), +gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), +gf2-tri(1) diff --git a/src/man/gf2-clkon.1 b/src/man/gf2-clkon.1 index c4e037a..2e68a9e 100644 --- a/src/man/gf2-clkon.1 +++ b/src/man/gf2-clkon.1 @@ -23,7 +23,8 @@ occur. Samuel Lourenço (samuel.fmlourenco@gmail.com). .SH "SEE ALSO" gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-dacoff(1), -gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), gf2-list(1), -gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), -gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), -gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) +gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), gf2-info(1), +gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), +gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), +gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), +gf2-tri(1) diff --git a/src/man/gf2-dacoff.1 b/src/man/gf2-dacoff.1 index ebcc065..c238572 100644 --- a/src/man/gf2-dacoff.1 +++ b/src/man/gf2-dacoff.1 @@ -24,7 +24,8 @@ occur. Samuel Lourenço (samuel.fmlourenco@gmail.com). .SH "SEE ALSO" gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), -gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), gf2-list(1), -gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), -gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), -gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) +gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), gf2-info(1), +gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), +gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), +gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), +gf2-tri(1) diff --git a/src/man/gf2-dacon.1 b/src/man/gf2-dacon.1 index 01148e1..54cad79 100644 --- a/src/man/gf2-dacon.1 +++ b/src/man/gf2-dacon.1 @@ -19,7 +19,8 @@ occur. Samuel Lourenço (samuel.fmlourenco@gmail.com). .SH "SEE ALSO" gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), -gf2-dacoff(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), gf2-list(1), -gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), -gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), -gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) +gf2-dacoff(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), gf2-info(1), +gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), +gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), +gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), +gf2-tri(1) diff --git a/src/man/gf2-freq.1 b/src/man/gf2-freq.1 index 5b5e131..288e7e7 100644 --- a/src/man/gf2-freq.1 +++ b/src/man/gf2-freq.1 @@ -35,7 +35,8 @@ occur, or two in case of bad input. Samuel Lourenço (samuel.fmlourenco@gmail.com). .SH "SEE ALSO" gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), -gf2-dacoff(1), gf2-dacon(1), gf2-freq0(1), gf2-freq1(1), gf2-list(1), -gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), -gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), -gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) +gf2-dacoff(1), gf2-dacon(1), gf2-freq0(1), gf2-freq1(1), gf2-info(1), +gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), +gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), +gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), +gf2-tri(1) diff --git a/src/man/gf2-freq0.1 b/src/man/gf2-freq0.1 index 7c97cbe..7d73085 100644 --- a/src/man/gf2-freq0.1 +++ b/src/man/gf2-freq0.1 @@ -29,7 +29,8 @@ occur, or two in case of bad input. Samuel Lourenço (samuel.fmlourenco@gmail.com). .SH "SEE ALSO" gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), -gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq1(1), gf2-list(1), -gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), -gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), -gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) +gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq1(1), gf2-info(1), +gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), +gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), +gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), +gf2-tri(1) diff --git a/src/man/gf2-freq1.1 b/src/man/gf2-freq1.1 index 4927f26..bc60549 100644 --- a/src/man/gf2-freq1.1 +++ b/src/man/gf2-freq1.1 @@ -26,7 +26,8 @@ occur, or two in case of bad input. Samuel Lourenço (samuel.fmlourenco@gmail.com). .SH "SEE ALSO" gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), -gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-list(1), -gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), -gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), -gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) +gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-info(1), +gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), +gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), +gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), +gf2-tri(1) diff --git a/src/man/gf2-info.1 b/src/man/gf2-info.1 new file mode 100644 index 0000000..0655526 --- /dev/null +++ b/src/man/gf2-info.1 @@ -0,0 +1,25 @@ +.TH GF2-INFO 1 +.SH NAME +gf2-info \- show information about GF2 Function Generator +.SH SYNOPSIS +.B gf2-info +.RI [ SERIALNUMBER ] +.SH DESCRIPTION +.B gf2-info +shows information about the function generator device, namely the manufacturer +and product names, the serial number, the hardware revision and the maximum +current consumption. + +Specifying a serial number is optional. +.SH "EXIT STATUS" +Exits with a status of zero in case of success. Returns one should an error +occur. +.SH AUTHOR +Samuel Lourenço (samuel.fmlourenco@gmail.com). +.SH "SEE ALSO" +gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), +gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), +gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), +gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), +gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), +gf2-tri(1) diff --git a/src/man/gf2-list.1 b/src/man/gf2-list.1 index 256b31a..1a40c20 100644 --- a/src/man/gf2-list.1 +++ b/src/man/gf2-list.1 @@ -17,6 +17,7 @@ Samuel Lourenço (samuel.fmlourenco@gmail.com). .SH "SEE ALSO" gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), -gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), -gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), -gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) +gf2-info(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), +gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), +gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), +gf2-tri(1) diff --git a/src/man/gf2-lockotp.1 b/src/man/gf2-lockotp.1 index 2d16102..d7525a0 100644 --- a/src/man/gf2-lockotp.1 +++ b/src/man/gf2-lockotp.1 @@ -22,6 +22,7 @@ Samuel Lourenço (samuel.fmlourenco@gmail.com). .SH "SEE ALSO" gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), -gf2-list(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), -gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), -gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) +gf2-info(1), gf2-list(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), +gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), +gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), +gf2-tri(1) diff --git a/src/man/gf2-phase.1 b/src/man/gf2-phase.1 index 820d33d..8a2fd98 100644 --- a/src/man/gf2-phase.1 +++ b/src/man/gf2-phase.1 @@ -35,6 +35,7 @@ Samuel Lourenço (samuel.fmlourenco@gmail.com). .SH "SEE ALSO" gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), -gf2-list(1), gf2-lockotp(1), gf2-phase0(1), gf2-phase1(1), gf2-reset(1), -gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), -gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) +gf2-info(1), gf2-list(1), gf2-lockotp(1), gf2-phase0(1), gf2-phase1(1), +gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), +gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), +gf2-tri(1) diff --git a/src/man/gf2-phase0.1 b/src/man/gf2-phase0.1 index 7ad3050..8e1860b 100644 --- a/src/man/gf2-phase0.1 +++ b/src/man/gf2-phase0.1 @@ -29,6 +29,7 @@ Samuel Lourenço (samuel.fmlourenco@gmail.com). .SH "SEE ALSO" gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), -gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase1(1), gf2-reset(1), -gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), -gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) +gf2-info(1), gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase1(1), +gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), +gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), +gf2-tri(1) diff --git a/src/man/gf2-phase1.1 b/src/man/gf2-phase1.1 index 891cbe1..560250f 100644 --- a/src/man/gf2-phase1.1 +++ b/src/man/gf2-phase1.1 @@ -26,6 +26,7 @@ Samuel Lourenço (samuel.fmlourenco@gmail.com). .SH "SEE ALSO" gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), -gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-reset(1), -gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), -gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) +gf2-info(1), gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), +gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), +gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), +gf2-tri(1) diff --git a/src/man/gf2-reset.1 b/src/man/gf2-reset.1 index 7bccf8f..0a99572 100644 --- a/src/man/gf2-reset.1 +++ b/src/man/gf2-reset.1 @@ -21,6 +21,7 @@ Samuel Lourenço (samuel.fmlourenco@gmail.com). .SH "SEE ALSO" gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), -gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), -gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), -gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) +gf2-info(1), gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), +gf2-phase1(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), +gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), +gf2-tri(1) diff --git a/src/man/gf2-selfreq0.1 b/src/man/gf2-selfreq0.1 index ad228da..ea3a2ce 100644 --- a/src/man/gf2-selfreq0.1 +++ b/src/man/gf2-selfreq0.1 @@ -28,6 +28,7 @@ Samuel Lourenço (samuel.fmlourenco@gmail.com). .SH "SEE ALSO" gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), -gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), -gf2-reset(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-selphase1(1), -gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) +gf2-info(1), gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), +gf2-phase1(1), gf2-reset(1), gf2-selfreq1(1), gf2-selphase0(1), +gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), +gf2-tri(1) diff --git a/src/man/gf2-selfreq1.1 b/src/man/gf2-selfreq1.1 index 6e696b4..8bb7399 100644 --- a/src/man/gf2-selfreq1.1 +++ b/src/man/gf2-selfreq1.1 @@ -28,6 +28,7 @@ Samuel Lourenço (samuel.fmlourenco@gmail.com). .SH "SEE ALSO" gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), -gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), -gf2-reset(1), gf2-selfreq0(1), gf2-selphase0(1), gf2-selphase1(1), -gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) +gf2-info(1), gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), +gf2-phase1(1), gf2-reset(1), gf2-selfreq0(1), gf2-selphase0(1), +gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), +gf2-tri(1) diff --git a/src/man/gf2-selphase0.1 b/src/man/gf2-selphase0.1 index 70d0954..a212a48 100644 --- a/src/man/gf2-selphase0.1 +++ b/src/man/gf2-selphase0.1 @@ -28,6 +28,7 @@ Samuel Lourenço (samuel.fmlourenco@gmail.com). .SH "SEE ALSO" gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), -gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), -gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase1(1), gf2-sine(1), -gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) +gf2-info(1), gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), +gf2-phase1(1), gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), +gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), +gf2-tri(1) diff --git a/src/man/gf2-selphase1.1 b/src/man/gf2-selphase1.1 index 3283a06..e525057 100644 --- a/src/man/gf2-selphase1.1 +++ b/src/man/gf2-selphase1.1 @@ -28,6 +28,7 @@ Samuel Lourenço (samuel.fmlourenco@gmail.com). .SH "SEE ALSO" gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), -gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), -gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), gf2-sine(1), -gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) +gf2-info(1), gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), +gf2-phase1(1), gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), +gf2-selphase0(1), gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1), +gf2-tri(1) diff --git a/src/man/gf2-sine.1 b/src/man/gf2-sine.1 index f1164dc..6aa5fc6 100644 --- a/src/man/gf2-sine.1 +++ b/src/man/gf2-sine.1 @@ -17,6 +17,7 @@ Samuel Lourenço (samuel.fmlourenco@gmail.com). .SH "SEE ALSO" gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), -gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), -gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), -gf2-selphase1(1), gf2-start(1), gf2-status(1), gf2-stop(1), gf2-tri(1) +gf2-info(1), gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), +gf2-phase1(1), gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), +gf2-selphase0(1), gf2-selphase1(1), gf2-start(1), gf2-status(1), gf2-stop(1), +gf2-tri(1) diff --git a/src/man/gf2-start.1 b/src/man/gf2-start.1 index 6289a14..4fe1c57 100644 --- a/src/man/gf2-start.1 +++ b/src/man/gf2-start.1 @@ -23,6 +23,7 @@ Samuel Lourenço (samuel.fmlourenco@gmail.com). .SH "SEE ALSO" gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), -gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), -gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), -gf2-selphase1(1), gf2-sine(1), gf2-status(1), gf2-stop(1), gf2-tri(1) +gf2-info(1), gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), +gf2-phase1(1), gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), +gf2-selphase0(1), gf2-selphase1(1), gf2-sine(1), gf2-status(1), gf2-stop(1), +gf2-tri(1) diff --git a/src/man/gf2-status.1 b/src/man/gf2-status.1 index 86ff6e5..e37a8e7 100644 --- a/src/man/gf2-status.1 +++ b/src/man/gf2-status.1 @@ -22,6 +22,7 @@ Samuel Lourenço (samuel.fmlourenco@gmail.com). .SH "SEE ALSO" gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), -gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), -gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), -gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-stop(1), gf2-tri(1) +gf2-info(1), gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), +gf2-phase1(1), gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), +gf2-selphase0(1), gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-stop(1), +gf2-tri(1) diff --git a/src/man/gf2-stop.1 b/src/man/gf2-stop.1 index 75169c3..e3b7040 100644 --- a/src/man/gf2-stop.1 +++ b/src/man/gf2-stop.1 @@ -24,6 +24,7 @@ Samuel Lourenço (samuel.fmlourenco@gmail.com). .SH "SEE ALSO" gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), -gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), -gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), -gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), gf2-tri(1) +gf2-info(1), gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), +gf2-phase1(1), gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), +gf2-selphase0(1), gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), +gf2-tri(1) diff --git a/src/man/gf2-tri.1 b/src/man/gf2-tri.1 index f934998..fa3d5ba 100644 --- a/src/man/gf2-tri.1 +++ b/src/man/gf2-tri.1 @@ -17,6 +17,7 @@ Samuel Lourenço (samuel.fmlourenco@gmail.com). .SH "SEE ALSO" gf2-amp(1), gf2-amp50(1), gf2-clear(1), gf2-clkoff(1), gf2-clkon(1), gf2-dacoff(1), gf2-dacon(1), gf2-freq(1), gf2-freq0(1), gf2-freq1(1), -gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), gf2-phase1(1), -gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), gf2-selphase0(1), -gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), gf2-stop(1) +gf2-info(1), gf2-list(1), gf2-lockotp(1), gf2-phase(1), gf2-phase0(1), +gf2-phase1(1), gf2-reset(1), gf2-selfreq0(1), gf2-selfreq1(1), +gf2-selphase0(1), gf2-selphase1(1), gf2-sine(1), gf2-start(1), gf2-status(1), +gf2-stop(1) From c2a731767ee7a95578929d3a2487ab35c38e0156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Sun, 24 Jul 2022 13:26:53 +0100 Subject: [PATCH 57/62] Add files via upload --- src/Makefile | 22 ++++++++++++ src/README.txt | 91 +++++++++++++++++++++++++++++++++----------------- 2 files changed, 83 insertions(+), 30 deletions(-) diff --git a/src/Makefile b/src/Makefile index 90b3b1e..607c32f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -18,12 +18,18 @@ # Please feel free to contact me via e-mail: samuel.fmlourenco@gmail.com +prefix = /usr/local + CC = gcc CFLAGS = -O2 -std=c11 -Wall -pedantic CXX = g++ CXXFLAGS = -O2 -std=c++11 -Wall -pedantic LDFLAGS = -s LDLIBS = -lusb-1.0 +MANPAGES = gf2-amp.1 gf2-amp50.1 gf2-clear.1 gf2-clkoff.1 gf2-clkon.1 gf2-dacoff.1 gf2-dacon.1 gf2-freq.1 gf2-freq0.1 gf2-freq1.1 gf2-info.1 gf2-list.1 gf2-lockotp.1 gf2-phase.1 gf2-phase0.1 gf2-phase1.1 gf2-reset.1 gf2-selfreq0.1 gf2-selfreq1.1 gf2-selphase0.1 gf2-selphase1.1 gf2-sine.1 gf2-start.1 gf2-status.1 gf2-stop.1 gf2-tri.1 +MANPAGESGZ = $(MANPAGES:=.gz) +MKDIR = mkdir -p +MV = mv -f OBJECTS = cp2130.o error.o gf2device.o libusb-extra.o utils.o TARGETS = gf2-amp gf2-amp50 gf2-clear gf2-clkoff gf2-clkon gf2-dacoff gf2-dacon gf2-freq gf2-freq0 gf2-freq1 gf2-info gf2-list gf2-lockotp gf2-phase gf2-phase0 gf2-phase1 gf2-reset gf2-selfreq0 gf2-selfreq1 gf2-selphase0 gf2-selphase1 gf2-sine gf2-start gf2-status gf2-stop gf2-tri @@ -42,3 +48,19 @@ $(TARGETS): % : %.o $(OBJECTS) clean: $(RM) *.o $(TARGETS) + +install: all install-bin install-man + +install-bin: + $(MKDIR) $(DESTDIR)$(prefix)/bin && $(MV) $(TARGETS) $(DESTDIR)$(prefix)/bin/. + +install-man: + cd man && gzip -fknv9 $(MANPAGES) && $(MKDIR) $(DESTDIR)$(prefix)/share/man/man1 && $(MV) $(MANPAGESGZ) $(DESTDIR)$(prefix)/share/man/man1/. + +uninstall: uninstall-man uninstall-bin clean + +uninstall-bin: + cd $(DESTDIR)$(prefix)/bin && $(RM) $(TARGETS) + +uninstall-man: + if [ -d $(DESTDIR)$(prefix)/share/man/man1 ]; then cd $(DESTDIR)$(prefix)/share/man/man1 && $(RM) $(MANPAGESGZ) && $(RMDIR) $(DESTDIR)$(prefix)/share/man/man1; fi diff --git a/src/README.txt b/src/README.txt index cb8dbb1..0ce87c6 100644 --- a/src/README.txt +++ b/src/README.txt @@ -1,37 +1,68 @@ This directory contains all source code files required for compiling the commands for GF2 Function Generator. A list of relevant files follows: -– common.c; -– common.h; -– gf2-amp.c; -– gf2-amp50.c; -– gf2-clear.c; -– gf2-clkoff.c; -– gf2-clkon.c; -– gf2-core.c; -– gf2-core.h; -– gf2-dacoff.c; -– gf2-dacon.c; -– gf2-freq.c; -– gf2-freq0.c; -– gf2-freq1.c; -– gf2-list.c; -– gf2-lockotp.c; -– gf2-phase.c; -– gf2-phase0.c; -– gf2-phase1.c; -– gf2-reset.c; -– gf2-selfreq0.c; -– gf2-selfreq1.c; -– gf2-selphase0.c; -– gf2-selphase1.c; -– gf2-sine.c; -– gf2-start.c; -– gf2-status.c; -– gf2-stop.c; -– gf2-tri.c; +– cp2130.cpp; +– cp2130.h; +– error.cpp; +– error.h; +– gf2-amp.cpp; +– gf2-amp50.cpp; +– gf2-clear.cpp; +– gf2-clkoff.cpp; +– gf2-clkon.cpp; +– gf2-dacoff.cpp; +– gf2-dacon.cpp; +– gf2device.cpp; +– gf2device.h; +– gf2-freq.cpp; +– gf2-freq0.cpp; +– gf2-freq1.cpp; +– gf2-info.cpp; +– gf2-list.cpp; +– gf2-lockotp.cpp; +– gf2-phase.cpp; +– gf2-phase0.cpp; +– gf2-phase1.cpp; +– gf2-reset.cpp; +– gf2-selfreq0.cpp; +– gf2-selfreq1.cpp; +– gf2-selphase0.cpp; +– gf2-selphase1.cpp; +– gf2-sine.cpp; +– gf2-start.cpp; +– gf2-status.cpp; +– gf2-stop.cpp; +– gf2-tri.cpp; – libusb-extra.c; – libusb-extra.h; -– Makefile. +– Makefile; +– man/gf2-amp.1; +– man/gf2-amp50.1; +– man/gf2-clear.1; +– man/gf2-clkoff.1; +– man/gf2-clkon.1; +– man/gf2-dacoff.1; +– man/gf2-dacon.1; +– man/gf2-freq.1; +– man/gf2-freq0.1; +– man/gf2-freq1.1; +– man/gf2-info.1; +– man/gf2-list.1; +– man/gf2-lockotp.1; +– man/gf2-phase.1; +– man/gf2-phase0.1; +– man/gf2-phase1.1; +– man/gf2-reset.1; +– man/gf2-selfreq0.1; +– man/gf2-selfreq1.1; +– man/gf2-selphase0.1; +– man/gf2-selphase1.1; +– man/gf2-sine.1; +– man/gf2-start.1; +– man/gf2-status.1; +– man/gf2-stop.1; +– man/gf2-tri.1; +– utils.cpp; +– utils.h. In order to compile successfully all commands, you must have the packages "build-essential" and "libusb-1.0-0-dev" installed. Given that, if you wish to From b7c0bea004a72c0dc9d1c953c851b280ef2060f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Sun, 24 Jul 2022 19:37:54 +0100 Subject: [PATCH 58/62] Add files via upload --- install.sh | 122 +++++++++++++++++++++++++++-------------------------- 1 file changed, 63 insertions(+), 59 deletions(-) diff --git a/install.sh b/install.sh index 5dce8a4..ca4163b 100644 --- a/install.sh +++ b/install.sh @@ -5,71 +5,75 @@ apt-get -qq update apt-get -qq install build-essential apt-get -qq install libusb-1.0-0-dev echo Copying source code files... -mkdir -p /usr/local/src/gf2 -cp -f src/common.c /usr/local/src/gf2/. -cp -f src/common.h /usr/local/src/gf2/. -cp -f src/gf2-amp.c /usr/local/src/gf2/. -cp -f src/gf2-amp50.c /usr/local/src/gf2/. -cp -f src/gf2-clear.c /usr/local/src/gf2/. -cp -f src/gf2-clkoff.c /usr/local/src/gf2/. -cp -f src/gf2-clkon.c /usr/local/src/gf2/. -cp -f src/gf2-core.c /usr/local/src/gf2/. -cp -f src/gf2-core.h /usr/local/src/gf2/. -cp -f src/gf2-dacoff.c /usr/local/src/gf2/. -cp -f src/gf2-dacon.c /usr/local/src/gf2/. -cp -f src/gf2-freq.c /usr/local/src/gf2/. -cp -f src/gf2-freq0.c /usr/local/src/gf2/. -cp -f src/gf2-freq1.c /usr/local/src/gf2/. -cp -f src/gf2-list.c /usr/local/src/gf2/. -cp -f src/gf2-lockotp.c /usr/local/src/gf2/. -cp -f src/gf2-phase.c /usr/local/src/gf2/. -cp -f src/gf2-phase0.c /usr/local/src/gf2/. -cp -f src/gf2-phase1.c /usr/local/src/gf2/. -cp -f src/gf2-reset.c /usr/local/src/gf2/. -cp -f src/gf2-selfreq0.c /usr/local/src/gf2/. -cp -f src/gf2-selfreq1.c /usr/local/src/gf2/. -cp -f src/gf2-selphase0.c /usr/local/src/gf2/. -cp -f src/gf2-selphase1.c /usr/local/src/gf2/. -cp -f src/gf2-sine.c /usr/local/src/gf2/. -cp -f src/gf2-start.c /usr/local/src/gf2/. -cp -f src/gf2-status.c /usr/local/src/gf2/. -cp -f src/gf2-stop.c /usr/local/src/gf2/. -cp -f src/gf2-tri.c /usr/local/src/gf2/. +mkdir -p /usr/local/src/gf2/man +cp -f src/cp2130.cpp /usr/local/src/gf2/. +cp -f src/cp2130.h /usr/local/src/gf2/. +cp -f src/error.cpp /usr/local/src/gf2/. +cp -f src/error.h /usr/local/src/gf2/. +cp -f src/gf2-amp.cpp /usr/local/src/gf2/. +cp -f src/gf2-amp50.cpp /usr/local/src/gf2/. +cp -f src/gf2-clear.cpp /usr/local/src/gf2/. +cp -f src/gf2-clkoff.cpp /usr/local/src/gf2/. +cp -f src/gf2-clkon.cpp /usr/local/src/gf2/. +cp -f src/gf2-dacoff.cpp /usr/local/src/gf2/. +cp -f src/gf2-dacon.cpp /usr/local/src/gf2/. +cp -f src/gf2device.cpp /usr/local/src/gf2/. +cp -f src/gf2device.h /usr/local/src/gf2/. +cp -f src/gf2-freq.cpp /usr/local/src/gf2/. +cp -f src/gf2-freq0.cpp /usr/local/src/gf2/. +cp -f src/gf2-freq1.cpp /usr/local/src/gf2/. +cp -f src/gf2-info.cpp /usr/local/src/gf2/. +cp -f src/gf2-list.cpp /usr/local/src/gf2/. +cp -f src/gf2-lockotp.cpp /usr/local/src/gf2/. +cp -f src/gf2-phase.cpp /usr/local/src/gf2/. +cp -f src/gf2-phase0.cpp /usr/local/src/gf2/. +cp -f src/gf2-phase1.cpp /usr/local/src/gf2/. +cp -f src/gf2-reset.cpp /usr/local/src/gf2/. +cp -f src/gf2-selfreq0.cpp /usr/local/src/gf2/. +cp -f src/gf2-selfreq1.cpp /usr/local/src/gf2/. +cp -f src/gf2-selphase0.cpp /usr/local/src/gf2/. +cp -f src/gf2-selphase1.cpp /usr/local/src/gf2/. +cp -f src/gf2-sine.cpp /usr/local/src/gf2/. +cp -f src/gf2-start.cpp /usr/local/src/gf2/. +cp -f src/gf2-status.cpp /usr/local/src/gf2/. +cp -f src/gf2-stop.cpp /usr/local/src/gf2/. +cp -f src/gf2-tri.cpp /usr/local/src/gf2/. cp -f src/GPL.txt /usr/local/src/gf2/. cp -f src/LGPL.txt /usr/local/src/gf2/. cp -f src/libusb-extra.c /usr/local/src/gf2/. cp -f src/libusb-extra.h /usr/local/src/gf2/. cp -f src/Makefile /usr/local/src/gf2/. +cp -f src/man/gf2-amp.1 /usr/local/src/gf2/man/. +cp -f src/man/gf2-amp50.1 /usr/local/src/gf2/man/. +cp -f src/man/gf2-clear.1 /usr/local/src/gf2/man/. +cp -f src/man/gf2-clkoff.1 /usr/local/src/gf2/man/. +cp -f src/man/gf2-clkon.1 /usr/local/src/gf2/man/. +cp -f src/man/gf2-dacoff.1 /usr/local/src/gf2/man/. +cp -f src/man/gf2-dacon.1 /usr/local/src/gf2/man/. +cp -f src/man/gf2-freq.1 /usr/local/src/gf2/man/. +cp -f src/man/gf2-freq0.1 /usr/local/src/gf2/man/. +cp -f src/man/gf2-freq1.1 /usr/local/src/gf2/man/. +cp -f src/man/gf2-info.1 /usr/local/src/gf2/man/. +cp -f src/man/gf2-list.1 /usr/local/src/gf2/man/. +cp -f src/man/gf2-lockotp.1 /usr/local/src/gf2/man/. +cp -f src/man/gf2-phase.1 /usr/local/src/gf2/man/. +cp -f src/man/gf2-phase0.1 /usr/local/src/gf2/man/. +cp -f src/man/gf2-phase1.1 /usr/local/src/gf2/man/. +cp -f src/man/gf2-reset.1 /usr/local/src/gf2/man/. +cp -f src/man/gf2-selfreq0.1 /usr/local/src/gf2/man/. +cp -f src/man/gf2-selfreq1.1 /usr/local/src/gf2/man/. +cp -f src/man/gf2-selphase0.1 /usr/local/src/gf2/man/. +cp -f src/man/gf2-selphase1.1 /usr/local/src/gf2/man/. +cp -f src/man/gf2-sine.1 /usr/local/src/gf2/man/. +cp -f src/man/gf2-start.1 /usr/local/src/gf2/man/. +cp -f src/man/gf2-status.1 /usr/local/src/gf2/man/. +cp -f src/man/gf2-stop.1 /usr/local/src/gf2/man/. +cp -f src/man/gf2-tri.1 /usr/local/src/gf2/man/. cp -f src/README.txt /usr/local/src/gf2/. -echo Building and installing binaries... -make -C /usr/local/src/gf2 all install clean -echo Installing man pages... -mkdir -p /usr/local/share/man/man1 -cp -f man/gf2-amp.1.gz /usr/local/share/man/man1/. -cp -f man/gf2-amp50.1.gz /usr/local/share/man/man1/. -cp -f man/gf2-clear.1.gz /usr/local/share/man/man1/. -cp -f man/gf2-clkoff.1.gz /usr/local/share/man/man1/. -cp -f man/gf2-clkon.1.gz /usr/local/share/man/man1/. -cp -f man/gf2-dacoff.1.gz /usr/local/share/man/man1/. -cp -f man/gf2-dacon.1.gz /usr/local/share/man/man1/. -cp -f man/gf2-freq.1.gz /usr/local/share/man/man1/. -cp -f man/gf2-freq0.1.gz /usr/local/share/man/man1/. -cp -f man/gf2-freq1.1.gz /usr/local/share/man/man1/. -cp -f man/gf2-list.1.gz /usr/local/share/man/man1/. -cp -f man/gf2-lockotp.1.gz /usr/local/share/man/man1/. -cp -f man/gf2-phase.1.gz /usr/local/share/man/man1/. -cp -f man/gf2-phase0.1.gz /usr/local/share/man/man1/. -cp -f man/gf2-phase1.1.gz /usr/local/share/man/man1/. -cp -f man/gf2-reset.1.gz /usr/local/share/man/man1/. -cp -f man/gf2-selfreq0.1.gz /usr/local/share/man/man1/. -cp -f man/gf2-selfreq1.1.gz /usr/local/share/man/man1/. -cp -f man/gf2-selphase0.1.gz /usr/local/share/man/man1/. -cp -f man/gf2-selphase1.1.gz /usr/local/share/man/man1/. -cp -f man/gf2-sine.1.gz /usr/local/share/man/man1/. -cp -f man/gf2-start.1.gz /usr/local/share/man/man1/. -cp -f man/gf2-status.1.gz /usr/local/share/man/man1/. -cp -f man/gf2-stop.1.gz /usr/local/share/man/man1/. -cp -f man/gf2-tri.1.gz /usr/local/share/man/man1/. +cp -f src/utils.cpp /usr/local/src/gf2/. +cp -f src/utils.h /usr/local/src/gf2/. +echo Building and installing binaries and man pages... +make -C /usr/local/src/gf2 install clean echo Applying configurations... cat > /etc/udev/rules.d/70-bgtn-gf2.rules << EOF SUBSYSTEM=="usb", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="8bf1", MODE="0666" From 2b3a7e879cf6fd266a332c94fb9efb1f7b80c84d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Sun, 24 Jul 2022 20:14:54 +0100 Subject: [PATCH 59/62] Add files via upload --- src/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Makefile b/src/Makefile index 607c32f..50a53f6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -31,6 +31,7 @@ MANPAGESGZ = $(MANPAGES:=.gz) MKDIR = mkdir -p MV = mv -f OBJECTS = cp2130.o error.o gf2device.o libusb-extra.o utils.o +RMDIR = rmdir --ignore-fail-on-non-empty TARGETS = gf2-amp gf2-amp50 gf2-clear gf2-clkoff gf2-clkon gf2-dacoff gf2-dacon gf2-freq gf2-freq0 gf2-freq1 gf2-info gf2-list gf2-lockotp gf2-phase gf2-phase0 gf2-phase1 gf2-reset gf2-selfreq0 gf2-selfreq1 gf2-selphase0 gf2-selphase1 gf2-sine gf2-start gf2-status gf2-stop gf2-tri .PHONY: all clean install uninstall From de74c7d11a5218021a3d5a3ec1db2037a7323d1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Sun, 24 Jul 2022 20:15:15 +0100 Subject: [PATCH 60/62] Add files via upload --- uninstall.sh | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/uninstall.sh b/uninstall.sh index 43cf557..9d446b3 100644 --- a/uninstall.sh +++ b/uninstall.sh @@ -3,34 +3,7 @@ echo Rolling back configurations... rm -f /etc/udev/rules.d/70-bgtn-gf2.rules service udev restart -echo Removing man pages... -rm -f /usr/local/share/man/man1/gf2-amp.1.gz -rm -f /usr/local/share/man/man1/gf2-amp50.1.gz -rm -f /usr/local/share/man/man1/gf2-clear.1.gz -rm -f /usr/local/share/man/man1/gf2-clkoff.1.gz -rm -f /usr/local/share/man/man1/gf2-clkon.1.gz -rm -f /usr/local/share/man/man1/gf2-dacoff.1.gz -rm -f /usr/local/share/man/man1/gf2-dacon.1.gz -rm -f /usr/local/share/man/man1/gf2-freq.1.gz -rm -f /usr/local/share/man/man1/gf2-freq0.1.gz -rm -f /usr/local/share/man/man1/gf2-freq1.1.gz -rm -f /usr/local/share/man/man1/gf2-list.1.gz -rm -f /usr/local/share/man/man1/gf2-lockotp.1.gz -rm -f /usr/local/share/man/man1/gf2-phase.1.gz -rm -f /usr/local/share/man/man1/gf2-phase0.1.gz -rm -f /usr/local/share/man/man1/gf2-phase1.1.gz -rm -f /usr/local/share/man/man1/gf2-reset.1.gz -rm -f /usr/local/share/man/man1/gf2-selfreq0.1.gz -rm -f /usr/local/share/man/man1/gf2-selfreq1.1.gz -rm -f /usr/local/share/man/man1/gf2-selphase0.1.gz -rm -f /usr/local/share/man/man1/gf2-selphase1.1.gz -rm -f /usr/local/share/man/man1/gf2-sine.1.gz -rm -f /usr/local/share/man/man1/gf2-start.1.gz -rm -f /usr/local/share/man/man1/gf2-status.1.gz -rm -f /usr/local/share/man/man1/gf2-stop.1.gz -rm -f /usr/local/share/man/man1/gf2-tri.1.gz -rmdir --ignore-fail-on-non-empty /usr/local/share/man/man1 -echo Removing binaries... +echo Removing binaries and man pages... make -C /usr/local/src/gf2 uninstall echo Removing source code files... rm -rf /usr/local/src/gf2 From 22edef814d3a328d157b76b44ce07959a880d523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Sun, 24 Jul 2022 20:22:08 +0100 Subject: [PATCH 61/62] Add files via upload --- src/README.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/README.txt b/src/README.txt index 0ce87c6..e6d5f54 100644 --- a/src/README.txt +++ b/src/README.txt @@ -68,9 +68,9 @@ In order to compile successfully all commands, you must have the packages "build-essential" and "libusb-1.0-0-dev" installed. Given that, if you wish to simply compile, change your working directory to the current one on a terminal window, and simply invoke "make" or "make all". If you wish to install besides -compiling, run "sudo make all install". Alternatively, if you wish to force a -rebuild, you should invoke "make clean all", or "sudo make clean all install" -if you prefer to install after rebuilding. +compiling, run "sudo make install". Alternatively, if you wish to force a +rebuild, you should invoke "make clean all", or "sudo make clean install" if +you prefer to install after rebuilding. It may be necessary to undo any previous operations. Invoking "make clean" will delete all object code generated (binaries included) during earlier From baba049dabc7b228fd50b6db07972cf1e7445f1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Louren=C3=A7o?= <16304376+samuelfmlourenco@users.noreply.github.com> Date: Sun, 24 Jul 2022 20:34:12 +0100 Subject: [PATCH 62/62] Add files via upload --- README.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.txt b/README.txt index bed80cb..619ce5e 100644 --- a/README.txt +++ b/README.txt @@ -15,9 +15,10 @@ to do is run "install.sh" by invoking "sudo ./install.sh" on a terminal window, after changing your working directory to the current one. This script will first obtain and install the required "build-essential" and "libusb-1.0-0-dev" packages (if they are not installed yet). Then it will -compile the binaries and move them to "/usr/local/bin/". It will also copy -related man pages to "/usr/local/share/man/man1/". Finally, it will create the -necessary rules for accessing the device. +compile the binaries and move them to "/usr/local/bin/". Note that the build +process will also compress the respective man pages and copy them to +"/usr/local/share/man/man1/". Finally, it will create the necessary rules for +accessing the device. The package also includes a test script named "test.sh". This will set up GF2 so that it generates a 1KHz triangle wave signal with its amplitude set to