Demo of low res colour vga video for stm32f3 discovery board

Dependencies:   STM32F3-Discovery-minimal

Fork of Space_Invaders_Demo by Martin Johnson

Committer:
MartinJohnson
Date:
Wed May 16 02:39:14 2018 +0000
Revision:
3:93e488fbb8a2
Parent:
1:1b37c4b989b4
Child:
7:513afc954d6e
Child:
14:3035b3271395
working colour video output

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MartinJohnson 0:404dae88af71 1 /***************************************************************************
MartinJohnson 0:404dae88af71 2 * STM32 VGA demo
MartinJohnson 0:404dae88af71 3 * Copyright (C) 2012 Artekit Italy
MartinJohnson 0:404dae88af71 4 * http://www.artekit.eu
MartinJohnson 0:404dae88af71 5 * Written by Ruben H. Meleca
MartinJohnson 0:404dae88af71 6
MartinJohnson 0:404dae88af71 7 ### main.c
MartinJohnson 0:404dae88af71 8
MartinJohnson 0:404dae88af71 9 # This program is free software; you can redistribute it and/or modify
MartinJohnson 0:404dae88af71 10 # it under the terms of the GNU General Public License as published by
MartinJohnson 0:404dae88af71 11 # the Free Software Foundation; either version 2 of the License, or
MartinJohnson 0:404dae88af71 12 # (at your option) any later version.
MartinJohnson 0:404dae88af71 13 #
MartinJohnson 0:404dae88af71 14 # This program is distributed in the hope that it will be useful,
MartinJohnson 0:404dae88af71 15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
MartinJohnson 0:404dae88af71 16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MartinJohnson 0:404dae88af71 17 # GNU General Public License for more details.
MartinJohnson 0:404dae88af71 18 #
MartinJohnson 0:404dae88af71 19 # You should have received a copy of the GNU General Public License
MartinJohnson 0:404dae88af71 20 # along with this program; if not, write to the Free Software
MartinJohnson 0:404dae88af71 21 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
MartinJohnson 0:404dae88af71 22
MartinJohnson 0:404dae88af71 23 ***************************************************************************/
MartinJohnson 0:404dae88af71 24
MartinJohnson 0:404dae88af71 25 #include "stm32f30x.h"
MartinJohnson 0:404dae88af71 26 #include "sys.h"
MartinJohnson 0:404dae88af71 27 #include "video.h"
MartinJohnson 0:404dae88af71 28 #include "gdi.h"
MartinJohnson 0:404dae88af71 29
MartinJohnson 0:404dae88af71 30 extern void demoInit(void);
MartinJohnson 0:404dae88af71 31
MartinJohnson 3:93e488fbb8a2 32 void RCC_Configuration(void) {
MartinJohnson 3:93e488fbb8a2 33 RCC->APB1ENR |= RCC_APB1ENR_PWREN | RCC_APB1ENR_TIM2EN ;
MartinJohnson 3:93e488fbb8a2 34 RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN | RCC_APB2ENR_TIM1EN | RCC_APB2ENR_TIM8EN ;//| RCC_APB2ENR_SPI1EN ;
MartinJohnson 3:93e488fbb8a2 35 RCC->AHBENR |= RCC_AHBENR_GPIOBEN | RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOEEN | RCC_AHBENR_GPIODEN;
MartinJohnson 0:404dae88af71 36 }
MartinJohnson 0:404dae88af71 37
MartinJohnson 3:93e488fbb8a2 38 void GPIO_Configuration(void) {
MartinJohnson 3:93e488fbb8a2 39 GPIOE->MODER = (GPIOE->MODER&0xffff) | 0x55550000; // output mode for PE8-15
MartinJohnson 3:93e488fbb8a2 40 GPIOD->MODER = (GPIOD->MODER&0xffff0000) | 0x5555; // output mode for PD0-7
MartinJohnson 3:93e488fbb8a2 41 GPIOA->MODER = (GPIOA->MODER&0xfffffffc) ; // input mode for PA0
MartinJohnson 3:93e488fbb8a2 42 GPIOA->PUPDR = (GPIOA->PUPDR & ~0x3) | 0x2; // pull down (10)
MartinJohnson 0:404dae88af71 43 }
MartinJohnson 3:93e488fbb8a2 44 extern void bounce(void);
MartinJohnson 3:93e488fbb8a2 45 extern void siInit(void);
MartinJohnson 3:93e488fbb8a2 46 int main(void) {
MartinJohnson 0:404dae88af71 47 RCC_Configuration();
MartinJohnson 0:404dae88af71 48 GPIO_Configuration();
MartinJohnson 0:404dae88af71 49 vidInit();
MartinJohnson 0:404dae88af71 50 sysInitSystemTimer();
MartinJohnson 3:93e488fbb8a2 51 if(GPIOA->IDR & 1)
MartinJohnson 0:404dae88af71 52 demoInit();
MartinJohnson 0:404dae88af71 53 else
MartinJohnson 3:93e488fbb8a2 54 bounce();
MartinJohnson 0:404dae88af71 55 return 0;
MartinJohnson 0:404dae88af71 56 }
MartinJohnson 0:404dae88af71 57