Zumo32U4 library
Zumo32U4.h
Go to the documentation of this file.
1// Copyright Pololu Corporation. For more information, see http://www.pololu.com/
2
10#pragma once
11
12#ifndef __AVR_ATmega32U4__
13#error "This library only supports the ATmega32U4. Try selecting A-Star 32U4 in the Boards menu."
14#endif
15
16#include <FastGPIO.h>
17#include <LSM303.h>
18#include <L3G.h>
19#include <Zumo32U4Buttons.h>
20#include <Zumo32U4Buzzer.h>
21#include <Zumo32U4Encoders.h>
22#include <Zumo32U4IMU.h>
23#include <Zumo32U4IRPulses.h>
24#include <Zumo32U4LCD.h>
25#include <Zumo32U4LineSensors.h>
26#include <Zumo32U4Motors.h>
28
29// TODO: servo support
30
38inline void ledRed(bool on)
39{
41}
42
46inline void ledYellow(bool on)
47{
49}
50
58inline void ledGreen(bool on)
59{
61}
62
71inline bool usbPowerPresent()
72{
73 return USBSTA >> VBUS & 1;
74}
75
77inline uint16_t readBatteryMillivolts()
78{
79 const uint8_t sampleCount = 8;
80 uint16_t sum = 0;
81 for (uint8_t i = 0; i < sampleCount; i++)
82 {
83 sum += analogRead(A1);
84 }
85
86 // VBAT = 2 * millivolt reading = 2 * raw * 5000/1024
87 // = raw * 625 / 64
88 // The correction term below makes it so that we round to the
89 // nearest whole number instead of always rounding down.
90 const uint32_t correction = 32 * sampleCount - 1;
91 return ((uint32_t)sum * 625 + correction) / (64 * sampleCount);
92}
93
void ledGreen(bool on)
Turns the green user LED (TX) on or off.
Definition: Zumo32U4.h:58
void ledYellow(bool on)
Turns the yellow user LED on pin 13 on or off.
Definition: Zumo32U4.h:46
uint16_t readBatteryMillivolts()
Reads the battery voltage and returns it in millivolts.
Definition: Zumo32U4.h:77
bool usbPowerPresent()
Returns true if USB power is detected.
Definition: Zumo32U4.h:71
void ledRed(bool on)
Turns the red user LED (RX) on or off.
Definition: Zumo32U4.h:38
static void setOutput(bool value) __attribute__((always_inline))
Sets the pin as an output.
Definition: FastGPIO.h:318