Skip to content

Update boot loader source to use new CMSIS packages #192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bootloaders/mkr1000/samd21_sam_ba_arduino_mkr1000.bin
Binary file not shown.
766 changes: 380 additions & 386 deletions bootloaders/mkr1000/samd21_sam_ba_arduino_mkr1000.hex

Large diffs are not rendered by default.

Binary file modified bootloaders/mkr1000/samd21_sam_ba_genuino_mkr1000.bin
Binary file not shown.
766 changes: 380 additions & 386 deletions bootloaders/mkr1000/samd21_sam_ba_genuino_mkr1000.hex

Large diffs are not rendered by default.

Binary file modified bootloaders/mkrzero/samd21_sam_ba_arduino_mkrzero.bin
Binary file not shown.
766 changes: 380 additions & 386 deletions bootloaders/mkrzero/samd21_sam_ba_arduino_mkrzero.hex

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion bootloaders/zero/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ ELF=$(NAME).elf
BIN=$(NAME).bin
HEX=$(NAME).hex

INCLUDES=-I"$(MODULE_PATH)/tools/CMSIS/4.0.0-atmel/CMSIS/Include/" -I"$(MODULE_PATH)/tools/CMSIS/4.0.0-atmel/Device/ATMEL/"

INCLUDES=-I"$(MODULE_PATH)/tools/CMSIS/4.5.0/CMSIS/Include/" -I"$(MODULE_PATH)/tools/CMSIS-Atmel/1.0.0/CMSIS/Device/ATMEL/"

# -----------------------------------------------------------------------------
# Linker options
Expand Down
28 changes: 11 additions & 17 deletions bootloaders/zero/board_driver_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,12 @@ uint32_t USB_Write(Usb *pUsb, const char *pData, uint32_t length, uint8_t ep_num
/* Set the multi packet size as zero for multi-packet transfers where length > ep size */
usb_endpoint_table[ep_num].DeviceDescBank[1].PCKSIZE.bit.MULTI_PACKET_SIZE = 0;
/* Clear the transfer complete flag */
//pUsb->DEVICE.DeviceEndpoint[ep_num].EPINTFLAG.bit.TRCPT1 = true;
pUsb->DEVICE.DeviceEndpoint[ep_num].EPINTFLAG.bit.TRCPT |= (1<<1);
pUsb->DEVICE.DeviceEndpoint[ep_num].EPINTFLAG.reg = USB_DEVICE_EPINTFLAG_TRCPT1;
/* Set the bank as ready */
pUsb->DEVICE.DeviceEndpoint[ep_num].EPSTATUSSET.bit.BK1RDY = true;

/* Wait for transfer to complete */
while ( (pUsb->DEVICE.DeviceEndpoint[ep_num].EPINTFLAG.bit.TRCPT & (1<<1)) == 0 );
while ( (pUsb->DEVICE.DeviceEndpoint[ep_num].EPINTFLAG.bit.TRCPT1) == 0 );

return length;
}
Expand All @@ -205,15 +204,14 @@ uint32_t USB_Read(Usb *pUsb, char *pData, uint32_t length)
}

/* Check for Transfer Complete 0 flag */
if ( pUsb->DEVICE.DeviceEndpoint[USB_EP_OUT].EPINTFLAG.bit.TRCPT & (1<<0) )
if ( pUsb->DEVICE.DeviceEndpoint[USB_EP_OUT].EPINTFLAG.bit.TRCPT0 )
{
/* Set packet size */
packetSize = SAM_BA_MIN(usb_endpoint_table[USB_EP_OUT].DeviceDescBank[0].PCKSIZE.bit.BYTE_COUNT, length);
/* Copy read data to user buffer */
memcpy(pData, udd_ep_out_cache_buffer[USB_EP_OUT-1], packetSize);
/* Clear the Transfer Complete 0 flag */
//pUsb->DEVICE.DeviceEndpoint[USB_EP_OUT].EPINTFLAG.bit.TRCPT0 = true;
pUsb->DEVICE.DeviceEndpoint[USB_EP_OUT].EPINTFLAG.bit.TRCPT |= (1 << 0);
pUsb->DEVICE.DeviceEndpoint[USB_EP_OUT].EPINTFLAG.reg = USB_DEVICE_EPINTFLAG_TRCPT0;
/* Clear the user flag */
read_job = false;
}
Expand All @@ -240,10 +238,9 @@ uint32_t USB_Read_blocking(Usb *pUsb, char *pData, uint32_t length)
/* Clear the bank 0 ready flag */
pUsb->DEVICE.DeviceEndpoint[USB_EP_OUT].EPSTATUSCLR.bit.BK0RDY = true;
/* Wait for transfer to complete */
while (!( pUsb->DEVICE.DeviceEndpoint[USB_EP_OUT].EPINTFLAG.bit.TRCPT & (1<<0) ));
while (!( pUsb->DEVICE.DeviceEndpoint[USB_EP_OUT].EPINTFLAG.bit.TRCPT0 ));
/* Clear Transfer complete 0 flag */
//pUsb->DEVICE.DeviceEndpoint[USB_EP_OUT].EPINTFLAG.bit.TRCPT0 = true;
pUsb->DEVICE.DeviceEndpoint[USB_EP_OUT].EPINTFLAG.bit.TRCPT |= (1 << 0);
pUsb->DEVICE.DeviceEndpoint[USB_EP_OUT].EPINTFLAG.reg = USB_DEVICE_EPINTFLAG_TRCPT0;

return length;
}
Expand All @@ -259,7 +256,7 @@ uint8_t USB_IsConfigured(P_USB_CDC pCdc)
if (pUsb->DEVICE.INTFLAG.reg & USB_DEVICE_INTFLAG_EORST)
{
/* Clear the flag */
pUsb->DEVICE.INTFLAG.bit.EORST = true;
pUsb->DEVICE.INTFLAG.reg = USB_DEVICE_INTFLAG_EORST;
/* Set Device address as 0 */
pUsb->DEVICE.DADD.reg = USB_DEVICE_DADD_ADDEN | 0;
/* Configure endpoint 0 */
Expand Down Expand Up @@ -303,14 +300,12 @@ void USB_SendStall(Usb *pUsb, bool direction_in)
if (direction_in)
{
/* Set STALL request on IN direction */
//pUsb->DEVICE.DeviceEndpoint[0].EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ1;
pUsb->DEVICE.DeviceEndpoint[0].EPSTATUSSET.bit.STALLRQ = (1<<1);
pUsb->DEVICE.DeviceEndpoint[0].EPSTATUSSET.bit.STALLRQ1 = 1;
}
else
{
/* Set STALL request on OUT direction */
//pUsb->DEVICE.DeviceEndpoint[0].EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ0;
pUsb->DEVICE.DeviceEndpoint[0].EPSTATUSSET.bit.STALLRQ = (1<<0);
pUsb->DEVICE.DeviceEndpoint[0].EPSTATUSSET.bit.STALLRQ0 = 1;
}
}

Expand All @@ -322,12 +317,11 @@ void USB_SendZlp(Usb *pUsb)
/* Set the byte count as zero */
usb_endpoint_table[0].DeviceDescBank[1].PCKSIZE.bit.BYTE_COUNT = 0;
/* Clear the transfer complete flag */
//pUsb->DEVICE.DeviceEndpoint[0].EPINTFLAG.bit.TRCPT1 = true;
pUsb->DEVICE.DeviceEndpoint[0].EPINTFLAG.bit.TRCPT |= (1 << 1);
pUsb->DEVICE.DeviceEndpoint[0].EPINTFLAG.reg = USB_DEVICE_EPINTFLAG_TRCPT1;
/* Set the bank as ready */
pUsb->DEVICE.DeviceEndpoint[0].EPSTATUSSET.bit.BK1RDY = true;
/* Wait for transfer to complete */
while (!( pUsb->DEVICE.DeviceEndpoint[0].EPINTFLAG.bit.TRCPT & (1<<1) ));
while (!( pUsb->DEVICE.DeviceEndpoint[0].EPINTFLAG.bit.TRCPT1 ));
}

/*----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion bootloaders/zero/sam_ba_cdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ bool cdc_is_rx_ready(/*P_USB_CDC pCdc*/void)
return 0;

/* Return transfer complete 0 flag status */
return (pCdc->pUsb->DEVICE.DeviceEndpoint[USB_EP_OUT].EPINTFLAG.bit.TRCPT & (1<<0));
return (pCdc->pUsb->DEVICE.DeviceEndpoint[USB_EP_OUT].EPINTFLAG.bit.TRCPT0);
}

uint32_t cdc_write_buf(/*P_USB_CDC pCdc,*/ void const* data, uint32_t length)
Expand Down
32 changes: 13 additions & 19 deletions bootloaders/zero/sam_ba_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void sam_ba_usb_CDC_Enumerate(P_USB_CDC pCdc)
static volatile uint16_t wValue, wIndex, wLength, wStatus;

/* Clear the Received Setup flag */
pUsb->DEVICE.DeviceEndpoint[0].EPINTFLAG.bit.RXSTP = true;
pUsb->DEVICE.DeviceEndpoint[0].EPINTFLAG.reg = USB_DEVICE_EPINTFLAG_RXSTP;

/* Read the USB request parameters */
bmRequestType = udd_ep_out_cache_buffer[0][0];
Expand Down Expand Up @@ -268,13 +268,11 @@ void sam_ba_usb_CDC_Enumerate(P_USB_CDC pCdc)
{
if (dir)
{
//wStatus = (pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUS.reg & USB_DEVICE_EPSTATUSSET_STALLRQ1) ? 1 : 0;
wStatus = (pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUS.bit.STALLRQ & (1<<1)) ? 1 : 0;
wStatus = (pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUS.reg & USB_DEVICE_EPSTATUSSET_STALLRQ1) ? 1 : 0;
}
else
{
//wStatus = (pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUS.reg & USB_DEVICE_EPSTATUSSET_STALLRQ0) ? 1 : 0;
wStatus = (pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUS.bit.STALLRQ & (1<<0)) ? 1 : 0;
wStatus = (pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUS.reg & USB_DEVICE_EPSTATUSSET_STALLRQ0) ? 1 : 0;
}
/* Return current status of endpoint */
USB_Write(pCdc->pUsb, (char *) &wStatus, sizeof(wStatus), USB_EP_CTRL);
Expand Down Expand Up @@ -304,13 +302,11 @@ void sam_ba_usb_CDC_Enumerate(P_USB_CDC pCdc)
/* Set STALL request for the endpoint */
if (dir)
{
//pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ1;
pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUSSET.bit.STALLRQ = (1<<1);
pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ1;
}
else
{
//pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ0;
pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUSSET.bit.STALLRQ = (1<<0);
pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ0;
}

/* Send ZLP */
Expand Down Expand Up @@ -342,29 +338,27 @@ void sam_ba_usb_CDC_Enumerate(P_USB_CDC pCdc)
{
if (dir)
{
if (pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUS.bit.STALLRQ & (1<<1))
if (pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUS.bit.STALLRQ1)
{
// Remove stall request
//pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUSCLR.reg = USB_DEVICE_EPSTATUSCLR_STALLRQ1;
pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUSCLR.bit.STALLRQ = (1<<1);
if (pUsb->DEVICE.DeviceEndpoint[wIndex].EPINTFLAG.bit.STALL & (1<<1))
pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUSCLR.reg = USB_DEVICE_EPSTATUSCLR_STALLRQ1;
if (pUsb->DEVICE.DeviceEndpoint[wIndex].EPINTFLAG.bit.STALL1)
{
pUsb->DEVICE.DeviceEndpoint[wIndex].EPINTFLAG.bit.STALL = (1<<1);
pUsb->DEVICE.DeviceEndpoint[wIndex].EPINTFLAG.reg = USB_DEVICE_EPINTFLAG_STALL1;
// The Stall has occurred, then reset data toggle
pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUSCLR.reg = USB_DEVICE_EPSTATUSSET_DTGLIN;
}
}
}
else
{
if (pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUS.bit.STALLRQ & (1<<0))
if (pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUS.bit.STALLRQ0)
{
// Remove stall request
//pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUSCLR.reg = USB_DEVICE_EPSTATUSCLR_STALLRQ0;
pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUSCLR.bit.STALLRQ = (1<<0);
if (pUsb->DEVICE.DeviceEndpoint[wIndex].EPINTFLAG.bit.STALL & (1<<0))
pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUSCLR.reg = USB_DEVICE_EPSTATUSCLR_STALLRQ0;
if (pUsb->DEVICE.DeviceEndpoint[wIndex].EPINTFLAG.bit.STALL0)
{
pUsb->DEVICE.DeviceEndpoint[wIndex].EPINTFLAG.bit.STALL = (1<<0);
pUsb->DEVICE.DeviceEndpoint[wIndex].EPINTFLAG.reg = USB_DEVICE_EPINTFLAG_STALL0;
// The Stall has occurred, then reset data toggle
pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUSCLR.reg = USB_DEVICE_EPSTATUSSET_DTGLOUT;
}
Expand Down
Binary file modified bootloaders/zero/samd21_sam_ba.bin
Binary file not shown.
Loading