Skip to content

Commit

Permalink
Use digital pin API for the reset pin as well. #368
Browse files Browse the repository at this point in the history
  • Loading branch information
krichardsson committed Aug 18, 2020
1 parent c68d7bc commit baf1af9
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions src/deck/drivers/src/locodeck.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,18 @@

// LOCO deck alternative IRQ and RESET pins(IO_2, IO_3) instead of default (RX1, TX1), leaving UART1 free for use
#ifdef LOCODECK_USE_ALT_PINS
#define GPIO_PIN_RESET GPIO_Pin_4
#define GPIO_PORT GPIOB
#define GPIO_PIN_IRQ DECK_GPIO_IO2
#define GPIO_PIN_RESET DECK_GPIO_IO3
#define EXTI_PortSource EXTI_PortSourceGPIOB
#define EXTI_PinSource EXTI_PinSource5
#define EXTI_LineN EXTI_Line5
#define EXTI_LineN EXTI_Line5
#define EXTI_IRQChannel EXTI9_5_IRQn
#else
#define GPIO_PIN_RESET GPIO_Pin_10
#define GPIO_PORT GPIOC
#define GPIO_PIN_IRQ DECK_GPIO_RX1
#define GPIO_PIN_RESET DECK_GPIO_TX1
#define EXTI_PortSource EXTI_PortSourceGPIOC
#define EXTI_PinSource EXTI_PinSource11
#define EXTI_LineN EXTI_Line11
#define EXTI_LineN EXTI_Line11
#define EXTI_IRQChannel EXTI15_10_IRQn
#endif

Expand Down Expand Up @@ -386,7 +384,6 @@ static dwOps_t dwOps = {
static void dwm1000Init(DeckInfo *info)
{
EXTI_InitTypeDef EXTI_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;

spiBegin();
Expand All @@ -400,21 +397,15 @@ static void dwm1000Init(DeckInfo *info)
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);

// Init reset output
GPIO_InitStructure.GPIO_Pin = GPIO_PIN_RESET;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIO_PORT, &GPIO_InitStructure);

// Init pins
pinMode(CS_PIN, OUTPUT);
pinMode(GPIO_PIN_RESET, OUTPUT);
pinMode(GPIO_PIN_IRQ, INPUT);

// Reset the DW1000 chip
GPIO_WriteBit(GPIO_PORT, GPIO_PIN_RESET, 0);
digitalWrite(GPIO_PIN_RESET, 0);
vTaskDelay(M2T(10));
GPIO_WriteBit(GPIO_PORT, GPIO_PIN_RESET, 1);
digitalWrite(GPIO_PIN_RESET, 1);
vTaskDelay(M2T(10));

// Initialize the driver
Expand Down

0 comments on commit baf1af9

Please sign in to comment.