refactor tree, add ecad, mcad

This commit is contained in:
2019-08-28 23:23:48 -07:00
parent d5ddd76bef
commit ae837eef12
45 changed files with 4629 additions and 169 deletions

354
cad/PcbSketch.step Normal file
View File

@@ -0,0 +1,354 @@
ISO-10303-21;
HEADER;
FILE_DESCRIPTION(('FreeCAD Model'),'2;1');
FILE_NAME('/home/max/work/stm32f0_demo/cad/PcbSketch.step',
'2019-08-24T22:13:15',('kicad StepUp'),('ksu MCAD'),
'Open CASCADE STEP processor 7.0','FreeCAD','Unknown');
FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214 1 1 1 1 }'));
ENDSEC;
DATA;
#1 = APPLICATION_PROTOCOL_DEFINITION('international standard',
'automotive_design',2000,#2);
#2 = APPLICATION_CONTEXT(
'core data for automotive mechanical design processes');
#3 = SHAPE_DEFINITION_REPRESENTATION(#4,#10);
#4 = PRODUCT_DEFINITION_SHAPE('','',#5);
#5 = PRODUCT_DEFINITION('design','',#6,#9);
#6 = PRODUCT_DEFINITION_FORMATION('','',#7);
#7 = PRODUCT('PcbSketch','PcbSketch','',(#8));
#8 = PRODUCT_CONTEXT('',#2,'mechanical');
#9 = PRODUCT_DEFINITION_CONTEXT('part definition',#2,'design');
#10 = SHAPE_REPRESENTATION('',(#11,#15,#215,#224,#233,#242),#251);
#11 = AXIS2_PLACEMENT_3D('',#12,#13,#14);
#12 = CARTESIAN_POINT('',(0.,0.,0.));
#13 = DIRECTION('',(0.,0.,1.));
#14 = DIRECTION('',(1.,0.,-0.));
#15 = GEOMETRIC_CURVE_SET('',(#16,#23,#30,#38,#45,#53,#60,#68,#75,#83,
#90,#97,#105,#112,#120,#127,#134,#141,#149,#156,#163,#171,#178,#185,
#192,#200,#207));
#16 = TRIMMED_CURVE('',#17,(#21,PARAMETER_VALUE(0.)),(#22,
PARAMETER_VALUE(1.1)),.T.,.PARAMETER.);
#17 = LINE('',#18,#19);
#18 = CARTESIAN_POINT('',(16.4,8.850842753845,0.));
#19 = VECTOR('',#20,1.);
#20 = DIRECTION('',(1.,0.,0.));
#21 = CARTESIAN_POINT('',(16.4,8.850842753845,0.));
#22 = CARTESIAN_POINT('',(17.5,8.850842753845,0.));
#23 = TRIMMED_CURVE('',#24,(#28,PARAMETER_VALUE(0.)),(#29,
PARAMETER_VALUE(5.649157246155)),.T.,.PARAMETER.);
#24 = LINE('',#25,#26);
#25 = CARTESIAN_POINT('',(17.5,8.850842753845,0.));
#26 = VECTOR('',#27,1.);
#27 = DIRECTION('',(6.288926868195E-16,1.,0.));
#28 = CARTESIAN_POINT('',(17.5,8.850842753845,0.));
#29 = CARTESIAN_POINT('',(17.5,14.5,0.));
#30 = TRIMMED_CURVE('',#31,(#36,PARAMETER_VALUE(2.80357188279E-16)),(#37
,PARAMETER_VALUE(1.570796326795)),.T.,.PARAMETER.);
#31 = CIRCLE('',#32,3.);
#32 = AXIS2_PLACEMENT_3D('',#33,#34,#35);
#33 = CARTESIAN_POINT('',(14.5,14.5,0.));
#34 = DIRECTION('',(0.,0.,1.));
#35 = DIRECTION('',(1.,0.,0.));
#36 = CARTESIAN_POINT('',(17.5,14.5,0.));
#37 = CARTESIAN_POINT('',(14.5,17.5,0.));
#38 = TRIMMED_CURVE('',#39,(#43,PARAMETER_VALUE(0.)),(#44,
PARAMETER_VALUE(29.)),.T.,.PARAMETER.);
#39 = LINE('',#40,#41);
#40 = CARTESIAN_POINT('',(14.5,17.5,0.));
#41 = VECTOR('',#42,1.);
#42 = DIRECTION('',(-1.,0.,0.));
#43 = CARTESIAN_POINT('',(14.5,17.5,0.));
#44 = CARTESIAN_POINT('',(-14.5,17.5,0.));
#45 = TRIMMED_CURVE('',#46,(#51,PARAMETER_VALUE(1.570796326795)),(#52,
PARAMETER_VALUE(3.14159265359)),.T.,.PARAMETER.);
#46 = CIRCLE('',#47,3.);
#47 = AXIS2_PLACEMENT_3D('',#48,#49,#50);
#48 = CARTESIAN_POINT('',(-14.5,14.5,0.));
#49 = DIRECTION('',(0.,0.,1.));
#50 = DIRECTION('',(1.,0.,0.));
#51 = CARTESIAN_POINT('',(-14.5,17.5,0.));
#52 = CARTESIAN_POINT('',(-17.5,14.5,0.));
#53 = TRIMMED_CURVE('',#54,(#58,PARAMETER_VALUE(0.)),(#59,
PARAMETER_VALUE(29.)),.T.,.PARAMETER.);
#54 = LINE('',#55,#56);
#55 = CARTESIAN_POINT('',(-17.5,14.5,0.));
#56 = VECTOR('',#57,1.);
#57 = DIRECTION('',(0.,-1.,0.));
#58 = CARTESIAN_POINT('',(-17.5,14.5,0.));
#59 = CARTESIAN_POINT('',(-17.5,-14.5,0.));
#60 = TRIMMED_CURVE('',#61,(#66,PARAMETER_VALUE(3.14159265359)),(#67,
PARAMETER_VALUE(4.712388980385)),.T.,.PARAMETER.);
#61 = CIRCLE('',#62,3.);
#62 = AXIS2_PLACEMENT_3D('',#63,#64,#65);
#63 = CARTESIAN_POINT('',(-14.5,-14.5,0.));
#64 = DIRECTION('',(0.,0.,1.));
#65 = DIRECTION('',(1.,0.,0.));
#66 = CARTESIAN_POINT('',(-17.5,-14.5,0.));
#67 = CARTESIAN_POINT('',(-14.5,-17.5,0.));
#68 = TRIMMED_CURVE('',#69,(#73,PARAMETER_VALUE(0.)),(#74,
PARAMETER_VALUE(29.)),.T.,.PARAMETER.);
#69 = LINE('',#70,#71);
#70 = CARTESIAN_POINT('',(-14.5,-17.5,0.));
#71 = VECTOR('',#72,1.);
#72 = DIRECTION('',(1.,0.,0.));
#73 = CARTESIAN_POINT('',(-14.5,-17.5,0.));
#74 = CARTESIAN_POINT('',(14.5,-17.5,0.));
#75 = TRIMMED_CURVE('',#76,(#81,PARAMETER_VALUE(4.712388980385)),(#82,
PARAMETER_VALUE(6.28318530718)),.T.,.PARAMETER.);
#76 = CIRCLE('',#77,3.);
#77 = AXIS2_PLACEMENT_3D('',#78,#79,#80);
#78 = CARTESIAN_POINT('',(14.5,-14.5,0.));
#79 = DIRECTION('',(0.,0.,1.));
#80 = DIRECTION('',(1.,0.,0.));
#81 = CARTESIAN_POINT('',(14.5,-17.5,0.));
#82 = CARTESIAN_POINT('',(17.5,-14.5,0.));
#83 = TRIMMED_CURVE('',#84,(#88,PARAMETER_VALUE(0.)),(#89,
PARAMETER_VALUE(5.550842753845)),.T.,.PARAMETER.);
#84 = LINE('',#85,#86);
#85 = CARTESIAN_POINT('',(17.5,-14.5,0.));
#86 = VECTOR('',#87,1.);
#87 = DIRECTION('',(0.,1.,0.));
#88 = CARTESIAN_POINT('',(17.5,-14.5,0.));
#89 = CARTESIAN_POINT('',(17.5,-8.949157246155,0.));
#90 = TRIMMED_CURVE('',#91,(#95,PARAMETER_VALUE(0.)),(#96,
PARAMETER_VALUE(1.1)),.T.,.PARAMETER.);
#91 = LINE('',#92,#93);
#92 = CARTESIAN_POINT('',(17.5,-8.949157246155,0.));
#93 = VECTOR('',#94,1.);
#94 = DIRECTION('',(-1.,0.,0.));
#95 = CARTESIAN_POINT('',(17.5,-8.949157246155,0.));
#96 = CARTESIAN_POINT('',(16.4,-8.949157246155,0.));
#97 = TRIMMED_CURVE('',#98,(#103,PARAMETER_VALUE(3.14159265359)),(#104,
PARAMETER_VALUE(4.712388980385)),.T.,.PARAMETER.);
#98 = CIRCLE('',#99,0.25);
#99 = AXIS2_PLACEMENT_3D('',#100,#101,#102);
#100 = CARTESIAN_POINT('',(16.4,-8.699157246155,0.));
#101 = DIRECTION('',(0.,0.,1.));
#102 = DIRECTION('',(1.,0.,0.));
#103 = CARTESIAN_POINT('',(16.15,-8.699157246155,0.));
#104 = CARTESIAN_POINT('',(16.4,-8.949157246155,0.));
#105 = TRIMMED_CURVE('',#106,(#110,PARAMETER_VALUE(0.)),(#111,
PARAMETER_VALUE(3.3)),.T.,.PARAMETER.);
#106 = LINE('',#107,#108);
#107 = CARTESIAN_POINT('',(16.15,-5.399157246155,0.));
#108 = VECTOR('',#109,1.);
#109 = DIRECTION('',(0.,-1.,0.));
#110 = CARTESIAN_POINT('',(16.15,-5.399157246155,0.));
#111 = CARTESIAN_POINT('',(16.15,-8.699157246155,0.));
#112 = TRIMMED_CURVE('',#113,(#118,PARAMETER_VALUE(1.570796326795)),(
#119,PARAMETER_VALUE(3.14159265359)),.T.,.PARAMETER.);
#113 = CIRCLE('',#114,0.25);
#114 = AXIS2_PLACEMENT_3D('',#115,#116,#117);
#115 = CARTESIAN_POINT('',(16.4,-5.399157246155,0.));
#116 = DIRECTION('',(0.,0.,1.));
#117 = DIRECTION('',(1.,0.,0.));
#118 = CARTESIAN_POINT('',(16.4,-5.149157246155,0.));
#119 = CARTESIAN_POINT('',(16.15,-5.399157246155,0.));
#120 = TRIMMED_CURVE('',#121,(#125,PARAMETER_VALUE(0.)),(#126,
PARAMETER_VALUE(1.1)),.T.,.PARAMETER.);
#121 = LINE('',#122,#123);
#122 = CARTESIAN_POINT('',(16.4,-5.149157246155,0.));
#123 = VECTOR('',#124,1.);
#124 = DIRECTION('',(1.,0.,0.));
#125 = CARTESIAN_POINT('',(16.4,-5.149157246155,0.));
#126 = CARTESIAN_POINT('',(17.5,-5.149157246155,0.));
#127 = TRIMMED_CURVE('',#128,(#132,PARAMETER_VALUE(0.)),(#133,
PARAMETER_VALUE(3.2)),.T.,.PARAMETER.);
#128 = LINE('',#129,#130);
#129 = CARTESIAN_POINT('',(17.5,-5.149157246155,0.));
#130 = VECTOR('',#131,1.);
#131 = DIRECTION('',(0.,1.,0.));
#132 = CARTESIAN_POINT('',(17.5,-5.149157246155,0.));
#133 = CARTESIAN_POINT('',(17.5,-1.949157246155,0.));
#134 = TRIMMED_CURVE('',#135,(#139,PARAMETER_VALUE(0.)),(#140,
PARAMETER_VALUE(1.1)),.T.,.PARAMETER.);
#135 = LINE('',#136,#137);
#136 = CARTESIAN_POINT('',(17.5,-1.949157246155,0.));
#137 = VECTOR('',#138,1.);
#138 = DIRECTION('',(-1.,0.,0.));
#139 = CARTESIAN_POINT('',(17.5,-1.949157246155,0.));
#140 = CARTESIAN_POINT('',(16.4,-1.949157246155,0.));
#141 = TRIMMED_CURVE('',#142,(#147,PARAMETER_VALUE(3.14159265359)),(#148
,PARAMETER_VALUE(4.712388980385)),.T.,.PARAMETER.);
#142 = CIRCLE('',#143,0.25);
#143 = AXIS2_PLACEMENT_3D('',#144,#145,#146);
#144 = CARTESIAN_POINT('',(16.4,-1.699157246155,0.));
#145 = DIRECTION('',(0.,0.,1.));
#146 = DIRECTION('',(1.,0.,0.));
#147 = CARTESIAN_POINT('',(16.15,-1.699157246155,0.));
#148 = CARTESIAN_POINT('',(16.4,-1.949157246155,0.));
#149 = TRIMMED_CURVE('',#150,(#154,PARAMETER_VALUE(0.)),(#155,
PARAMETER_VALUE(1.699157246155)),.T.,.PARAMETER.);
#150 = LINE('',#151,#152);
#151 = CARTESIAN_POINT('',(16.15,0.,0.));
#152 = VECTOR('',#153,1.);
#153 = DIRECTION('',(0.,-1.,0.));
#154 = CARTESIAN_POINT('',(16.15,0.,0.));
#155 = CARTESIAN_POINT('',(16.15,-1.699157246155,0.));
#156 = TRIMMED_CURVE('',#157,(#161,PARAMETER_VALUE(0.)),(#162,
PARAMETER_VALUE(1.699157246155)),.T.,.PARAMETER.);
#157 = LINE('',#158,#159);
#158 = CARTESIAN_POINT('',(16.15,0.,0.));
#159 = VECTOR('',#160,1.);
#160 = DIRECTION('',(0.,1.,0.));
#161 = CARTESIAN_POINT('',(16.15,0.,0.));
#162 = CARTESIAN_POINT('',(16.15,1.699157246155,0.));
#163 = TRIMMED_CURVE('',#164,(#169,PARAMETER_VALUE(1.570796326795)),(
#170,PARAMETER_VALUE(2.737187459543)),.T.,.PARAMETER.);
#164 = CIRCLE('',#165,0.25);
#165 = AXIS2_PLACEMENT_3D('',#166,#167,#168);
#166 = CARTESIAN_POINT('',(16.379834149817,1.600789245374,0.));
#167 = DIRECTION('',(0.,0.,1.));
#168 = DIRECTION('',(1.,0.,0.));
#169 = CARTESIAN_POINT('',(16.379834149817,1.850789245374,0.));
#170 = CARTESIAN_POINT('',(16.15,1.699157246155,0.));
#171 = TRIMMED_CURVE('',#172,(#176,PARAMETER_VALUE(0.)),(#177,
PARAMETER_VALUE(1.120165850183)),.T.,.PARAMETER.);
#172 = LINE('',#173,#174);
#173 = CARTESIAN_POINT('',(16.379834149817,1.850789245374,0.));
#174 = VECTOR('',#175,1.);
#175 = DIRECTION('',(1.,0.,0.));
#176 = CARTESIAN_POINT('',(16.379834149817,1.850789245374,0.));
#177 = CARTESIAN_POINT('',(17.5,1.850789245374,0.));
#178 = TRIMMED_CURVE('',#179,(#183,PARAMETER_VALUE(0.)),(#184,
PARAMETER_VALUE(3.200053508471)),.T.,.PARAMETER.);
#179 = LINE('',#180,#181);
#180 = CARTESIAN_POINT('',(17.5,1.850789245374,0.));
#181 = VECTOR('',#182,1.);
#182 = DIRECTION('',(0.,1.,0.));
#183 = CARTESIAN_POINT('',(17.5,1.850789245374,0.));
#184 = CARTESIAN_POINT('',(17.5,5.050842753845,0.));
#185 = TRIMMED_CURVE('',#186,(#190,PARAMETER_VALUE(0.)),(#191,
PARAMETER_VALUE(1.1)),.T.,.PARAMETER.);
#186 = LINE('',#187,#188);
#187 = CARTESIAN_POINT('',(17.5,5.050842753845,0.));
#188 = VECTOR('',#189,1.);
#189 = DIRECTION('',(-1.,0.,0.));
#190 = CARTESIAN_POINT('',(17.5,5.050842753845,0.));
#191 = CARTESIAN_POINT('',(16.4,5.050842753845,0.));
#192 = TRIMMED_CURVE('',#193,(#198,PARAMETER_VALUE(3.14159265359)),(#199
,PARAMETER_VALUE(4.712388980385)),.T.,.PARAMETER.);
#193 = CIRCLE('',#194,0.25);
#194 = AXIS2_PLACEMENT_3D('',#195,#196,#197);
#195 = CARTESIAN_POINT('',(16.4,5.300842753845,0.));
#196 = DIRECTION('',(0.,0.,1.));
#197 = DIRECTION('',(1.,0.,0.));
#198 = CARTESIAN_POINT('',(16.15,5.300842753845,0.));
#199 = CARTESIAN_POINT('',(16.4,5.050842753845,0.));
#200 = TRIMMED_CURVE('',#201,(#205,PARAMETER_VALUE(0.)),(#206,
PARAMETER_VALUE(3.3)),.T.,.PARAMETER.);
#201 = LINE('',#202,#203);
#202 = CARTESIAN_POINT('',(16.15,8.600842753845,0.));
#203 = VECTOR('',#204,1.);
#204 = DIRECTION('',(0.,-1.,0.));
#205 = CARTESIAN_POINT('',(16.15,8.600842753845,0.));
#206 = CARTESIAN_POINT('',(16.15,5.300842753845,0.));
#207 = TRIMMED_CURVE('',#208,(#213,PARAMETER_VALUE(1.570796326795)),(
#214,PARAMETER_VALUE(3.14159265359)),.T.,.PARAMETER.);
#208 = CIRCLE('',#209,0.25);
#209 = AXIS2_PLACEMENT_3D('',#210,#211,#212);
#210 = CARTESIAN_POINT('',(16.4,8.600842753845,0.));
#211 = DIRECTION('',(0.,0.,1.));
#212 = DIRECTION('',(1.,0.,0.));
#213 = CARTESIAN_POINT('',(16.4,8.850842753845,0.));
#214 = CARTESIAN_POINT('',(16.15,8.600842753845,0.));
#215 = GEOMETRIC_CURVE_SET('',(#216));
#216 = TRIMMED_CURVE('',#217,(#222,PARAMETER_VALUE(0.)),(#223,
PARAMETER_VALUE(6.28318530718)),.T.,.PARAMETER.);
#217 = CIRCLE('',#218,1.1);
#218 = AXIS2_PLACEMENT_3D('',#219,#220,#221);
#219 = CARTESIAN_POINT('',(-15.455,13.5,0.));
#220 = DIRECTION('',(0.,0.,1.));
#221 = DIRECTION('',(1.,0.,0.));
#222 = CARTESIAN_POINT('',(-14.355,13.5,0.));
#223 = CARTESIAN_POINT('',(-14.355,13.5,0.));
#224 = GEOMETRIC_CURVE_SET('',(#225));
#225 = TRIMMED_CURVE('',#226,(#231,PARAMETER_VALUE(0.)),(#232,
PARAMETER_VALUE(6.28318530718)),.T.,.PARAMETER.);
#226 = CIRCLE('',#227,1.1);
#227 = AXIS2_PLACEMENT_3D('',#228,#229,#230);
#228 = CARTESIAN_POINT('',(-15.455,-13.5,0.));
#229 = DIRECTION('',(0.,0.,1.));
#230 = DIRECTION('',(1.,0.,0.));
#231 = CARTESIAN_POINT('',(-14.355,-13.5,0.));
#232 = CARTESIAN_POINT('',(-14.355,-13.5,0.));
#233 = GEOMETRIC_CURVE_SET('',(#234));
#234 = TRIMMED_CURVE('',#235,(#240,PARAMETER_VALUE(0.)),(#241,
PARAMETER_VALUE(6.28318530718)),.T.,.PARAMETER.);
#235 = CIRCLE('',#236,1.1);
#236 = AXIS2_PLACEMENT_3D('',#237,#238,#239);
#237 = CARTESIAN_POINT('',(15.455,-13.5,0.));
#238 = DIRECTION('',(0.,0.,1.));
#239 = DIRECTION('',(1.,0.,0.));
#240 = CARTESIAN_POINT('',(16.555,-13.5,0.));
#241 = CARTESIAN_POINT('',(16.555,-13.5,0.));
#242 = GEOMETRIC_CURVE_SET('',(#243));
#243 = TRIMMED_CURVE('',#244,(#249,PARAMETER_VALUE(0.)),(#250,
PARAMETER_VALUE(6.28318530718)),.T.,.PARAMETER.);
#244 = CIRCLE('',#245,1.1);
#245 = AXIS2_PLACEMENT_3D('',#246,#247,#248);
#246 = CARTESIAN_POINT('',(15.455,13.5,0.));
#247 = DIRECTION('',(0.,0.,1.));
#248 = DIRECTION('',(1.,0.,0.));
#249 = CARTESIAN_POINT('',(16.555,13.5,0.));
#250 = CARTESIAN_POINT('',(16.555,13.5,0.));
#251 = ( GEOMETRIC_REPRESENTATION_CONTEXT(3)
GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((#255)) GLOBAL_UNIT_ASSIGNED_CONTEXT
((#252,#253,#254)) REPRESENTATION_CONTEXT('Context #1',
'3D Context with UNIT and UNCERTAINTY') );
#252 = ( LENGTH_UNIT() NAMED_UNIT(*) SI_UNIT(.MILLI.,.METRE.) );
#253 = ( NAMED_UNIT(*) PLANE_ANGLE_UNIT() SI_UNIT($,.RADIAN.) );
#254 = ( NAMED_UNIT(*) SI_UNIT($,.STERADIAN.) SOLID_ANGLE_UNIT() );
#255 = UNCERTAINTY_MEASURE_WITH_UNIT(LENGTH_MEASURE(1.E-07),#252,
'distance_accuracy_value','confusion accuracy');
#256 = PRODUCT_RELATED_PRODUCT_CATEGORY('part',$,(#7));
#257 = MECHANICAL_DESIGN_GEOMETRIC_PRESENTATION_REPRESENTATION('',(#258,
#268,#277,#286,#295),#251);
#258 = STYLED_ITEM('color',(#259),#15);
#259 = PRESENTATION_STYLE_ASSIGNMENT((#260,#266));
#260 = SURFACE_STYLE_USAGE(.BOTH.,#261);
#261 = SURFACE_SIDE_STYLE('',(#262));
#262 = SURFACE_STYLE_FILL_AREA(#263);
#263 = FILL_AREA_STYLE('',(#264));
#264 = FILL_AREA_STYLE_COLOUR('',#265);
#265 = COLOUR_RGB('',0.800000011921,0.800000011921,0.800000011921);
#266 = CURVE_STYLE('',#267,POSITIVE_LENGTH_MEASURE(0.1),#265);
#267 = DRAUGHTING_PRE_DEFINED_CURVE_FONT('continuous');
#268 = STYLED_ITEM('color',(#269),#215);
#269 = PRESENTATION_STYLE_ASSIGNMENT((#270,#275));
#270 = SURFACE_STYLE_USAGE(.BOTH.,#271);
#271 = SURFACE_SIDE_STYLE('',(#272));
#272 = SURFACE_STYLE_FILL_AREA(#273);
#273 = FILL_AREA_STYLE('',(#274));
#274 = FILL_AREA_STYLE_COLOUR('',#265);
#275 = CURVE_STYLE('',#276,POSITIVE_LENGTH_MEASURE(0.1),#265);
#276 = DRAUGHTING_PRE_DEFINED_CURVE_FONT('continuous');
#277 = STYLED_ITEM('color',(#278),#224);
#278 = PRESENTATION_STYLE_ASSIGNMENT((#279,#284));
#279 = SURFACE_STYLE_USAGE(.BOTH.,#280);
#280 = SURFACE_SIDE_STYLE('',(#281));
#281 = SURFACE_STYLE_FILL_AREA(#282);
#282 = FILL_AREA_STYLE('',(#283));
#283 = FILL_AREA_STYLE_COLOUR('',#265);
#284 = CURVE_STYLE('',#285,POSITIVE_LENGTH_MEASURE(0.1),#265);
#285 = DRAUGHTING_PRE_DEFINED_CURVE_FONT('continuous');
#286 = STYLED_ITEM('color',(#287),#233);
#287 = PRESENTATION_STYLE_ASSIGNMENT((#288,#293));
#288 = SURFACE_STYLE_USAGE(.BOTH.,#289);
#289 = SURFACE_SIDE_STYLE('',(#290));
#290 = SURFACE_STYLE_FILL_AREA(#291);
#291 = FILL_AREA_STYLE('',(#292));
#292 = FILL_AREA_STYLE_COLOUR('',#265);
#293 = CURVE_STYLE('',#294,POSITIVE_LENGTH_MEASURE(0.1),#265);
#294 = DRAUGHTING_PRE_DEFINED_CURVE_FONT('continuous');
#295 = STYLED_ITEM('color',(#296),#242);
#296 = PRESENTATION_STYLE_ASSIGNMENT((#297,#302));
#297 = SURFACE_STYLE_USAGE(.BOTH.,#298);
#298 = SURFACE_SIDE_STYLE('',(#299));
#299 = SURFACE_STYLE_FILL_AREA(#300);
#300 = FILL_AREA_STYLE('',(#301));
#301 = FILL_AREA_STYLE_COLOUR('',#265);
#302 = CURVE_STYLE('',#303,POSITIVE_LENGTH_MEASURE(0.1),#265);
#303 = DRAUGHTING_PRE_DEFINED_CURVE_FONT('continuous');
ENDSEC;
END-ISO-10303-21;

3
cad/PcbSketch.wrl Normal file
View File

@@ -0,0 +1,3 @@
#VRML V2.0 utf8
#kicad StepUp wrl exported

470
cad/button_pads.dxf Normal file
View File

@@ -0,0 +1,470 @@
0
SECTION
2
HEADER
9
$ACADVER
1
AC1009
9
$INSBASE
10
0.0
20
0.0
30
0.0
9
$EXTMIN
10
0.0
20
0.0
30
0.0
9
$EXTMAX
10
0.0
20
0.0
30
0.0
0
ENDSEC
0
SECTION
2
TABLES
0
TABLE
2
VPORT
70
0
0
ENDTAB
0
TABLE
2
LTYPE
70
1
0
LTYPE
2
CONTINUOUS
70
0
3
Solid line
72
65
73
0
40
0.0
0
ENDTAB
0
TABLE
2
LAYER
70
1
0
LAYER
2
0
70
64
62
7
6
continuous
0
ENDTAB
0
TABLE
2
STYLE
70
1
0
STYLE
2
STANDARD
70
0
40
0
41
1.0
50
0.0
71
0
42
1
3
ARIAL.TTF
4
0
ENDTAB
0
TABLE
2
VIEW
70
0
0
ENDTAB
0
ENDSEC
0
SECTION
2
BLOCKS
0
BLOCK
8
0
2
SKETCH
70
0
10
0.0
20
0.0
30
0.0
3
SKETCH
0
POLYLINE
8
0
62
7
70
1
66
1
10
0.0
20
0.0
30
0.0
0
VERTEX
8
0
10
-1.55
20
0.0
30
0.0
0
VERTEX
8
0
10
-0.75
20
0.0
30
0.0
0
VERTEX
8
0
10
-0.75
20
1.25
30
0.0
0
VERTEX
8
0
10
-1.55
20
1.25
30
0.0
0
SEQEND
8
0
0
POLYLINE
8
0
62
7
70
1
66
1
10
0.0
20
0.0
30
0.0
0
VERTEX
8
0
10
-0.40000000000000013
20
0.0
30
0.0
0
VERTEX
8
0
10
0.4
20
0.0
30
0.0
0
VERTEX
8
0
10
0.4
20
1.25
30
0.0
0
VERTEX
8
0
10
-0.40000000000000013
20
1.25
30
0.0
0
SEQEND
8
0
0
POLYLINE
8
0
62
7
70
1
66
1
10
0.0
20
0.0
30
0.0
0
VERTEX
8
0
10
0.7499999999999998
20
0.0
30
0.0
0
VERTEX
8
0
10
1.55
20
0.0
30
0.0
0
VERTEX
8
0
10
1.55
20
1.25
30
0.0
0
VERTEX
8
0
10
0.7499999999999998
20
1.25
30
0.0
0
SEQEND
8
0
0
POLYLINE
8
0
62
7
70
1
66
1
10
0.0
20
0.0
30
0.0
0
VERTEX
8
0
10
-2.15
20
-0.44999999999999996
30
0.0
0
VERTEX
8
0
10
-2.7999999999999994
20
-0.44999999999999996
30
0.0
0
VERTEX
8
0
10
-2.7999999999999994
20
-1.15
30
0.0
0
VERTEX
8
0
10
-2.15
20
-1.15
30
0.0
0
SEQEND
8
0
0
POLYLINE
8
0
62
7
70
1
66
1
10
0.0
20
0.0
30
0.0
0
VERTEX
8
0
10
2.8000000000000003
20
-0.44999999999999996
30
0.0
0
VERTEX
8
0
10
2.15
20
-0.45
30
0.0
0
VERTEX
8
0
10
2.15
20
-1.15
30
0.0
0
VERTEX
8
0
10
2.8000000000000003
20
-1.15
30
0.0
0
SEQEND
8
0
0
ENDBLK
0
ENDSEC
0
SECTION
2
ENTITIES
0
INSERT
2
SKETCH
8
0
62
7
10
0.0
20
0.0
30
0.0
0
ENDSEC
0
EOF

536
cad/pcb_outline.dxf Normal file
View File

@@ -0,0 +1,536 @@
0
SECTION
2
HEADER
9
$ACADVER
1
AC1009
9
$INSBASE
10
0.0
20
0.0
30
0.0
9
$EXTMIN
10
0.0
20
0.0
30
0.0
9
$EXTMAX
10
0.0
20
0.0
30
0.0
0
ENDSEC
0
SECTION
2
TABLES
0
TABLE
2
VPORT
70
0
0
ENDTAB
0
TABLE
2
LTYPE
70
1
0
LTYPE
2
CONTINUOUS
70
0
3
Solid line
72
65
73
0
40
0.0
0
ENDTAB
0
TABLE
2
LAYER
70
1
0
LAYER
2
0
70
64
62
7
6
continuous
0
ENDTAB
0
TABLE
2
STYLE
70
1
0
STYLE
2
STANDARD
70
0
40
0
41
1.0
50
0.0
71
0
42
1
3
ARIAL.TTF
4
0
ENDTAB
0
TABLE
2
VIEW
70
0
0
ENDTAB
0
ENDSEC
0
SECTION
2
BLOCKS
0
BLOCK
8
0
2
SKETCH
70
0
10
0.0
20
0.0
30
0.0
3
SKETCH
0
POLYLINE
8
0
62
7
70
1
66
1
10
0.0
20
0.0
30
0.0
0
VERTEX
8
0
10
16.400000000000002
20
7.431276388518711
30
0.0
0
VERTEX
8
0
10
17.5
20
7.431276388518711
30
0.0
0
VERTEX
8
0
10
17.5
20
14.5
30
0.0
42
0.414213562373095
0
VERTEX
8
0
10
14.500000000000002
20
17.5
30
0.0
0
VERTEX
8
0
10
-14.500000000000002
20
17.5
30
0.0
42
0.414213562373095
0
VERTEX
8
0
10
-17.5
20
14.5
30
0.0
0
VERTEX
8
0
10
-17.5
20
-14.5
30
0.0
42
0.41421356237309503
0
VERTEX
8
0
10
-14.500000000000002
20
-17.5
30
0.0
0
VERTEX
8
0
10
14.499999999999995
20
-17.5
30
0.0
42
0.41421356237309503
0
VERTEX
8
0
10
17.499999999999993
20
-14.5
30
0.0
0
VERTEX
8
0
10
17.499999999999996
20
-8.949158870918295
30
0.0
0
VERTEX
8
0
10
16.4
20
-8.949158870918295
30
0.0
42
-0.4142135623730932
0
VERTEX
8
0
10
16.15
20
-8.699158870918295
30
0.0
0
VERTEX
8
0
10
16.15
20
-5.399158870918294
30
0.0
42
-0.4142135623730967
0
VERTEX
8
0
10
16.4
20
-5.149158870918294
30
0.0
0
VERTEX
8
0
10
17.5
20
-5.149158870918294
30
0.0
0
VERTEX
8
0
10
17.5
20
-1.9491588709182937
30
0.0
0
VERTEX
8
0
10
16.4
20
-1.9491588709182934
30
0.0
42
-0.4142135623730933
0
VERTEX
8
0
10
16.15
20
-1.6991588709182937
30
0.0
0
VERTEX
8
0
10
16.15
20
-4.0275046997025876e-29
30
0.0
0
VERTEX
8
0
10
16.15
20
1.6991588709182937
30
0.0
42
-0.30014982232863346
0
VERTEX
8
0
10
16.379832755841093
20
1.850787613213165
30
0.0
0
VERTEX
8
0
10
17.5
20
1.850787613213165
30
0.0
0
VERTEX
8
0
10
17.5
20
3.631276388518711
30
0.0
0
VERTEX
8
0
10
16.400000000000002
20
3.631276388518711
30
0.0
42
-0.41421356237309437
0
VERTEX
8
0
10
16.150000000000002
20
3.881276388518711
30
0.0
0
VERTEX
8
0
10
16.150000000000002
20
7.181276388518711
30
0.0
42
-0.4142135623730962
0
SEQEND
8
0
0
CIRCLE
8
0
62
7
10
-15.5
20
13.499999999999998
30
0.0
40
1.1
0
CIRCLE
8
0
62
7
10
-15.5
20
-13.499999999999995
30
0.0
40
1.1
0
CIRCLE
8
0
62
7
10
15.5
20
-13.499999999999995
30
0.0
40
1.1
0
CIRCLE
8
0
62
7
10
15.5
20
13.499999999999998
30
0.0
40
1.1
0
ENDBLK
0
ENDSEC
0
SECTION
2
ENTITIES
0
INSERT
2
SKETCH
8
0
62
7
10
0.0
20
0.0
30
0.0
0
ENDSEC
0
EOF

BIN
cad/watch_board.FCStd Normal file

Binary file not shown.

BIN
cad/watch_board.FCStd1 Normal file

Binary file not shown.

395
ecad/watch-v1_1.net Normal file
View File

@@ -0,0 +1,395 @@
(export (version D)
(design
(source /home/max/work/kicad/kicad.sch)
(date "Wed 28 Aug 2019 08:52:54 PM PDT")
(tool "Eeschema 5.0.2+dfsg1-1")
(sheet (number 1) (name /) (tstamps /)
(title_block
(title)
(company)
(rev)
(date)
(source kicad.sch)
(comment (number 1) (value ""))
(comment (number 2) (value ""))
(comment (number 3) (value ""))
(comment (number 4) (value "")))))
(components
(comp (ref U1)
(value STM32L031F6Px)
(footprint Package_SO:TSSOP-20_4.4x6.5mm_P0.65mm)
(libsource (lib kicad-rescue) (part STM32L031F6Px) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5CBC08BF))
(comp (ref Y1)
(value Crystal)
(footprint Crystal:Crystal_SMD_G8-2Pin_3.2x1.5mm_HandSoldering)
(datasheet ~)
(libsource (lib Device) (part Crystal) (description "Two pin crystal"))
(sheetpath (names /) (tstamps /))
(tstamp 5CC13AA5))
(comp (ref SW1)
(value SW_Push)
(footprint footprints:Panasonic_RightAngle_Button)
(libsource (lib Switch) (part SW_Push) (description "Push button switch, generic, two pins"))
(sheetpath (names /) (tstamps /))
(tstamp 5CC13D70))
(comp (ref SW2)
(value SW_Push)
(footprint footprints:Panasonic_RightAngle_Button)
(libsource (lib Switch) (part SW_Push) (description "Push button switch, generic, two pins"))
(sheetpath (names /) (tstamps /))
(tstamp 5CC13E33))
(comp (ref SW3)
(value SW_Push)
(footprint footprints:Panasonic_RightAngle_Button)
(libsource (lib Switch) (part SW_Push) (description "Push button switch, generic, two pins"))
(sheetpath (names /) (tstamps /))
(tstamp 5CC13EAF))
(comp (ref C3)
(value 4.3pF)
(footprint Capacitor_SMD:C_0805_2012Metric_Pad1.15x1.40mm_HandSolder)
(datasheet ~)
(libsource (lib Device) (part C_Small) (description "Unpolarized capacitor, small symbol"))
(sheetpath (names /) (tstamps /))
(tstamp 5CC14877))
(comp (ref C4)
(value 4.3pF)
(footprint Capacitor_SMD:C_0805_2012Metric_Pad1.15x1.40mm_HandSolder)
(datasheet ~)
(libsource (lib Device) (part C_Small) (description "Unpolarized capacitor, small symbol"))
(sheetpath (names /) (tstamps /))
(tstamp 5CC14926))
(comp (ref C1)
(value 100nF)
(footprint Capacitor_SMD:C_0805_2012Metric_Pad1.15x1.40mm_HandSolder)
(datasheet ~)
(fields
(field (name Spice_Model) 100nF)
(field (name Spice_Netlist_Enabled) Y)
(field (name Spice_Primitive) C))
(libsource (lib Device) (part C_Small) (description "Unpolarized capacitor, small symbol"))
(sheetpath (names /) (tstamps /))
(tstamp 5CC1601D))
(comp (ref C2)
(value 100nF)
(footprint Capacitor_SMD:C_0805_2012Metric_Pad1.15x1.40mm_HandSolder)
(datasheet ~)
(libsource (lib Device) (part C_Small) (description "Unpolarized capacitor, small symbol"))
(sheetpath (names /) (tstamps /))
(tstamp 5CC160C6))
(comp (ref C6)
(value 100nF)
(footprint Capacitor_SMD:C_0805_2012Metric_Pad1.15x1.40mm_HandSolder)
(datasheet ~)
(libsource (lib Device) (part C_Small) (description "Unpolarized capacitor, small symbol"))
(sheetpath (names /) (tstamps /))
(tstamp 5CC1613E))
(comp (ref J2)
(value "Display FPC")
(footprint 0528921033:MOLEX_0528921033)
(datasheet Molex)
(fields
(field (name Field4) "Conn Ffc Bottom 10pos 0.50mm r/a")
(field (name Field5) None)
(field (name Field6) Unavailable)
(field (name Field7) None)
(field (name Field8) 0528921033))
(libsource (lib 0528921033) (part 0528921033) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5CC19477))
(comp (ref BT1)
(value CR2025)
(footprint footprints:CR2025-LINX)
(datasheet ~)
(libsource (lib Device) (part Battery_Cell) (description "Single-cell battery"))
(sheetpath (names /) (tstamps /))
(tstamp 5CC3508E))
(comp (ref C5)
(value 100nF)
(footprint Capacitor_SMD:C_0805_2012Metric_Pad1.15x1.40mm_HandSolder)
(datasheet ~)
(libsource (lib Device) (part C_Small) (description "Unpolarized capacitor, small symbol"))
(sheetpath (names /) (tstamps /))
(tstamp 5CC3ABC3))
(comp (ref J1)
(value "SWD Headers")
(footprint Connector_PinHeader_2.54mm:PinHeader_1x05_P2.54mm_Vertical)
(datasheet ~)
(libsource (lib Connector) (part Conn_01x05_Female) (description "Generic connector, single row, 01x05, script generated (kicad-library-utils/schlib/autogen/connector/)"))
(sheetpath (names /) (tstamps /))
(tstamp 5CC5188F))
(comp (ref R1)
(value 10k)
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder)
(datasheet ~)
(libsource (lib Device) (part R_Small_US) (description "Resistor, small US symbol"))
(sheetpath (names /) (tstamps /))
(tstamp 5CC5BB36))
(comp (ref C9)
(value 1uF)
(footprint Capacitor_SMD:C_0805_2012Metric_Pad1.15x1.40mm_HandSolder)
(datasheet ~)
(libsource (lib Device) (part C_Small) (description "Unpolarized capacitor, small symbol"))
(sheetpath (names /) (tstamps /))
(tstamp 5CC8A464))
(comp (ref C8)
(value 100nF)
(footprint Capacitor_SMD:C_0805_2012Metric_Pad1.15x1.40mm_HandSolder)
(datasheet ~)
(libsource (lib Device) (part C_Small) (description "Unpolarized capacitor, small symbol"))
(sheetpath (names /) (tstamps /))
(tstamp 5CC8A56E))
(comp (ref TP0)
(value TestPoint)
(footprint TestPoint:TestPoint_Pad_D1.0mm)
(datasheet ~)
(libsource (lib Connector) (part TestPoint) (description "test point"))
(sheetpath (names /) (tstamps /))
(tstamp 5CCA9B83))
(comp (ref TP1)
(value TestPoint)
(footprint TestPoint:TestPoint_Pad_D1.0mm)
(datasheet ~)
(libsource (lib Connector) (part TestPoint) (description "test point"))
(sheetpath (names /) (tstamps /))
(tstamp 5CCA9C4C))
(comp (ref TP2)
(value TestPoint)
(footprint TestPoint:TestPoint_Pad_D1.0mm)
(datasheet ~)
(libsource (lib Connector) (part TestPoint) (description "test point"))
(sheetpath (names /) (tstamps /))
(tstamp 5CCADC31))
(comp (ref C7)
(value 1uF)
(footprint Capacitor_SMD:C_0805_2012Metric_Pad1.15x1.40mm_HandSolder)
(datasheet ~)
(libsource (lib Device) (part C_Small) (description "Unpolarized capacitor, small symbol"))
(sheetpath (names /) (tstamps /))
(tstamp 5CD10A30)))
(libparts
(libpart (lib 0528921033) (part 0528921033)
(fields
(field (name Reference) J)
(field (name Value) 0528921033)
(field (name Footprint) MOLEX_0528921033)
(field (name Datasheet) Molex)
(field (name Field4) "Conn Ffc Bottom 10pos 0.50mm r/a")
(field (name Field5) None)
(field (name Field6) Unavailable)
(field (name Field7) None)
(field (name Field8) 0528921033))
(pins
(pin (num 1) (name 1) (type passive))
(pin (num 2) (name 2) (type passive))
(pin (num 3) (name 3) (type passive))
(pin (num 4) (name 4) (type passive))
(pin (num 5) (name 5) (type passive))
(pin (num 6) (name 6) (type passive))
(pin (num 7) (name 7) (type passive))
(pin (num 8) (name 8) (type passive))
(pin (num 9) (name 9) (type passive))
(pin (num 10) (name 10) (type passive))
(pin (num 11) (name SHIELD) (type passive))
(pin (num 12) (name SHIELD) (type passive))))
(libpart (lib Connector) (part Conn_01x05_Female)
(description "Generic connector, single row, 01x05, script generated (kicad-library-utils/schlib/autogen/connector/)")
(docs ~)
(footprints
(fp Connector*:*_1x??_*))
(fields
(field (name Reference) J)
(field (name Value) Conn_01x05_Female))
(pins
(pin (num 1) (name Pin_1) (type passive))
(pin (num 2) (name Pin_2) (type passive))
(pin (num 3) (name Pin_3) (type passive))
(pin (num 4) (name Pin_4) (type passive))
(pin (num 5) (name Pin_5) (type passive))))
(libpart (lib Connector) (part TestPoint)
(description "test point")
(docs ~)
(footprints
(fp Pin*)
(fp Test*))
(fields
(field (name Reference) TP)
(field (name Value) TestPoint))
(pins
(pin (num 1) (name 1) (type passive))))
(libpart (lib Device) (part Battery_Cell)
(description "Single-cell battery")
(docs ~)
(fields
(field (name Reference) BT)
(field (name Value) Battery_Cell))
(pins
(pin (num 1) (name +) (type passive))
(pin (num 2) (name -) (type passive))))
(libpart (lib Device) (part C_Small)
(description "Unpolarized capacitor, small symbol")
(docs ~)
(footprints
(fp C_*))
(fields
(field (name Reference) C)
(field (name Value) C_Small))
(pins
(pin (num 1) (name ~) (type passive))
(pin (num 2) (name ~) (type passive))))
(libpart (lib Device) (part Crystal)
(description "Two pin crystal")
(docs ~)
(footprints
(fp Crystal*))
(fields
(field (name Reference) Y)
(field (name Value) Crystal))
(pins
(pin (num 1) (name 1) (type passive))
(pin (num 2) (name 2) (type passive))))
(libpart (lib Device) (part R_Small_US)
(description "Resistor, small US symbol")
(docs ~)
(footprints
(fp R_*))
(fields
(field (name Reference) R)
(field (name Value) R_Small_US))
(pins
(pin (num 1) (name ~) (type passive))
(pin (num 2) (name ~) (type passive))))
(libpart (lib Switch) (part SW_Push)
(description "Push button switch, generic, two pins")
(fields
(field (name Reference) SW)
(field (name Value) SW_Push))
(pins
(pin (num 1) (name 1) (type passive))
(pin (num 2) (name 2) (type passive))))
(libpart (lib kicad-rescue) (part STM32L031F6Px)
(footprints
(fp TSSOP*4.4x6.5mm*P0.65mm*))
(fields
(field (name Reference) U)
(field (name Value) STM32L031F6Px)
(field (name Footprint) Package_SO:TSSOP-20_4.4x6.5mm_P0.65mm))
(pins
(pin (num 1) (name BOOT0) (type input))
(pin (num 2) (name PC14) (type BiDi))
(pin (num 3) (name PC15) (type BiDi))
(pin (num 4) (name NRST) (type input))
(pin (num 5) (name VDDA) (type power_in))
(pin (num 6) (name PA0) (type BiDi))
(pin (num 7) (name PA1) (type BiDi))
(pin (num 8) (name PA2) (type BiDi))
(pin (num 9) (name PA3) (type BiDi))
(pin (num 10) (name PA4) (type BiDi))
(pin (num 11) (name PA5) (type BiDi))
(pin (num 12) (name PA6) (type BiDi))
(pin (num 13) (name PA7) (type BiDi))
(pin (num 14) (name PB1) (type BiDi))
(pin (num 15) (name VSS) (type power_in))
(pin (num 16) (name VDD) (type power_in))
(pin (num 17) (name PA9) (type BiDi))
(pin (num 18) (name PA10) (type BiDi))
(pin (num 19) (name PA13) (type BiDi))
(pin (num 20) (name PA14) (type BiDi)))))
(libraries
(library (logical 0528921033)
(uri /home/max/Downloads/0528921033.lib))
(library (logical Connector)
(uri /usr/share/kicad/library/Connector.lib))
(library (logical Device)
(uri /usr/share/kicad/library/Device.lib))
(library (logical Switch)
(uri /usr/share/kicad/library/Switch.lib))
(library (logical kicad-rescue)
(uri /home/max/work/kicad/kicad-rescue.lib)))
(nets
(net (code 1) (name MCU_VDD)
(node (ref J2) (pin 8))
(node (ref C7) (pin 1))
(node (ref J2) (pin 5))
(node (ref J2) (pin 6))
(node (ref J2) (pin 7))
(node (ref J1) (pin 2))
(node (ref C8) (pin 1))
(node (ref C9) (pin 2))
(node (ref U1) (pin 16))
(node (ref U1) (pin 5))
(node (ref C6) (pin 1))
(node (ref C2) (pin 1))
(node (ref C1) (pin 1))
(node (ref BT1) (pin 1)))
(net (code 2) (name SWCK)
(node (ref J1) (pin 3))
(node (ref U1) (pin 20)))
(net (code 3) (name GND)
(node (ref C4) (pin 2))
(node (ref C3) (pin 2))
(node (ref J2) (pin 10))
(node (ref J2) (pin 11))
(node (ref J2) (pin 12))
(node (ref C1) (pin 2))
(node (ref J2) (pin 9))
(node (ref C2) (pin 2))
(node (ref C6) (pin 2))
(node (ref SW3) (pin 1))
(node (ref SW2) (pin 1))
(node (ref SW1) (pin 1))
(node (ref U1) (pin 9))
(node (ref U1) (pin 18))
(node (ref U1) (pin 17))
(node (ref U1) (pin 15))
(node (ref U1) (pin 12))
(node (ref BT1) (pin 2))
(node (ref C5) (pin 2))
(node (ref J1) (pin 1))
(node (ref C7) (pin 2))
(node (ref R1) (pin 1))
(node (ref C8) (pin 2))
(node (ref C9) (pin 1)))
(net (code 4) (name SCK)
(node (ref TP0) (pin 1))
(node (ref J2) (pin 1))
(node (ref U1) (pin 11)))
(net (code 5) (name SS)
(node (ref J2) (pin 3))
(node (ref U1) (pin 10))
(node (ref TP2) (pin 1)))
(net (code 6) (name EXTCOMM)
(node (ref U1) (pin 13))
(node (ref J2) (pin 4)))
(net (code 7) (name SWDIO)
(node (ref U1) (pin 19))
(node (ref J1) (pin 4)))
(net (code 8) (name nRST)
(node (ref J1) (pin 5))
(node (ref U1) (pin 4))
(node (ref C5) (pin 1)))
(net (code 9) (name /BOOT0)
(node (ref U1) (pin 1))
(node (ref R1) (pin 2)))
(net (code 10) (name /XOSC1)
(node (ref C4) (pin 1))
(node (ref U1) (pin 3))
(node (ref Y1) (pin 2)))
(net (code 11) (name BTN_MID)
(node (ref SW2) (pin 2))
(node (ref U1) (pin 7)))
(net (code 12) (name BTN_DOWN)
(node (ref SW3) (pin 2))
(node (ref U1) (pin 6)))
(net (code 13) (name BTN_UP)
(node (ref SW1) (pin 2))
(node (ref U1) (pin 8)))
(net (code 14) (name MOSI)
(node (ref J2) (pin 2))
(node (ref TP1) (pin 1))
(node (ref U1) (pin 14)))
(net (code 15) (name /XOSC0)
(node (ref C3) (pin 1))
(node (ref U1) (pin 2))
(node (ref Y1) (pin 1)))))

1516
ecad/watch_v1-1.kicad_pcb Normal file

File diff suppressed because it is too large Load Diff

63
ecad/watch_v1-1.pro Normal file
View File

@@ -0,0 +1,63 @@
update=Sat 20 Apr 2019 10:29:46 PM PDT
version=1
last_client=kicad
[pcbnew]
version=1
LastNetListRead=
UseCmpFile=1
PadDrill=0.600000000000
PadDrillOvalY=0.600000000000
PadSizeH=1.500000000000
PadSizeV=1.500000000000
PcbTextSizeV=1.500000000000
PcbTextSizeH=1.500000000000
PcbTextThickness=0.300000000000
ModuleTextSizeV=1.000000000000
ModuleTextSizeH=1.000000000000
ModuleTextSizeThickness=0.150000000000
SolderMaskClearance=0.000000000000
SolderMaskMinWidth=0.000000000000
DrawSegmentWidth=0.200000000000
BoardOutlineThickness=0.100000000000
ModuleOutlineThickness=0.150000000000
[cvpcb]
version=1
NetIExt=net
[eeschema]
version=1
LibDir=
[eeschema/libraries]
LibName1=power
LibName2=device
LibName3=switches
LibName4=relays
LibName5=motors
LibName6=transistors
LibName7=conn
LibName8=linear
LibName9=regul
LibName10=74xx
LibName11=cmos4000
LibName12=adc-dac
LibName13=memory
LibName14=xilinx
LibName15=microcontrollers
LibName16=dsp
LibName17=microchip
LibName18=analog_switches
LibName19=motorola
LibName20=texas
LibName21=intel
LibName22=audio
LibName23=interface
LibName24=digital-audio
LibName25=philips
LibName26=display
LibName27=cypress
LibName28=siliconi
LibName29=opto
LibName30=atmel
LibName31=contrib
LibName32=valves
[general]
version=1

790
ecad/watch_v1-1.sch Normal file
View File

@@ -0,0 +1,790 @@
EESchema Schematic File Version 4
LIBS:kicad-cache
EELAYER 26 0
EELAYER END
$Descr A4 11693 8268
encoding utf-8
Sheet 1 1
Title ""
Date ""
Rev ""
Comp ""
Comment1 ""
Comment2 ""
Comment3 ""
Comment4 ""
$EndDescr
$Comp
L kicad-rescue:STM32L031F6Px U1
U 1 1 5CBC08BF
P 5800 3100
F 0 "U1" H 5400 3750 50 0000 L CNN
F 1 "STM32L031F6Px" H 6000 3750 50 0000 L CNN
F 2 "Package_SO:TSSOP-20_4.4x6.5mm_P0.65mm" H 5400 2400 50 0001 R CNN
F 3 "" H 5800 3100 50 0001 C CNN
1 5800 3100
1 0 0 -1
$EndComp
$Comp
L Device:Crystal Y1
U 1 1 5CC13AA5
P 4750 3450
F 0 "Y1" V 4704 3581 50 0000 L CNN
F 1 "Crystal" V 4795 3581 50 0000 L CNN
F 2 "Crystal:Crystal_SMD_G8-2Pin_3.2x1.5mm_HandSoldering" H 4750 3450 50 0001 C CNN
F 3 "~" H 4750 3450 50 0001 C CNN
1 4750 3450
0 1 1 0
$EndComp
$Comp
L Switch:SW_Push SW1
U 1 1 5CC13D70
P 9450 1300
F 0 "SW1" H 9450 1585 50 0000 C CNN
F 1 "SW_Push" H 9450 1494 50 0000 C CNN
F 2 "footprints:Panasonic_RightAngle_Button" H 9450 1500 50 0001 C CNN
F 3 "" H 9450 1500 50 0001 C CNN
1 9450 1300
1 0 0 -1
$EndComp
$Comp
L Switch:SW_Push SW2
U 1 1 5CC13E33
P 9450 1650
F 0 "SW2" H 9450 1935 50 0000 C CNN
F 1 "SW_Push" H 9450 1844 50 0000 C CNN
F 2 "footprints:Panasonic_RightAngle_Button" H 9450 1850 50 0001 C CNN
F 3 "" H 9450 1850 50 0001 C CNN
1 9450 1650
1 0 0 -1
$EndComp
$Comp
L Switch:SW_Push SW3
U 1 1 5CC13EAF
P 9450 2000
F 0 "SW3" H 9450 2285 50 0000 C CNN
F 1 "SW_Push" H 9450 2194 50 0000 C CNN
F 2 "footprints:Panasonic_RightAngle_Button" H 9450 2200 50 0001 C CNN
F 3 "" H 9450 2200 50 0001 C CNN
1 9450 2000
1 0 0 -1
$EndComp
$Comp
L power:GND #PWR012
U 1 1 5CC145B2
P 5800 3900
F 0 "#PWR012" H 5800 3650 50 0001 C CNN
F 1 "GND" H 5805 3727 50 0000 C CNN
F 2 "" H 5800 3900 50 0001 C CNN
F 3 "" H 5800 3900 50 0001 C CNN
1 5800 3900
1 0 0 -1
$EndComp
Wire Wire Line
5300 3400 5300 3300
Wire Wire Line
5300 3300 4750 3300
Wire Wire Line
4750 3600 5300 3600
Wire Wire Line
5300 3600 5300 3500
$Comp
L Device:C_Small C3
U 1 1 5CC14877
P 4500 3300
F 0 "C3" V 4271 3300 50 0000 C CNN
F 1 "4.3pF" V 4362 3300 50 0000 C CNN
F 2 "Capacitor_SMD:C_0805_2012Metric_Pad1.15x1.40mm_HandSolder" H 4500 3300 50 0001 C CNN
F 3 "~" H 4500 3300 50 0001 C CNN
1 4500 3300
0 1 1 0
$EndComp
$Comp
L Device:C_Small C4
U 1 1 5CC14926
P 4500 3600
F 0 "C4" V 4600 3600 50 0000 C CNN
F 1 "4.3pF" V 4700 3600 50 0000 C CNN
F 2 "Capacitor_SMD:C_0805_2012Metric_Pad1.15x1.40mm_HandSolder" H 4500 3600 50 0001 C CNN
F 3 "~" H 4500 3600 50 0001 C CNN
1 4500 3600
0 1 1 0
$EndComp
Wire Wire Line
4750 3300 4600 3300
Connection ~ 4750 3300
Wire Wire Line
4600 3600 4750 3600
Connection ~ 4750 3600
Wire Wire Line
4400 3300 4250 3300
Wire Wire Line
4250 3300 4250 3600
Wire Wire Line
4250 3600 4400 3600
Wire Wire Line
4250 3600 4250 3700
Connection ~ 4250 3600
$Comp
L power:GND #PWR07
U 1 1 5CC14C6B
P 4250 3700
F 0 "#PWR07" H 4250 3450 50 0001 C CNN
F 1 "GND" H 4255 3527 50 0000 C CNN
F 2 "" H 4250 3700 50 0001 C CNN
F 3 "" H 4250 3700 50 0001 C CNN
1 4250 3700
1 0 0 -1
$EndComp
Text GLabel 6450 2700 2 50 Input ~ 0
BTN_MID
Text GLabel 6450 2600 2 50 Input ~ 0
BTN_DOWN
Text GLabel 6450 2800 2 50 Input ~ 0
BTN_UP
Wire Wire Line
6300 2600 6450 2600
Wire Wire Line
6300 2700 6450 2700
Wire Wire Line
6300 2800 6450 2800
Wire Wire Line
9250 1300 9150 1300
Wire Wire Line
9150 1300 9150 1650
Wire Wire Line
9150 1650 9250 1650
Wire Wire Line
9150 1650 9150 2000
Wire Wire Line
9150 2000 9250 2000
Connection ~ 9150 1650
$Comp
L power:GND #PWR020
U 1 1 5CC15593
P 8850 1650
F 0 "#PWR020" H 8850 1400 50 0001 C CNN
F 1 "GND" H 8855 1477 50 0000 C CNN
F 2 "" H 8850 1650 50 0001 C CNN
F 3 "" H 8850 1650 50 0001 C CNN
1 8850 1650
-1 0 0 -1
$EndComp
Text GLabel 9800 1300 2 50 Input ~ 0
BTN_UP
Text GLabel 9800 1650 2 50 Input ~ 0
BTN_MID
Text GLabel 9800 2000 2 50 Input ~ 0
BTN_DOWN
Wire Wire Line
9650 1300 9800 1300
Wire Wire Line
9650 1650 9800 1650
Wire Wire Line
9650 2000 9800 2000
$Comp
L Device:C_Small C1
U 1 1 5CC1601D
P 4150 1250
F 0 "C1" H 4000 1300 50 0000 L CNN
F 1 "100nF" H 3850 1200 50 0000 L CNN
F 2 "Capacitor_SMD:C_0805_2012Metric_Pad1.15x1.40mm_HandSolder" H 4150 1250 50 0001 C CNN
F 3 "~" H 4150 1250 50 0001 C CNN
F 4 "C" H 4150 1250 50 0001 C CNN "Spice_Primitive"
F 5 "100nF" H 4150 1250 50 0001 C CNN "Spice_Model"
F 6 "Y" H 4150 1250 50 0001 C CNN "Spice_Netlist_Enabled"
1 4150 1250
1 0 0 -1
$EndComp
$Comp
L Device:C_Small C2
U 1 1 5CC160C6
P 4400 1250
F 0 "C2" H 4492 1296 50 0000 L CNN
F 1 "100nF" H 4492 1205 50 0000 L CNN
F 2 "Capacitor_SMD:C_0805_2012Metric_Pad1.15x1.40mm_HandSolder" H 4400 1250 50 0001 C CNN
F 3 "~" H 4400 1250 50 0001 C CNN
1 4400 1250
1 0 0 -1
$EndComp
$Comp
L Device:C_Small C6
U 1 1 5CC1613E
P 5050 1250
F 0 "C6" H 5142 1296 50 0000 L CNN
F 1 "100nF" H 5142 1205 50 0000 L CNN
F 2 "Capacitor_SMD:C_0805_2012Metric_Pad1.15x1.40mm_HandSolder" H 5050 1250 50 0001 C CNN
F 3 "~" H 5050 1250 50 0001 C CNN
1 5050 1250
1 0 0 -1
$EndComp
Wire Wire Line
4150 1150 4250 1150
Wire Wire Line
4150 1350 4250 1350
Wire Wire Line
4250 1150 4250 1050
Connection ~ 4250 1150
Wire Wire Line
4250 1150 4400 1150
Wire Wire Line
4250 1350 4250 1450
Connection ~ 4250 1350
Wire Wire Line
4250 1350 4400 1350
Text GLabel 4250 1050 0 50 Input ~ 0
MCU_VDD
Text GLabel 5800 2400 1 50 Input ~ 0
MCU_VDD
Text GLabel 5900 2400 1 50 Input ~ 0
MCU_VDDA
$Comp
L power:VDD #PWR05
U 1 1 5CC1927A
P 4250 1050
F 0 "#PWR05" H 4250 900 50 0001 C CNN
F 1 "VDD" H 4267 1223 50 0000 C CNN
F 2 "" H 4250 1050 50 0001 C CNN
F 3 "" H 4250 1050 50 0001 C CNN
1 4250 1050
1 0 0 -1
$EndComp
$Comp
L 0528921033:0528921033 J2
U 1 1 5CC19477
P 9850 4250
F 0 "J2" H 9625 4246 50 0000 R CNN
F 1 "Display FPC" H 9625 4155 50 0000 R CNN
F 2 "0528921033:MOLEX_0528921033" H 9850 4250 50 0001 L BNN
F 3 "Molex" H 9850 4250 50 0001 L BNN
F 4 "Conn Ffc Bottom 10pos 0.50mm r/a" H 9850 4250 50 0001 L BNN "Field4"
F 5 "None" H 9850 4250 50 0001 L BNN "Field5"
F 6 "Unavailable" H 9850 4250 50 0001 L BNN "Field6"
F 7 "None" H 9850 4250 50 0001 L BNN "Field7"
F 8 "0528921033" H 9850 4250 50 0001 L BNN "Field8"
1 9850 4250
-1 0 0 -1
$EndComp
Wire Wire Line
9550 4750 9450 4750
Wire Wire Line
9450 4750 9450 4850
Wire Wire Line
9450 4850 9550 4850
Wire Wire Line
9200 4850 9200 4950
Connection ~ 9450 4850
$Comp
L power:GND #PWR019
U 1 1 5CC1A496
P 9200 4950
F 0 "#PWR019" H 9200 4700 50 0001 C CNN
F 1 "GND" H 9205 4777 50 0000 C CNN
F 2 "" H 9200 4950 50 0001 C CNN
F 3 "" H 9200 4950 50 0001 C CNN
1 9200 4950
1 0 0 -1
$EndComp
Text GLabel 9350 3850 0 50 Input ~ 0
MOSI
Text GLabel 9350 3750 0 50 Input ~ 0
SCK
Text GLabel 9350 3950 0 50 Input ~ 0
SS
Text GLabel 9350 4050 0 50 Input ~ 0
EXTCOMM
$Comp
L power:VDD #PWR014
U 1 1 5CC1C700
P 8350 3800
F 0 "#PWR014" H 8350 3650 50 0001 C CNN
F 1 "VDD" V 8368 3927 50 0000 L CNN
F 2 "" H 8350 3800 50 0001 C CNN
F 3 "" H 8350 3800 50 0001 C CNN
1 8350 3800
0 -1 -1 0
$EndComp
Text Label 9350 4150 0 50 ~ 0
DISP
Wire Wire Line
9350 3750 9550 3750
Wire Wire Line
9550 3850 9350 3850
Wire Wire Line
9350 3950 9550 3950
Wire Wire Line
9550 4050 9350 4050
Wire Wire Line
9200 4850 9450 4850
Text Label 9200 4650 0 50 ~ 0
VSSA
Wire Wire Line
8900 4550 9200 4550
$Comp
L power:GND #PWR018
U 1 1 5CC21221
P 8900 4550
F 0 "#PWR018" H 8900 4300 50 0001 C CNN
F 1 "GND" H 8905 4377 50 0000 C CNN
F 2 "" H 8900 4550 50 0001 C CNN
F 3 "" H 8900 4550 50 0001 C CNN
1 8900 4550
1 0 0 -1
$EndComp
Text Label 9200 4550 0 50 ~ 0
VSS
Wire Wire Line
9550 4450 8950 4450
$Comp
L power:VDD #PWR017
U 1 1 5CC21C28
P 8900 4450
F 0 "#PWR017" H 8900 4300 50 0001 C CNN
F 1 "VDD" V 8950 4450 50 0000 L CNN
F 2 "" H 8900 4450 50 0001 C CNN
F 3 "" H 8900 4450 50 0001 C CNN
1 8900 4450
0 -1 -1 0
$EndComp
Wire Wire Line
8900 4150 9550 4150
Wire Wire Line
9550 4350 8950 4350
Wire Wire Line
8950 4350 8950 4450
Connection ~ 8950 4450
Wire Wire Line
8950 4450 8900 4450
Text Label 9200 4450 0 50 ~ 0
EXTMODE
Text Label 9200 4350 0 50 ~ 0
VDD
Text Label 9200 4250 0 50 ~ 0
VDDA
Text GLabel 6450 3100 2 50 Input ~ 0
SCK
Text GLabel 6450 3000 2 50 Input ~ 0
SS
Text GLabel 5300 3700 0 50 Input ~ 0
MOSI
Text GLabel 6700 3300 2 50 Input ~ 0
EXTCOMM
Wire Wire Line
6300 3100 6450 3100
Wire Wire Line
6300 3000 6450 3000
Text Label 6300 3300 0 50 ~ 0
LPTIM_OUT
$Comp
L Device:Battery_Cell BT1
U 1 1 5CC3508E
P 4000 5800
F 0 "BT1" H 4118 5896 50 0000 L CNN
F 1 "CR2025" H 4118 5805 50 0000 L CNN
F 2 "footprints:CR2025-LINX" V 4000 5860 50 0001 C CNN
F 3 "~" V 4000 5860 50 0001 C CNN
1 4000 5800
1 0 0 -1
$EndComp
$Comp
L Device:C_Small C5
U 1 1 5CC3ABC3
P 4950 2500
F 0 "C5" H 4800 2400 50 0000 C CNN
F 1 "100nF" H 4750 2500 50 0000 C CNN
F 2 "Capacitor_SMD:C_0805_2012Metric_Pad1.15x1.40mm_HandSolder" H 4950 2500 50 0001 C CNN
F 3 "~" H 4950 2500 50 0001 C CNN
1 4950 2500
-1 0 0 1
$EndComp
Wire Wire Line
5300 2600 4950 2600
Wire Wire Line
6300 3300 6700 3300
Text GLabel 6850 3700 2 50 Input ~ 0
SWCK
Text GLabel 6850 3600 2 50 Input ~ 0
SWDIO
$Comp
L Connector:Conn_01x05_Female J1
U 1 1 5CC5188F
P 1850 2950
F 0 "J1" H 1744 2525 50 0000 C CNN
F 1 "SWD Headers" H 1744 2616 50 0000 C CNN
F 2 "Connector_PinHeader_2.54mm:PinHeader_1x05_P2.54mm_Vertical" H 1850 2950 50 0001 C CNN
F 3 "~" H 1850 2950 50 0001 C CNN
1 1850 2950
-1 0 0 1
$EndComp
Wire Wire Line
2350 2750 2050 2750
Wire Wire Line
2350 2850 2050 2850
Wire Wire Line
2350 2950 2050 2950
Wire Wire Line
2350 3050 2050 3050
Wire Wire Line
2350 3150 2050 3150
Text GLabel 2350 2850 2 50 Input ~ 0
SWDIO
Text GLabel 2350 2950 2 50 Input ~ 0
SWCK
Text GLabel 2350 2750 2 50 Input ~ 0
nRST
Text GLabel 4550 2600 0 50 Input ~ 0
nRST
$Comp
L power:GND #PWR08
U 1 1 5CC5B9B4
P 4850 2800
F 0 "#PWR08" H 4850 2550 50 0001 C CNN
F 1 "GND" H 4855 2627 50 0000 C CNN
F 2 "" H 4850 2800 50 0001 C CNN
F 3 "" H 4850 2800 50 0001 C CNN
1 4850 2800
1 0 0 -1
$EndComp
$Comp
L Device:R_Small_US R1
U 1 1 5CC5BB36
P 5050 2800
F 0 "R1" V 4950 2800 50 0000 C CNN
F 1 "10k" V 4850 2800 50 0000 C CNN
F 2 "Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder" H 5050 2800 50 0001 C CNN
F 3 "~" H 5050 2800 50 0001 C CNN
1 5050 2800
0 -1 -1 0
$EndComp
Wire Wire Line
4850 2800 4950 2800
Wire Wire Line
5150 2800 5300 2800
$Comp
L power:GND #PWR01
U 1 1 5CC64E23
P 2350 3150
F 0 "#PWR01" H 2350 2900 50 0001 C CNN
F 1 "GND" V 2355 3022 50 0000 R CNN
F 2 "" H 2350 3150 50 0001 C CNN
F 3 "" H 2350 3150 50 0001 C CNN
1 2350 3150
0 -1 -1 0
$EndComp
$Comp
L power:VDD #PWR02
U 1 1 5CC64EF0
P 2350 3050
F 0 "#PWR02" H 2350 2900 50 0001 C CNN
F 1 "VDD" V 2350 3200 50 0000 L CNN
F 2 "" H 2350 3050 50 0001 C CNN
F 3 "" H 2350 3050 50 0001 C CNN
1 2350 3050
0 1 1 0
$EndComp
Wire Wire Line
6300 3600 6850 3600
Wire Wire Line
6300 3700 6850 3700
$Comp
L power:VDD #PWR03
U 1 1 5CC351B8
P 4000 5600
F 0 "#PWR03" H 4000 5450 50 0001 C CNN
F 1 "VDD" H 4017 5773 50 0000 C CNN
F 2 "" H 4000 5600 50 0001 C CNN
F 3 "" H 4000 5600 50 0001 C CNN
1 4000 5600
1 0 0 -1
$EndComp
Connection ~ 4000 5600
$Comp
L power:PWR_FLAG #FLG01
U 1 1 5CC71999
P 4000 5600
F 0 "#FLG01" H 4000 5675 50 0001 C CNN
F 1 "PWR_FLAG" V 4000 5728 50 0000 L CNN
F 2 "" H 4000 5600 50 0001 C CNN
F 3 "~" H 4000 5600 50 0001 C CNN
1 4000 5600
0 -1 -1 0
$EndComp
Wire Wire Line
4000 5900 4000 6000
$Comp
L power:PWR_FLAG #FLG02
U 1 1 5CC7D5EC
P 4000 6000
F 0 "#FLG02" H 4000 6075 50 0001 C CNN
F 1 "PWR_FLAG" V 4000 6128 50 0000 L CNN
F 2 "" H 4000 6000 50 0001 C CNN
F 3 "~" H 4000 6000 50 0001 C CNN
1 4000 6000
0 1 1 0
$EndComp
Connection ~ 4000 6000
Wire Wire Line
4000 6000 4000 6100
$Comp
L power:GND #PWR04
U 1 1 5CC7D65F
P 4000 6100
F 0 "#PWR04" H 4000 5850 50 0001 C CNN
F 1 "GND" H 4005 5927 50 0000 C CNN
F 2 "" H 4000 6100 50 0001 C CNN
F 3 "" H 4000 6100 50 0001 C CNN
1 4000 6100
1 0 0 -1
$EndComp
Wire Wire Line
5050 1350 5050 1450
$Comp
L power:GND #PWR09
U 1 1 5CC820A9
P 4950 2400
F 0 "#PWR09" H 4950 2150 50 0001 C CNN
F 1 "GND" H 4955 2227 50 0000 C CNN
F 2 "" H 4950 2400 50 0001 C CNN
F 3 "" H 4950 2400 50 0001 C CNN
1 4950 2400
-1 0 0 1
$EndComp
Wire Wire Line
4550 2600 4950 2600
Connection ~ 4950 2600
$Comp
L power:GND #PWR011
U 1 1 5CC86EF0
P 5050 1450
F 0 "#PWR011" H 5050 1200 50 0001 C CNN
F 1 "GND" H 5055 1277 50 0000 C CNN
F 2 "" H 5050 1450 50 0001 C CNN
F 3 "" H 5050 1450 50 0001 C CNN
1 5050 1450
1 0 0 -1
$EndComp
$Comp
L power:VDD #PWR010
U 1 1 5CC86FC9
P 5050 850
F 0 "#PWR010" H 5050 700 50 0001 C CNN
F 1 "VDD" H 5067 1023 50 0000 C CNN
F 2 "" H 5050 850 50 0001 C CNN
F 3 "" H 5050 850 50 0001 C CNN
1 5050 850
1 0 0 -1
$EndComp
Text GLabel 5050 1100 2 50 Input ~ 0
MCU_VDDA
Wire Wire Line
9150 1650 8850 1650
$Comp
L Device:C_Small C9
U 1 1 5CC8A464
P 8500 4450
F 0 "C9" H 8408 4404 50 0000 R CNN
F 1 "1uF" H 8408 4495 50 0000 R CNN
F 2 "Capacitor_SMD:C_0805_2012Metric_Pad1.15x1.40mm_HandSolder" H 8500 4450 50 0001 C CNN
F 3 "~" H 8500 4450 50 0001 C CNN
1 8500 4450
-1 0 0 1
$EndComp
$Comp
L Device:C_Small C8
U 1 1 5CC8A56E
P 8400 3950
F 0 "C8" H 8492 3996 50 0000 L CNN
F 1 "100nF" H 8492 3905 50 0000 L CNN
F 2 "Capacitor_SMD:C_0805_2012Metric_Pad1.15x1.40mm_HandSolder" H 8400 3950 50 0001 C CNN
F 3 "~" H 8400 3950 50 0001 C CNN
1 8400 3950
1 0 0 -1
$EndComp
$Comp
L power:VDD #PWR013
U 1 1 5CC992AC
P 7750 4850
F 0 "#PWR013" H 7750 4700 50 0001 C CNN
F 1 "VDD" H 7768 5023 50 0000 C CNN
F 2 "" H 7750 4850 50 0001 C CNN
F 3 "" H 7750 4850 50 0001 C CNN
1 7750 4850
-1 0 0 1
$EndComp
$Comp
L power:GND #PWR015
U 1 1 5CC9DA3C
P 8400 4050
F 0 "#PWR015" H 8400 3800 50 0001 C CNN
F 1 "GND" H 8405 3877 50 0000 C CNN
F 2 "" H 8400 4050 50 0001 C CNN
F 3 "" H 8400 4050 50 0001 C CNN
1 8400 4050
1 0 0 -1
$EndComp
Wire Wire Line
8350 3800 8400 3800
Wire Wire Line
8900 3800 8900 4150
Wire Wire Line
8400 3850 8400 3800
Connection ~ 8400 3800
Wire Wire Line
8400 3800 8900 3800
Wire Wire Line
8950 4350 8500 4350
Connection ~ 8950 4350
$Comp
L power:GND #PWR016
U 1 1 5CCA5789
P 8500 4550
F 0 "#PWR016" H 8500 4300 50 0001 C CNN
F 1 "GND" H 8505 4377 50 0000 C CNN
F 2 "" H 8500 4550 50 0001 C CNN
F 3 "" H 8500 4550 50 0001 C CNN
1 8500 4550
1 0 0 -1
$EndComp
$Comp
L Connector:TestPoint TP0
U 1 1 5CCA9B83
P 2000 4250
F 0 "TP0" V 1954 4438 50 0000 L CNN
F 1 "TestPoint" V 2045 4438 50 0000 L CNN
F 2 "TestPoint:TestPoint_Pad_D1.0mm" H 2200 4250 50 0001 C CNN
F 3 "~" H 2200 4250 50 0001 C CNN
1 2000 4250
0 1 1 0
$EndComp
$Comp
L Connector:TestPoint TP1
U 1 1 5CCA9C4C
P 2000 4450
F 0 "TP1" V 1954 4638 50 0000 L CNN
F 1 "TestPoint" V 2045 4638 50 0000 L CNN
F 2 "TestPoint:TestPoint_Pad_D1.0mm" H 2200 4450 50 0001 C CNN
F 3 "~" H 2200 4450 50 0001 C CNN
1 2000 4450
0 1 1 0
$EndComp
Text GLabel 2000 4250 0 50 Input ~ 0
SCK
Text GLabel 2000 4450 0 50 Input ~ 0
MOSI
$Comp
L Connector:TestPoint TP2
U 1 1 5CCADC31
P 2000 4650
F 0 "TP2" V 1954 4838 50 0000 L CNN
F 1 "TestPoint" V 2045 4838 50 0000 L CNN
F 2 "TestPoint:TestPoint_Pad_D1.0mm" H 2200 4650 50 0001 C CNN
F 3 "~" H 2200 4650 50 0001 C CNN
1 2000 4650
0 1 1 0
$EndComp
Text GLabel 2000 4650 0 50 Input ~ 0
SS
Wire Wire Line
7750 4250 7750 4850
Text Label 5250 2800 3 50 ~ 0
BOOT0
Wire Wire Line
5050 850 5050 1150
$Comp
L power:GND #PWR06
U 1 1 5CD002C4
P 4250 1450
F 0 "#PWR06" H 4250 1200 50 0001 C CNN
F 1 "GND" H 4255 1277 50 0000 C CNN
F 2 "" H 4250 1450 50 0001 C CNN
F 3 "" H 4250 1450 50 0001 C CNN
1 4250 1450
1 0 0 -1
$EndComp
Wire Wire Line
9200 4650 9250 4650
Wire Wire Line
9200 4650 9200 4550
Connection ~ 9200 4550
Wire Wire Line
9200 4550 9550 4550
Wire Wire Line
7750 4250 8050 4250
$Comp
L Device:C_Small C7
U 1 1 5CD10A30
P 8050 4450
F 0 "C7" H 8142 4496 50 0000 L CNN
F 1 "1uF" H 8142 4405 50 0000 L CNN
F 2 "Capacitor_SMD:C_0805_2012Metric_Pad1.15x1.40mm_HandSolder" H 8050 4450 50 0001 C CNN
F 3 "~" H 8050 4450 50 0001 C CNN
1 8050 4450
1 0 0 -1
$EndComp
Wire Wire Line
8050 4250 8050 4350
Connection ~ 8050 4250
Wire Wire Line
8050 4250 9550 4250
Wire Wire Line
8050 4550 8050 4850
Wire Wire Line
8050 4850 9150 4850
Wire Wire Line
9150 4850 9150 4750
Wire Wire Line
9150 4750 9250 4750
Wire Wire Line
9250 4750 9250 4650
Connection ~ 9250 4650
Wire Wire Line
9250 4650 9550 4650
$Comp
L power:GND #PWR0101
U 1 1 5D64CB1D
P 6300 2900
F 0 "#PWR0101" H 6300 2650 50 0001 C CNN
F 1 "GND" V 6305 2772 50 0000 R CNN
F 2 "" H 6300 2900 50 0001 C CNN
F 3 "" H 6300 2900 50 0001 C CNN
1 6300 2900
0 -1 -1 0
$EndComp
$Comp
L power:GND #PWR0102
U 1 1 5D64CBC9
P 6300 3200
F 0 "#PWR0102" H 6300 2950 50 0001 C CNN
F 1 "GND" V 6305 3072 50 0000 R CNN
F 2 "" H 6300 3200 50 0001 C CNN
F 3 "" H 6300 3200 50 0001 C CNN
1 6300 3200
0 -1 -1 0
$EndComp
Text Label 4900 3300 0 50 ~ 0
XOSC0
Text Label 4900 3600 0 50 ~ 0
XOSC1
$Comp
L power:GND #PWR0103
U 1 1 5D64F1D1
P 6300 3400
F 0 "#PWR0103" H 6300 3150 50 0001 C CNN
F 1 "GND" V 6305 3272 50 0000 R CNN
F 2 "" H 6300 3400 50 0001 C CNN
F 3 "" H 6300 3400 50 0001 C CNN
1 6300 3400
0 -1 -1 0
$EndComp
$Comp
L power:GND #PWR0104
U 1 1 5D64F271
P 6300 3500
F 0 "#PWR0104" H 6300 3250 50 0001 C CNN
F 1 "GND" V 6305 3372 50 0000 R CNN
F 2 "" H 6300 3500 50 0001 C CNN
F 3 "" H 6300 3500 50 0001 C CNN
1 6300 3500
0 -1 -1 0
$EndComp
$EndSCHEMATC

View File

@@ -27,8 +27,8 @@
namespace BSP { namespace BSP {
using Common::ReturnCode; using BSP::ReturnCode;
using Common::Schedule::NextTime; using BSP::Schedule::NextTime;
ButtonManager *ButtonManager::m_instance = nullptr; ButtonManager *ButtonManager::m_instance = nullptr;
@@ -67,8 +67,8 @@ ReturnCode ButtonManager::init()
NextTime ButtonManager::execute() NextTime ButtonManager::execute()
{ {
Common::time_t systime; BSP::time_t systime;
Common::time_t endtime = 0; BSP::time_t endtime = 0;
BSP::SystemTimer::get_time(systime); BSP::SystemTimer::get_time(systime);
@@ -121,7 +121,7 @@ void ButtonManager::remove_callback(Button btn)
void ButtonManager::irq() void ButtonManager::irq()
{ {
uint32_t idr = GPIOA->IDR; uint32_t idr = GPIOA->IDR;
static Common::time_t systime; static BSP::time_t systime;
// TODO: is this call too expensive for an interrupt handler? // TODO: is this call too expensive for an interrupt handler?
BSP::SystemTimer::get_time(systime); BSP::SystemTimer::get_time(systime);

View File

@@ -29,13 +29,13 @@
namespace BSP { namespace BSP {
class ButtonManager : public Common::Schedule::Task { class ButtonManager : public BSP::Schedule::Task {
public: public:
ButtonManager(Common::Schedule::TaskScheduler &scheduler, ButtonManager(BSP::Schedule::TaskScheduler &scheduler,
uint8_t up_gpio_idx, uint8_t up_gpio_idx,
uint8_t mid_gpio_idx, uint8_t mid_gpio_idx,
uint8_t down_gpio_idx, uint8_t down_gpio_idx,
Common::time_t debounce_time) BSP::time_t debounce_time)
: m_scheduler(scheduler) : m_scheduler(scheduler)
, m_buttons , m_buttons
{ {
@@ -66,9 +66,9 @@ public:
using ChangeCallback = std::function<void(ButtonState)>; using ChangeCallback = std::function<void(ButtonState)>;
Common::Schedule::NextTime execute() override; BSP::Schedule::NextTime execute() override;
Common::ReturnCode init(); BSP::ReturnCode init();
void set_callback(Button btn, ChangeCallback callback); void set_callback(Button btn, ChangeCallback callback);
void remove_callback(Button btn); void remove_callback(Button btn);
@@ -79,7 +79,7 @@ private:
struct button_state { struct button_state {
button_state(uint8_t gpio_index, button_state(uint8_t gpio_index,
Common::time_t debounce_time, BSP::time_t debounce_time,
ChangeCallback callback) ChangeCallback callback)
: m_gpio_idx(gpio_index) : m_gpio_idx(gpio_index)
, m_debounce_time(debounce_time) , m_debounce_time(debounce_time)
@@ -88,15 +88,15 @@ private:
, m_callback(callback) , m_callback(callback)
{} {}
uint8_t const m_gpio_idx; uint8_t const m_gpio_idx;
Common::time_t const m_debounce_time; BSP::time_t const m_debounce_time;
ButtonState m_prev_call_state; /*<! The last state the button was in when it the callback was called */ ButtonState m_prev_call_state; /*<! The last state the button was in when it the callback was called */
ButtonState m_state; /*<! The state the button was in during the last iteration */ ButtonState m_state; /*<! The state the button was in during the last iteration */
Common::time_t m_state_change_ts; /*<! The system time when the button entered its current state */ BSP::time_t m_state_change_ts; /*<! The system time when the button entered its current state */
ChangeCallback m_callback; /*<! The callback to call when the button has changed states (post-debounce) */ ChangeCallback m_callback; /*<! The callback to call when the button has changed states (post-debounce) */
}; };
Common::Schedule::TaskScheduler &m_scheduler; BSP::Schedule::TaskScheduler &m_scheduler;
button_state m_buttons[Button::Count]; button_state m_buttons[Button::Count];
static void nop_callback(ButtonState) {}; static void nop_callback(ButtonState) {};

View File

@@ -24,11 +24,11 @@
// TODO: Basically all of the error checking // TODO: Basically all of the error checking
using Common::Schedule::Task; using BSP::Schedule::Task;
using Common::Schedule::NextTime; using BSP::Schedule::NextTime;
using Common::ReturnCode; using BSP::ReturnCode;
ScreenManager::ScreenManager(Common::Schedule::TaskScheduler &scheduler, ScreenManager::ScreenManager(BSP::Schedule::TaskScheduler &scheduler,
BSP::DisplayDriver &display, BSP::DisplayDriver &display,
BSP::ButtonManager &buttons) BSP::ButtonManager &buttons)
: m_scheduler(scheduler) : m_scheduler(scheduler)

View File

@@ -31,21 +31,21 @@
#include "Application/ButtonManager.h" #include "Application/ButtonManager.h"
#include "Application/Screens/Screen.h" #include "Application/Screens/Screen.h"
class ScreenManager : public Common::Schedule::Task { class ScreenManager : public BSP::Schedule::Task {
public: public:
ScreenManager(Common::Schedule::TaskScheduler &scheduler, ScreenManager(BSP::Schedule::TaskScheduler &scheduler,
BSP::DisplayDriver &display, BSP::DisplayDriver &display,
BSP::ButtonManager &buttons); BSP::ButtonManager &buttons);
Common::ReturnCode init(); BSP::ReturnCode init();
Common::ReturnCode set_root_screen(Screen &screen); BSP::ReturnCode set_root_screen(Screen &screen);
Common::Schedule::NextTime execute() override; BSP::Schedule::NextTime execute() override;
Common::ReturnCode pop_screen(); BSP::ReturnCode pop_screen();
Common::ReturnCode push_screen(Screen &screen); BSP::ReturnCode push_screen(Screen &screen);
Common::ReturnCode set_screen(Screen &screen); BSP::ReturnCode set_screen(Screen &screen);
private: private:
@@ -58,7 +58,7 @@ private:
static constexpr std::size_t MAX_SCREEN_STACK = 5; static constexpr std::size_t MAX_SCREEN_STACK = 5;
Common::Schedule::TaskScheduler &m_scheduler; BSP::Schedule::TaskScheduler &m_scheduler;
std::array<Screen *, MAX_SCREEN_STACK> m_screen_stack; std::array<Screen *, MAX_SCREEN_STACK> m_screen_stack;
std::size_t m_screen_stack_depth; std::size_t m_screen_stack_depth;

View File

@@ -0,0 +1,191 @@
/*
* Copyright (C) 2019 Max Regan
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <algorithm>
#include <cmath>
#include "Application/Screens/AnalogTimeScreen.h"
#include "Application/SystemFonts.h"
#include "Bsp/Drivers/RtcDriver.h"
#include "Bsp/SystemTime.h"
#include "Bsp/Drivers/LowPower.h"
using BSP::ReturnCode;
using BSP::Time;
using BSP::Schedule::NextTime;
using Color = BSP::DisplayDriver::Color;
// TODO: remove all calls to std::cos and std::sin?
AnalogTimeScreen::AnalogTimeScreen(BSP::DisplayDriver &driver,
ScreenManager &manager,
Screen &menu_screen)
: m_driver(driver)
, m_last_time()
, m_manager(manager)
, m_menu_screen(menu_screen)
, m_display_seconds(true)
{}
ReturnCode AnalogTimeScreen::init()
{
return ReturnCode::OK;
}
void AnalogTimeScreen::draw_ticks() {
// After profiling, using lookup tables is 6-10% faster than using std::sin & std::cos.
static constexpr float sin_tbl[8] = {
0.0,
0.10452539173303049,
0.20790564888802265,
0.30900818248165035,
0.4067253572759511,
0.4999866265466325,
0.5877702605258084,
0.6691145400274635,
};
static constexpr float cos_tbl[8] = {
1.0,
0.9945222181947755,
0.9781488849661131,
0.9510593794077146,
0.9135504823209005,
0.8660331248136633,
0.8090278863187741,
0.7431592913526923,
};
const uint32_t y_center = m_driver.get_height() / 2;
const uint32_t x_center = m_driver.get_width() / 2;
const uint32_t radius = std::min(m_driver.get_width(), m_driver.get_height()) / 2;
// This only works for square screens, but saves a a bunch of float math and calls to trig functions
for (int i = 0; i < 8; i++) {
const uint32_t len = (i % 5 == 0) ? 10 : 5;
const uint32_t width = (i % 5 == 0) ? 3 : 1;
const uint32_t end1_offset = sin_tbl[i] * radius;
const uint32_t end2_offset = cos_tbl[i] * radius;
const uint32_t start1_offset = sin_tbl[i] * (radius - len);
const uint32_t start2_offset = cos_tbl[i] * (radius - len);
m_driver.draw_line(x_center + start1_offset, y_center + start2_offset,
x_center + end1_offset, y_center + end2_offset,
Color::BLACK, width);
m_driver.draw_line(x_center - start1_offset, y_center + start2_offset,
x_center - end1_offset, y_center + end2_offset,
Color::BLACK, width);
m_driver.draw_line(x_center + start1_offset, y_center - start2_offset,
x_center + end1_offset, y_center - end2_offset,
Color::BLACK, width);
m_driver.draw_line(x_center - start1_offset, y_center - start2_offset,
x_center - end1_offset, y_center - end2_offset,
Color::BLACK, width);
m_driver.draw_line(x_center + start2_offset, y_center + start1_offset,
x_center + end2_offset, y_center + end1_offset,
Color::BLACK, width);
m_driver.draw_line(x_center - start2_offset, y_center + start1_offset,
x_center - end2_offset, y_center + end1_offset,
Color::BLACK, width);
m_driver.draw_line(x_center + start2_offset, y_center - start1_offset,
x_center + end2_offset, y_center - end1_offset,
Color::BLACK, width);
m_driver.draw_line(x_center - start2_offset, y_center - start1_offset,
x_center - end2_offset, y_center - end1_offset,
Color::BLACK, width);
}
}
void AnalogTimeScreen::draw_hand(uint32_t ticks, uint32_t len, int32_t width, Color color) {
const uint32_t y_center = m_driver.get_height() / 2;
const uint32_t x_center = m_driver.get_width() / 2;
uint32_t x_end = x_center + std::sin(ticks * TURNS_PER_TICK) * len;
uint32_t y_end = y_center - std::cos(ticks * TURNS_PER_TICK) * len;
m_driver.draw_line(x_center, y_center, x_end, y_end, color, width);
}
void AnalogTimeScreen::display_time()
{
BSP::WallClockTime time;
BSP::RtcDriver::get_time(time);
m_driver.clear(Color::WHITE);
draw_ticks();
const uint32_t seconds_len = std::min(m_driver.get_width(), m_driver.get_height()) * 9 / 20;
const uint32_t minutes_len = std::min(m_driver.get_width(), m_driver.get_height()) * 17 / 40;
const uint32_t hours_len = std::min(m_driver.get_width(), m_driver.get_height()) * 6 / 20;
draw_hand(time.get_hours_12() * 5, hours_len, 3, Color::BLACK);
draw_hand(time.get_minutes(), minutes_len, 3, Color::BLACK);
if (m_display_seconds) {
draw_hand(time.get_seconds(), seconds_len, 2, Color::RED);
}
m_last_time = time;
m_driver.refresh();
}
NextTime AnalogTimeScreen::execute()
{
display_time();
BSP::time_t now;
BSP::SystemTimer::get_time(now);
if (m_display_seconds) {
return NextTime::in(Time::seconds(1));
} else {
BSP::WallClockTime wall_time;
BSP::RtcDriver::get_time(wall_time);
return NextTime::in(Time::seconds(61 - wall_time.get_seconds()));
}
}
void AnalogTimeScreen::enable() {
m_last_time = {};
display_time();
}
void AnalogTimeScreen::disable() {
}
void AnalogTimeScreen::notify_up_button() {
/* TODO: This should open a menu first */
m_manager.push_screen(m_menu_screen);
}
void AnalogTimeScreen::notify_middle_button() {
}
void AnalogTimeScreen::notify_down_button() {
}

View File

@@ -0,0 +1,61 @@
/*
* Copyright (C) 2019 Max Regan
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#pragma once
#include "Bsp/macros.h"
#include "Application/ScreenManager.h"
#include "Application/Screens/Screen.h"
class AnalogTimeScreen : public Screen {
public:
AnalogTimeScreen(BSP::DisplayDriver &display,
ScreenManager &m_manager,
Screen &m_menu_screen);
BSP::ReturnCode init();
BSP::Schedule::NextTime execute() override;
void enable() override;
void disable() override;
void notify_up_button() override;
void notify_middle_button() override;
void notify_down_button() override;
private:
static constexpr float TURNS_PER_TICK = 2 * 3.1415 / 60;
void draw_hand(uint32_t ticks, uint32_t len, int32_t width, BSP::DisplayDriver::Color color);
void draw_ticks();
void display_time();
BSP::DisplayDriver &m_driver;
BSP::WallClockTime m_last_time;
ScreenManager &m_manager;
Screen &m_menu_screen;
const bool m_display_seconds;
};

View File

@@ -19,18 +19,18 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include "Application/Screens/DisplayTimeScreen.h" #include "Application/Screens/BigDigitalTimeScreen.h"
#include "Application/SystemFonts.h" #include "Application/SystemFonts.h"
#include "Bsp/Drivers/RtcDriver.h" #include "Bsp/Drivers/RtcDriver.h"
#include "Bsp/SystemTime.h" #include "Bsp/SystemTime.h"
#include "Bsp/Drivers/LowPower.h" #include "Bsp/Drivers/LowPower.h"
using Common::ReturnCode; using BSP::ReturnCode;
using Common::Time; using BSP::Time;
using Common::Schedule::NextTime; using BSP::Schedule::NextTime;
using Color = BSP::DisplayDriver::Color; using Color = BSP::DisplayDriver::Color;
DisplayTimeScreen::DisplayTimeScreen(BSP::DisplayDriver &driver, BigDigitalTimeScreen::BigDigitalTimeScreen(BSP::DisplayDriver &driver,
ScreenManager &manager, ScreenManager &manager,
Screen &menu_screen) Screen &menu_screen)
: m_driver(driver) : m_driver(driver)
@@ -48,14 +48,12 @@ static char get_char_for_digit(uint8_t bcd_digit)
return bcd_digit + '0'; return bcd_digit + '0';
} }
ReturnCode DisplayTimeScreen::init() ReturnCode BigDigitalTimeScreen::init()
{ {
SET(RCC->CFGR, RCC_CFGR_SW_HSI);
return ReturnCode::OK; return ReturnCode::OK;
} }
void DisplayTimeScreen::display_number(uint32_t *x, uint32_t y, uint32_t tens, uint32_t ones, const struct font &f) void BigDigitalTimeScreen::display_number(uint32_t *x, uint32_t y, uint32_t tens, uint32_t ones, const struct font &f)
{ {
char time_str[3] = { 0 }; char time_str[3] = { 0 };
@@ -63,12 +61,12 @@ void DisplayTimeScreen::display_number(uint32_t *x, uint32_t y, uint32_t tens, u
time_str[1] = get_char_for_digit(ones); time_str[1] = get_char_for_digit(ones);
time_str[2] = '\0'; time_str[2] = '\0';
m_driver.string_at(x, y, time_str, &f, Color::WHITE); m_driver.string_at(x, y, time_str, &f, Color::BLACK);
} }
void DisplayTimeScreen::display_time() void BigDigitalTimeScreen::display_time()
{ {
Common::WallClockTime time; BSP::WallClockTime time;
BSP::RtcDriver::get_time(time); BSP::RtcDriver::get_time(time);
const struct font &font = font_large_digits; const struct font &font = font_large_digits;
const uint32_t y_space = (m_driver.get_height() - (2 * font.height)) / 3; const uint32_t y_space = (m_driver.get_height() - (2 * font.height)) / 3;
@@ -76,7 +74,7 @@ void DisplayTimeScreen::display_time()
uint32_t x = 0; uint32_t x = 0;
m_driver.clear(Color::BLACK); m_driver.clear(Color::WHITE);
x = x_space; x = x_space;
display_number(&x, y_space, display_number(&x, y_space,
@@ -90,40 +88,40 @@ void DisplayTimeScreen::display_time()
m_driver.refresh(); m_driver.refresh();
} }
NextTime DisplayTimeScreen::execute() NextTime BigDigitalTimeScreen::execute()
{ {
display_time(); display_time();
Common::time_t now; BSP::time_t now;
BSP::SystemTimer::get_time(now); BSP::SystemTimer::get_time(now);
if (m_display_seconds) { if (m_display_seconds) {
return NextTime::in(Time::seconds(1)); return NextTime::in(Time::seconds(1));
} else { } else {
Common::WallClockTime wall_time; BSP::WallClockTime wall_time;
BSP::RtcDriver::get_time(wall_time); BSP::RtcDriver::get_time(wall_time);
return NextTime::in(Time::seconds(61 - wall_time.get_seconds())); return NextTime::in(Time::seconds(61 - wall_time.get_seconds()));
} }
} }
void DisplayTimeScreen::enable() { void BigDigitalTimeScreen::enable() {
m_last_time = {}; m_last_time = {};
display_time(); display_time();
} }
void DisplayTimeScreen::disable() { void BigDigitalTimeScreen::disable() {
} }
void DisplayTimeScreen::notify_up_button() { void BigDigitalTimeScreen::notify_up_button() {
/* TODO: This should open a menu first */ /* TODO: This should open a menu first */
m_manager.push_screen(m_menu_screen); m_manager.push_screen(m_menu_screen);
} }
void DisplayTimeScreen::notify_middle_button() { void BigDigitalTimeScreen::notify_middle_button() {
} }
void DisplayTimeScreen::notify_down_button() { void BigDigitalTimeScreen::notify_down_button() {
} }

View File

@@ -12,7 +12,7 @@
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
@@ -26,15 +26,15 @@
#include "Application/ScreenManager.h" #include "Application/ScreenManager.h"
#include "Application/Screens/Screen.h" #include "Application/Screens/Screen.h"
class DisplayTimeScreen : public Screen { class BigDigitalTimeScreen : public Screen {
public: public:
DisplayTimeScreen(BSP::DisplayDriver &display, BigDigitalTimeScreen(BSP::DisplayDriver &display,
ScreenManager &m_manager, ScreenManager &m_manager,
Screen &m_menu_screen); Screen &m_menu_screen);
Common::ReturnCode init(); BSP::ReturnCode init();
Common::Schedule::NextTime execute() override; BSP::Schedule::NextTime execute() override;
void enable() override; void enable() override;
void disable() override; void disable() override;
@@ -49,7 +49,7 @@ private:
void display_number(uint32_t *x, uint32_t y, uint32_t tens, uint32_t ones, const font &f); void display_number(uint32_t *x, uint32_t y, uint32_t tens, uint32_t ones, const font &f);
BSP::DisplayDriver &m_driver; BSP::DisplayDriver &m_driver;
Common::WallClockTime m_last_time; BSP::WallClockTime m_last_time;
ScreenManager &m_manager; ScreenManager &m_manager;
Screen &m_menu_screen; Screen &m_menu_screen;

View File

@@ -39,8 +39,8 @@ public:
, m_manager(manager) , m_manager(manager)
{} {}
Common::ReturnCode init() { BSP::ReturnCode init() {
return Common::ReturnCode::OK; return BSP::ReturnCode::OK;
} }
void render() { void render() {
@@ -58,9 +58,9 @@ public:
m_driver.refresh(); m_driver.refresh();
} }
Common::Schedule::NextTime execute() override { BSP::Schedule::NextTime execute() override {
render(); render();
return Common::Schedule::NextTime::never(); return BSP::Schedule::NextTime::never();
} }
void enable() override { void enable() override {

View File

@@ -124,12 +124,12 @@ public:
m_driver.refresh(); m_driver.refresh();
} }
Common::ReturnCode init() { BSP::ReturnCode init() {
return Common::ReturnCode::OK; return BSP::ReturnCode::OK;
} }
Common::Schedule::NextTime execute() override { BSP::Schedule::NextTime execute() override {
return Common::Schedule::NextTime::never(); return BSP::Schedule::NextTime::never();
} }
void enable() override { void enable() override {

View File

@@ -24,7 +24,7 @@
#include "Bsp/ReturnCode.h" #include "Bsp/ReturnCode.h"
#include "Bsp/Task.h" #include "Bsp/Task.h"
class Screen : public Common::Schedule::Task { class Screen : public BSP::Schedule::Task {
public: public:
virtual void enable() = 0; virtual void enable() = 0;

View File

@@ -26,9 +26,9 @@
#include "Bsp/SystemTime.h" #include "Bsp/SystemTime.h"
#include "Bsp/Drivers/RtcDriver.h" #include "Bsp/Drivers/RtcDriver.h"
using Common::ReturnCode; using BSP::ReturnCode;
using Common::Time; using BSP::Time;
using Common::Schedule::NextTime; using BSP::Schedule::NextTime;
SetDateScreen::SetDateScreen(BSP::DisplayDriver &display, SetDateScreen::SetDateScreen(BSP::DisplayDriver &display,
ScreenManager &manager) ScreenManager &manager)

View File

@@ -36,8 +36,8 @@ public:
SetDateScreen(BSP::DisplayDriver &display, SetDateScreen(BSP::DisplayDriver &display,
ScreenManager &m_manager); ScreenManager &m_manager);
Common::ReturnCode init(); BSP::ReturnCode init();
Common::Schedule::NextTime execute() override; BSP::Schedule::NextTime execute() override;
void enable() override; void enable() override;
void disable() override; void disable() override;
@@ -70,7 +70,7 @@ private:
SetState m_state; SetState m_state;
bool m_is_acked = false; bool m_is_acked = false;
Common::WallClockTime m_time; BSP::WallClockTime m_time;
const struct font &m_font; const struct font &m_font;
const uint32_t m_row_spacing; const uint32_t m_row_spacing;
const uint32_t m_row_0_y; const uint32_t m_row_0_y;

View File

@@ -26,9 +26,9 @@
#include "Bsp/SystemTime.h" #include "Bsp/SystemTime.h"
#include "Bsp/Drivers/RtcDriver.h" #include "Bsp/Drivers/RtcDriver.h"
using Common::ReturnCode; using BSP::ReturnCode;
using Common::Time; using BSP::Time;
using Common::Schedule::NextTime; using BSP::Schedule::NextTime;
SetTimeScreen::SetTimeScreen(BSP::DisplayDriver &display, SetTimeScreen::SetTimeScreen(BSP::DisplayDriver &display,
ScreenManager &manager) ScreenManager &manager)

View File

@@ -36,8 +36,8 @@ public:
SetTimeScreen(BSP::DisplayDriver &display, SetTimeScreen(BSP::DisplayDriver &display,
ScreenManager &m_manager); ScreenManager &m_manager);
Common::ReturnCode init(); BSP::ReturnCode init();
Common::Schedule::NextTime execute() override; BSP::Schedule::NextTime execute() override;
void enable() override; void enable() override;
void disable() override; void disable() override;
@@ -70,7 +70,7 @@ private:
SetState m_state; SetState m_state;
bool m_is_acked = false; bool m_is_acked = false;
Common::WallClockTime m_time; BSP::WallClockTime m_time;
const struct font &m_font; const struct font &m_font;
const uint32_t m_row_spacing; const uint32_t m_row_spacing;
const uint32_t m_row_0_y; const uint32_t m_row_0_y;

View File

@@ -28,7 +28,8 @@
#include "Application/ButtonManager.h" #include "Application/ButtonManager.h"
#include "Application/ScreenManager.h" #include "Application/ScreenManager.h"
#include "Application/Screens/DisplayTimeScreen.h" #include "Application/Screens/AnalogTimeScreen.h"
#include "Application/Screens/BigDigitalTimeScreen.h"
#include "Application/Screens/DebugScreen.h" #include "Application/Screens/DebugScreen.h"
#include "Application/Screens/MenuScreen.h" #include "Application/Screens/MenuScreen.h"
#include "Application/Screens/SetTimeScreen.h" #include "Application/Screens/SetTimeScreen.h"
@@ -39,13 +40,13 @@
// TODO: Don't include this here. // TODO: Don't include this here.
#include "stm32l0xx.h" #include "stm32l0xx.h"
using Common::Time; using BSP::Time;
static Common::Schedule::LowPowerTaskScheduler<5> g_sched; static BSP::Schedule::LowPowerTaskScheduler<5> g_sched;
static BSP::SpiDriver g_spi(g_sched); static BSP::SpiDriver g_spi(g_sched);
static BSP::DisplayDriver g_display(g_sched, g_spi); static BSP::DisplayDriver g_display(g_sched, g_spi);
static BSP::LptimPwm g_lptim_pwm(LPTIM1); static BSP::LptimPwm g_lptim_pwm(LPTIM1);
static BSP::ButtonManager g_btn_manager(g_sched, 2, 1, 0, Time::millis(1)); static BSP::ButtonManager g_btn_manager(g_sched, 0, 1, 2, Time::millis(1));
static ScreenManager g_screen_manager(g_sched, g_display, g_btn_manager); static ScreenManager g_screen_manager(g_sched, g_display, g_btn_manager);
static SetTimeScreen g_set_time_screen(g_display, g_screen_manager); static SetTimeScreen g_set_time_screen(g_display, g_screen_manager);
@@ -72,7 +73,7 @@ static MenuScreen g_main_menu_screen(g_display,
std::initializer_list<MenuScreenItem>({MenuScreenItem("Apps", g_settings_menu_screen), std::initializer_list<MenuScreenItem>({MenuScreenItem("Apps", g_settings_menu_screen),
MenuScreenItem("Settings", g_settings_menu_screen)})); MenuScreenItem("Settings", g_settings_menu_screen)}));
static DisplayTimeScreen g_display_time_screen(g_display, g_screen_manager, g_main_menu_screen); static AnalogTimeScreen g_display_time_screen(g_display, g_screen_manager, g_main_menu_screen);
extern "C" void __cxa_pure_virtual() { while(1) {} } extern "C" void __cxa_pure_virtual() { while(1) {} }
@@ -121,7 +122,45 @@ void SystemInit()
/*!< Reset HSEBYP bit (disable HSE bypass) */ /*!< Reset HSEBYP bit (disable HSE bypass) */
CLR(RCC->CR, CLR(RCC->CR,
RCC_CR_HSEBYP); RCC_CR_HSEBYP)
;
/* (1) Test if PLL is used as System clock */
/* (2) Select HSI as system clock */
/* (3) Wait for HSI switched */
/* (4) Disable the PLL */
/* (5) Wait until PLLRDY is cleared */
/* (6) Set latency to 1 wait state */
/* (7) Set the PLL multiplier to 24 and divider by 3 */
/* (8) Enable the PLL */
/* (9) Wait until PLLRDY is set */
/* (10) Select PLL as system clock */
/* (11) Wait until the PLL is switched on */
// SET(RCC->CR, RCC_CR_HSION);
// while((RCC->CR & RCC_CR_HSIRDY) != 0) {}
// if ((RCC->CFGR & RCC_CFGR_SWS) == RCC_CFGR_SWS_PLL) /* (1) */
// {
// RCC->CFGR = (RCC->CFGR & (uint32_t) (~RCC_CFGR_SW)) | RCC_CFGR_SW_HSI; /* (2) */
// while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_HSI) /* (3) */
// { /* For robust implementation, add here time-out management */ }
// }
// RCC->CR &= (uint32_t)(~RCC_CR_PLLON);/* (4) */
// while((RCC->CR & RCC_CR_PLLRDY) != 0) /* (5) */
// { /* For robust implementation, add here time-out management */ }
// FLASH->ACR |= FLASH_ACR_LATENCY; /* (6) */
// RCC->CFGR = RCC->CFGR & ((~(RCC_CFGR_PLLMUL| RCC_CFGR_PLLDIV )) | (RCC_CFGR_PLLMUL24 | RCC_CFGR_PLLDIV2)); /* (7) */
// RCC->CR |= RCC_CR_PLLON; /* (8) */
// while ((RCC->CR & RCC_CR_PLLRDY) == 0) /* (9) */
// { /* For robust implementation, add here time-out management */ }
// RCC->CFGR |= (uint32_t) (RCC_CFGR_SW_PLL); /* (10) */
// while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL) /* (11) */
// { /* For robust implementation, add here time-out management */ }
/*!< Reset /*!< Reset
* PLLSRC (HSI16 is the PLL source), * PLLSRC (HSI16 is the PLL source),
@@ -129,7 +168,7 @@ void SystemInit()
* Don't touch PLLDIV[1:0], since 0 is undefined * Don't touch PLLDIV[1:0], since 0 is undefined
*/ */
CLR(RCC->CFGR, CLR(RCC->CFGR,
RCC_CFGR_PLLSRC | RCC_CFGR_PLLMUL | RCC_CFGR_PLLDIV); RCC_CFGR_PLLSRC | RCC_CFGR_PLLMUL | RCC_CFGR_PLLDIV);
/*!< Disable all interrupts */ /*!< Disable all interrupts */
RCC->CIER = 0x00000000; RCC->CIER = 0x00000000;
@@ -170,7 +209,7 @@ static void _init(void)
g_screen_manager.set_root_screen(g_display_time_screen); g_screen_manager.set_root_screen(g_display_time_screen);
// Enqueue each of the tasks // Enqueue each of the tasks
Common::Schedule::NextTime asap = Common::Schedule::NextTime::asap(); BSP::Schedule::NextTime asap = BSP::Schedule::NextTime::asap();
g_sched.add_task(g_spi, asap); g_sched.add_task(g_spi, asap);
g_sched.add_task(g_btn_manager, asap); g_sched.add_task(g_btn_manager, asap);
g_sched.add_task(g_display, asap); g_sched.add_task(g_display, asap);

View File

@@ -20,6 +20,7 @@
*/ */
#include <cstring> #include <cstring>
#include <cstdlib>
#include "Bsp/Drivers/DisplayDriver.h" #include "Bsp/Drivers/DisplayDriver.h"
#include "Bsp/macros.h" #include "Bsp/macros.h"
@@ -27,10 +28,10 @@
namespace BSP { namespace BSP {
using Common::Schedule::NextTime; using BSP::Schedule::NextTime;
using Common::ReturnCode; using BSP::ReturnCode;
DisplayDriver::DisplayDriver(Common::Schedule::TaskScheduler &scheduler, SpiDriver &spi) DisplayDriver::DisplayDriver(BSP::Schedule::TaskScheduler &scheduler, SpiDriver &spi)
: m_scheduler(scheduler) : m_scheduler(scheduler)
, m_spi(spi) , m_spi(spi)
, m_is_dirty(true) , m_is_dirty(true)
@@ -42,7 +43,7 @@ DisplayDriver::DisplayDriver(Common::Schedule::TaskScheduler &scheduler, SpiDriv
ReturnCode DisplayDriver::init() ReturnCode DisplayDriver::init()
{ {
return Common::ReturnCode::OK; return BSP::ReturnCode::OK;
} }
NextTime DisplayDriver::execute() NextTime DisplayDriver::execute()
@@ -98,6 +99,45 @@ void DisplayDriver::set_dirty(unsigned int y)
} }
} }
void DisplayDriver::draw_line(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, Color color, int32_t width)
{
const int32_t dx = abs(x1 - x0);
const int32_t sx = (x0 < x1) ? 1 : -1;
const int32_t dy = -abs(y1 - y0);
const int32_t sy = (y0 < y1) ? 1 : -1;
int32_t err = dx + dy;
uint32_t x = x0;
uint32_t y = y0;
while (true) {
for (int32_t i = -width / 2; i < (-width / 2) + width; i++) {
uint32_t xp, yp;
if (dx > -dy) {
xp = x;
yp = y + i;
} else {
xp = x + i;
yp = y;
}
set_pixel(xp, yp, color);
}
if (x == x1 && y == y1)
break;
const int32_t e2 = 2 * err;
if (e2 >= dy) {
err += dy;
x += sx;
}
if (e2 <= dx) {
err += dx;
y += sy;
}
}
}
// TODO: write my own implementation // TODO: write my own implementation
#define R2(n) n, n + 2*64, n + 1*64, n + 3*64 #define R2(n) n, n + 2*64, n + 1*64, n + 3*64
#define R4(n) R2(n), R2(n + 2*16), R2(n + 1*16), R2(n + 3*16) #define R4(n) R2(n), R2(n + 2*16), R2(n + 1*16), R2(n + 3*16)

View File

@@ -27,15 +27,15 @@
namespace BSP { namespace BSP {
class DisplayDriver final : public Common::Schedule::Task { class DisplayDriver final : public BSP::Schedule::Task {
public: public:
DisplayDriver(Common::Schedule::TaskScheduler &scheduler, SpiDriver &spi); DisplayDriver(BSP::Schedule::TaskScheduler &scheduler, SpiDriver &spi);
/** /**
* Common::Schedule::Task * BSP::Schedule::Task
*/ */
Common::ReturnCode init(); BSP::ReturnCode init();
Common::Schedule::NextTime execute() override; BSP::Schedule::NextTime execute() override;
static constexpr uint32_t BITS_PER_PIXEL = 3; static constexpr uint32_t BITS_PER_PIXEL = 3;
@@ -62,6 +62,7 @@ public:
const char *string, const struct font *font, const char *string, const struct font *font,
Color color=DEFAULT_COLOR); Color color=DEFAULT_COLOR);
void draw_hline(uint32_t x, uint32_t y, uint32_t width, Color color=DEFAULT_COLOR); void draw_hline(uint32_t x, uint32_t y, uint32_t width, Color color=DEFAULT_COLOR);
void draw_line(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, Color color=DEFAULT_COLOR, int32_t width=1);
void refresh(); void refresh();
void clear(Color color=Color::WHITE); void clear(Color color=Color::WHITE);
@@ -98,7 +99,7 @@ private:
}; };
Common::Schedule::TaskScheduler &m_scheduler; BSP::Schedule::TaskScheduler &m_scheduler;
SpiDriver &m_spi; SpiDriver &m_spi;
struct display_buffer m_buffer; struct display_buffer m_buffer;

View File

@@ -29,7 +29,7 @@ uint32_t wakeups = 0;
namespace BSP { namespace BSP {
using Common::ReturnCode; using BSP::ReturnCode;
ReturnCode LowPower::init() ReturnCode LowPower::init()
{ {
@@ -40,12 +40,12 @@ ReturnCode LowPower::init()
ReturnCode LowPower::enable_debug() ReturnCode LowPower::enable_debug()
{ {
/* Enable Clocks */ /* Enable Clocks */
SET(RCC->APB2ENR, RCC_APB2ENR_DBGEN); // SET(RCC->APB2ENR, RCC_APB2ENR_DBGEN);
SET(RCC->APB2SMENR, RCC_APB2SMENR_DBGSMEN); // SET(RCC->APB2SMENR, RCC_APB2SMENR_DBGSMEN);
SET(DBGMCU->CR, DBGMCU_CR_DBG_STOP); // SET(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
SET(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP); // SET(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP);
SET(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY); // SET(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
return ReturnCode::OK; return ReturnCode::OK;
} }

View File

@@ -31,11 +31,11 @@ class LowPower {
public: public:
LowPower() = delete; LowPower() = delete;
static Common::ReturnCode init(); static BSP::ReturnCode init();
static Common::ReturnCode sleep(); static BSP::ReturnCode sleep();
static Common::ReturnCode stop(); static BSP::ReturnCode stop();
static Common::ReturnCode enable_debug(); static BSP::ReturnCode enable_debug();
static Common::ReturnCode disable_debug(); static BSP::ReturnCode disable_debug();
}; };
} }

View File

@@ -24,7 +24,7 @@
namespace BSP { namespace BSP {
using Common::ReturnCode; using BSP::ReturnCode;
LptimPwm::LptimPwm(LPTIM_TypeDef *lptim) LptimPwm::LptimPwm(LPTIM_TypeDef *lptim)
: m_lptim(lptim) : m_lptim(lptim)

View File

@@ -32,7 +32,7 @@ public:
LptimPwm() = delete; LptimPwm() = delete;
LptimPwm(LPTIM_TypeDef *lptim); LptimPwm(LPTIM_TypeDef *lptim);
Common::ReturnCode init(); BSP::ReturnCode init();
private: private:
void init_lptim(); void init_lptim();

View File

@@ -26,8 +26,8 @@
namespace BSP { namespace BSP {
using Common::ReturnCode; using BSP::ReturnCode;
using Common::time_t; using BSP::time_t;
RtcDriver::RtcSystemTimer RtcDriver::m_sys_timer; RtcDriver::RtcSystemTimer RtcDriver::m_sys_timer;
@@ -106,11 +106,11 @@ ReturnCode RtcDriver::init_hw()
uint32_t time = 0; uint32_t time = 0;
SET(time, RTC_TR_PM); SET(time, RTC_TR_PM);
SET_TO(time, RTC_TR_HT, 1 << RTC_TR_HT_Pos); SET_TO(time, RTC_TR_HT, 1 << RTC_TR_HT_Pos);
SET_TO(time, RTC_TR_HU, 2 << RTC_TR_HU_Pos); SET_TO(time, RTC_TR_HU, 0 << RTC_TR_HU_Pos);
SET_TO(time, RTC_TR_MNT, 5 << RTC_TR_MNT_Pos); SET_TO(time, RTC_TR_MNT, 0 << RTC_TR_MNT_Pos);
SET_TO(time, RTC_TR_MNU, 9 << RTC_TR_MNU_Pos); SET_TO(time, RTC_TR_MNU, 9 << RTC_TR_MNU_Pos);
SET_TO(time, RTC_TR_ST, 0 << RTC_TR_ST_Pos); SET_TO(time, RTC_TR_ST, 3 << RTC_TR_ST_Pos);
SET_TO(time, RTC_TR_SU, 0 << RTC_TR_SU_Pos); SET_TO(time, RTC_TR_SU, 6 << RTC_TR_SU_Pos);
RTC->TR = time; RTC->TR = time;
CLR(RTC->ISR, RTC_ISR_INIT); CLR(RTC->ISR, RTC_ISR_INIT);
@@ -119,7 +119,7 @@ ReturnCode RtcDriver::init_hw()
SET(EXTI->EMR, EXTI_EMR_EM20); SET(EXTI->EMR, EXTI_EMR_EM20);
SET(EXTI->RTSR, EXTI_RTSR_RT20); SET(EXTI->RTSR, EXTI_RTSR_RT20);
// Enable Wakeup interrupts, we may/will use them later // Enable Wakeup irq, we may/will use them later
SET(RTC->CR, RTC_CR_WUTIE); SET(RTC->CR, RTC_CR_WUTIE);
NVIC_EnableIRQ(RTC_IRQn); NVIC_EnableIRQ(RTC_IRQn);
NVIC_SetPriority(RTC_IRQn, 0); NVIC_SetPriority(RTC_IRQn, 0);
@@ -131,7 +131,7 @@ ReturnCode RtcDriver::init_hw()
return ReturnCode::OK; return ReturnCode::OK;
} }
ReturnCode RtcDriver::get_time(Common::WallClockTime &wall_time) ReturnCode RtcDriver::get_time(BSP::WallClockTime &wall_time)
{ {
/*<! The value of TR in the shadow register is locked when SSR is /*<! The value of TR in the shadow register is locked when SSR is
read (by the system timer), until the date register is read. We're read (by the system timer), until the date register is read. We're
@@ -155,12 +155,12 @@ ReturnCode RtcDriver::get_time(Common::WallClockTime &wall_time)
hours += 12; hours += 12;
} }
new (&wall_time) Common::WallClockTime(hours, minutes, seconds); new (&wall_time) BSP::WallClockTime(hours, minutes, seconds);
return ReturnCode::OK; return ReturnCode::OK;
} }
ReturnCode RtcDriver::set_time(const Common::WallClockTime &wall_time) ReturnCode RtcDriver::set_time(const BSP::WallClockTime &wall_time)
{ {
enable_rtc_write(); enable_rtc_write();
@@ -191,13 +191,13 @@ ReturnCode RtcDriver::set_time(const Common::WallClockTime &wall_time)
return ReturnCode::OK; return ReturnCode::OK;
} }
ReturnCode RtcDriver::set_wakeup_in(Common::time_t wakeup_delay) ReturnCode RtcDriver::set_wakeup_in(BSP::time_t wakeup_delay)
{ {
/*<! 2^64 / (1000000 * 32768) / 60 / 60 / 24 / 365 = ~17.85 This /*<! 2^64 / (1000000 * 32768) / 60 / 60 / 24 / 365 = ~17.85 This
value will only overflow for wakeup_delays > 17.85 years, so value will only overflow for wakeup_delays > 17.85 years, so
this is fine. */ this is fine. */
uint64_t delay_cycles = Common::Time::to_micros(wakeup_delay) * LSE_CLOCK_FREQ / uint64_t delay_cycles = BSP::Time::to_micros(wakeup_delay) * LSE_CLOCK_FREQ /
Common::Time::MICROS_PER_SEC; BSP::Time::MICROS_PER_SEC;
enable_rtc_write(); enable_rtc_write();
@@ -244,25 +244,29 @@ ReturnCode RtcDriver::set_wakeup_in(Common::time_t wakeup_delay)
return ReturnCode::OK; return ReturnCode::OK;
} }
Common::time_t RtcDriver::RtcSystemTimer::get_time() BSP::time_t RtcDriver::RtcSystemTimer::get_time()
{ {
uint32_t new_secs, old_secs, ssr, subsecond; uint32_t new_secs, old_secs, ssr;
uint64_t new_timer_ticks, new_millis;
do { do {
__disable_irq();
old_secs = m_seconds; old_secs = m_seconds;
ssr = RTC->SSR & 0xFFFF; ssr = RTC->SSR & 0xFFFF;
new_secs = m_seconds; new_secs = m_seconds;
__enable_irq();
} while (new_secs != old_secs); } while (new_secs != old_secs);
new_secs = new_secs * LSE_CLOCK_FREQ; new_timer_ticks = (uint64_t) new_secs * LSE_CLOCK_FREQ;
/** SSR is a countdown register */ /** SSR is a countdown register */
subsecond = (new_secs + LSE_CLOCK_FREQ - 1 - ssr) * Common::Time::MILLIS_PER_SEC / LSE_CLOCK_FREQ; new_millis = (new_timer_ticks + LSE_CLOCK_FREQ - 1 - ssr) * BSP::Time::MILLIS_PER_SEC / LSE_CLOCK_FREQ;
return Common::Time::millis(subsecond); return BSP::Time::millis(new_millis);
} }
void RtcDriver::RtcSystemTimer::increment_seconds() void RtcDriver::RtcSystemTimer::increment_seconds()
{ {
/** TODO: Atomic increment */ __disable_irq();
m_seconds++; m_seconds++;
__enable_irq();
} }
void RtcDriver::increment_seconds() void RtcDriver::increment_seconds()
@@ -274,7 +278,7 @@ static uint32_t wakeup_alarms = 0;
extern "C" void RTC_IRQHandler() extern "C" void RTC_IRQHandler()
{ {
// Clear the wakeup and alarm interrupts in the EXTI // Clear the wakeup and alarm irq in the EXTI
SET(EXTI->PR, EXTI_PR_PIF20 | EXTI_PR_PIF17); SET(EXTI->PR, EXTI_PR_PIF20 | EXTI_PR_PIF17);
if (RTC->ISR & RTC_ISR_ALRAF) { if (RTC->ISR & RTC_ISR_ALRAF) {

View File

@@ -40,15 +40,15 @@ public:
static SystemTimerImpl& get_system_timer() { static SystemTimerImpl& get_system_timer() {
return m_sys_timer; return m_sys_timer;
}; };
static Common::ReturnCode init(); static BSP::ReturnCode init();
static void increment_seconds(); static void increment_seconds();
static Common::ReturnCode get_time(Common::WallClockTime &tm_bcd); static BSP::ReturnCode get_time(BSP::WallClockTime &tm_bcd);
static Common::ReturnCode set_time(const Common::WallClockTime &tm_bcd); static BSP::ReturnCode set_time(const BSP::WallClockTime &tm_bcd);
static Common::ReturnCode set_wakeup_in(Common::time_t wakeup_delay); static BSP::ReturnCode set_wakeup_in(BSP::time_t wakeup_delay);
private: private:
static Common::ReturnCode init_hw(); static BSP::ReturnCode init_hw();
static void enable_rtc_write(); static void enable_rtc_write();
static void disable_rtc_write(); static void disable_rtc_write();
static void enable_rtc_wakeup_interrupt(); static void enable_rtc_wakeup_interrupt();
@@ -67,7 +67,7 @@ private:
~RtcSystemTimer() {} ~RtcSystemTimer() {}
Common::time_t get_time() override; BSP::time_t get_time() override;
void increment_seconds(); void increment_seconds();
private: private:

View File

@@ -24,10 +24,10 @@
namespace BSP { namespace BSP {
using RC = Common::ReturnCode; using RC = BSP::ReturnCode;
using Common::Schedule::TaskScheduler; using BSP::Schedule::TaskScheduler;
using Common::Schedule::NextTime; using BSP::Schedule::NextTime;
using Common::Time; using BSP::Time;
SpiDriver::SpiDriver(TaskScheduler &scheduler) SpiDriver::SpiDriver(TaskScheduler &scheduler)
: m_scheduler(scheduler) : m_scheduler(scheduler)

View File

@@ -29,18 +29,18 @@
namespace BSP { namespace BSP {
class SpiDriver : public Common::Schedule::Task { class SpiDriver : public BSP::Schedule::Task {
public: public:
// TODO: Add configurability / provide a real abstraction // TODO: Add configurability / provide a real abstraction
SpiDriver(Common::Schedule::TaskScheduler &scheduler); SpiDriver(BSP::Schedule::TaskScheduler &scheduler);
void init(); void init();
Common::Schedule::NextTime execute() override; BSP::Schedule::NextTime execute() override;
Common::ReturnCode tx_blocking(const uint8_t *data, size_t len); BSP::ReturnCode tx_blocking(const uint8_t *data, size_t len);
private: private:
Common::Schedule::TaskScheduler &m_scheduler; BSP::Schedule::TaskScheduler &m_scheduler;
SPI_TypeDef *m_spi; SPI_TypeDef *m_spi;
}; };

View File

@@ -28,7 +28,7 @@
#include "Drivers/LowPower.h" #include "Drivers/LowPower.h"
#include "Drivers/RtcDriver.h" #include "Drivers/RtcDriver.h"
namespace Common { namespace BSP {
namespace Schedule { namespace Schedule {
template <uint32_t MAX_TASKS> template <uint32_t MAX_TASKS>
@@ -100,13 +100,13 @@ private:
void inline cycle() void inline cycle()
{ {
Common::time_t time = 0; BSP::time_t time = 0;
BSP::SystemTimer::get_time(time); BSP::SystemTimer::get_time(time);
bool task_died = false; bool task_died = false;
/* Keep state for when the next task will execute. */ /* Keep state for when the next task will execute. */
bool execed = false; bool execed = false;
Common::time_t next_time = ~0; BSP::time_t next_time = ~0;
for (size_t i = 0; i < m_task_count; i++) { for (size_t i = 0; i < m_task_count; i++) {
TaskEvent &event = m_tasks[i]; TaskEvent &event = m_tasks[i];
@@ -128,13 +128,13 @@ private:
} }
if (m_task_count == 0) { if (m_task_count == 0) {
Common::ReturnCode rc = BSP::RtcDriver::set_wakeup_in(Time::seconds(5)); BSP::ReturnCode rc = BSP::RtcDriver::set_wakeup_in(Time::seconds(5));
if (rc == Common::ReturnCode::OK) { if (rc == BSP::ReturnCode::OK) {
BSP::LowPower::stop(); BSP::LowPower::stop();
} }
} else if (!execed && (next_time - time > Time::millis(2))) { } else if (!execed && (next_time - time > Time::millis(2))) {
Common::ReturnCode rc = BSP::RtcDriver::set_wakeup_in(next_time - time); BSP::ReturnCode rc = BSP::RtcDriver::set_wakeup_in(next_time - time);
if (rc == Common::ReturnCode::OK) { if (rc == BSP::ReturnCode::OK) {
BSP::LowPower::stop(); BSP::LowPower::stop();
} }
} }

View File

@@ -21,7 +21,7 @@
#pragma once #pragma once
namespace Common { namespace BSP {
enum class ReturnCode : int { enum class ReturnCode : int {
OK = 0, OK = 0,

View File

@@ -24,8 +24,8 @@
namespace BSP { namespace BSP {
using Common::ReturnCode; using BSP::ReturnCode;
using Common::time_t; using BSP::time_t;
SystemTimerImpl *SystemTimer::m_impl = nullptr; SystemTimerImpl *SystemTimer::m_impl = nullptr;

View File

@@ -32,7 +32,7 @@ namespace BSP {
class SystemTimerImpl { class SystemTimerImpl {
public: public:
virtual Common::time_t get_time() = 0; virtual BSP::time_t get_time() = 0;
}; };
class SystemTimer final { class SystemTimer final {
@@ -40,7 +40,7 @@ public:
SystemTimer() = delete; SystemTimer() = delete;
~SystemTimer() = delete; ~SystemTimer() = delete;
static Common::ReturnCode get_time(Common::time_t &time); static BSP::ReturnCode get_time(BSP::time_t &time);
static void set_timer(SystemTimerImpl& timer); static void set_timer(SystemTimerImpl& timer);
private: private:
static SystemTimerImpl *m_impl; static SystemTimerImpl *m_impl;

View File

@@ -19,6 +19,6 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
namespace Common { namespace BSP {
} }

View File

@@ -25,7 +25,7 @@
#include "Time.h" #include "Time.h"
#include "SystemTime.h" #include "SystemTime.h"
namespace Common { namespace BSP {
namespace Schedule { namespace Schedule {
enum class ScheduleType { enum class ScheduleType {
@@ -112,4 +112,4 @@ public:
}; };
} // namespace Schedule } // namespace Schedule
} // namespace Common } // namespace BSP

View File

@@ -26,7 +26,7 @@
#include "Task.h" #include "Task.h"
#include "system.h" #include "system.h"
namespace Common { namespace BSP {
namespace Schedule { namespace Schedule {
class TaskScheduler { class TaskScheduler {

View File

@@ -23,7 +23,7 @@
#include <stdint.h> #include <stdint.h>
namespace Common { namespace BSP {
using time_t = uint64_t; using time_t = uint64_t;

View File

@@ -32,6 +32,7 @@ AS = $(TOOL_PREFIX)as
LD = $(TOOL_PREFIX)g++ LD = $(TOOL_PREFIX)g++
OBJCOPY = $(TOOL_PREFIX)objcopy OBJCOPY = $(TOOL_PREFIX)objcopy
STM32_PROG = STM32_Programmer.sh STM32_PROG = STM32_Programmer.sh
# #
# Device Variables # Device Variables
# #
@@ -114,6 +115,7 @@ LDFLAGS += $(CPU_FLAGS)
LDFLAGS += -Wl,--gc-sections -Wl,--build-id=none -static LDFLAGS += -Wl,--gc-sections -Wl,--build-id=none -static
LDFLAGS += -Wl,--wrap=malloc -Wl,--wrap=free # Fail to link if dynamic allocation is sneaking through LDFLAGS += -Wl,--wrap=malloc -Wl,--wrap=free # Fail to link if dynamic allocation is sneaking through
LDFLAGS += -Wl,-print-memory-usage LDFLAGS += -Wl,-print-memory-usage
# LDFLAGS += -lstdc++ -latomic
LDFLAGS += -nostartfiles LDFLAGS += -nostartfiles
# #
@@ -127,23 +129,22 @@ build: $(OUTPUT_BIN)
# #
%.o: %.c $(FONT_H_FILES) %.o: %.c $(FONT_H_FILES)
@echo "CC $@" @echo "CC $@"
@$(CC) $(CFLAGS) -c $< -o $@ @$(CC) $(CFLAGS) -c $< -o $@
%.o: %.S $(FONT_H_FILES) %.o: %.S $(FONT_H_FILES)
@echo "AS $@" @echo "AS $@"
@$(CC) $(ASFLAGS) -c $< -o $@ @$(CC) $(ASFLAGS) -c $< -o $@
%.o: %.cpp $(FONT_H_FILES) %.o: %.cpp $(FONT_H_FILES)
@echo "CXX $@" @echo "CXX $@"
@$(CXX) $(CXX_FLAGS) $(CFLAGS) -c $< -o $@ @$(CXX) $(CXX_FLAGS) $(CFLAGS) -c $< -o $@
SMALL_FONT=ThirdParty/fonts/roboto_mono/RobotoMono-Medium.ttf SMALL_FONT=ThirdParty/fonts/roboto_mono/RobotoMono-Regular.ttf
$(FONT_GEN_DIR)/small.h $(FONT_GEN_DIR)/small.c: Gen/fixedfont-to-c.py Gen/font.py $(FONT_GEN_DIR)/small.h $(FONT_GEN_DIR)/small.c: Gen/fixedfont-to-c.py Gen/font.py
@echo "GEN $@" @echo "GEN $@"
@mkdir -p $(FONT_GEN_DIR) @mkdir -p $(FONT_GEN_DIR)
@Gen/fixedfont-to-c.py $(patsubst .%,%,$(suffix $@)) $(SMALL_FONT) "$@" -s 18 --header-dir "Bsp/" --name font_small @Gen/fixedfont-to-c.py $(patsubst .%,%,$(suffix $@)) $(SMALL_FONT) "$@" -s 24 --header-dir "Bsp/" --name font_small
@$(call gen_font,$(FONT),29,small)
LARGE_FONT=ThirdParty/fonts/roboto_mono/RobotoMono-Bold.ttf LARGE_FONT=ThirdParty/fonts/roboto_mono/RobotoMono-Bold.ttf
$(FONT_GEN_DIR)/large_digits.h $(FONT_GEN_DIR)/large_digits.c: Gen/fixedfont-to-c.py Gen/font.py $(FONT_GEN_DIR)/large_digits.h $(FONT_GEN_DIR)/large_digits.c: Gen/fixedfont-to-c.py Gen/font.py
@@ -156,7 +157,7 @@ $(OUTPUT_BIN): $(OUTPUT_ELF)
@$(OBJCOPY) -O binary $(OUTPUT_ELF) $(OUTPUT_BIN) @$(OBJCOPY) -O binary $(OUTPUT_ELF) $(OUTPUT_BIN)
$(OUTPUT_MAP) $(OUTPUT_ELF): $(LINKER_SCRIPT) $(OBJS) $(OUTPUT_MAP) $(OUTPUT_ELF): $(LINKER_SCRIPT) $(OBJS)
@echo "LD $@" @echo "LD $@"
@$(LD) -T $(LINKER_SCRIPT) $(LDFLAGS) -o $(OUTPUT_ELF) $(OBJS) -Wl,-Map=$(OUTPUT_MAP) @$(LD) -T $(LINKER_SCRIPT) $(LDFLAGS) -o $(OUTPUT_ELF) $(OBJS) -Wl,-Map=$(OUTPUT_MAP)
# #
@@ -172,6 +173,4 @@ flash: $(OUTPUT_BIN)
.PHONY: clean .PHONY: clean
clean: clean:
@echo "RM $(OBJS)" rm -f $(OBJS) $(OUTPUT_BIN) $(OUTPUT_ELF) $(FONT_C_FILES) $(FONT_H_FILES) $(OUTPUT_MAP) $(addsuffix .su,$(basename $(OBJS)))
@rm -f $(OBJS) $(OUTPUT_BIN) $(OUTPUT_ELF) $(FONT_C_FILES) $(OUTPUT_MAP) ./*.su
@rm -rf build/