Skip to content

Commit

Permalink
Fix for USB bug in RPi 3 B+
Browse files Browse the repository at this point in the history
  • Loading branch information
juribeparada committed Sep 8, 2018
1 parent 3fbeee3 commit ad2df94
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 25 deletions.
7 changes: 3 additions & 4 deletions IOArduino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void CIO::Init()
#endif

#endif

pinMode(PIN_SCLK, OUTPUT);
pinMode(PIN_SDATA, OUTPUT);
pinMode(PIN_SREAD, INPUT);
Expand All @@ -170,19 +170,18 @@ void CIO::Init()
pinMode(PIN_NXDN_LED, OUTPUT);
pinMode(PIN_PTT_LED, OUTPUT);
pinMode(PIN_COS_LED, OUTPUT);

#if defined(DUPLEX)
pinMode(PIN_SLE2, OUTPUT);
pinMode(PIN_RXD2, INPUT);
pinMode(PIN_TXD2, INPUT);
#endif

#if defined(BIDIR_DATA_PIN)
pinMode(PIN_TXD, INPUT);
#else
pinMode(PIN_TXD, OUTPUT);
#endif

}

void CIO::startInt()
Expand Down
38 changes: 19 additions & 19 deletions IOSTM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,15 @@ extern "C" {
}

void CIO::Init()
{
// USB Conf IO:
{
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_StructInit(&GPIO_InitStruct);

EXTI_InitTypeDef EXTI_InitStructure;
#if defined(DUPLEX)
EXTI_InitTypeDef EXTI_InitStructure2;
#endif

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO, ENABLE);

#if defined(PI_HAT_7021_REV_02)
Expand All @@ -288,32 +295,25 @@ void CIO::Init()
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
#endif

RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);

EXTI_InitTypeDef EXTI_InitStructure;
#if defined(DUPLEX)
EXTI_InitTypeDef EXTI_InitStructure2;
#endif

GPIO_InitTypeDef GPIO_InitStruct;
GPIO_StructInit(&GPIO_InitStruct);

// Pin PA12 = LOW, USB Reset in generic boards
// Pin PA11,PA12 = LOW, USB Reset
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_12;
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_WriteBit(GPIOA, GPIO_Pin_11, Bit_RESET);
GPIO_WriteBit(GPIOA, GPIO_Pin_12, Bit_RESET);

volatile unsigned int delay;
for(delay = 0;delay<512;delay++);
// 10 ms delay
delay_us(10000U);

GPIO_InitStruct.GPIO_Pin = GPIO_Pin_12;
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA, &GPIO_InitStruct);

RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);

// Pin SCLK
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Pin = PIN_SCLK;
Expand Down
4 changes: 2 additions & 2 deletions version.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

#define VER_MAJOR "1"
#define VER_MINOR "4"
#define VER_REV "7"
#define VERSION_DATE "20180821"
#define VER_REV "8"
#define VERSION_DATE "20180908"

#if defined(ZUMSPOT_ADF7021)
#define BOARD_INFO "ZUMspot"
Expand Down

0 comments on commit ad2df94

Please sign in to comment.