mirror of
				https://github.com/jhbruhn/eurorack.git
				synced 2025-10-30 02:46:01 +00:00 
			
		
		
		
	Start driver implementation
This commit is contained in:
		
							parent
							
								
									d725452ddb
								
							
						
					
					
						commit
						c728ed9a28
					
				
					 4 changed files with 79 additions and 8 deletions
				
			
		
							
								
								
									
										21
									
								
								midi2cv/drivers/gpio.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								midi2cv/drivers/gpio.cc
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,21 @@ | ||||||
|  | #include "gpio.h" | ||||||
|  | 
 | ||||||
|  | #include <stm32f10x_conf.h> | ||||||
|  | 
 | ||||||
|  | void GPIO::Init() { | ||||||
|  |   GPIO_InitTypeDef gpio_init; | ||||||
|  |    | ||||||
|  |   gpio_init.GPIO_Pin = PIN_SS_DAC0 | PIN_SS_DAC1 | PIN_RST_USB | PIN_SS_USB | PIN_SS_OLED | PIN_SDC_OLED; | ||||||
|  |   gpio_init.GPIO_Speed = GPIO_Speed_50MHz; | ||||||
|  |   gpio_init.GPIO_Mode = GPIO_Mode_Out_PP; | ||||||
|  |   GPIO_Init(GPIOB, &gpio_init); | ||||||
|  | 
 | ||||||
|  |   gpio_init.GPIO_Pin = PIN_GATE_OUT_1 | PIN_GATE_OUT_2 | PIN_GATE_OUT_3 | PIN_GATE_OUT_4 | PIN_GATE_OUT_5 | PIN_GATE_OUT_6; | ||||||
|  |   gpio_init.GPIO_Speed = GPIO_Speed_50MHz; | ||||||
|  |   gpio_init.GPIO_Mode = GPIO_Mode_Out_PP; | ||||||
|  |   GPIO_Init(GPIOA, &gpio_init); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void GPIO::Write(GPIO_TypeDef* port, uint16_t pin, bool state) { | ||||||
|  |   GPIO_WriteBit(GPIOB, pin, static_cast<BitAction>(state)); | ||||||
|  | } | ||||||
							
								
								
									
										47
									
								
								midi2cv/drivers/gpio.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								midi2cv/drivers/gpio.h
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,47 @@ | ||||||
|  | #ifndef MIDI2CV_DRIVERS_GPIO_H | ||||||
|  | #define MIDI2CV_DRIVERS_GPIO_H | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | #include "stmlib/stmlib.h" | ||||||
|  | #include <stm32f10x_conf.h> | ||||||
|  | 
 | ||||||
|  | #define PORT_SS_DAC0 GPIOB | ||||||
|  | #define PIN_SS_DAC0 GPIO_Pin_6 | ||||||
|  | #define PORT_SS_DAC1 GPIOB | ||||||
|  | #define PIN_SS_DAC1 GPIO_Pin_7 | ||||||
|  | #define PORT_RST_USB GPIOB | ||||||
|  | #define PIN_RST_USB GPIO_Pin_8 | ||||||
|  | #define PORT_SS_USB GPIOB | ||||||
|  | #define PIN_SS_USB GPIO_Pin_9 | ||||||
|  | #define PORT_SS_OLED GPIOB | ||||||
|  | #define PIN_SS_OLED GPIO_Pin_11 | ||||||
|  | #define PORT_SDC_OLED GPIOB | ||||||
|  | #define PIN_SDC_OLED GPIO_Pin_12 | ||||||
|  | 
 | ||||||
|  | #define PORT_GATE_OUT_1 GPIOA | ||||||
|  | #define PIN_GATE_OUT_1 GPIO_Pin_0 | ||||||
|  | #define PORT_GATE_OUT_2 GPIOA | ||||||
|  | #define PIN_GATE_OUT_2 GPIO_Pin_1 | ||||||
|  | #define PORT_GATE_OUT_3 GPIOA | ||||||
|  | #define PIN_GATE_OUT_3 GPIO_Pin_2 | ||||||
|  | #define PORT_GATE_OUT_4 GPIOA | ||||||
|  | #define PIN_GATE_OUT_4 GPIO_Pin_3 | ||||||
|  | #define PORT_GATE_OUT_5 GPIOA | ||||||
|  | #define PIN_GATE_OUT_5 GPIO_Pin_4 | ||||||
|  | #define PORT_GATE_OUT_6 GPIOA | ||||||
|  | #define PIN_GATE_OUT_6 GPIO_Pin_5 | ||||||
|  | 
 | ||||||
|  | #define GPIO_PIN(x) PORT_##x, PIN_##x | ||||||
|  | 
 | ||||||
|  | class GPIO { | ||||||
|  |   public: | ||||||
|  |     GPIO() { } | ||||||
|  |     ~GPIO() {} | ||||||
|  | 
 | ||||||
|  |     void Init(); | ||||||
|  |     void Write(GPIO_TypeDef* port, uint16_t pin, bool state); | ||||||
|  |   private: | ||||||
|  |     DISALLOW_COPY_AND_ASSIGN(GPIO); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | #endif | ||||||
|  | @ -32,7 +32,7 @@ DENSITY        = md | ||||||
| MEMORY_MODE    = flash | MEMORY_MODE    = flash | ||||||
| # USB            = enabled
 | # USB            = enabled
 | ||||||
| 
 | 
 | ||||||
| #APPLICATION    = TRUE
 | APPLICATION    = TRUE | ||||||
| BOOTLOADER     = midi2cv_bootloader | BOOTLOADER     = midi2cv_bootloader | ||||||
| 
 | 
 | ||||||
| # Preferred upload command
 | # Preferred upload command
 | ||||||
|  | @ -50,8 +50,3 @@ TOOLCHAIN_PATH ?= /usr/local/arm-4.8.3/ | ||||||
| 
 | 
 | ||||||
| include stmlib/makefile.inc | include stmlib/makefile.inc | ||||||
| 
 | 
 | ||||||
| # Rule for building the firmware update file
 |  | ||||||
| wav:  $(TARGET_BIN) |  | ||||||
| 	python stm_audio_bootloader/fsk/encoder.py \
 |  | ||||||
| 		-s 48000 -b 16 -n 8 -z 4 -p 256 \
 |  | ||||||
| 		$(TARGET_BIN) |  | ||||||
|  |  | ||||||
|  | @ -1,14 +1,22 @@ | ||||||
| #include <stm32f10x_conf.h> | #include <stm32f10x_conf.h> | ||||||
| 
 | 
 | ||||||
| #include "stmlib/system/system_clock.h" | #include "stmlib/system/system_clock.h" | ||||||
|  | #include "drivers/gpio.h" | ||||||
| 
 | 
 | ||||||
| using namespace stmlib; | using namespace stmlib; | ||||||
| 
 | 
 | ||||||
|  | GPIO gpio; | ||||||
|  | 
 | ||||||
| void Init(void) { | void Init(void) { | ||||||
|   system_clock.Init(); |   //system_clock.Init();
 | ||||||
|  |   gpio.Init(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int main(void) { | int main(void) { | ||||||
|   Init(); |   Init(); | ||||||
|   // hi
 |   // hi
 | ||||||
|  |   gpio.Write(GPIO_PIN(GATE_OUT_1), 1); | ||||||
|  |   gpio.Write(GPIO_PIN(GATE_OUT_2), 0); | ||||||
|  |   gpio.Write(GPIO_PIN(GATE_OUT_3), 1); | ||||||
|  |   gpio.Write(GPIO_PIN(GATE_OUT_4), 0); | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue