Use new LED pins
This commit is contained in:
parent
64a01bef05
commit
a900c9481d
6 changed files with 46 additions and 15 deletions
|
|
@ -1 +1 @@
|
||||||
322
|
325
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,18 @@
|
||||||
#include "led.h"
|
#include "led.h"
|
||||||
|
|
||||||
#include "ownership.h"
|
#include "ownership.h"
|
||||||
MODULE_OWNS_PIN(GPIOB, PIN_LED);
|
MODULE_OWNS_PIN(GPIOA, PIN_LED_PINK);
|
||||||
|
MODULE_OWNS_PIN(GPIOA, PIN_LED_ORANGE);
|
||||||
|
|
||||||
void LED_Init(void)
|
void LED_Init(void)
|
||||||
{
|
{
|
||||||
RCC->APB2ENR |= RCC_APB2ENR_IOPCEN;
|
RCC->APB2ENR |= RCC_APB2ENR_IOPAEN;
|
||||||
|
|
||||||
GPIOC->CRH = (GPIOB->CRH
|
GPIOA->CRL = (GPIOA->CRL
|
||||||
& ~(0x0f << (PIN_LED * 4 - 32)))
|
& ~(0x0f << (PIN_LED_PINK * 4))
|
||||||
| (0x02 << (PIN_LED * 4 - 32)) // 2 MHz push-pull output
|
& ~(0x0f << (PIN_LED_ORANGE * 4)))
|
||||||
|
| (0x02 << (PIN_LED_PINK * 4)) // 2 MHz push-pull output
|
||||||
|
| (0x02 << (PIN_LED_ORANGE * 4)) // 2 MHz push-pull output
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,37 @@
|
||||||
#include "stm32f1xx.h"
|
#include "stm32f1xx.h"
|
||||||
#include "pinning.h"
|
#include "pinning.h"
|
||||||
|
|
||||||
#define LED_ON() do { GPIOC->BRR = 1 << PIN_LED; } while(0);
|
typedef enum
|
||||||
#define LED_OFF() do { GPIOC->BSRR = 1 << PIN_LED; } while(0);
|
{
|
||||||
|
LED_Pink,
|
||||||
|
LED_Orange
|
||||||
|
} LED_t;
|
||||||
|
|
||||||
|
inline void LED_On(LED_t led)
|
||||||
|
{
|
||||||
|
switch(led)
|
||||||
|
{
|
||||||
|
case LED_Pink:
|
||||||
|
GPIOA->BSRR = 1 << PIN_LED_PINK;
|
||||||
|
break;
|
||||||
|
case LED_Orange:
|
||||||
|
GPIOA->BSRR = 1 << PIN_LED_ORANGE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void LED_Off(LED_t led)
|
||||||
|
{
|
||||||
|
switch(led)
|
||||||
|
{
|
||||||
|
case LED_Pink:
|
||||||
|
GPIOA->BRR = 1 << PIN_LED_PINK;
|
||||||
|
break;
|
||||||
|
case LED_Orange:
|
||||||
|
GPIOA->BRR = 1 << PIN_LED_ORANGE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void LED_Init(void);
|
void LED_Init(void);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ int main(void)
|
||||||
USB_Init();
|
USB_Init();
|
||||||
Output_Init();
|
Output_Init();
|
||||||
|
|
||||||
LED_ON();
|
LED_On(LED_Orange);
|
||||||
|
|
||||||
// uint8_t buffer[32];
|
// uint8_t buffer[32];
|
||||||
for(;;)
|
for(;;)
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,14 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// Port A
|
// Port A
|
||||||
|
#define PIN_OUTPUT_ENABLE 3 // PA3 - Relay coil driver
|
||||||
|
#define PIN_LED_PINK 6 // PA6 - Status LED 1
|
||||||
|
#define PIN_LED_ORANGE 7 // PA7 - Status LED 2
|
||||||
#define PIN_OUTPUT_X 8 // PA8 - TIM1_CH1
|
#define PIN_OUTPUT_X 8 // PA8 - TIM1_CH1
|
||||||
#define PIN_OUTPUT_Y 9 // PA9 - TIM1_CH2
|
#define PIN_OUTPUT_Y 9 // PA9 - TIM1_CH2
|
||||||
#define PIN_USB_DM 11 // PA11 - USB_DM
|
#define PIN_USB_DM 11 // PA11 - USB_DM
|
||||||
#define PIN_USB_DP 12 // PA12 - USB_DP
|
#define PIN_USB_DP 12 // PA12 - USB_DP
|
||||||
// #define PIN_USB_PULLUP 15 // PA15 - 1.5 kΩ to D+
|
|
||||||
|
|
||||||
// Port B
|
// Port B
|
||||||
#define PIN_PEN_STATE 6 // PB6 - TIM4_CH1
|
#define PIN_PEN_STATE 6 // PB6 - TIM4_CH1
|
||||||
|
|
||||||
// Port C
|
|
||||||
#define PIN_LED 13 // PC13 - Status LED
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ static inline void USB_HandleReset(void)
|
||||||
// Enable
|
// Enable
|
||||||
USB->DADDR = USB_DADDR_EF;
|
USB->DADDR = USB_DADDR_EF;
|
||||||
|
|
||||||
LED_OFF();
|
LED_Off(LED_Orange);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void USB_HandleIn(void)
|
static inline void USB_HandleIn(void)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue