File tree Expand file tree Collapse file tree 4 files changed +87
-0
lines changed
microNode/libraries/system Expand file tree Collapse file tree 4 files changed +87
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include <system.h>
2
+
3
+ uint16_t readVCC (){
4
+
5
+ // disable ADC
6
+ while (ADC -> STATUS .bit .SYNCBUSY );
7
+ ADC -> CTRLA .bit .ENABLE = 0x00 ;
8
+
9
+ // internal 1V reference (default)
10
+ analogReference (AR_INTERNAL1V0 );
11
+ // 12 bit resolution (default)
12
+ analogWriteResolution (12 );
13
+ // MUXp 0x1B = SCALEDIOVCC/4 => connected to Vcc
14
+ ADC -> INPUTCTRL .bit .MUXPOS = 0x1B ;
15
+
16
+ // enable ADC
17
+ while (ADC -> STATUS .bit .SYNCBUSY );
18
+ ADC -> CTRLA .bit .ENABLE = 0x01 ;
19
+
20
+ // start conversion
21
+ while (ADC -> STATUS .bit .SYNCBUSY );
22
+ ADC -> SWTRIG .bit .START = 1 ;
23
+
24
+ // clear the Data Ready flag
25
+ ADC -> INTFLAG .bit .RESRDY = 1 ;
26
+
27
+ // start conversion again, reading after input change needs to be discarded
28
+ while (ADC -> STATUS .bit .SYNCBUSY );
29
+ ADC -> SWTRIG .bit .START = 1 ;
30
+
31
+ // waiting for conversion to complete
32
+ while (!ADC -> INTFLAG .bit .RESRDY );
33
+ const uint32_t valueRead = ADC -> RESULT .reg ;
34
+
35
+ // disable ADC
36
+ while (ADC -> STATUS .bit .SYNCBUSY );
37
+ ADC -> CTRLA .bit .ENABLE = 0x00 ;
38
+
39
+ uint32_t voltage = valueRead * 4 * 1000 ;
40
+ voltage /= 4096 ;
41
+
42
+ return voltage ;
43
+ }
Original file line number Diff line number Diff line change
1
+ #include <stdio.h>
2
+ #include <Arduino.h>
3
+
4
+ uint16_t readVCC ();
Original file line number Diff line number Diff line change 352
352
"version" : " 4.0.0-atmel"
353
353
}
354
354
]
355
+ },
356
+ {
357
+ "version" : " 1.0.6" ,
358
+ "boards" : [
359
+ {
360
+ "name" : " microNode"
361
+ }
362
+ ],
363
+ "archiveFileName" : " microNode-1.0.6.tar.bz2" ,
364
+ "checksum" : " SHA-256:22266056f02077a0afd2cf22b303537a1988c1e80917ad11dd648dab0244f080" ,
365
+ "url" : " https://github.com/loranodes/arduino-core/raw/1.0.6/microNode-1.0.6.tar.bz2" ,
366
+ "size" : 1182020 ,
367
+ "architecture" : " samd" ,
368
+ "name" : " LoRaNodes M0 Boards" ,
369
+ "category" : " LoRaNodes" ,
370
+ "help" : {
371
+ "online" : " https://github.com/loranodes"
372
+ },
373
+ "toolsDependencies" : [
374
+ {
375
+ "name" : " arm-none-eabi-gcc" ,
376
+ "packager" : " arduino" ,
377
+ "version" : " 4.8.3-2014q1"
378
+ },
379
+ {
380
+ "name" : " bossac" ,
381
+ "packager" : " arduino" ,
382
+ "version" : " 1.6.1-arduino"
383
+ },
384
+ {
385
+ "name" : " openocd" ,
386
+ "packager" : " arduino" ,
387
+ "version" : " 0.9.0-arduino"
388
+ },
389
+ {
390
+ "name" : " CMSIS" ,
391
+ "packager" : " arduino" ,
392
+ "version" : " 4.0.0-atmel"
393
+ }
394
+ ]
355
395
}
356
396
]
357
397
}
You can’t perform that action at this time.
0 commit comments