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:
Tue Mar 01 02:40:19 2016 +0000
Revision:
0:404dae88af71
Child:
1:1b37c4b989b4
space invaders game

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 0:404dae88af71 32 void RCC_Configuration(void)
MartinJohnson 0:404dae88af71 33 {
MartinJohnson 0:404dae88af71 34 GPIO_InitTypeDef GPIO_InitStructure;
MartinJohnson 0:404dae88af71 35 /* TIM1, GPIOA, GPIOB, GPIOE and AFIO clocks enable */
MartinJohnson 0:404dae88af71 36 RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
MartinJohnson 0:404dae88af71 37 RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
MartinJohnson 0:404dae88af71 38
MartinJohnson 0:404dae88af71 39 /* Enable the USB disconnect GPIO clock */
MartinJohnson 0:404dae88af71 40 // RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIO_DISCONNECT, ENABLE);
MartinJohnson 0:404dae88af71 41
MartinJohnson 0:404dae88af71 42 /*Set PA11,12 as IN - USB_DM,DP*/
MartinJohnson 0:404dae88af71 43 /*
MartinJohnson 0:404dae88af71 44 RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
MartinJohnson 0:404dae88af71 45 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12;
MartinJohnson 0:404dae88af71 46 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
MartinJohnson 0:404dae88af71 47 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
MartinJohnson 0:404dae88af71 48 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
MartinJohnson 0:404dae88af71 49 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
MartinJohnson 0:404dae88af71 50 GPIO_Init(GPIOA, &GPIO_InitStructure);
MartinJohnson 0:404dae88af71 51 */
MartinJohnson 0:404dae88af71 52
MartinJohnson 0:404dae88af71 53 /*SET PA11,12 for USB: USB_DM,DP*/
MartinJohnson 0:404dae88af71 54 // GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_14);
MartinJohnson 0:404dae88af71 55 // GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_14);
MartinJohnson 0:404dae88af71 56
MartinJohnson 0:404dae88af71 57
MartinJohnson 0:404dae88af71 58 RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1 | /* RCC_AHBPeriph_ADC12 |*/ RCC_AHBPeriph_GPIOB | RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOE, ENABLE);
MartinJohnson 0:404dae88af71 59 RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1 | RCC_APB2Periph_TIM1, ENABLE);
MartinJohnson 0:404dae88af71 60 RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
MartinJohnson 0:404dae88af71 61 }
MartinJohnson 0:404dae88af71 62
MartinJohnson 0:404dae88af71 63 void GPIO_Configuration(void)
MartinJohnson 0:404dae88af71 64 {
MartinJohnson 0:404dae88af71 65 GPIO_InitTypeDef GPIO_InitStructure;
MartinJohnson 0:404dae88af71 66 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
MartinJohnson 0:404dae88af71 67 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
MartinJohnson 0:404dae88af71 68 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
MartinJohnson 0:404dae88af71 69 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
MartinJohnson 0:404dae88af71 70 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
MartinJohnson 0:404dae88af71 71 GPIO_Init(GPIOE, &GPIO_InitStructure);
MartinJohnson 0:404dae88af71 72 GPIOE->ODR = 0x000;
MartinJohnson 0:404dae88af71 73 }
MartinJohnson 0:404dae88af71 74
MartinJohnson 0:404dae88af71 75 int main(void)
MartinJohnson 0:404dae88af71 76 {
MartinJohnson 0:404dae88af71 77 // GPIOE->BRR = 0x100;
MartinJohnson 0:404dae88af71 78 RCC_Configuration();
MartinJohnson 0:404dae88af71 79 // GPIOE->BSRR = 0x200;
MartinJohnson 0:404dae88af71 80 GPIO_Configuration();
MartinJohnson 0:404dae88af71 81 // GPIOE->ODR = 0x300;
MartinJohnson 0:404dae88af71 82 vidInit();
MartinJohnson 0:404dae88af71 83 // GPIOE->ODR = 0x400;
MartinJohnson 0:404dae88af71 84 sysInitSystemTimer();
MartinJohnson 0:404dae88af71 85 // GPIOE->ODR = 0x500;
MartinJohnson 0:404dae88af71 86
MartinJohnson 0:404dae88af71 87 // GPIOE->ODR = 0x200;
MartinJohnson 0:404dae88af71 88 //demoInit();
MartinJohnson 0:404dae88af71 89 if(GPIOA->IDR & GPIO_Pin_0)
MartinJohnson 0:404dae88af71 90 demoInit();
MartinJohnson 0:404dae88af71 91 else
MartinJohnson 0:404dae88af71 92 siInit();
MartinJohnson 0:404dae88af71 93 return 0;
MartinJohnson 0:404dae88af71 94 }
MartinJohnson 0:404dae88af71 95