add missing files
This commit is contained in:
6
Inc/address_selector.h
Normal file
6
Inc/address_selector.h
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
void adress_selector_init_gpio();
|
||||||
|
uint8_t read_address();
|
||||||
|
|
||||||
|
extern uint8_t dmx_address;
|
||||||
53
Src/address_selector.c
Normal file
53
Src/address_selector.c
Normal file
@@ -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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user