From 0dbf9d8b81a51995e18e1aaf0d7da1cdfdb3450b Mon Sep 17 00:00:00 2001 From: bsongis Date: Wed, 5 Mar 2014 14:46:55 +0100 Subject: [PATCH] 5 more files removed --- radio/bootloader/Fat12.cpp | 562 -------------------------- radio/bootloader/Makefile | 3 - radio/bootloader/boot.cpp | 40 +- radio/bootloader/driversboot.cpp | 83 ---- radio/bootloader/include/drivers.h | 69 ---- radio/bootloader/include/misc.h | 178 -------- radio/bootloader/include/radio.h | 64 --- radio/bootloader/logicioboot.cpp | 377 ----------------- radio/bootloader/usbd_storage_msd.cpp | 7 +- 9 files changed, 14 insertions(+), 1369 deletions(-) delete mode 100644 radio/bootloader/Fat12.cpp delete mode 100644 radio/bootloader/driversboot.cpp delete mode 100644 radio/bootloader/include/drivers.h delete mode 100644 radio/bootloader/include/misc.h delete mode 100644 radio/bootloader/include/radio.h delete mode 100644 radio/bootloader/logicioboot.cpp diff --git a/radio/bootloader/Fat12.cpp b/radio/bootloader/Fat12.cpp deleted file mode 100644 index 44d9b2e34..000000000 --- a/radio/bootloader/Fat12.cpp +++ /dev/null @@ -1,562 +0,0 @@ -/**************************************************************************** -* Copyright (c) 2013 by Michael Blandford. All rights reserved. -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 as -* published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* Original source of this code: Primoz Beltram -* http://sourceforge.net/projects/fat12ctrlface/files/ -* - * Other Authors (alphabetical order) - * - Andre Bernet - * - Andreas Weitl - * - Bertrand Songis - * - Bryan J. Rentoul (Gruvin) - * - Cameron Weeks - * - Erez Raviv - * - Gabriel Birkus - * - Jean-Pierre Parisy - * - Karl Szmutny - * - Michal Hlavinka - * - Pat Mackenzie - * - Philip Moss - * - Rob Thomson - * - Romolo Manfredini - * - Thomas Husterer -* -****************************************************************************/ - - - -#include -#include "string.h" -//#include "myeeprom.h" -#include "file.h" - -#define BLOCKSIZE 512 - -//------------------------------------------------------------------------------ -/** - * FAT12 boot sector partition. - */ -const char g_FATboot[BLOCKSIZE] = { - // See http://en.wikipedia.org/wiki/FAT12#Boot_Sector - 0xeb, 0x3c, 0x90, // Jump instruction. - 0x39, 0x58, 0x20, 0x54, 0x45, 0x41, 0x4D, 0x00, // OEM Name - 0x00, 0x02, // Bytes per sector - 0x08, // Sectors per FS cluster. - 0x01, 0x00, // Reserved sector count - - 0x01, // Number of FATs - 0x10, 0x00, // Number of root directory entries -#ifdef REVX - 0x03, 0x08, // Total sectors = 2051 -#else - 0x03, 0x06, // Total sectors = 1539 -#endif - 0xf8, // Media descriptor - 0x01, 0x00, // Sectors per FAT table - 0x08, 0x00, // Sectors per track - 0x40, 0x00, // Number of heads - 0x00, 0x00, 0x00, 0x00, // Number of hidden sectors - - 0x00, 0x00, 0x00, 0x00, // Large number of sectors. - 0x00, // Physical drive number - 0x00, // Reserved - 0x29, // Extended boot signature - 0xCE, 0xFA, 0x5C, 0xD1, // Disk ID (serial number) - 0x56, 0x49, 0x52, 0x54, 0x46, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, // Volume label - 0x46, 0x41, 0x54, 0x31, 0x32, 0x20, 0x20, 0x20, // FAT file system type - 0x00, 0x00, // OS boot code - - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa -}; - -const char g_FAT[BLOCKSIZE] = -{ -#ifdef REVX - 0xF8, 0xFF, 0xFF, 0x03, 0x40, 0x00, 0x05, 0x60, 0x00, 0x07, 0x80, 0x00, 0x09, 0xA0, 0x00, 0x0B, - 0xC0, 0x00, 0x0D, 0xE0, 0x00, 0x0F, 0x00, 0x01, 0x11, 0x20, 0x01, 0x13, 0x40, 0x01, 0x15, 0x60, - 0x01, 0x17, 0x80, 0x01, 0x19, 0xA0, 0x01, 0x1B, 0xC0, 0x01, 0x1D, 0xE0, 0x01, 0x1F, 0x00, 0x02, - 0x21, 0x20, 0x02, 0x23, 0x40, 0x02, 0x25, 0x60, 0x02, 0x27, 0x80, 0x02, 0x29, 0xA0, 0x02, 0x2B, - 0xC0, 0x02, 0x2D, 0xE0, 0x02, 0x2F, 0x00, 0x03, 0x31, 0x20, 0x03, 0x33, 0x40, 0x03, 0x35, 0x60, - 0x03, 0x37, 0x80, 0x03, 0x39, 0xA0, 0x03, 0x3B, 0xC0, 0x03, 0x3D, 0xE0, 0x03, 0x3F, 0x00, 0x04, - 0x41, 0x20, 0x04, 0x43, 0x40, 0x04, 0x45, 0x60, 0x04, 0x47, 0x80, 0x04, 0x49, 0xA0, 0x04, 0x4B, - 0xC0, 0x04, 0x4D, 0xE0, 0x04, 0x4F, 0x00, 0x05, 0x51, 0x20, 0x05, 0x53, 0x40, 0x05, 0x55, 0x60, - 0x05, 0x57, 0x80, 0x05, 0x59, 0xA0, 0x05, 0x5B, 0xC0, 0x05, 0x5D, 0xE0, 0x05, 0x5F, 0x00, 0x06, - 0x61, 0x20, 0x06, 0x63, 0x40, 0x06, 0x65, 0x60, 0x06, 0x67, 0x80, 0x06, 0x69, 0xA0, 0x06, 0x6B, - 0xC0, 0x06, 0x6D, 0xE0, 0x06, 0x6F, 0x00, 0x07, 0x71, 0x20, 0x07, 0x73, 0x40, 0x07, 0x75, 0x60, - 0x07, 0x77, 0x80, 0x07, 0x79, 0xA0, 0x07, 0x7B, 0xC0, 0x07, 0x7D, 0xE0, 0x07, 0x7F, 0x00, 0x08, - 0x81, 0xF0, 0xFF, 0x83, 0x40, 0x08, 0x85, 0x60, 0x08, 0x87, 0x80, 0x08, 0x89, 0xA0, 0x08, 0x8B, - 0xC0, 0x08, 0x8D, 0xE0, 0x08, 0x8F, 0x00, 0x09, 0x91, 0x20, 0x09, 0x93, 0x40, 0x09, 0x95, 0x60, - 0x09, 0x97, 0x80, 0x09, 0x99, 0xA0, 0x09, 0x9B, 0xC0, 0x09, 0x9D, 0xE0, 0x09, 0x9F, 0x00, 0x0A, - 0xA1, 0x20, 0x0A, 0xA3, 0x40, 0x0A, 0xA5, 0x60, 0x0A, 0xA7, 0x80, 0x0A, 0xA9, 0xA0, 0x0A, 0xAB, - 0xC0, 0x0A, 0xAD, 0xE0, 0x0A, 0xAF, 0x00, 0x0B, 0xB1, 0x20, 0x0B, 0xB3, 0x40, 0x0B, 0xB5, 0x60, - 0x0B, 0xB7, 0x80, 0x0B, 0xB9, 0xA0, 0x0B, 0xBB, 0xC0, 0x0B, 0xBD, 0xE0, 0x0B, 0xBF, 0x00, 0x0C, - 0xC1, 0x20, 0x0C, 0xC3, 0x40, 0x0C, 0xC5, 0x60, 0x0C, 0xC7, 0x80, 0x0C, 0xC9, 0xA0, 0x0C, 0xCB, - 0xC0, 0x0C, 0xCD, 0xE0, 0x0C, 0xCF, 0x00, 0x0D, 0xD1, 0x20, 0x0D, 0xD3, 0x40, 0x0D, 0xD5, 0x60, - 0x0D, 0xD7, 0x80, 0x0D, 0xD9, 0xA0, 0x0D, 0xDB, 0xC0, 0x0D, 0xDD, 0xE0, 0x0D, 0xDF, 0x00, 0x0E, - 0xE1, 0x20, 0x0E, 0xE3, 0x40, 0x0E, 0xE5, 0x60, 0x0E, 0xE7, 0x80, 0x0E, 0xE9, 0xA0, 0x0E, 0xEB, - 0xC0, 0x0E, 0xED, 0xE0, 0x0E, 0xEF, 0x00, 0x0F, 0xF1, 0x20, 0x0F, 0xF3, 0x40, 0x0F, 0xF5, 0x60, - 0x0F, 0xF7, 0x80, 0x0F, 0xF9, 0xA0, 0x0F, 0xFB, 0xC0, 0x0F, 0xFD, 0xE0, 0x0F, 0xFF, 0x00, 0x10, - 0x01, 0xF1, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -#else - 0xF8, 0xFF, 0xFF, 0x03, 0x40, 0x00, 0x05, 0x60, 0x00, 0x07, 0x80, 0x00, 0x09, 0xA0, 0x00, 0x0B, - 0xC0, 0x00, 0x0D, 0xE0, 0x00, 0x0F, 0x00, 0x01, 0x11, 0x20, 0x01, 0x13, 0x40, 0x01, 0x15, 0x60, - 0x01, 0x17, 0x80, 0x01, 0x19, 0xA0, 0x01, 0x1B, 0xC0, 0x01, 0x1D, 0xE0, 0x01, 0x1F, 0x00, 0x02, - 0x21, 0x20, 0x02, 0x23, 0x40, 0x02, 0x25, 0x60, 0x02, 0x27, 0x80, 0x02, 0x29, 0xA0, 0x02, 0x2B, - 0xC0, 0x02, 0x2D, 0xE0, 0x02, 0x2F, 0x00, 0x03, 0x31, 0x20, 0x03, 0x33, 0x40, 0x03, 0x35, 0x60, - 0x03, 0x37, 0x80, 0x03, 0x39, 0xA0, 0x03, 0x3B, 0xC0, 0x03, 0x3D, 0xE0, 0x03, 0x3F, 0x00, 0x04, - 0x41, 0x20, 0x04, 0x43, 0x40, 0x04, 0x45, 0x60, 0x04, 0x47, 0x80, 0x04, 0x49, 0xA0, 0x04, 0x4B, - 0xC0, 0x04, 0x4D, 0xE0, 0x04, 0x4F, 0x00, 0x05, 0x51, 0x20, 0x05, 0x53, 0x40, 0x05, 0x55, 0x60, - 0x05, 0x57, 0x80, 0x05, 0x59, 0xA0, 0x05, 0x5B, 0xC0, 0x05, 0x5D, 0xE0, 0x05, 0x5F, 0x00, 0x06, - 0x61, 0x20, 0x06, 0x63, 0x40, 0x06, 0x65, 0x60, 0x06, 0x67, 0x80, 0x06, 0x69, 0xA0, 0x06, 0x6B, - 0xC0, 0x06, 0x6D, 0xE0, 0x06, 0x6F, 0x00, 0x07, 0x71, 0x20, 0x07, 0x73, 0x40, 0x07, 0x75, 0x60, - 0x07, 0x77, 0x80, 0x07, 0x79, 0xA0, 0x07, 0x7B, 0xC0, 0x07, 0x7D, 0xE0, 0x07, 0x7F, 0x00, 0x08, - 0x81, 0xF0, 0xFF, 0x83, 0x40, 0x08, 0x85, 0x60, 0x08, 0x87, 0x80, 0x08, 0x89, 0xA0, 0x08, 0x8B, - 0xC0, 0x08, 0x8D, 0xE0, 0x08, 0x8F, 0x00, 0x09, 0x91, 0x20, 0x09, 0x93, 0x40, 0x09, 0x95, 0x60, - 0x09, 0x97, 0x80, 0x09, 0x99, 0xA0, 0x09, 0x9B, 0xC0, 0x09, 0x9D, 0xE0, 0x09, 0x9F, 0x00, 0x0A, - 0xA1, 0x20, 0x0A, 0xA3, 0x40, 0x0A, 0xA5, 0x60, 0x0A, 0xA7, 0x80, 0x0A, 0xA9, 0xA0, 0x0A, 0xAB, - 0xC0, 0x0A, 0xAD, 0xE0, 0x0A, 0xAF, 0x00, 0x0B, 0xB1, 0x20, 0x0B, 0xB3, 0x40, 0x0B, 0xB5, 0x60, - 0x0B, 0xB7, 0x80, 0x0B, 0xB9, 0xA0, 0x0B, 0xBB, 0xC0, 0x0B, 0xBD, 0xE0, 0x0B, 0xBF, 0x00, 0x0C, - 0xC1, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -#endif -}; - - -// File Attributes -// 0 0x01 Read Only. -// 1 0x02 Hidden. -// 2 0x04 System. -// 3 0x08 Volume Label. -// 4 0x10 Subdirectory. -// 5 0x20 Archive. -// 6 0x40 Device. -// 7 0x80 Reserved. - -typedef struct -{ - uint8_t name[8]; - uint8_t ext[3]; - uint8_t attribute; - uint8_t reserved; - uint8_t create_time_ms; - uint16_t create_time; - uint16_t create_date; - uint16_t access_date; - uint16_t ea_index; - uint16_t modify_time; - uint16_t modify_date; - uint16_t start_cluster; - uint32_t file_size; -} FATDirEntry_t; - -// First 16 FAT root directory entries (1 sector) -const FATDirEntry_t g_DIRroot[16] = -{ - { - { 'E', 'R', 'S', 'K', 'Y', '_', '9', 'X'}, - { ' ', ' ', ' '}, - 0x08, // Volume - 0x00, - 0x00, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x00000000 - }, - { - { 'E', 'R', 'S', 'K', 'Y', '9', 'X', ' '}, - { 'B', 'I', 'N'}, - 0x26, // Archive, hidden, system, read-only - 0x00, - 0x3E, - 0xA301, - 0x3D55, - 0x3D55, - 0x0000, - 0xA302, - 0x3D55, - 0x0002, - 0x00080000 - }, - { - { 'F', 'I', 'R', 'M', 'W', 'A', 'R', 'E'}, - { 'B', 'I', 'N'}, - 0x26, - 0x00, - 0x3E, - 0xA301, - 0x3D55, - 0x3D55, - 0x0000, - 0xA302, - 0x3D55, - 0x0082, -#ifdef REVX - 0x00080000 -#else - 0x00040000 -#endif - }, - { - { 'A', '2', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x27, - 0x00, - 0x3E, - 0xA301, - 0x3D55, - 0x3D55, - 0x0000, - 0xA302, - 0x3D55, - 0x0000, - 0x00000000 - }, - { - { 'A', '3', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x27, - 0x00, - 0x3E, - 0xA301, - 0x3D55, - 0x3D55, - 0x0000, - 0xA302, - 0x3D55, - 0x0000, - 0x00000000 - }, - { - { 'A', '4', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x27, - 0x00, - 0x3E, - 0xA301, - 0x3D55, - 0x3D55, - 0x0000, - 0xA302, - 0x3D55, - 0x0000, - 0x00000000 - }, - { - { 'A', '5', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x27, - 0x00, - 0x3E, - 0xA301, - 0x3D55, - 0x3D55, - 0x0000, - 0xA302, - 0x3D55, - 0x0000, - 0x00000000 - }, - { - { 'A', '6', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x27, - 0x00, - 0x3E, - 0xA301, - 0x3D55, - 0x3D55, - 0x0000, - 0xA302, - 0x3D55, - 0x0000, - 0x00000000 - }, - { - { 'A', '7', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x27, - 0x00, - 0x3E, - 0xA301, - 0x3D55, - 0x3D55, - 0x0000, - 0xA302, - 0x3D55, - 0x0000, - 0x00000000 - }, - { - { 'A', '8', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x27, - 0x00, - 0x3E, - 0xA301, - 0x3D55, - 0x3D55, - 0x0000, - 0xA302, - 0x3D55, - 0x0000, - 0x00000000 - }, - { - { 'A', '9', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x27, - 0x00, - 0x3E, - 0xA301, - 0x3D55, - 0x3D55, - 0x0000, - 0xA302, - 0x3D55, - 0x0000, - 0x00000000 - }, - { - { 'A', 'A', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x27, - 0x00, - 0x3E, - 0xA301, - 0x3D55, - 0x3D55, - 0x0000, - 0xA302, - 0x3D55, - 0x0000, - 0x00000000 - }, - { - { 'A', 'B', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x27, - 0x00, - 0x3E, - 0xA301, - 0x3D55, - 0x3D55, - 0x0000, - 0xA302, - 0x3D55, - 0x0000, - 0x00000000 - }, - { - { 'A', 'C', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x27, - 0x00, - 0x3E, - 0xA301, - 0x3D55, - 0x3D55, - 0x0000, - 0xA302, - 0x3D55, - 0x0000, - 0x00000000 - }, - { - { '\0', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x00, - 0x00, - 0x00, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x00000000 - }, -// { -// { 'A', 'E', ' ', ' ', ' ', ' ', ' ', ' '}, -// { ' ', ' ', ' '}, -// 0x27, -// 0x00, -// 0x3E, -// 0xA301, -// 0x3D55, -// 0x3D55, -// 0x0000, -// 0xA302, -// 0x3D55, -// 0x0000, -// 0x00000000 -// } - { - { '\0', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x00, - 0x00, - 0x00, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x00000000 - } -}; - - -int fat12Read( uint8_t *buffer, uint16_t sector ) -{ - if (sector == 0) - { - memcpy( buffer, g_FATboot, BLOCKSIZE ) ; - return TRUE; - } - else if ( sector == 1/*Reserved sector count*/) - { - // FAT table. - memcpy( buffer, g_FAT, BLOCKSIZE); - return TRUE; - } - else if ( sector == 2) - { - // Directory - memcpy( buffer, g_DIRroot, BLOCKSIZE ) ; - return TRUE; - } - - sector -= 3 ; - if ( sector < 1024 ) - { - ee32_read_512( sector, buffer ) ; - } -#ifdef REVX - else if ( sector < 2048 ) -#else - else if ( sector < 1536 ) -#endif - { - uint32_t address ; - address = sector - 1024 ; - address *= 512 ; - address += 0x00400000 ; - memcpy( buffer, (uint8_t *)address, BLOCKSIZE ) ; - } - else - { - memset( buffer, 0, BLOCKSIZE ) ; - } - return TRUE; -} - - -uint32_t program( uint32_t *address, uint32_t *buffer ) ; // size is 256 bytes -uint32_t ee32_write( const uint8_t *buffer, uint32_t sector, uint32_t count ) ; - -int fat12Write( const uint8_t *buffer, uint16_t sector, uint32_t count ) -{ - // TO DO, actually write to the EEPROM - if ( sector >= 3 ) - { - sector -= 3 ; - // Look for a 4K block boundary, writing 4K+ - if ( sector < 1024 ) - { - ee32_write( buffer, sector, count ) ; - } -#ifdef REVX - else if ( sector < 2048 ) -#else - else if ( sector < 1536 ) -#endif - { - // FIRMWARE - uint32_t address ; - address = sector - 1024 ; - address *= 512 ; - address += 0x00400000 ; - // Write to flash - uint32_t i ; - while ( count ) - { - for ( i = 0 ; i < 2 ; i += 1 ) - { - if ( address >= 0x00408000 ) // Protect bootloader - { - program( (uint32_t *)address, (uint32_t *) buffer ) ; // size is 256 bytes - } - address += 256 ; - buffer += 256 ; - } - count -= 1 ; - } - } - } - return TRUE; -} - - diff --git a/radio/bootloader/Makefile b/radio/bootloader/Makefile index f67923ab8..d756d8518 100644 --- a/radio/bootloader/Makefile +++ b/radio/bootloader/Makefile @@ -98,7 +98,6 @@ else CPPDEFS += -DHSE_VALUE=12000000 CPPDEFS += -DPCBTARANIS FULL_PRJ = $(PROJECT)_ramBoot - EXTRAINCDIRS += include EXTRAINCDIRS += ../src/targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc EXTRAINCDIRS += ../src/targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Include EXTRAINCDIRS += ../src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc @@ -143,8 +142,6 @@ SRC = system_stm32f2xx.c \ CPPSRC = ../src/targets/taranis/lcd_driver.cpp \ ../src/targets/taranis/keys_driver.cpp \ - driversboot.cpp \ - logicioboot.cpp \ ../src/targets/taranis/diskio.cpp \ ../src/targets/taranis/usbd_usr.cpp \ usbd_storage_msd.cpp \ diff --git a/radio/bootloader/boot.cpp b/radio/bootloader/boot.cpp index b4c39a97d..91f0f94e4 100644 --- a/radio/bootloader/boot.cpp +++ b/radio/bootloader/boot.cpp @@ -75,31 +75,14 @@ extern "C" { #include "../src/lcd.h" #include "../src/keys.h" -// #include "radio.h" #include "../src/FatFs/ff.h" #include "../src/FatFs/diskio.h" -//#include "drivers.h" -// #include "logicio.h" - -#ifdef PCBSKY -extern void usbMassStorage( void ) ; -#endif - -#ifdef PCBSKY -#define BOOT_KEY_UP KEY_UP -#define BOOT_KEY_DOWN KEY_DOWN -#define BOOT_KEY_LEFT KEY_LEFT -#define BOOT_KEY_RIGHT KEY_RIGHT -#define BOOT_KEY_MENU KEY_MENU -#define BOOT_KEY_EXIT KEY_EXIT -#define DISPLAY_CHAR_WIDTH 21 -#endif #ifdef PCBTARANIS -#define BOOT_KEY_UP KEY_PLUS +#define BOOT_KEY_UP KEY_PLUS #define BOOT_KEY_DOWN KEY_MINUS #define BOOT_KEY_LEFT KEY_MENU -#define BOOT_KEY_RIGHT KEY_PAGE +#define BOOT_KEY_RIGHT KEY_PAGE #define BOOT_KEY_MENU KEY_ENTER #define BOOT_KEY_EXIT KEY_EXIT #define DISPLAY_CHAR_WIDTH 35 @@ -117,10 +100,6 @@ extern void usbMassStorage( void ) ; #define ST_REBOOT 11 - - - - /*---------------------------------------------------------------------------- * Local variables *----------------------------------------------------------------------------*/ @@ -131,8 +110,6 @@ uint32_t Master_frequency ; volatile uint8_t Tenms ; uint8_t EE_timer ; -extern uint32_t sd_card_ready( void ) ; - TCHAR FlashFilename[60] ; FATFS g_FATFS ; FIL FlashFile ; @@ -325,11 +302,18 @@ void clearLockBits() } #endif -void per10ms(void); void interrupt10ms(void) { - Tenms |= 1 ; // 10 mS has passed - per10ms() ; + Tenms |= 1 ; // 10 mS has passed + + uint8_t enuk = KEY_MENU; + uint8_t in = ~readKeys(); + + for (int i=1; i<7; i++) { + uint8_t value = in & (1< - * - * Based on th9x -> http://code.google.com/p/th9x/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - - - -#include -#include - -#include "../src/opentx.h" - -void per10ms(void) -{ - register uint32_t i ; - - uint8_t enuk = KEY_MENU; - uint8_t in = ~readKeys() ; - // Bits 3-6 are down, up, right and left - // Try to only allow one at a -#ifdef REVX - static uint8_t current ; - uint8_t dir_keys ; - uint8_t lcurrent ; - - dir_keys = in & 0x78 ; // Mask to direction keys - if ( ( lcurrent = current ) ) - { // Something already pressed - if ( ( lcurrent & dir_keys ) == 0 ) - { - lcurrent = 0 ; // No longer pressed - } - else - { - in &= lcurrent | 0x06 ; // current or MENU or EXIT allowed - } - } - if ( lcurrent == 0 ) - { // look for a key - if ( dir_keys & 0x20 ) // right - { - lcurrent = 0x60 ; // Allow L and R for 9X - } - else if ( dir_keys & 0x40 ) // left - { - lcurrent = 0x60 ; // Allow L and R for 9X - } - else if ( dir_keys & 0x08 ) // down - { - lcurrent = 0x08 ; - } - else if ( dir_keys & 0x10 ) // up - { - lcurrent = 0x10 ; - } - in &= lcurrent | 0x06 ; // current or MENU or EXIT allowed - } - current = lcurrent ; -#endif - - for( i=1; i<7; i++) - { - uint8_t value = in & (1<PIO_PDSR & PIO_PB7) == 0 ) -#endif - -extern uint32_t Card_ID[4] ; -extern uint32_t Card_SCR[2] ; -extern uint32_t Card_CSD[4] ; -extern uint32_t Sd_128_resp[4] ; -extern uint32_t Sd_rca ; -//extern uint32_t Cmd_55_resp ; - -extern uint32_t Card_state ; - -extern uint32_t SD_SetBusWidth( uint32_t busWidth) ; -extern void SD_EnableHsMode( uint8_t hsEnable) ; -extern uint32_t SD_SetSpeed( uint32_t mciSpeed ) ; -extern void SD_Reset( uint8_t keepSettings) ; -extern uint32_t sd_cmd55( void ) ; -extern uint32_t sd_acmd41( void ) ; -extern uint32_t sd_cmd2( void ) ; -extern uint32_t sd_cmd3( void ) ; -extern uint32_t sd_cmd7( void ) ; -extern uint32_t sd_cmd9( void ) ; -extern uint32_t sd_cmd17( uint32_t address, uint32_t *presult ) ; -extern uint32_t sd_acmd6( void ) ; -extern uint32_t sd_acmd51( uint32_t *presult ) ; -extern void sd_poll_10mS( void ) ; -extern uint32_t sd_card_ready( void ) ; -extern uint32_t sd_read_block( uint32_t block_no, uint32_t *data ) ; - -class Key -{ -#define FILTERBITS 4 -#define FFVAL ((1<
© COPYRIGHT 2012 STMicroelectronics
- * - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __MISC_H -#define __MISC_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f2xx.h" - -/** @addtogroup STM32F2xx_StdPeriph_Driver - * @{ - */ - -/** @addtogroup MISC - * @{ - */ - -/* Exported types ------------------------------------------------------------*/ - -/** - * @brief NVIC Init Structure definition - */ - -typedef struct -{ - uint8_t NVIC_IRQChannel; /*!< Specifies the IRQ channel to be enabled or disabled. - This parameter can be an enumerator of @ref IRQn_Type - enumeration (For the complete STM32 Devices IRQ Channels - list, please refer to stm32f2xx.h file) */ - - uint8_t NVIC_IRQChannelPreemptionPriority; /*!< Specifies the pre-emption priority for the IRQ channel - specified in NVIC_IRQChannel. This parameter can be a value - between 0 and 15 as described in the table @ref MISC_NVIC_Priority_Table - A lower priority value indicates a higher priority */ - - uint8_t NVIC_IRQChannelSubPriority; /*!< Specifies the subpriority level for the IRQ channel specified - in NVIC_IRQChannel. This parameter can be a value - between 0 and 15 as described in the table @ref MISC_NVIC_Priority_Table - A lower priority value indicates a higher priority */ - - FunctionalState NVIC_IRQChannelCmd; /*!< Specifies whether the IRQ channel defined in NVIC_IRQChannel - will be enabled or disabled. - This parameter can be set either to ENABLE or DISABLE */ -} NVIC_InitTypeDef; - -/* Exported constants --------------------------------------------------------*/ - -/** @defgroup MISC_Exported_Constants - * @{ - */ - -/** @defgroup MISC_Vector_Table_Base - * @{ - */ - -#define NVIC_VectTab_RAM ((uint32_t)0x20000000) -#define NVIC_VectTab_FLASH ((uint32_t)0x08000000) -#define IS_NVIC_VECTTAB(VECTTAB) (((VECTTAB) == NVIC_VectTab_RAM) || \ - ((VECTTAB) == NVIC_VectTab_FLASH)) -/** - * @} - */ - -/** @defgroup MISC_System_Low_Power - * @{ - */ - -#define NVIC_LP_SEVONPEND ((uint8_t)0x10) -#define NVIC_LP_SLEEPDEEP ((uint8_t)0x04) -#define NVIC_LP_SLEEPONEXIT ((uint8_t)0x02) -#define IS_NVIC_LP(LP) (((LP) == NVIC_LP_SEVONPEND) || \ - ((LP) == NVIC_LP_SLEEPDEEP) || \ - ((LP) == NVIC_LP_SLEEPONEXIT)) -/** - * @} - */ - -/** @defgroup MISC_Preemption_Priority_Group - * @{ - */ - -#define NVIC_PriorityGroup_0 ((uint32_t)0x700) /*!< 0 bits for pre-emption priority - 4 bits for subpriority */ -#define NVIC_PriorityGroup_1 ((uint32_t)0x600) /*!< 1 bits for pre-emption priority - 3 bits for subpriority */ -#define NVIC_PriorityGroup_2 ((uint32_t)0x500) /*!< 2 bits for pre-emption priority - 2 bits for subpriority */ -#define NVIC_PriorityGroup_3 ((uint32_t)0x400) /*!< 3 bits for pre-emption priority - 1 bits for subpriority */ -#define NVIC_PriorityGroup_4 ((uint32_t)0x300) /*!< 4 bits for pre-emption priority - 0 bits for subpriority */ - -#define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PriorityGroup_0) || \ - ((GROUP) == NVIC_PriorityGroup_1) || \ - ((GROUP) == NVIC_PriorityGroup_2) || \ - ((GROUP) == NVIC_PriorityGroup_3) || \ - ((GROUP) == NVIC_PriorityGroup_4)) - -#define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) - -#define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) - -#define IS_NVIC_OFFSET(OFFSET) ((OFFSET) < 0x000FFFFF) - -/** - * @} - */ - -/** @defgroup MISC_SysTick_clock_source - * @{ - */ - -#define SysTick_CLKSource_HCLK_Div8 ((uint32_t)0xFFFFFFFB) -#define SysTick_CLKSource_HCLK ((uint32_t)0x00000004) -#define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \ - ((SOURCE) == SysTick_CLKSource_HCLK_Div8)) -/** - * @} - */ - -/** - * @} - */ - -/* Exported macro ------------------------------------------------------------*/ -/* Exported functions --------------------------------------------------------*/ - -void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup); -void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct); -void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset); -void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState); -void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource); - -#ifdef __cplusplus -} -#endif - -#endif /* __MISC_H */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/radio/bootloader/include/radio.h b/radio/bootloader/include/radio.h deleted file mode 100644 index afc5e5b46..000000000 --- a/radio/bootloader/include/radio.h +++ /dev/null @@ -1,64 +0,0 @@ - - -#include - -#ifdef PCBSKY -#define wdt_reset() (WDT->WDT_CR = 0xA5000001) -#endif -#ifdef PCBTARANIS -#define wdt_reset() (IWDG->KR = 0x0000AAAAL) -#endif - -#define POWER_OFF 0 -#define POWER_ON 1 - -#define DIM(arr) (sizeof((arr))/sizeof((arr)[0])) - -#define BITMASK(bit) (1<<(bit)) - -#define _MSK_KEY_REPT 0x40 -#define _MSK_KEY_DBL 0x10 -#define IS_KEY_BREAK(key) (((key)&0xf0) == 0x20) -#define EVT_KEY_BREAK(key) ((key)| 0x20) -#define EVT_KEY_FIRST(key) ((key)| _MSK_KEY_REPT|0x20) -#define EVT_KEY_REPT(key) ((key)| _MSK_KEY_REPT ) -#define EVT_KEY_LONG(key) ((key)|0x80) -#define EVT_KEY_DBL(key) ((key)|_MSK_KEY_DBL) -//#define EVT_KEY_DBL(key) ((key)|0x10) -#define EVT_ENTRY (0xff - _MSK_KEY_REPT) -#define EVT_ENTRY_UP (0xfe - _MSK_KEY_REPT) -#define EVT_KEY_MASK 0x0f - - -#define NUM_KEYS 6 - -#ifdef PCBSKY -enum EnumKeys { - KEY_MENU , - KEY_EXIT , - KEY_DOWN , - KEY_UP , - KEY_RIGHT , - KEY_LEFT -} ; -#endif - -#ifdef PCBTARANIS -enum EnumKeys { - KEY_MENU , - KEY_EXIT , - KEY_ENTER , - KEY_PAGE , - KEY_PLUS , - KEY_MINUS -} ; -#endif - -extern void init_SDcard( void ) ; -extern unsigned long Master_frequency ; - -extern void init_soft_power( void ) ; -extern uint32_t check_soft_power( void ) ; -extern void soft_power_off( void ) ; - - diff --git a/radio/bootloader/logicioboot.cpp b/radio/bootloader/logicioboot.cpp deleted file mode 100644 index cc3df751a..000000000 --- a/radio/bootloader/logicioboot.cpp +++ /dev/null @@ -1,377 +0,0 @@ -/**************************************************************************** -* Copyright (c) 2012 by Michael Blandford. All rights reserved. -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 as -* published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* -****************************************************************************/ - -#include -#include -#include -#include - - -#ifdef PCBSKY -#include "AT91SAM3S4.h" -#include "radio.h" -#include "drivers.h" -#endif - -#include "../src/opentx.h" - - -#ifndef SIMU -#ifdef PCBSKY -void configure_pins( uint32_t pins, uint16_t config ) -{ - register Pio *pioptr ; - - pioptr = PIOA + ( ( config & PIN_PORT_MASK ) >> 6) ; - if ( config & PIN_PULLUP ) - { - pioptr->PIO_PPDDR = pins ; - pioptr->PIO_PUER = pins ; - } - else - { - pioptr->PIO_PUDR = pins ; - } - - if ( config & PIN_PULLDOWN ) - { - pioptr->PIO_PUDR = pins ; - pioptr->PIO_PPDER = pins ; - } - else - { - pioptr->PIO_PPDDR = pins ; - } - - if ( config & PIN_HIGH ) - { - pioptr->PIO_SODR = pins ; - } - else - { - pioptr->PIO_CODR = pins ; - } - - if ( config & PIN_INPUT ) - { - pioptr->PIO_ODR = pins ; - } - else - { - pioptr->PIO_OER = pins ; - } - - if ( config & PIN_PERI_MASK_L ) - { - pioptr->PIO_ABCDSR[0] |= pins ; - } - else - { - pioptr->PIO_ABCDSR[0] &= ~pins ; - } - if ( config & PIN_PERI_MASK_H ) - { - pioptr->PIO_ABCDSR[1] |= pins ; - } - else - { - pioptr->PIO_ABCDSR[1] &= ~pins ; - } - - if ( config & PIN_ENABLE ) - { - pioptr->PIO_PER = pins ; - } - else - { - pioptr->PIO_PDR = pins ; - } -} -#endif - - -#ifdef PCBTARANIS -void configure_pins( uint32_t pins, uint16_t config ) -{ - uint32_t address ; - GPIO_TypeDef *pgpio ; - uint32_t thispin ; - uint32_t pos ; - - address = ( config & PIN_PORT_MASK ) >> 8 ; - address *= (GPIOB_BASE-GPIOA_BASE) ; - address += GPIOA_BASE ; - pgpio = (GPIO_TypeDef* ) address ; - - /* -------------------------Configure the port pins---------------- */ - /*-- GPIO Mode Configuration --*/ - for (thispin = 0x0001, pos = 0; thispin < 0x10000; thispin <<= 1, pos +=1 ) - { - if ( pins & thispin) - { - pgpio->MODER &= ~(GPIO_MODER_MODER0 << (pos * 2)) ; - pgpio->MODER |= (config & PIN_MODE_MASK) << (pos * 2) ; - - if ( ( (config & PIN_MODE_MASK ) == PIN_OUTPUT) || ( (config & PIN_MODE_MASK) == PIN_PERIPHERAL) ) - { - /* Speed mode configuration */ - pgpio->OSPEEDR &= ~GPIO_OSPEEDER_OSPEEDR0 << (pos * 2) ; - pgpio->OSPEEDR |= ((config & PIN_SPEED_MASK) >> 13 ) << (pos * 2) ; - - /* Output mode configuration*/ - pgpio->OTYPER &= ~((GPIO_OTYPER_OT_0) << ((uint16_t)pos)) ; - if ( config & PIN_ODRAIN ) - { - pgpio->OTYPER |= (GPIO_OTYPER_OT_0) << pos ; - } - } - /* Pull-up Pull down resistor configuration*/ - pgpio->PUPDR &= ~(GPIO_PUPDR_PUPDR0 << ((uint16_t)pos * 2)); - pgpio->PUPDR |= ((config & PIN_PULL_MASK) >> 2) << (pos * 2) ; - - pgpio->AFR[pos >> 3] &= ~(0x000F << ((pos & 7)*4)) ; - pgpio->AFR[pos >> 3] |= ((config & PIN_PERI_MASK) >> 4) << ((pos & 7)*4) ; - } - } -} - -#endif - - - -#ifdef PCBSKY - -void init_keys() -{ - register Pio *pioptr ; - - pioptr = PIOC ; - // Next section configures the key inputs on the LCD data - pioptr->PIO_PER = 0x0000003BL ; // Enable bits 1,3,4,5, 0 - pioptr->PIO_OER = PIO_PC0 ; // Set bit 0 output - pioptr->PIO_ODR = 0x0000003AL ; // Set bits 1, 3, 4, 5 input - pioptr->PIO_PUER = 0x0000003AL ; // Set bits 1, 3, 4, 5 with pullups - - pioptr = PIOB ; - pioptr->PIO_PUER = PIO_PB5 ; // Enable pullup on bit B5 (MENU) - pioptr->PIO_PER = PIO_PB5 ; // Enable bit B5 -} - -// Assumes PMC has already enabled clocks to ports -void setup_switches() -{ - configure_pins( 0x01808087, PIN_ENABLE | PIN_INPUT | PIN_PORTA | PIN_PULLUP ) ; - configure_pins( 0x00000030, PIN_ENABLE | PIN_INPUT | PIN_PORTB | PIN_PULLUP ) ; - configure_pins( 0x91114900, PIN_ENABLE | PIN_INPUT | PIN_PORTC | PIN_PULLUP ) ; -} - - -// Switch input pins -// Needs updating for REVB board ******** -// AIL-DR PA2 -// TRIM_LH_DOWN PA7 (PA23) -// ELE_DR PA8 (PC31) -// RUN_DR PA15 -// TRIM_LV_DOWN PA27 (PA24) -// SW_TCUT PA28 (PC20) -// TRIM_RH_DOWN PA29 (PA0) -// TRIM_RV_UP PA30 (PA1) -// TRIM_LH_UP //PB4 -// SW-TRAIN PC8 -// TRIM_RH_UP PC9 -// TRIM_RV_DOWN PC10 -// SW_IDL2 PC11 -// SW_IDL1 PC14 -// SW_GEAR PC16 -// TRIM_LV_UP PC28 - -// KEY_MENU PB6 (PB5) -// KEY_EXIT PA31 (PC24) -// Shared with LCD data -// KEY_DOWN LCD5 PC3 -// KEY_UP LCD6 PC2 -// KEY_RIGHT LCD4 PC4 -// KEY_LEFT LCD3 PC5 - -// PORTA 1111 1000 0000 0000 1000 0001 1000 0100 = 0xF8008184 proto -// PORTA 0000 0001 1000 0000 1000 0000 0000 0111 = 0x01808087 REVB -// PORTB 0000 0000 0001 0000 = 0x0010 proto -// PORTB 0000 0000 0010 0000 = 0x0030 REVB -// PORTC 0001 0000 0000 0001 0100 1001 0000 0000 = 0x10014900 proto -// PORTC 1001 0001 0001 0001 0100 1001 0000 0000 = 0x91114900 REVB - - -// Prototype -// Free pins (PA16 is stock buzzer) -// PA23, PA24, PA25, PB7, PB13 -// PC20, PC21(labelled 17), PC22, PC24 -// REVB -// PA25, use for stock buzzer -// PB14, PB6 -// PC21, PC19, PC15 (PPM2 output) -void config_free_pins() -{ - - configure_pins( PIO_PB14, PIN_ENABLE | PIN_INPUT | PIN_PORTB | PIN_PULLUP ) ; - -} - -#endif - -#endif // ndef BOOT - -// keys: -// KEY_EXIT PA31 (PC24) -// KEY_MENU PB6 (PB5) -// KEY_DOWN LCD5 PC3 (PC5) -// KEY_UP LCD6 PC2 (PC1) -// KEY_RIGHT LCD4 PC4 (PC4) -// KEY_LEFT LCD3 PC5 (PC3) -// Reqd. bit 6 LEFT, 5 RIGHT, 4 UP, 3 DOWN 2 EXIT 1 MENU -// LCD pins 5 DOWN, 4 RIGHT, 3 LEFT, 1 UP -#ifdef PCBSKY -uint32_t read_keys() -{ - register uint32_t x ; - register uint32_t y ; - - x = LcdLock ? LcdInputs : PIOC->PIO_PDSR << 1 ; // 6 LEFT, 5 RIGHT, 4 DOWN, 3 UP () - - y = x & 0x00000020 ; // RIGHT - if ( x & 0x00000004 ) - { - y |= 0x00000010 ; // UP - } - if ( x & 0x00000010 ) - { - y |= 0x00000040 ; // LEFT - } - if ( x & 0x00000040 ) - { - y |= 0x00000008 ; // DOWN - } - - if ( PIOC->PIO_PDSR & 0x01000000 ) - { - y |= 4 ; // EXIT - } - if ( PIOB->PIO_PDSR & 0x000000020 ) - { - y |= 2 ; // MENU - } - return y ; -} -#endif - -#ifdef PCBSKY -uint32_t read_trims() -{ - uint32_t trims ; - uint32_t trima ; - - trims = 0 ; - - trima = PIOA->PIO_PDSR ; -// TRIM_LH_DOWN PA7 (PA23) -#ifndef REVX - if ( ( trima & 0x00800000 ) == 0 ) -#else - if ( ( PIOB->PIO_PDSR & 0x10 ) == 0 ) -#endif - { - trims |= 1 ; - } - -// TRIM_LV_DOWN PA27 (PA24) - if ( ( trima & 0x01000000 ) == 0 ) - { - trims |= 4 ; - } - -// TRIM_RV_UP PA30 (PA1) -#ifndef REVX - if ( ( trima & 0x00000002 ) == 0 ) -#else - if ( ( PIOC->PIO_PDSR & 0x00000400 ) == 0 ) -#endif - { - trims |= 0x20 ; - } - -// TRIM_RH_DOWN PA29 (PA0) - if ( ( trima & 0x00000001 ) == 0 ) - { - trims |= 0x40 ; - } - -// TRIM_LH_UP PB4 -#ifndef REVX - if ( ( PIOB->PIO_PDSR & 0x10 ) == 0 ) -#else - if ( ( trima & 0x00800000 ) == 0 ) -#endif - { - trims |= 2 ; - } - - trima = PIOC->PIO_PDSR ; -// TRIM_LV_UP PC28 - if ( ( trima & 0x10000000 ) == 0 ) - { - trims |= 8 ; - } - -// TRIM_RV_DOWN PC10 -#ifndef REVX - if ( ( trima & 0x00000400 ) == 0 ) -#else - if ( ( PIOA->PIO_PDSR & 0x00000002 ) == 0 ) -#endif - { - trims |= 0x10 ; - } - -// TRIM_RH_UP PC9 - if ( ( trima & 0x00000200 ) == 0 ) - { - trims |= 0x80 ; - } - - return trims ; -} - -#endif - -#ifdef PCBSKY -extern "C" uint32_t initReadTrims( void ) ; - -uint32_t initReadTrims( void ) -{ - PMC->PMC_PCER0 = (1< #include -//#include -#include "drivers.h" #include "../src/targets/taranis/i2c.h" +#include "../src/keys.h" +#include "../src/eeprom_rlc.h" extern "C" { #include "../src/FatFs/diskio.h" }