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:
2:1c1f7677ac17
Child:
16:915db2280bc4
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 ### sys.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
MartinJohnson 0:404dae88af71 28 volatile __attribute__ ((section ("ccmram"))) u32 sysTiming;
MartinJohnson 0:404dae88af71 29 volatile __attribute__ ((section ("ccmram"))) u32 sysTicks = 0;
MartinJohnson 0:404dae88af71 30 //extern volatile sysTicks;
MartinJohnson 0:404dae88af71 31 volatile u32 sysDel1Ms;
MartinJohnson 0:404dae88af71 32
MartinJohnson 0:404dae88af71 33 //*****************************************************************************
MartinJohnson 0:404dae88af71 34 // Function sysInitSystemTimer(void)
MartinJohnson 0:404dae88af71 35 //
MartinJohnson 0:404dae88af71 36 // Initialize system timer
MartinJohnson 0:404dae88af71 37 //
MartinJohnson 0:404dae88af71 38 //
MartinJohnson 0:404dae88af71 39 // return 0=Fail, 1=OK
MartinJohnson 0:404dae88af71 40 //*****************************************************************************
MartinJohnson 0:404dae88af71 41 u8 sysInitSystemTimer(void) {
MartinJohnson 0:404dae88af71 42
MartinJohnson 0:404dae88af71 43 if (SysTick_Config((SystemCoreClock / 1000) -1 )) {
MartinJohnson 0:404dae88af71 44 return(0);
MartinJohnson 0:404dae88af71 45 }
MartinJohnson 0:404dae88af71 46 return(1);
MartinJohnson 0:404dae88af71 47 }
MartinJohnson 0:404dae88af71 48
MartinJohnson 0:404dae88af71 49 //*****************************************************************************
MartinJohnson 0:404dae88af71 50 // Function sysDelay1Ms(void)
MartinJohnson 0:404dae88af71 51 //
MartinJohnson 0:404dae88af71 52 // Performs delay 1 milliseconds
MartinJohnson 0:404dae88af71 53 //
MartinJohnson 0:404dae88af71 54 // return None
MartinJohnson 0:404dae88af71 55 //*****************************************************************************
MartinJohnson 0:404dae88af71 56 __attribute__ ((section ("ccmram")))
MartinJohnson 0:404dae88af71 57 void sysDelay1Ms(void) {
MartinJohnson 0:404dae88af71 58
MartinJohnson 0:404dae88af71 59 for (sysDel1Ms = 0; sysDel1Ms < 1000; sysDel1Ms++) { };
MartinJohnson 0:404dae88af71 60 }
MartinJohnson 0:404dae88af71 61
MartinJohnson 0:404dae88af71 62
MartinJohnson 0:404dae88af71 63 //volatile pu16 __timer = (pu16) 0x40006c04;
MartinJohnson 0:404dae88af71 64
MartinJohnson 0:404dae88af71 65 //*****************************************************************************
MartinJohnson 0:404dae88af71 66 // Function sysDelayMs(u32 dly)
MartinJohnson 0:404dae88af71 67 //
MartinJohnson 0:404dae88af71 68 // Performs delay "dly" milliseconds
MartinJohnson 0:404dae88af71 69 //
MartinJohnson 0:404dae88af71 70 // parameters dly Delay value in milliseconds
MartinJohnson 0:404dae88af71 71 //
MartinJohnson 0:404dae88af71 72 // return None
MartinJohnson 0:404dae88af71 73 //*****************************************************************************
MartinJohnson 0:404dae88af71 74 __attribute__ ((section ("ccmram")))
MartinJohnson 0:404dae88af71 75 void sysDelayMs(u32 dly) {
MartinJohnson 0:404dae88af71 76
MartinJohnson 0:404dae88af71 77 sysTiming = dly;
MartinJohnson 0:404dae88af71 78
MartinJohnson 3:93e488fbb8a2 79 while (sysTiming > 0) ;//{__wfi();};
MartinJohnson 0:404dae88af71 80
MartinJohnson 0:404dae88af71 81 }
MartinJohnson 0:404dae88af71 82
MartinJohnson 0:404dae88af71 83 //*****************************************************************************
MartinJohnson 0:404dae88af71 84 // Function sysDelayMs(u32 dly)
MartinJohnson 0:404dae88af71 85 //
MartinJohnson 0:404dae88af71 86 // Performs delay "dly" milliseconds
MartinJohnson 0:404dae88af71 87 //
MartinJohnson 0:404dae88af71 88 // parameters dly Delay value in milliseconds
MartinJohnson 0:404dae88af71 89 //
MartinJohnson 0:404dae88af71 90 // return None
MartinJohnson 0:404dae88af71 91 //*****************************************************************************
MartinJohnson 0:404dae88af71 92 __attribute__ ((section ("ccmram")))
MartinJohnson 0:404dae88af71 93 void sysTickCount(void) {
MartinJohnson 0:404dae88af71 94
MartinJohnson 0:404dae88af71 95 sysTicks++;
MartinJohnson 0:404dae88af71 96 if (sysTiming > 0) --sysTiming;
MartinJohnson 0:404dae88af71 97 }
MartinJohnson 0:404dae88af71 98
MartinJohnson 0:404dae88af71 99 __attribute__ ((section ("ccmram"))) void SysTick_Handler(void) {
MartinJohnson 0:404dae88af71 100 sysTicks++;
MartinJohnson 0:404dae88af71 101 if (sysTiming > 0) --sysTiming;
MartinJohnson 0:404dae88af71 102 }
MartinJohnson 0:404dae88af71 103
MartinJohnson 0:404dae88af71 104