atsamd: Add a GET_FUSE() helper macro

Add a helper macro for accessing the non-volatile factory-calibrated
"fuse" values.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2019-02-22 07:31:10 -05:00
parent 5bc47d9416
commit 37797c8128
3 changed files with 19 additions and 26 deletions

View File

@@ -193,12 +193,9 @@ usbserial_init(void)
uint32_t ptype = CONFIG_MACH_SAMD21 ? 'G' : 'H';
gpio_peripheral(GPIO('A', 24), ptype, 0);
gpio_peripheral(GPIO('A', 25), ptype, 0);
uint16_t trim = (readl((void*)USB_FUSES_TRIM_ADDR)
& USB_FUSES_TRIM_Msk) >> USB_FUSES_TRIM_Pos;
uint16_t transp = (readl((void*)USB_FUSES_TRANSP_ADDR)
& USB_FUSES_TRANSP_Msk) >> USB_FUSES_TRANSP_Pos;
uint16_t transn = (readl((void*)USB_FUSES_TRANSN_ADDR)
& USB_FUSES_TRANSN_Msk) >> USB_FUSES_TRANSN_Pos;
uint32_t trim = GET_FUSE(USB_FUSES_TRIM);
uint32_t transp = GET_FUSE(USB_FUSES_TRANSP);
uint32_t transn = GET_FUSE(USB_FUSES_TRANSN);
USB->DEVICE.PADCAL.reg = (USB_PADCAL_TRIM(trim) | USB_PADCAL_TRANSP(transp)
| USB_PADCAL_TRANSN(transn));
// Enable USB in device mode