diff --git a/hal/at90usb646/hardware.h b/hal/at90usb646/hardware.h index 8c0549a..c041c0d 100644 --- a/hal/at90usb646/hardware.h +++ b/hal/at90usb646/hardware.h @@ -25,6 +25,7 @@ #ifndef HAL_AT90USB646_HARDWARE_H_ #define HAL_AT90USB646_HARDWARE_H_ +#include #include #include #include @@ -63,4 +64,15 @@ static inline void DelayUS(uint16_t us) _delay_us(us); } +/** Determines if this code is running on an AT90USB128x or AT90USB64x + * + * @return True if it's an AT90USB128x, false if AT90USB64x + */ +static inline bool IsAT90USB128x(void) +{ + // Read the device signature byte 2 to determine whether this is an + // AT90USB128x or AT90USB64x. + return boot_signature_byte_get(0x0002) == 0x97; +} + #endif /* HAL_AT90USB646_HARDWARE_H_ */