add missing files
parent
584d2b8951
commit
baee1b2e94
@ -0,0 +1,6 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
void adress_selector_init_gpio();
|
||||||
|
uint8_t read_address();
|
||||||
|
|
||||||
|
extern uint8_t dmx_address;
|
||||||
@ -0,0 +1,53 @@
|
|||||||
|
#include "stm32g0b1xx.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
uint8_t dmx_address;
|
||||||
|
|
||||||
|
void adress_selector_init_gpio(){
|
||||||
|
RCC->IOPENR |= RCC_IOPENR_GPIOEEN;
|
||||||
|
RCC->IOPENR |= RCC_IOPENR_GPIOBEN;
|
||||||
|
|
||||||
|
GPIOE->MODER &= ~(0x3 << (9 * 2));
|
||||||
|
GPIOE->MODER &= ~(0x3 << (10 * 2));
|
||||||
|
GPIOE->MODER &= ~(0x3 << (11 * 2));
|
||||||
|
GPIOE->MODER &= ~(0x3 << (12 * 2));
|
||||||
|
GPIOE->MODER &= ~(0x3 << (13 * 2));
|
||||||
|
GPIOE->MODER &= ~(0x3 << (14 * 2));
|
||||||
|
GPIOE->MODER &= ~(0x3 << (15 * 2));
|
||||||
|
GPIOB->MODER &= ~(0x3 << (10 * 2)); // B10
|
||||||
|
|
||||||
|
GPIOE->PUPDR &= ~(0x3 << (9 * 2));
|
||||||
|
GPIOE->PUPDR |= (0x1 << (9 * 2));
|
||||||
|
|
||||||
|
GPIOE->PUPDR &= ~(0x3 << (10 * 2));
|
||||||
|
GPIOE->PUPDR |= (0x1 << (10 * 2));
|
||||||
|
|
||||||
|
GPIOE->PUPDR &= ~(0x3 << (11 * 2));
|
||||||
|
GPIOE->PUPDR |= (0x1 << (11 * 2));
|
||||||
|
|
||||||
|
GPIOE->PUPDR &= ~(0x3 << (12 * 2));
|
||||||
|
GPIOE->PUPDR |= (0x1 << (12 * 2));
|
||||||
|
|
||||||
|
GPIOE->PUPDR |= (0x1 << (13 * 2));
|
||||||
|
GPIOE->PUPDR &= ~(0x3 << (13 * 2));
|
||||||
|
|
||||||
|
GPIOE->PUPDR |= (0x1 << (14 * 2));
|
||||||
|
GPIOE->PUPDR &= ~(0x3 << (14 * 2));
|
||||||
|
|
||||||
|
GPIOE->PUPDR |= (0x1 << (15 * 2));
|
||||||
|
GPIOE->PUPDR &= ~(0x3 << (15 * 2));
|
||||||
|
|
||||||
|
GPIOB->PUPDR &= ~(0x3 << (10 * 2)); // B10
|
||||||
|
GPIOB->PUPDR |= (0x1 << (10 * 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t read_address(){
|
||||||
|
#ifndef DMX_ADDRESS
|
||||||
|
uint16_t address = ((GPIOE->IDR >> 9)&0x7F) | (GPIOB->IDR & (1<<10))>>3;
|
||||||
|
printf("read address: %d = 0x%x\n", address);
|
||||||
|
#else
|
||||||
|
uint16_t address = DMX_ADDRESS;
|
||||||
|
printf("static address: %d\n", address);
|
||||||
|
#endif
|
||||||
|
return address;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue