├── .gitattributes ├── .gitignore ├── Makefile ├── README ├── bl ├── bl.c └── bl.h ├── emucc ├── bus.c ├── bus.h ├── cia.c ├── cia.h ├── cpu.c ├── cpu.h ├── emuccif.c ├── emuccif.h ├── joy.c ├── joy.h ├── key.c ├── key.h ├── sid.c ├── sid.h ├── tap.c ├── tap.h ├── vic.c └── vic.h ├── emudd ├── bus.c ├── bus.h ├── cpu.c ├── cpu.h ├── emuddif.c ├── emuddif.h ├── fdd.c ├── fdd.h ├── via.c └── via.h ├── emudoc ├── emucc │ ├── disassembly │ │ └── c64.txt │ ├── memmap │ │ └── c64.txt │ ├── schematics │ │ ├── c64_1.gif │ │ ├── c64_2.gif │ │ └── keymatrix.gif │ └── specs │ │ ├── 6510.txt │ │ ├── 6526.pdf │ │ ├── 6569.txt │ │ └── serial-bus.pdf └── emudd │ ├── disassembly │ └── 1541.txt │ ├── memmap │ └── 1541.txt │ ├── schematics │ └── 1541.gif │ └── specs │ └── 6522.pdf ├── hw ├── config │ ├── config.c │ └── config.h ├── core │ ├── cmsis │ │ ├── arm_common_tables.h │ │ ├── arm_const_structs.h │ │ ├── arm_math.h │ │ ├── cmsis_armcc.h │ │ ├── cmsis_armcc_V6.h │ │ ├── cmsis_gcc.h │ │ ├── core_cm0.h │ │ ├── core_cm0plus.h │ │ ├── core_cm3.h │ │ ├── core_cm4.h │ │ ├── core_cm7.h │ │ ├── core_cmFunc.h │ │ ├── core_cmInstr.h │ │ ├── core_cmSimd.h │ │ ├── core_sc000.h │ │ └── core_sc300.h │ └── cmsis_boot │ │ ├── startup │ │ └── startup_stm32f767xx.s │ │ ├── stm32f767xx.h │ │ ├── stm32f7xx.h │ │ ├── system_stm32f7xx.c │ │ └── system_stm32f7xx.h ├── diag │ ├── diag.c │ └── diag.h ├── drivers │ ├── adv7511 │ │ ├── adv7511.c │ │ └── adv7511.h │ ├── crc │ │ ├── crc.c │ │ └── crc.h │ ├── disp │ │ ├── disp.c │ │ └── disp.h │ ├── joyst │ │ ├── joyst.c │ │ └── joyst.h │ ├── rng │ │ ├── rng.c │ │ └── rng.h │ ├── sdcard │ │ ├── diskio.c │ │ ├── diskio.h │ │ ├── sdcard.c │ │ └── sdcard.h │ ├── sdram │ │ ├── sdram.c │ │ └── sdram.h │ ├── sidbus │ │ ├── sidbus.c │ │ └── sidbus.h │ ├── timer │ │ ├── timer.c │ │ └── timer.h │ ├── usbd_ll │ │ ├── usbd_conf.c │ │ └── usbd_conf.h │ └── usbh_ll │ │ ├── usbh_conf.c │ │ └── usbh_conf.h ├── hal │ ├── Legacy │ │ └── stm32_hal_legacy.h │ ├── stm32f7xx_hal.c │ ├── stm32f7xx_hal.h │ ├── stm32f7xx_hal_conf.h │ ├── stm32f7xx_hal_cortex.c │ ├── stm32f7xx_hal_cortex.h │ ├── stm32f7xx_hal_crc.c │ ├── stm32f7xx_hal_crc.h │ ├── stm32f7xx_hal_crc_ex.c │ ├── stm32f7xx_hal_crc_ex.h │ ├── stm32f7xx_hal_def.h │ ├── stm32f7xx_hal_dma.c │ ├── stm32f7xx_hal_dma.h │ ├── stm32f7xx_hal_dma2d.h │ ├── stm32f7xx_hal_dma_ex.c │ ├── stm32f7xx_hal_dma_ex.h │ ├── stm32f7xx_hal_flash.c │ ├── stm32f7xx_hal_flash.h │ ├── stm32f7xx_hal_flash_ex.c │ ├── stm32f7xx_hal_flash_ex.h │ ├── stm32f7xx_hal_gpio.c │ ├── stm32f7xx_hal_gpio.h │ ├── stm32f7xx_hal_gpio_ex.h │ ├── stm32f7xx_hal_hcd.c │ ├── stm32f7xx_hal_hcd.h │ ├── stm32f7xx_hal_i2c.c │ ├── stm32f7xx_hal_i2c.h │ ├── stm32f7xx_hal_i2c_ex.c │ ├── stm32f7xx_hal_i2c_ex.h │ ├── stm32f7xx_hal_ltdc.c │ ├── stm32f7xx_hal_ltdc.h │ ├── stm32f7xx_hal_ltdc_ex.c │ ├── stm32f7xx_hal_ltdc_ex.h │ ├── stm32f7xx_hal_pcd.c │ ├── stm32f7xx_hal_pcd.h │ ├── stm32f7xx_hal_pcd_ex.c │ ├── stm32f7xx_hal_pcd_ex.h │ ├── stm32f7xx_hal_pwr.c │ ├── stm32f7xx_hal_pwr.h │ ├── stm32f7xx_hal_pwr_ex.c │ ├── stm32f7xx_hal_pwr_ex.h │ ├── stm32f7xx_hal_rcc.c │ ├── stm32f7xx_hal_rcc.h │ ├── stm32f7xx_hal_rcc_ex.c │ ├── stm32f7xx_hal_rcc_ex.h │ ├── stm32f7xx_hal_rng.c │ ├── stm32f7xx_hal_rng.h │ ├── stm32f7xx_hal_sd.c │ ├── stm32f7xx_hal_sd.h │ ├── stm32f7xx_hal_sdram.c │ ├── stm32f7xx_hal_sdram.h │ ├── stm32f7xx_hal_tim.c │ ├── stm32f7xx_hal_tim.h │ ├── stm32f7xx_hal_tim_ex.c │ ├── stm32f7xx_hal_tim_ex.h │ ├── stm32f7xx_ll_fmc.c │ ├── stm32f7xx_ll_fmc.h │ ├── stm32f7xx_ll_sdmmc.c │ ├── stm32f7xx_ll_sdmmc.h │ ├── stm32f7xx_ll_usb.c │ └── stm32f7xx_ll_usb.h ├── hostif │ ├── hostif.c │ └── hostif.h ├── irq │ ├── irq.c │ └── irq.h ├── main │ ├── main.c │ └── main.h ├── mware │ ├── fatfs │ │ ├── ccsbcs.c │ │ ├── ff.c │ │ ├── ff.h │ │ ├── ffconf.h │ │ └── integer.h │ └── usb │ │ ├── device │ │ ├── cdc │ │ │ ├── usbd_cdc.c │ │ │ └── usbd_cdc.h │ │ ├── core │ │ │ ├── usbd_core.c │ │ │ ├── usbd_core.h │ │ │ ├── usbd_ctlreq.c │ │ │ ├── usbd_ctlreq.h │ │ │ ├── usbd_def.h │ │ │ ├── usbd_ioreq.c │ │ │ └── usbd_ioreq.h │ │ └── cust │ │ │ ├── usbd_cdc_if.c │ │ │ ├── usbd_cdc_if.h │ │ │ ├── usbd_desc.c │ │ │ └── usbd_desc.h │ │ └── host │ │ ├── core │ │ ├── usbh_core.c │ │ ├── usbh_core.h │ │ ├── usbh_ctlreq.c │ │ ├── usbh_ctlreq.h │ │ ├── usbh_def.h │ │ ├── usbh_ioreq.c │ │ ├── usbh_ioreq.h │ │ ├── usbh_pipes.c │ │ └── usbh_pipes.h │ │ └── hid │ │ ├── usbh_hid.c │ │ ├── usbh_hid.h │ │ ├── usbh_hid_keybd.c │ │ ├── usbh_hid_keybd.h │ │ ├── usbh_hid_parser.c │ │ ├── usbh_hid_parser.h │ │ └── usbh_hid_usage.h ├── rom │ ├── romcc.c │ ├── romcc.h │ ├── romdd.c │ └── romdd.h ├── sm │ ├── sm.c │ └── sm.h └── util │ ├── console │ ├── console.c │ └── console.h │ ├── keybd │ ├── keybd.c │ └── keybd.h │ └── stage │ ├── stage.c │ └── stage.h ├── if └── if.h ├── link.ld ├── out_target ├── target.bin └── target.elf ├── pcb ├── case │ ├── memwa2.skp │ └── memwa2.stl └── mk2 │ ├── gerber.zip │ ├── layer_stack.jpg │ ├── model.3ds │ ├── part_list.txt │ ├── schematics.pdf │ └── schematics.png └── sdcard.zip /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled source # 2 | ################### 3 | *.o 4 | 5 | # Compiled folders # 6 | ################### 7 | out_bl/ 8 | out_libemucc/ 9 | out_libemudd/ 10 | 11 | # Packages # 12 | ############ 13 | *.7z 14 | *.dmg 15 | *.gz 16 | *.iso 17 | *.jar 18 | *.rar 19 | *.tar 20 | *.zip 21 | 22 | # Misc # 23 | ###################### 24 | *.map 25 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | *** Building software: 2 | 3 | 1. Download the gnu arm cross compiler package 4 | 2. Download memwa2 source code from github 5 | 3. Extract everything and enter folder memwa2 6 | 4. Modify PATH variable to include the bin folder for cross compiler 7 | 5. Make 8 | 6. Done 9 | 10 | *** Flashing software: 11 | 12 | 1. Copy the file ./out_target/target.bin to the root directory on the sdcard 13 | 2. Insert the SD card and startup hardware 14 | 3. New firmware will automatically start flash procedure if firmware file is found 15 | 4. If software is flashed successfully the target.bin file will be removed 16 | 17 | *** SD card: 18 | 19 | There are some folders that can be added to the sdcard 20 | in order to configure the software and to run programs. 21 | 22 | "conf" folder 23 | 24 | "key.cfg" file 25 | 26 | This file contain entries like this -> "2A:0,0". This specific entry 27 | means that the USB scan code 2A (back space) should be mapped 28 | to the commodore key matrix equivalent of 0 and 0. In other words 29 | the CIA1 IC portA bit 0 and CIA1 portB bit 0 will have a connection. 30 | 31 | "palette.cfg" file 32 | 33 | This file contains all c64 colors in RGB888 format. In addition to this 34 | it also contains 3 extra colors that are used for text background, 35 | text forground and marker. 36 | 37 | "d64, t64, tap, prg" folders 38 | 39 | Here all programs should be stored. 40 | 41 | "rom" folder 42 | 43 | "cc_brom.bin" 44 | 45 | Contains the basic rom. 46 | 47 | "cc_crom.bin" 48 | 49 | Contains the char rom. 50 | 51 | "cc_krom.bin" 52 | 53 | Contains the kernal rom. 54 | 55 | "dd_dos.bin" 56 | 57 | Contains the disk drive rom. 58 | 59 | "res" folder 60 | 61 | Contains the bitmaps used in menu. 62 | 63 | *** Startup: 64 | 65 | 1. Unzip the sdcard.zip file onto an sdcard 66 | 2. Insert sdcard into memwa2 board 67 | 3. Power on 68 | 69 | *** Key shortcuts: 70 | 71 | Ctrl + Esc: Menu 72 | Ctrl + F1: Show info 73 | Ctrl + F2: Activate/deactivate disk drive 74 | Ctrl + F3: Activate/deactivate freq lock 75 | Ctrl + F4: Full/half emulated frame rate 76 | Ctrl + F5: Play/Stop datasette 77 | Ctrl + F6: Clear last message 78 | Ctrl + F9: C64 palette 79 | Ctrl + F10: C64 soft reset 80 | Ctrl + F11: C64 hard reset 81 | Ctrl + F12: Hardware reset 82 | Joystick A: Arrow keys 83 | Joystick B: Num keys 84 | 85 | *** Design: 86 | 87 | +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ ^ 88 | Emulators | vic | | tap | | sid | | cia | | cpu | | bus | | via | | fdd | | cpu | | bus | | 89 | +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ | 90 | | 91 | +---------------------------------------------+ +-----------------------------+ + 92 | | emuccif | | emuddif | Emulator 93 | +----------------------+----------------------+ +---------------+-------------+ 94 | Interface | | 95 | +----------------------+-------------------------------------------+-------------+ 96 | | hostif | Hardware 97 | +--------------------------------------------------------------------------------+ + 98 | | 99 | +-----------+ | 100 | Higher layer +-------+ sm | | 101 | | +-----+-----+ | 102 | | | | 103 | +-----+----+ +-----+-----+ +-----------+ | 104 | Util layer | stage | | keybd | | console | | 105 | +----------+ +-----+-----+ +---------+-+ | 106 | | | | 107 | +-----------+ | +------------+ | | 108 | Mware layer | fatfs | +-+ usb +---+ | 109 | +-----------+ +------------+ | 110 | | 111 | +-------+ +---+ +----+ +-----+ +---+ +------+ +-----+ +------+ +-------+ +-------+ | 112 | Driver layer |adv7511| |crc| |disp| |joyst| |rng| |sdcard| |sdram| |sidbus| |usbd_ll| |usbh_ll| | 113 | +-------+ +---+ +----+ +-----+ +---+ +------+ +-----+ +------+ +-------+ +-------+ | 114 | | 115 | +--------------------------------------------------------------------------------+ | 116 | HAL layer | HAL | | 117 | +--------------------------------------------------------------------------------+ v 118 | 119 | 120 | -------------------------------------------------------------------------------- /bl/bl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 bootloader 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | #ifndef _BL_H 25 | #define _BL_H 26 | 27 | #include "stm32f7xx_hal.h" 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /emucc/bus.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 emulator bus 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | #ifndef _BUS_H 25 | #define _BUS_H 26 | 27 | #include "emuccif.h" 28 | 29 | /* MEMORY SIZE */ 30 | 31 | #define MEMORY_RAM_SIZE 0x10000 32 | #define MEMORY_KROM_SIZE 0x2000 33 | #define MEMORY_BROM_SIZE 0x2000 34 | #define MEMORY_CROM_SIZE 0x1000 35 | #define MEMORY_IO_SIZE 0x10000 36 | #define MEMORY_VIC_SIZE 0x400 37 | #define MEMORY_SID_SIZE 0x400 38 | 39 | /* MEMORY OFFSETS */ 40 | 41 | #define OFFSET_RAM 0x0000 42 | #define OFFSET_CROM 0xD000 43 | #define OFFSET_STACK 0x0100 44 | #define OFFSET_COLOR_RAM 0xD800 45 | 46 | typedef uint8_t (*bus_event_read_t)(uint16_t addr); 47 | typedef void (*bus_event_write_t)(uint16_t addr, uint8_t value); 48 | 49 | typedef enum 50 | { 51 | MEMORY_RAM, 52 | MEMORY_KROM, 53 | MEMORY_BROM, 54 | MEMORY_CROM, 55 | MEMORY_IO, 56 | MEMORY_UTIL1, 57 | MEMORY_UTIL2 58 | } memory_bank_t; 59 | 60 | typedef struct 61 | { 62 | uint8_t *ram_p; 63 | uint8_t *krom_p; 64 | uint8_t *brom_p; 65 | uint8_t *crom_p; 66 | uint8_t *io_p; 67 | bus_event_read_t *event_read_fpp; 68 | bus_event_write_t *event_write_fpp; 69 | } memory_t; 70 | 71 | void bus_init(); 72 | void bus_mem_conifig(uint8_t mem_config); 73 | uint8_t bus_read_byte(uint16_t addr); 74 | void bus_write_byte(uint16_t addr, uint8_t byte); 75 | void bus_set_memory(uint8_t *mem_p, memory_bank_t memory_bank); 76 | uint8_t *bus_translate_emu_to_host_addr(uint16_t addr); 77 | void bus_event_read_subscribe(uint16_t addr, bus_event_read_t bus_event_read_fp); 78 | void bus_event_read_unsubscribe(uint16_t addr, bus_event_read_t bus_event_read_fp); 79 | void bus_event_write_subscribe(uint16_t addr, bus_event_write_t bus_event_write_fp); 80 | void bus_event_write_unsubscribe(uint16_t addr, bus_event_write_t bus_event_write_fp); 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /emucc/cpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 cpu component 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | #ifndef _CPU_H 25 | #define _CPU_H 26 | 27 | #include "emuccif.h" 28 | 29 | #define PORT_DIRECTION_DEFAULT 0x2F 30 | #define PORT_DEFAULT 0x37 31 | 32 | #define REG_PORT_DIRECTION 0x0000 33 | #define REG_PORT_INPUT_OUTPUT 0x0001 34 | 35 | typedef struct 36 | { 37 | uint8_t addr_zero; 38 | uint8_t addr_one; 39 | } cpu_on_chip_port_t; 40 | 41 | #define INTR_NMI 0x0 42 | #define INTR_IRQ 0x1 43 | 44 | uint32_t cpu_step(); 45 | void cpu_init(); 46 | void cpu_reset(); 47 | void cpu_clear_nmi(); 48 | uint8_t cpu_get_nmi(); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /emucc/emuccif.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 host-emulator interface 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | #ifndef _EMUCCIF_H 24 | #define _EMUCCIF_H 25 | 26 | typedef unsigned char uint8_t; 27 | typedef signed char int8_t; 28 | typedef unsigned short uint16_t; 29 | typedef signed short int16_t; 30 | typedef unsigned int uint32_t; 31 | typedef signed int int32_t; 32 | 33 | #define UPPER_BORDER 32 34 | #define LOWER_BORDER 50 35 | #define LEFT_BORDER 44 36 | #define RIGHT_BORDER 36 37 | #define FORGROUND_WIDTH (320 + LEFT_BORDER + RIGHT_BORDER) 38 | #define FORGROUND_HEIGHT (200 + UPPER_BORDER + LOWER_BORDER) 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /emucc/joy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 joystick component 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | /** 25 | * Contains functions for controlling the keyboard matrix 26 | * connected to the joysticks. These functions will indirectly 27 | * inform CIA about which keys that are pressed. 28 | */ 29 | 30 | #include "joy.h" 31 | #include 32 | 33 | /* First is joystick A and B, second is direction. Contains action status */ 34 | joy_action_state_t g_joy_action_state_aa[2][5] = 35 | { 36 | {0, 0, 0, 0, 0}, 37 | {0, 0, 0, 0, 0} 38 | }; 39 | 40 | /* First is joystick A and B, second is direction. Contains source for an action */ 41 | static joy_action_source_t g_joy_action_source_aa[2][5] = 42 | { 43 | {0, 0, 0, 0, 0}, 44 | {0, 0, 0, 0, 0} 45 | }; 46 | 47 | void joy_set(joy_port_t joy_port, 48 | joy_action_t joy_action, 49 | joy_action_state_t joy_action_state, 50 | joy_action_source_t joy_action_source) 51 | { 52 | switch(joy_action_source) 53 | { 54 | case JOY_ACTION_SOURCE_JOY: 55 | g_joy_action_state_aa[joy_port][joy_action] = joy_action_state; 56 | g_joy_action_source_aa[joy_port][joy_action] = joy_action_source; 57 | break; 58 | case JOY_ACTION_SOURCE_KEY: 59 | /* If joy is pressed and action was set by the joystick itself... */ 60 | if(g_joy_action_state_aa[joy_port][joy_action] == JOY_ACTION_STATE_PRESSED && 61 | g_joy_action_source_aa[joy_port][joy_action] == JOY_ACTION_SOURCE_JOY) 62 | { 63 | ; /* Then action by keyboard should be ignored */ 64 | } 65 | else 66 | { 67 | /* In any other case it is safe to let keyboard action modify state */ 68 | g_joy_action_state_aa[joy_port][joy_action] = joy_action_state; 69 | g_joy_action_source_aa[joy_port][joy_action] = joy_action_source; 70 | } 71 | break; 72 | } 73 | 74 | } 75 | 76 | void joy_clear(joy_action_source_t joy_action_source) 77 | { 78 | uint8_t i; 79 | uint8_t k; 80 | 81 | for(i = 0; i < 2; i++) 82 | { 83 | for(k = 0; k < 5; k ++) 84 | { 85 | if(g_joy_action_source_aa[i][k] == joy_action_source) 86 | { 87 | g_joy_action_state_aa[i][k] = JOY_ACTION_STATE_RELEASED; 88 | } 89 | } 90 | } 91 | } 92 | 93 | uint8_t joy_init() 94 | { 95 | memset(g_joy_action_state_aa, 0x00, sizeof(g_joy_action_state_aa)); 96 | return 0; 97 | } 98 | -------------------------------------------------------------------------------- /emucc/joy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 joystick component 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | #ifndef _JOY_H 25 | #define _JOY_H 26 | 27 | #include "emuccif.h" 28 | 29 | #define JOY_A_UP_PORT_VAL 0xFE /* Connected to PB0 */ 30 | #define JOY_A_DOWN_PORT_VAL 0xFD /* Connected to PB1 */ 31 | #define JOY_A_LEFT_PORT_VAL 0xFB /* Connected to PB2 */ 32 | #define JOY_A_RIGHT_PORT_VAL 0xF7 /* Connected to PB3 */ 33 | #define JOY_A_FIRE_PORT_VAL 0xEF /* Connected to PB4 */ 34 | 35 | #define JOY_B_UP_PORT_VAL 0xFE /* Connected to PA0 */ 36 | #define JOY_B_DOWN_PORT_VAL 0xFD /* Connected to PA1 */ 37 | #define JOY_B_LEFT_PORT_VAL 0xFB /* Connected to PA2 */ 38 | #define JOY_B_RIGHT_PORT_VAL 0xF7 /* Connected to PA3 */ 39 | #define JOY_B_FIRE_PORT_VAL 0xEF /* Connected to PA4 */ 40 | 41 | typedef enum 42 | { 43 | JOY_PORT_A, 44 | JOY_PORT_B 45 | } joy_port_t; 46 | 47 | typedef enum 48 | { 49 | JOY_ACTION_UP, 50 | JOY_ACTION_DOWN, 51 | JOY_ACTION_RIGHT, 52 | JOY_ACTION_LEFT, 53 | JOY_ACTION_FIRE 54 | } joy_action_t; 55 | 56 | typedef enum 57 | { 58 | JOY_ACTION_STATE_RELEASED, 59 | JOY_ACTION_STATE_PRESSED 60 | } joy_action_state_t; 61 | 62 | typedef enum 63 | { 64 | JOY_ACTION_SOURCE_JOY, /* Will always have priority */ 65 | JOY_ACTION_SOURCE_KEY 66 | } joy_action_source_t; 67 | 68 | void joy_set(joy_port_t joy_port, 69 | joy_action_t joy_action, 70 | joy_action_state_t joy_action_state, 71 | joy_action_source_t joy_action_source); 72 | void joy_clear(joy_action_source_t joy_action_source); 73 | uint8_t joy_init(); 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /emucc/key.c: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 keyboard component 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | /** 25 | * Contains functions for controlling the keyboard matrix 26 | * connected to the keyboard. These functions will indirectly 27 | * inform CIA about which keys that are pressed. 28 | */ 29 | 30 | #include "key.h" 31 | #include "joy.h" 32 | #include 33 | 34 | #define JOYSTICK1_UP_PORT_VAL 0xFE 35 | #define JOYSTICK1_DOWN_PORT_VAL 0xFD 36 | #define JOYSTICK1_LEFT_PORT_VAL 0xFB 37 | #define JOYSTICK1_RIGHT_PORT_VAL 0xF7 38 | #define JOYSTICK1_FIRE_PORT_VAL 0xEF 39 | 40 | #define JOYSTICK2_UP_PORT_VAL 0xFE 41 | #define JOYSTICK2_DOWN_PORT_VAL 0xFD 42 | #define JOYSTICK2_LEFT_PORT_VAL 0xFB 43 | #define JOYSTICK2_RIGHT_PORT_VAL 0xF7 44 | #define JOYSTICK2_FIRE_PORT_VAL 0xEF 45 | 46 | typedef enum 47 | { 48 | KEY_RELEASE, 49 | KEY_PRESS 50 | } key_state_t; 51 | 52 | typedef struct 53 | { 54 | uint8_t matrix_x; 55 | uint8_t matrix_y; 56 | uint8_t active; 57 | } key_map_t; 58 | 59 | typedef struct 60 | { 61 | uint8_t col; 62 | uint8_t row; 63 | } key_coor_t; 64 | 65 | /* Contains matrix of pushed keys */ 66 | uint8_t g_matrix_active_aa[8][8]; 67 | 68 | static key_map_t g_key_map_a[256]; /* No scan code is larger than this it seems */ 69 | 70 | void key_pressed(uint8_t key, uint8_t shift, uint8_t ctrl) 71 | { 72 | if(shift == KEY_PRESS) 73 | { 74 | g_matrix_active_aa[0x7][0x1] = KEY_PRESS; 75 | } 76 | 77 | if(ctrl == KEY_PRESS) 78 | { 79 | g_matrix_active_aa[0x2][0x7] = KEY_PRESS; 80 | } 81 | 82 | if(g_key_map_a[key].active) 83 | { 84 | if(g_key_map_a[key].matrix_x < 8 && g_key_map_a[key].matrix_y < 8) 85 | { 86 | /* Normal key */ 87 | g_matrix_active_aa[g_key_map_a[key].matrix_x][g_key_map_a[key].matrix_y] = KEY_PRESS; 88 | } 89 | else 90 | { 91 | /* Joystick key */ 92 | if(g_key_map_a[key].matrix_x == 8) /* This means joystick A */ 93 | { 94 | switch(g_key_map_a[key].matrix_y) 95 | { 96 | case 0: 97 | joy_set(JOY_PORT_A, JOY_ACTION_UP, JOY_ACTION_STATE_PRESSED, JOY_ACTION_SOURCE_KEY); 98 | break; 99 | case 1: 100 | joy_set(JOY_PORT_A, JOY_ACTION_DOWN, JOY_ACTION_STATE_PRESSED, JOY_ACTION_SOURCE_KEY); 101 | break; 102 | case 2: 103 | joy_set(JOY_PORT_A, JOY_ACTION_RIGHT, JOY_ACTION_STATE_PRESSED, JOY_ACTION_SOURCE_KEY); 104 | break; 105 | case 3: 106 | joy_set(JOY_PORT_A, JOY_ACTION_LEFT, JOY_ACTION_STATE_PRESSED, JOY_ACTION_SOURCE_KEY); 107 | break; 108 | case 4: 109 | joy_set(JOY_PORT_A, JOY_ACTION_FIRE, JOY_ACTION_STATE_PRESSED, JOY_ACTION_SOURCE_KEY); 110 | break; 111 | } 112 | } 113 | else if(g_key_map_a[key].matrix_y == 8) /* This means joystick B */ 114 | { 115 | switch(g_key_map_a[key].matrix_x) 116 | { 117 | case 0: 118 | joy_set(JOY_PORT_B, JOY_ACTION_UP, JOY_ACTION_STATE_PRESSED, JOY_ACTION_SOURCE_KEY); 119 | break; 120 | case 1: 121 | joy_set(JOY_PORT_B, JOY_ACTION_DOWN, JOY_ACTION_STATE_PRESSED, JOY_ACTION_SOURCE_KEY); 122 | break; 123 | case 2: 124 | joy_set(JOY_PORT_B, JOY_ACTION_RIGHT, JOY_ACTION_STATE_PRESSED, JOY_ACTION_SOURCE_KEY); 125 | break; 126 | case 3: 127 | joy_set(JOY_PORT_B, JOY_ACTION_LEFT, JOY_ACTION_STATE_PRESSED, JOY_ACTION_SOURCE_KEY); 128 | break; 129 | case 4: 130 | joy_set(JOY_PORT_B, JOY_ACTION_FIRE, JOY_ACTION_STATE_PRESSED, JOY_ACTION_SOURCE_KEY); 131 | break; 132 | } 133 | } 134 | } 135 | } 136 | } 137 | 138 | void key_clear_keys() 139 | { 140 | memset(g_matrix_active_aa, 0, sizeof(g_matrix_active_aa)); 141 | } 142 | 143 | void key_map_insert(uint8_t scan_code, uint8_t matrix_x, uint8_t matrix_y) 144 | { 145 | g_key_map_a[scan_code].matrix_x = matrix_x; 146 | g_key_map_a[scan_code].matrix_y = matrix_y; 147 | g_key_map_a[scan_code].active = 1; 148 | } 149 | 150 | uint8_t key_init() 151 | { 152 | uint8_t i; 153 | uint8_t k; 154 | 155 | memset(g_matrix_active_aa, 0x00, sizeof(g_matrix_active_aa)); 156 | 157 | for(i = 0; i < 2; i++) 158 | { 159 | for(k = 0; k < 5; k++) 160 | { 161 | joy_set(i, k, JOY_ACTION_STATE_RELEASED, JOY_ACTION_SOURCE_KEY); 162 | } 163 | } 164 | 165 | return 0; 166 | } 167 | -------------------------------------------------------------------------------- /emucc/key.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 keyboard component 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | #ifndef _KEY_H 25 | #define _KEY_H 26 | 27 | #include "emuccif.h" 28 | 29 | #define REG_KEY_PORT_A 0xDC00 30 | #define REG_KEY_PORT_B 0xDC01 31 | 32 | void key_pressed(uint8_t key, uint8_t shift, uint8_t ctrl); 33 | void key_clear_keys(); 34 | void key_map_insert(uint8_t scan_code, uint8_t matrix_x, uint8_t matrix_y); 35 | uint8_t key_init(); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /emucc/sid.c: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 sid component 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | /** 25 | * SID implementation (MOS6581) 26 | */ 27 | 28 | #include "sid.h" 29 | #include "bus.h" 30 | #include "if.h" 31 | 32 | extern memory_t g_memory; /* Memory interface */ 33 | extern if_host_t g_if_host; /* Main interface */ 34 | 35 | static void event_write(uint16_t addr, uint8_t value) 36 | { 37 | if(addr >= SID_READ_ONLY_LOW && addr <= SID_READ_ONLY_HIGH) /* Read only */ 38 | { 39 | ; 40 | } 41 | else /* Write only */ 42 | { 43 | g_if_host.if_host_sid.sid_write_fp(addr & 0x1F, value); 44 | } 45 | } 46 | 47 | static uint8_t event_read(uint16_t addr) 48 | { 49 | if(addr >= SID_READ_ONLY_LOW && addr <= SID_READ_ONLY_HIGH) /* Read only */ 50 | { 51 | return g_if_host.if_host_sid.sid_read_fp(addr & 0x1F); 52 | } 53 | else /* Write only */ 54 | { 55 | return 0; 56 | } 57 | } 58 | 59 | void sid_init() 60 | { 61 | uint32_t i; 62 | 63 | /* Clear */ 64 | for(i = 0; i < 0x20; i++) 65 | { 66 | event_write(0xD400 + i, 0x00); 67 | } 68 | 69 | /* Subscribe to sid write address range */ 70 | for(i = 0; i < 0x20; i++) 71 | { 72 | bus_event_write_subscribe(0xD400 + i, event_write); 73 | } 74 | 75 | /* Subscribe to sid read address range */ 76 | for(i = 0; i < 0x20; i++) 77 | { 78 | bus_event_read_subscribe(0xD400 + i, event_read); 79 | } 80 | } 81 | 82 | 83 | -------------------------------------------------------------------------------- /emucc/sid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 sid component 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | #ifndef _SID_H 25 | #define _SID_H 26 | 27 | #include "emuccif.h" 28 | 29 | #define SID_READ_ONLY_LOW 0xD419 30 | #define SID_READ_ONLY_HIGH 0xD41C 31 | 32 | void sid_init(); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /emucc/tap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 tape (datasette) component 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | #ifndef _TAP_H 25 | #define _TAP_H 26 | 27 | #include "emuccif.h" 28 | 29 | #define MASK_DATASETTE_OUTPUT_SIGNAL_LEVEL 0x08 30 | #define MASK_DATASETTE_BUTTON_STATUS 0x10 31 | #define MASK_DATASETTE_MOTOR_CTRL 0x20 32 | 33 | void tap_init(); 34 | void tap_play(); 35 | void tap_step(uint8_t cc); 36 | void tap_stop(); 37 | void tap_insert_tape(uint32_t *fd_p); 38 | void tap_set_motor(uint8_t status); 39 | uint8_t tap_get_play(); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /emucc/vic.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Staringlizard/memwa2/4eb942e0ed6235af7c8ab64a5269c08a0e9c2924/emucc/vic.h -------------------------------------------------------------------------------- /emudd/bus.c: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 emulator bus 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | /** 25 | * This is the main bus for the emulator. The cpu is connected to this bus 26 | * and all data communication from and to the cpu will go through these functions 27 | * (bus_read_byte, bus_write_byte). 28 | * All emulated components can subscribe to a memory address on this bus so that 29 | * they will get a callback when read or write events takes place for the address. 30 | */ 31 | 32 | #include "bus.h" 33 | #include "cpu.h" 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | /* MEMORY MAP */ 40 | 41 | /* 42 | * +----------------------------+ 43 | * |16KB ROM, DOS and controller| 44 | * C000-FFFF | routines | 45 | * +----------------------------+ 46 | * 1C00-180F | VIA 2 | 47 | * +----------------------------+ 48 | * 1800-180F | VIA 1 | 49 | * +----------------------------+ 50 | * 0000-07FF | 2K RAM | 51 | * +----------------------------+ 52 | */ 53 | 54 | typedef enum 55 | { 56 | MEMORY_TYPE_READ_WRITE, 57 | MEMORY_TYPE_READ_ONLY, 58 | MEMORY_TYPE_WRITE_ONLY 59 | } memory_type_t; 60 | 61 | typedef struct 62 | { 63 | uint8_t *memory_p; 64 | memory_type_t memory_type; 65 | } memory_config_t; 66 | 67 | static memory_config_t g_memory_config_a[2]; 68 | memory_dd_t g_memory_dd; 69 | 70 | static void bus_dd_mem_conifig() 71 | { 72 | g_memory_config_a[0].memory_p = g_memory_dd.all_p; 73 | g_memory_config_a[0].memory_type = MEMORY_TYPE_READ_WRITE; /* Ok, not really true, but this is not needed anyway... */ 74 | } 75 | 76 | void bus_dd_set_memory(uint8_t *mem_p, memory_bank_dd_t memory_bank) 77 | { 78 | switch(memory_bank) 79 | { 80 | case MEMORY_ALL: 81 | g_memory_dd.all_p = mem_p; 82 | break; 83 | case MEMORY_UTIL1: 84 | g_memory_dd.event_read_fpp = (bus_event_read_t *)mem_p; 85 | break; 86 | case MEMORY_UTIL2: 87 | g_memory_dd.event_write_fpp = (bus_event_write_t *)mem_p; 88 | break; 89 | } 90 | } 91 | 92 | /* Subscriptions can only be made for io and for ram memory up to address 0xA000 */ 93 | void bus_dd_event_read_subscribe(uint16_t addr, bus_event_read_t bus_event_read_fp) 94 | { 95 | g_memory_dd.event_read_fpp[addr] = bus_event_read_fp; 96 | } 97 | 98 | void bus_dd_event_read_unsubscribe(uint16_t addr, bus_event_read_t bus_event_read_fp) 99 | { 100 | g_memory_dd.event_read_fpp[addr] = bus_event_read_fp; 101 | } 102 | 103 | void bus_dd_event_write_subscribe(uint16_t addr, bus_event_write_t bus_event_write_fp) 104 | { 105 | g_memory_dd.event_write_fpp[addr] = bus_event_write_fp; 106 | } 107 | 108 | void bus_dd_event_write_unsubscribe(uint16_t addr, bus_event_write_t bus_event_write_fp) 109 | { 110 | g_memory_dd.event_write_fpp[addr] = NULL; 111 | } 112 | 113 | void bus_dd_init() 114 | { 115 | memset(g_memory_dd.all_p, 0, MEMORY_RAM_SIZE); 116 | 117 | bus_dd_mem_conifig(); 118 | } 119 | 120 | uint8_t bus_dd_read_byte(uint16_t addr) 121 | { 122 | if(addr >= MEMORY_ALL && addr < (MEMORY_ALL + MEMORY_ALL_SIZE)) 123 | { 124 | if(g_memory_dd.event_read_fpp[addr] != NULL) 125 | { 126 | /* If subscribed, then bus takes no responsibility for this address */ 127 | return g_memory_dd.event_read_fpp[addr](addr); 128 | } 129 | 130 | return g_memory_config_a[0].memory_p[addr]; 131 | } 132 | else 133 | { 134 | assert(0); 135 | } 136 | } 137 | 138 | void bus_dd_write_byte(uint16_t addr, uint8_t byte) 139 | { 140 | if(addr >= MEMORY_ALL && addr < (MEMORY_ALL + MEMORY_ALL_SIZE)) 141 | { 142 | if(g_memory_dd.event_write_fpp[addr] != NULL) 143 | { 144 | /* If subscribed, then bus takes no responsibility for this address */ 145 | g_memory_dd.event_write_fpp[addr](addr, byte); 146 | return; 147 | } 148 | 149 | g_memory_config_a[0].memory_p[addr] = byte; 150 | } 151 | else 152 | { 153 | assert(0); 154 | } 155 | } 156 | 157 | uint8_t *bus_dd_translate_emu_to_host_addr(uint16_t addr) 158 | { 159 | if(addr >= MEMORY_ALL && addr < (MEMORY_ALL + MEMORY_ALL_SIZE)) 160 | { 161 | return g_memory_config_a[0].memory_p + addr; 162 | } 163 | else 164 | { 165 | assert(0); 166 | } 167 | 168 | return 0; 169 | } 170 | -------------------------------------------------------------------------------- /emudd/bus.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 emulator bus 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | #ifndef _BUS_H 25 | #define _BUS_H 26 | 27 | #include "emuddif.h" 28 | 29 | /* MEMORY SIZE */ 30 | 31 | #define MEMORY_ALL_SIZE 0x10000 32 | #define MEMORY_RAM_SIZE 0xC000 33 | 34 | /* MEMORY OFFSETS */ 35 | 36 | #define OFFSET_RAM 0x0000 37 | #define OFFSET_ROM 0xC000 38 | #define OFFSET_STACK 0x0100 39 | 40 | typedef uint8_t (*bus_event_read_t)(uint16_t addr); 41 | typedef void (*bus_event_write_t)(uint16_t addr, uint8_t value); 42 | 43 | typedef enum 44 | { 45 | MEMORY_ALL, 46 | MEMORY_UTIL1, 47 | MEMORY_UTIL2 48 | } memory_bank_dd_t; 49 | 50 | typedef struct 51 | { 52 | uint8_t *all_p; 53 | bus_event_read_t *event_read_fpp; 54 | bus_event_write_t *event_write_fpp; 55 | } memory_dd_t; 56 | 57 | void bus_dd_init(); 58 | uint8_t bus_dd_read_byte(uint16_t addr); 59 | void bus_dd_write_byte(uint16_t addr, uint8_t byte); 60 | void bus_dd_set_memory(uint8_t *mem_p, memory_bank_dd_t memory_bank); 61 | uint8_t *bus_dd_translate_emu_to_host_addr(uint16_t addr); 62 | void bus_dd_event_read_subscribe(uint16_t addr, bus_event_read_t bus_event_read_fp); 63 | void bus_dd_event_read_unsubscribe(uint16_t addr, bus_event_read_t bus_event_read_fp); 64 | void bus_dd_event_write_subscribe(uint16_t addr, bus_event_write_t bus_event_write_fp); 65 | void bus_dd_event_write_unsubscribe(uint16_t addr, bus_event_write_t bus_event_write_fp); 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /emudd/cpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 cpu component 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | #ifndef _CPU_H 25 | #define _CPU_H 26 | 27 | #include "emuddif.h" 28 | 29 | #define INTR_IRQ 0x1 30 | 31 | uint32_t cpu_dd_step(); 32 | void cpu_dd_reset(); 33 | void cpu_dd_boot(); 34 | void cpu_dd_init(); 35 | void cpu_jump_to_emu_addr(uint16_t addr); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /emudd/emuddif.c: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 host-emulator interface 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | /** 25 | * DD (Disk Drive) interface implemenation. Contains all functions 26 | * necessary for the host to work. The interface for this file is dictated 27 | * by if.h file. 28 | */ 29 | 30 | #include "emuddif.h" 31 | #include "bus.h" 32 | #include "via.h" 33 | #include "cpu.h" 34 | #include "if.h" 35 | #include "fdd.h" 36 | 37 | void if_emu_dd_mem_set(uint8_t *mem_p, if_mem_dd_type_t mem_type); 38 | void if_emu_dd_op_init(); 39 | void if_emu_dd_op_run(int32_t cycles); 40 | void if_emu_dd_op_reset(); 41 | void if_emu_dd_disk_drive_load(uint32_t *fd_p); 42 | void if_emu_dd_ports_write_serial(uint8_t data); 43 | 44 | static int32_t g_cycle_queue; 45 | 46 | if_emu_dd_t g_if_dd_emu = 47 | { 48 | { 49 | if_emu_dd_mem_set 50 | }, 51 | { 52 | if_emu_dd_op_init, 53 | if_emu_dd_op_run, 54 | if_emu_dd_op_reset 55 | }, 56 | { 57 | if_emu_dd_disk_drive_load 58 | }, 59 | { 60 | if_emu_dd_ports_write_serial 61 | } 62 | }; 63 | 64 | void if_emu_dd_mem_set(uint8_t *mem_p, if_mem_dd_type_t mem_type) 65 | { 66 | switch(mem_type) 67 | { 68 | case IF_MEM_DD_TYPE_ALL: 69 | case IF_MEM_DD_TYPE_UTIL1: 70 | case IF_MEM_DD_TYPE_UTIL2: 71 | bus_dd_set_memory(mem_p, (memory_bank_dd_t)mem_type); 72 | break; 73 | } 74 | } 75 | 76 | void if_emu_dd_op_init() 77 | { 78 | bus_dd_init(); 79 | via_init(); 80 | cpu_dd_init(); 81 | fdd_init(); 82 | 83 | /* Lets boot it up a bit before halting */ 84 | cpu_dd_boot(); 85 | } 86 | 87 | void if_emu_dd_op_run(int32_t cycles) 88 | { 89 | uint32_t cc = 0; 90 | 91 | g_cycle_queue += cycles; 92 | 93 | while(g_cycle_queue > 0) 94 | { 95 | cc = cpu_dd_step(); 96 | 97 | via_step(cc); 98 | 99 | g_cycle_queue -= cc; 100 | } 101 | } 102 | 103 | void if_emu_dd_op_reset() 104 | { 105 | cpu_dd_reset(); 106 | /* Lets boot it up a bit before halting */ 107 | cpu_dd_boot(); 108 | } 109 | 110 | void if_emu_dd_disk_drive_load(uint32_t *fd_p) 111 | { 112 | fdd_insert_disk(fd_p); 113 | } 114 | 115 | void if_emu_dd_ports_write_serial(uint8_t data) 116 | { 117 | via_serial_port_activity(data); 118 | } 119 | -------------------------------------------------------------------------------- /emudd/emuddif.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 host-emulator interface 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | #ifndef _EMUDDIF_H 25 | #define _EMUDDIF_H 26 | 27 | typedef unsigned char uint8_t; 28 | typedef signed char int8_t; 29 | typedef unsigned short uint16_t; 30 | typedef signed short int16_t; 31 | typedef unsigned int uint32_t; 32 | typedef signed int int32_t; 33 | 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /emudd/fdd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 fdd component 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | 25 | #ifndef _FDD_H 26 | #define _FDD_H 27 | 28 | #include "emuddif.h" 29 | 30 | void fdd_init(); 31 | void fdd_insert_disk(uint32_t *fd_p); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /emudoc/emucc/schematics/c64_1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Staringlizard/memwa2/4eb942e0ed6235af7c8ab64a5269c08a0e9c2924/emudoc/emucc/schematics/c64_1.gif -------------------------------------------------------------------------------- /emudoc/emucc/schematics/c64_2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Staringlizard/memwa2/4eb942e0ed6235af7c8ab64a5269c08a0e9c2924/emudoc/emucc/schematics/c64_2.gif -------------------------------------------------------------------------------- /emudoc/emucc/schematics/keymatrix.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Staringlizard/memwa2/4eb942e0ed6235af7c8ab64a5269c08a0e9c2924/emudoc/emucc/schematics/keymatrix.gif -------------------------------------------------------------------------------- /emudoc/emucc/specs/6526.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Staringlizard/memwa2/4eb942e0ed6235af7c8ab64a5269c08a0e9c2924/emudoc/emucc/specs/6526.pdf -------------------------------------------------------------------------------- /emudoc/emucc/specs/6569.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Staringlizard/memwa2/4eb942e0ed6235af7c8ab64a5269c08a0e9c2924/emudoc/emucc/specs/6569.txt -------------------------------------------------------------------------------- /emudoc/emucc/specs/serial-bus.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Staringlizard/memwa2/4eb942e0ed6235af7c8ab64a5269c08a0e9c2924/emudoc/emucc/specs/serial-bus.pdf -------------------------------------------------------------------------------- /emudoc/emudd/schematics/1541.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Staringlizard/memwa2/4eb942e0ed6235af7c8ab64a5269c08a0e9c2924/emudoc/emudd/schematics/1541.gif -------------------------------------------------------------------------------- /emudoc/emudd/specs/6522.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Staringlizard/memwa2/4eb942e0ed6235af7c8ab64a5269c08a0e9c2924/emudoc/emudd/specs/6522.pdf -------------------------------------------------------------------------------- /hw/config/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 configuration 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | #ifndef _CONFIG_H 25 | #define _CONFIG_H 26 | 27 | #include "stm32f7xx_hal_dma.h" 28 | #include "stm32f7xx_hal_sd.h" 29 | #include "stm32f7xx_hal_hcd.h" 30 | #include "stm32f7xx_hal_i2c.h" 31 | #include "stm32f7xx_hal_sdram.h" 32 | #include "main.h" 33 | 34 | #define SDCARD_CD_PIN GPIO_PIN_7 35 | #define SDCARD_CD_PORT GPIOA 36 | 37 | #define SID_SET_CS_HIGH() \ 38 | GPIOI->BSRR = (1 << 6); 39 | 40 | #define SID_SET_CS_LOW() \ 41 | GPIOI->BSRR = (1 << 6) << 16; 42 | 43 | #define SID_ASSERT_READ() \ 44 | GPIOI->BSRR = (1 << 5); 45 | 46 | #define SID_ASSERT_WRITE() \ 47 | GPIOI->BSRR = (1 << 5) << 16; 48 | 49 | #define SID_SET_DATA(data) \ 50 | GPIOH->BSRR = 0xFF00 << 16; \ 51 | GPIOH->BSRR = data << 8; 52 | 53 | #define SID_SET_ADDR(addr) \ 54 | GPIOI->BSRR = 0x0F80 << 16; \ 55 | GPIOI->BSRR = (addr & 0x1F) << 7; 56 | 57 | #define SID_GET_DATA() \ 58 | (GPIOH->IDR & 0xFF00) >> 8; \ 59 | 60 | 61 | void config_init(); 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /hw/core/cmsis/arm_const_structs.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 19. March 2015 5 | * $Revision: V.1.4.5 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_const_structs.h 9 | * 10 | * Description: This file has constant structs that are initialized for 11 | * user convenience. For example, some can be given as 12 | * arguments to the arm_cfft_f32() function. 13 | * 14 | * Target Processor: Cortex-M4/Cortex-M3 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions 18 | * are met: 19 | * - Redistributions of source code must retain the above copyright 20 | * notice, this list of conditions and the following disclaimer. 21 | * - Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in 23 | * the documentation and/or other materials provided with the 24 | * distribution. 25 | * - Neither the name of ARM LIMITED nor the names of its contributors 26 | * may be used to endorse or promote products derived from this 27 | * software without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 30 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 31 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 32 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 33 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 34 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 35 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 37 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 39 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 40 | * POSSIBILITY OF SUCH DAMAGE. 41 | * -------------------------------------------------------------------- */ 42 | 43 | #ifndef _ARM_CONST_STRUCTS_H 44 | #define _ARM_CONST_STRUCTS_H 45 | 46 | #include "arm_math.h" 47 | #include "arm_common_tables.h" 48 | 49 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len16; 50 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len32; 51 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len64; 52 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len128; 53 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len256; 54 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len512; 55 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024; 56 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048; 57 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096; 58 | 59 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len16; 60 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len32; 61 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len64; 62 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len128; 63 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len256; 64 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len512; 65 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024; 66 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048; 67 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096; 68 | 69 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len16; 70 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len32; 71 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len64; 72 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len128; 73 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len256; 74 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len512; 75 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024; 76 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048; 77 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /hw/core/cmsis/core_cmFunc.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmFunc.h 3 | * @brief CMSIS Cortex-M Core Function Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMFUNC_H 42 | #define __CORE_CMFUNC_H 43 | 44 | 45 | /* ########################### Core Function Access ########################### */ 46 | /** \ingroup CMSIS_Core_FunctionInterface 47 | \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@} end of CMSIS_Core_RegAccFunctions */ 86 | 87 | #endif /* __CORE_CMFUNC_H */ 88 | -------------------------------------------------------------------------------- /hw/core/cmsis/core_cmInstr.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmInstr.h 3 | * @brief CMSIS Cortex-M Core Instruction Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMINSTR_H 42 | #define __CORE_CMINSTR_H 43 | 44 | 45 | /* ########################## Core Instruction Access ######################### */ 46 | /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface 47 | Access to dedicated instructions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@}*/ /* end of group CMSIS_Core_InstructionInterface */ 86 | 87 | #endif /* __CORE_CMINSTR_H */ 88 | -------------------------------------------------------------------------------- /hw/core/cmsis/core_cmSimd.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmSimd.h 3 | * @brief CMSIS Cortex-M SIMD Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMSIMD_H 42 | #define __CORE_CMSIMD_H 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | 49 | /* ################### Compiler specific Intrinsics ########################### */ 50 | /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics 51 | Access to dedicated SIMD instructions 52 | @{ 53 | */ 54 | 55 | /*------------------ RealView Compiler -----------------*/ 56 | #if defined ( __CC_ARM ) 57 | #include "cmsis_armcc.h" 58 | 59 | /*------------------ ARM Compiler V6 -------------------*/ 60 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 61 | #include "cmsis_armcc_V6.h" 62 | 63 | /*------------------ GNU Compiler ----------------------*/ 64 | #elif defined ( __GNUC__ ) 65 | #include "cmsis_gcc.h" 66 | 67 | /*------------------ ICC Compiler ----------------------*/ 68 | #elif defined ( __ICCARM__ ) 69 | #include 70 | 71 | /*------------------ TI CCS Compiler -------------------*/ 72 | #elif defined ( __TMS470__ ) 73 | #include 74 | 75 | /*------------------ TASKING Compiler ------------------*/ 76 | #elif defined ( __TASKING__ ) 77 | /* 78 | * The CMSIS functions have been implemented as intrinsics in the compiler. 79 | * Please use "carm -?i" to get an up to date list of all intrinsics, 80 | * Including the CMSIS ones. 81 | */ 82 | 83 | /*------------------ COSMIC Compiler -------------------*/ 84 | #elif defined ( __CSMC__ ) 85 | #include 86 | 87 | #endif 88 | 89 | /*@} end of group CMSIS_SIMD_intrinsics */ 90 | 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* __CORE_CMSIMD_H */ 97 | -------------------------------------------------------------------------------- /hw/core/cmsis_boot/stm32f767xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Staringlizard/memwa2/4eb942e0ed6235af7c8ab64a5269c08a0e9c2924/hw/core/cmsis_boot/stm32f767xx.h -------------------------------------------------------------------------------- /hw/core/cmsis_boot/stm32f7xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Staringlizard/memwa2/4eb942e0ed6235af7c8ab64a5269c08a0e9c2924/hw/core/cmsis_boot/stm32f7xx.h -------------------------------------------------------------------------------- /hw/core/cmsis_boot/system_stm32f7xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f7xx.h 4 | * @author MCD Application Team 5 | * @version V1.1.2 6 | * @date 23-September-2016 7 | * @brief CMSIS Cortex-M7 Device System Source File for STM32F7xx devices. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2016 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /** @addtogroup CMSIS 39 | * @{ 40 | */ 41 | 42 | /** @addtogroup stm32f7xx_system 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @brief Define to prevent recursive inclusion 48 | */ 49 | #ifndef __SYSTEM_STM32F7XX_H 50 | #define __SYSTEM_STM32F7XX_H 51 | 52 | #ifdef __cplusplus 53 | extern "C" { 54 | #endif 55 | 56 | /** @addtogroup STM32F7xx_System_Includes 57 | * @{ 58 | */ 59 | 60 | /** 61 | * @} 62 | */ 63 | 64 | 65 | /** @addtogroup STM32F7xx_System_Exported_Variables 66 | * @{ 67 | */ 68 | /* The SystemCoreClock variable is updated in three ways: 69 | 1) by calling CMSIS function SystemCoreClockUpdate() 70 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 71 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 72 | Note: If you use this function to configure the system clock; then there 73 | is no need to call the 2 first functions listed above, since SystemCoreClock 74 | variable is updated automatically. 75 | */ 76 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 77 | 78 | extern const uint8_t AHBPrescTable[16]; /*!< AHB prescalers table values */ 79 | extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */ 80 | 81 | 82 | /** 83 | * @} 84 | */ 85 | 86 | /** @addtogroup STM32F7xx_System_Exported_Constants 87 | * @{ 88 | */ 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | /** @addtogroup STM32F7xx_System_Exported_Macros 95 | * @{ 96 | */ 97 | 98 | /** 99 | * @} 100 | */ 101 | 102 | /** @addtogroup STM32F7xx_System_Exported_Functions 103 | * @{ 104 | */ 105 | 106 | extern void SystemInit(void); 107 | extern void SystemCoreClockUpdate(void); 108 | /** 109 | * @} 110 | */ 111 | 112 | #ifdef __cplusplus 113 | } 114 | #endif 115 | 116 | #endif /*__SYSTEM_STM32F7XX_H */ 117 | 118 | /** 119 | * @} 120 | */ 121 | 122 | /** 123 | * @} 124 | */ 125 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 126 | -------------------------------------------------------------------------------- /hw/diag/diag.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 diagnostic 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | 25 | #ifndef _DIAG_H 26 | #define _DIAG_H 27 | 28 | #include "stm32f7xx_hal.h" 29 | #include "main.h" 30 | 31 | typedef enum 32 | { 33 | DIAG_STATUS_OK, 34 | DIAG_STATUS_ERROR_SDRAM, 35 | DIAG_STATUS_ERROR_SDCARD, 36 | DIAG_STATUS_ERROR_I2C, 37 | DIAG_STATUS_ERROR_GRAPHIC, 38 | DIAG_STATUS_ERROR_SID, 39 | DIAG_STATUS_ERROR_KEYBOARD, 40 | } diag_status_t; 41 | 42 | diag_status_t diag_run(); 43 | diag_status_t diag_sdcard_run(); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /hw/drivers/adv7511/adv7511.c: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 adv7511w driver 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | /** 25 | * Handles all communication with the HDMI transmitter. 26 | */ 27 | 28 | #include "adv7511.h" 29 | #include "config.h" 30 | #include "stm32f7xx_hal_i2c.h" 31 | 32 | #define I2C_ADDRESS 0x72 33 | #define I2C_OWN_ADDRESS 0x00 34 | #define I2C_TIMING 0x40912732 35 | 36 | #define ADV7511_REG_IRQ 0x96 37 | #define ADV7511_REG_STATUS 0xC8 38 | #define ADV7511_REG_DETECT 0x42 39 | 40 | static I2C_HandleTypeDef g_i2c_handle; 41 | 42 | __weak void HAL_ADV7511_MspInit() 43 | { 44 | ; 45 | } 46 | 47 | void adv7511_init() 48 | { 49 | HAL_StatusTypeDef ret = HAL_OK; 50 | 51 | g_i2c_handle.Instance = I2C4; 52 | g_i2c_handle.Init.Timing = I2C_TIMING; 53 | g_i2c_handle.Init.OwnAddress1 = I2C_OWN_ADDRESS; 54 | g_i2c_handle.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; 55 | g_i2c_handle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; 56 | g_i2c_handle.Init.OwnAddress2 = I2C_OWN_ADDRESS; 57 | g_i2c_handle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; 58 | g_i2c_handle.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; 59 | 60 | ret = HAL_I2C_Init(&g_i2c_handle); 61 | if(ret != HAL_OK) 62 | { 63 | main_error("Failed to initialize I2C!", __FILE__, __LINE__, ret); 64 | } 65 | 66 | HAL_I2CEx_ConfigAnalogFilter(&g_i2c_handle, I2C_ANALOGFILTER_ENABLE); 67 | 68 | adv7511_wr_reg(ADV7511_REG_IRQ, 0xFF); /* Clear interrupts */ 69 | 70 | HAL_ADV7511_MspInit(); /* Configure IRQ */ 71 | } 72 | 73 | void adv7511_configure() 74 | { 75 | /* startup stuff */ 76 | adv7511_wr_reg(0x01, 0x00); 77 | adv7511_wr_reg(0x02, 0x18); 78 | adv7511_wr_reg(0x03, 0x00); 79 | adv7511_wr_reg(0x15, 0x00); 80 | adv7511_wr_reg(0x16, 0x00); 81 | adv7511_wr_reg(0x18, 0x08); 82 | 83 | /* configuration */ 84 | adv7511_wr_reg(0x40, 0x80); 85 | adv7511_wr_reg(0x41, 0x10); 86 | adv7511_wr_reg(0x49, 0xA8); 87 | adv7511_wr_reg(0x55, 0x00); 88 | adv7511_wr_reg(0x56, 0x08); 89 | adv7511_wr_reg(0x96, 0x20); 90 | adv7511_wr_reg(0x98, 0x03); 91 | adv7511_wr_reg(0x99, 0x02); 92 | adv7511_wr_reg(0x9C, 0x30); 93 | adv7511_wr_reg(0x9D, 0x61); 94 | adv7511_wr_reg(0xA2, 0xA4); 95 | adv7511_wr_reg(0xA3, 0xA4); 96 | adv7511_wr_reg(0xA5, 0x44); 97 | adv7511_wr_reg(0xAB, 0x40); 98 | adv7511_wr_reg(0xAF, 0x14); 99 | adv7511_wr_reg(0xBA, 0xA0); 100 | adv7511_wr_reg(0xDE, 0x9C); 101 | adv7511_wr_reg(0xE4, 0x60); 102 | adv7511_wr_reg(0xFA, 0x7D); 103 | adv7511_wr_reg(0x48, 0x00); 104 | adv7511_wr_reg(0x55, 0x10); 105 | adv7511_wr_reg(0x56, 0x00); 106 | 107 | adv7511_set_bits(0x16, 0x10); /* Color Depth = 10 bit */ 108 | adv7511_set_bits(0x17, 0x00); /* DE Generator Enable = Disable */ 109 | } 110 | 111 | void adv7511_wr_reg(uint8_t reg, uint8_t val) 112 | { 113 | if(HAL_I2C_Master_WriteReg(&g_i2c_handle, (uint16_t)I2C_ADDRESS, ®, &val, 2000) != HAL_OK) 114 | { 115 | main_error("Failed to write I2C register!", __FILE__, __LINE__, reg); 116 | } 117 | } 118 | 119 | uint8_t adv7511_rd_reg(uint8_t reg) 120 | { 121 | uint8_t val; 122 | 123 | if(HAL_I2C_Master_ReadReg(&g_i2c_handle, (uint16_t)I2C_ADDRESS, ®, &val, 2000) != HAL_OK) 124 | { 125 | main_error("Failed to read I2C register!", __FILE__, __LINE__, reg); 126 | } 127 | 128 | return val; 129 | } 130 | 131 | void adv7511_set_bits(uint8_t reg, uint8_t bits_to_set) 132 | { 133 | adv7511_wr_reg(reg, adv7511_rd_reg(reg) | bits_to_set); 134 | } 135 | 136 | void adv7511_clear_bits(uint8_t reg, uint8_t bits_to_clear) 137 | { 138 | adv7511_wr_reg(reg, adv7511_rd_reg(reg) & ~bits_to_clear); 139 | } 140 | 141 | void adv7511_irq() 142 | { 143 | uint8_t val; 144 | 145 | val = adv7511_rd_reg(ADV7511_REG_IRQ); 146 | 147 | /* is this interrupt about HPD? */ 148 | if(val & 0x80) 149 | { 150 | /* is HPD asserted ? */ 151 | if(adv7511_rd_reg(ADV7511_REG_DETECT) & 0x40) 152 | { 153 | adv7511_configure(); 154 | } 155 | } 156 | 157 | adv7511_wr_reg(ADV7511_REG_IRQ, 0xFF); /* Clear interrupt */ 158 | } 159 | -------------------------------------------------------------------------------- /hw/drivers/adv7511/adv7511.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 adv7511w driver 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | #ifndef _ADV7511_H 25 | #define _ADV7511_H 26 | 27 | #include "stm32f7xx_hal.h" 28 | #include "main.h" 29 | 30 | void adv7511_init(); 31 | void adv7511_configure(); 32 | void adv7511_wr_reg(uint8_t reg, uint8_t val); 33 | uint8_t adv7511_rd_reg(uint8_t reg); 34 | void adv7511_set_bits(uint8_t reg, uint8_t bits_to_set); 35 | void adv7511_clear_bits(uint8_t reg, uint8_t bits_to_clear); 36 | void adv7511_irq(); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /hw/drivers/crc/crc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 crc driver 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | /** 25 | * Responsible for hw crc routines. 26 | */ 27 | 28 | #include "crc.h" 29 | 30 | static CRC_HandleTypeDef g_crc_handle_type; 31 | 32 | void crc_init() 33 | { 34 | HAL_StatusTypeDef ret = HAL_OK; 35 | 36 | g_crc_handle_type.Instance = CRC; 37 | 38 | /* The default polynomial is used */ 39 | g_crc_handle_type.Init.DefaultPolynomialUse = DEFAULT_POLYNOMIAL_ENABLE; 40 | 41 | /* The default init value is used */ 42 | g_crc_handle_type.Init.DefaultInitValueUse = DEFAULT_INIT_VALUE_ENABLE; 43 | 44 | /* The input data are not inverted */ 45 | g_crc_handle_type.Init.InputDataInversionMode = CRC_INPUTDATA_INVERSION_NONE; 46 | 47 | /* The output data are not inverted */ 48 | g_crc_handle_type.Init.OutputDataInversionMode = CRC_OUTPUTDATA_INVERSION_DISABLE; 49 | 50 | /* The input data are 32 bits lenght */ 51 | g_crc_handle_type.InputDataFormat = CRC_INPUTDATA_FORMAT_BYTES; 52 | 53 | ret = HAL_CRC_Init(&g_crc_handle_type); 54 | if(ret != HAL_OK) 55 | { 56 | main_error("Failed to initialize CRC!", __FILE__, __LINE__, ret); 57 | } 58 | } 59 | 60 | uint32_t crc_calculate(uint8_t *buffer_p, uint32_t length) 61 | { 62 | return HAL_CRC_Calculate(&g_crc_handle_type, (uint32_t *)buffer_p, length); 63 | } 64 | -------------------------------------------------------------------------------- /hw/drivers/crc/crc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 crc driver 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | #ifndef _CRC_H 25 | #define _CRC_H 26 | 27 | #include "stm32f7xx_hal.h" 28 | #include "main.h" 29 | 30 | void crc_init(); 31 | uint32_t crc_calculate(uint8_t *buffer_p, uint32_t length); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /hw/drivers/disp/disp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 display driver 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | #ifndef _DISP_H 25 | #define _DISP_H 26 | 27 | #include "stm32f7xx_hal.h" 28 | #include "main.h" 29 | 30 | #define MEM_ADDR_BUFFER0 0 31 | #define MEM_ADDR_BUFFER1 1 32 | #define MEM_ADDR_BUFFER2 2 33 | 34 | typedef enum 35 | { 36 | DISP_MODE_VGA, 37 | DISP_MODE_SVGA 38 | } disp_mode_t; 39 | 40 | typedef enum 41 | { 42 | DISP_COLOR_BLACK, 43 | DISP_COLOR_WHITE, 44 | DISP_COLOR_RED, 45 | DISP_COLOR_CYAN, 46 | DISP_COLOR_VIOLET, 47 | DISP_COLOR_GREEN, 48 | DISP_COLOR_BLUE, 49 | DISP_COLOR_YELLOW, 50 | DISP_COLOR_ORANGE, 51 | DISP_COLOR_BROWN, 52 | DISP_COLOR_LRED, 53 | DISP_COLOR_GREY1, 54 | DISP_COLOR_GREY2, 55 | DISP_COLOR_LGREEN, 56 | DISP_COLOR_LBLUE, 57 | DISP_COLOR_GREY3, 58 | DISP_COLOR_TEXT_BG, 59 | DISP_COLOR_TEXT_FG, 60 | DISP_COLOR_MARKER, 61 | } disp_color_t; 62 | 63 | void disp_init(disp_mode_t disp_mode); 64 | void *disp_get_layer(uint8_t layer); 65 | void disp_set_memory(uint8_t layer, uint32_t memory); 66 | void disp_set_layer(uint8_t layer, 67 | uint32_t window_x0, 68 | uint32_t window_x1, 69 | uint32_t window_y0, 70 | uint32_t window_y1, 71 | uint32_t buffer_x, 72 | uint32_t buffer_y, 73 | uint8_t alpha, 74 | uint32_t pixel_format); 75 | void disp_activate_layer(uint8_t layer); 76 | void disp_deactivate_layer(uint8_t layer); 77 | void disp_fill_layer(uint8_t layer, uint32_t color); 78 | void disp_move_layer(uint8_t layer, uint32_t x, uint32_t y); 79 | void disp_flip_buffer(uint8_t **done_buffer_pp); 80 | void disp_set_clut_table(uint32_t *clut_p); 81 | void disp_enable_clut(uint8_t layer); 82 | void disp_disable_clut(uint8_t layer); 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /hw/drivers/joyst/joyst.c: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 joystick driver 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | /** 25 | * Handles both joysticks. 26 | */ 27 | 28 | #include "joyst.h" 29 | #include "if.h" 30 | 31 | extern if_emu_cc_t g_if_cc_emu; 32 | 33 | __weak void HAL_JOYST_MspInit() 34 | { 35 | ; 36 | } 37 | 38 | void joyst_irq(joyst_port_t joyst_port, joyst_action_t joyst_action, joyst_action_state_t action_state) 39 | { 40 | /* All types happens to fit perfectly to interface, so just cast and forget :) */ 41 | g_if_cc_emu.if_emu_cc_ue.ue_joyst_fp((if_joyst_port_t)joyst_port, 42 | (if_joyst_action_t)joyst_action, 43 | (if_joyst_action_state_t)action_state); 44 | } 45 | 46 | void joyst_init() 47 | { 48 | HAL_JOYST_MspInit(); 49 | } 50 | -------------------------------------------------------------------------------- /hw/drivers/joyst/joyst.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 joystick driver 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | 25 | #ifndef _JOYST_H 26 | #define _JOYST_H 27 | 28 | #include "stm32f7xx_hal.h" 29 | #include "main.h" 30 | 31 | typedef enum 32 | { 33 | JOYST_PORT_A, 34 | JOYST_PORT_B 35 | } joyst_port_t; 36 | 37 | typedef enum 38 | { 39 | JOYST_ACTION_UP, 40 | JOYST_ACTION_DOWN, 41 | JOYST_ACTION_RIGHT, 42 | JOYST_ACTION_LEFT, 43 | JOYST_ACTION_FIRE 44 | } joyst_action_t; 45 | 46 | typedef enum 47 | { 48 | JOYST_ACTION_STATE_RELEASED, 49 | JOYST_ACTION_STATE_PRESSED 50 | } joyst_action_state_t; 51 | 52 | void joyst_irq(joyst_port_t joyst_port, joyst_action_t joyst_action, joyst_action_state_t action_state); 53 | void joyst_init(); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /hw/drivers/rng/rng.c: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 random generator driver 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | /** 25 | * Responsible for random generator. 26 | */ 27 | 28 | #include "rng.h" 29 | 30 | static RNG_HandleTypeDef g_rng_handle; 31 | 32 | void rng_init() 33 | { 34 | HAL_StatusTypeDef ret = HAL_OK; 35 | 36 | g_rng_handle.Instance = RNG; 37 | 38 | ret = HAL_RNG_Init(&g_rng_handle); 39 | if(ret != HAL_OK) 40 | { 41 | main_error("Failed to initialize RNG!", __FILE__, __LINE__, 0); 42 | } 43 | } 44 | 45 | uint32_t rng_get() 46 | { 47 | HAL_StatusTypeDef status = HAL_ERROR; 48 | uint32_t rnd_number; 49 | 50 | while(status != HAL_OK) 51 | { 52 | status = HAL_RNG_GenerateRandomNumber(&g_rng_handle, &rnd_number); 53 | } 54 | return rnd_number; 55 | } 56 | -------------------------------------------------------------------------------- /hw/drivers/rng/rng.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 random generator driver 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | #ifndef _RNG_H 25 | #define _RNG_H 26 | 27 | #include "stm32f7xx_hal.h" 28 | #include "main.h" 29 | 30 | void rng_init(); 31 | uint32_t rng_get(); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /hw/drivers/sdcard/diskio.c: -------------------------------------------------------------------------------- 1 | /*-----------------------------------------------------------------------*/ 2 | /* Low level disk I/O module skeleton for FatFs (C)ChaN, 2014 */ 3 | /* */ 4 | /* Portions COPYRIGHT 2015 STMicroelectronics */ 5 | /* Portions Copyright (C) 2014, ChaN, all right reserved */ 6 | /*-----------------------------------------------------------------------*/ 7 | /* If a working storage control module is available, it should be */ 8 | /* attached to the FatFs via a glue function rather than modifying it. */ 9 | /* This is an example of glue functions to attach various exsisting */ 10 | /* storage control modules to the FatFs module with a defined API. */ 11 | /*-----------------------------------------------------------------------*/ 12 | 13 | /** 14 | ****************************************************************************** 15 | * @file diskio.c 16 | * @author MCD Application Team 17 | * @version V1.3.0 18 | * @date 08-May-2015 19 | * @brief FatFs low level disk I/O module. 20 | ****************************************************************************** 21 | * @attention 22 | * 23 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 24 | * You may not use this file except in compliance with the License. 25 | * You may obtain a copy of the License at: 26 | * 27 | * http://www.st.com/software_license_agreement_liberty_v2 28 | * 29 | * Unless required by applicable law or agreed to in writing, software 30 | * distributed under the License is distributed on an "AS IS" BASIS, 31 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 32 | * See the License for the specific language governing permissions and 33 | * limitations under the License. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /* Includes ------------------------------------------------------------------*/ 39 | #include "diskio.h" 40 | #include "config.h" 41 | #include "stm32f7xx_hal_dma.h" 42 | #include "stm32f7xx_hal_sd.h" 43 | 44 | #define BLOCK_SIZE 512 45 | static uint8_t initialized; 46 | 47 | extern SD_HandleTypeDef g_sd_handle; 48 | 49 | /** 50 | * @brief Gets Disk Status 51 | * @param pdrv: Physical drive number (0..) 52 | * @retval DSTATUS: Operation status 53 | */ 54 | DSTATUS disk_status(BYTE pdrv) 55 | { 56 | DSTATUS stat = RES_OK; 57 | return stat; 58 | } 59 | 60 | /** 61 | * @brief Initializes a Drive 62 | * @param pdrv: Physical drive number (0..) 63 | * @retval DSTATUS: Operation status 64 | */ 65 | DSTATUS disk_initialize(BYTE pdrv) 66 | { 67 | DSTATUS stat = RES_OK; 68 | initialized = 1; 69 | return stat; 70 | } 71 | 72 | /** 73 | * @brief Reads Sector(s) 74 | * @param pdrv: Physical drive number (0..) 75 | * @param *buff: Data buffer to store read data 76 | * @param sector: Sector address (LBA) 77 | * @param count: Number of sectors to read (1..128) 78 | * @retval DRESULT: Operation result 79 | */ 80 | DRESULT disk_read ( 81 | BYTE pdrv, /* Physical drive nmuber to identify the drive */ 82 | BYTE *buff, /* Data buffer to store read data */ 83 | DWORD sector, /* Sector address in LBA */ 84 | UINT count /* Number of sectors to read */ 85 | ) 86 | { 87 | HAL_SD_ErrorTypedef hal_sd_res = SD_OK; 88 | DRESULT res = RES_OK; 89 | 90 | hal_sd_res = HAL_SD_ReadBlocks(&g_sd_handle, (uint32_t *)buff, (uint32_t)(sector), BLOCK_SIZE, count); 91 | 92 | if(hal_sd_res != SD_OK) 93 | { 94 | res = RES_ERROR; 95 | } 96 | 97 | return res; 98 | } 99 | 100 | /** 101 | * @brief Writes Sector(s) 102 | * @param pdrv: Physical drive number (0..) 103 | * @param *buff: Data to be written 104 | * @param sector: Sector address (LBA) 105 | * @param count: Number of sectors to write (1..128) 106 | * @retval DRESULT: Operation result 107 | */ 108 | #if _USE_WRITE == 1 109 | DRESULT disk_write ( 110 | BYTE pdrv, /* Physical drive nmuber to identify the drive */ 111 | const BYTE *buff, /* Data to be written */ 112 | DWORD sector, /* Sector address in LBA */ 113 | UINT count /* Number of sectors to write */ 114 | ) 115 | { 116 | HAL_SD_ErrorTypedef hal_sd_res = SD_OK; 117 | DRESULT res = RES_OK; 118 | 119 | hal_sd_res = HAL_SD_WriteBlocks(&g_sd_handle, (uint32_t *)buff, (uint32_t)(sector), BLOCK_SIZE, count); 120 | 121 | if(hal_sd_res != SD_OK) 122 | { 123 | res = RES_ERROR; 124 | } 125 | 126 | return res; 127 | } 128 | #endif /* _USE_WRITE == 1 */ 129 | 130 | /** 131 | * @brief I/O control operation 132 | * @param pdrv: Physical drive number (0..) 133 | * @param cmd: Control code 134 | * @param *buff: Buffer to send/receive control data 135 | * @retval DRESULT: Operation result 136 | */ 137 | #if _USE_IOCTL == 1 138 | DRESULT disk_ioctl ( 139 | BYTE pdrv, /* Physical drive nmuber (0..) */ 140 | BYTE cmd, /* Control code */ 141 | void *buff /* Buffer to send/receive control data */ 142 | ) 143 | { 144 | DRESULT res = RES_OK; 145 | 146 | HAL_SD_CardInfoTypedef HAL_SD_CardInfoType; 147 | 148 | if(!initialized) 149 | { 150 | return RES_NOTRDY; 151 | } 152 | 153 | switch (cmd) 154 | { 155 | /* Make sure that no pending write process */ 156 | case CTRL_SYNC : 157 | res = RES_OK; 158 | break; 159 | 160 | /* Get number of sectors on the disk (DWORD) */ 161 | case GET_SECTOR_COUNT: 162 | HAL_SD_Get_CardInfo(&g_sd_handle, &HAL_SD_CardInfoType); 163 | *(DWORD*)buff = HAL_SD_CardInfoType.CardCapacity / BLOCK_SIZE; 164 | res = RES_OK; 165 | break; 166 | 167 | /* Get R/W sector size (WORD) */ 168 | case GET_SECTOR_SIZE : 169 | *(WORD*)buff = BLOCK_SIZE; 170 | res = RES_OK; 171 | break; 172 | 173 | /* Get erase block size in unit of sector (DWORD) */ 174 | case GET_BLOCK_SIZE : 175 | *(DWORD*)buff = BLOCK_SIZE; 176 | break; 177 | 178 | default: 179 | res = RES_PARERR; 180 | } 181 | 182 | return res; 183 | } 184 | #endif /* _USE_IOCTL == 1 */ 185 | 186 | /** 187 | * @brief Gets Time from RTC 188 | * @param None 189 | * @retval Time in DWORD 190 | */ 191 | DWORD get_fattime (void) 192 | { 193 | return 0; 194 | } 195 | 196 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 197 | 198 | -------------------------------------------------------------------------------- /hw/drivers/sdcard/diskio.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------- 2 | / Low level disk interface modlue include file (C)ChaN, 2014 3 | /-----------------------------------------------------------------------*/ 4 | 5 | #ifndef _DISKIO_H 6 | #define _DISKIO_H 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #define _USE_WRITE 1 /* 1: Enable disk_write() function */ 13 | #define _USE_IOCTL 1 /* 1: Enable disk_ioctl() fucntion */ 14 | 15 | #include "integer.h" 16 | 17 | 18 | /* Status of Disk Functions */ 19 | typedef BYTE DSTATUS; 20 | 21 | /* Results of Disk Functions */ 22 | typedef enum { 23 | RES_OK = 0, /* 0: Successful */ 24 | RES_ERROR, /* 1: R/W Error */ 25 | RES_WRPRT, /* 2: Write Protected */ 26 | RES_NOTRDY, /* 3: Not Ready */ 27 | RES_PARERR /* 4: Invalid Parameter */ 28 | } DRESULT; 29 | 30 | 31 | /*---------------------------------------*/ 32 | /* Prototypes for disk control functions */ 33 | /*---------------------------------------*/ 34 | 35 | 36 | DSTATUS disk_initialize (BYTE pdrv); 37 | DSTATUS disk_status (BYTE pdrv); 38 | DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); 39 | #if _USE_WRITE 40 | DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); 41 | #endif 42 | #if _USE_IOCTL 43 | DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); 44 | #endif 45 | DWORD get_fattime (void); 46 | 47 | /* Disk Status Bits (DSTATUS) */ 48 | #define STA_NOINIT 0x01 /* Drive not initialized */ 49 | #define STA_NODISK 0x02 /* No medium in the drive */ 50 | #define STA_PROTECT 0x04 /* Write protected */ 51 | 52 | 53 | /* Command code for disk_ioctrl fucntion */ 54 | 55 | /* Generic command (Used by FatFs) */ 56 | #define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ 57 | #define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ 58 | #define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ 59 | #define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ 60 | #define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ 61 | 62 | /* Generic command (Not used by FatFs) */ 63 | #define CTRL_FORMAT 5 /* Create physical format on the media */ 64 | #define CTRL_POWER_IDLE 6 /* Put the device idle state */ 65 | #define CTRL_POWER_OFF 7 /* Put the device off state */ 66 | #define CTRL_LOCK 8 /* Lock media removal */ 67 | #define CTRL_UNLOCK 9 /* Unlock media removal */ 68 | #define CTRL_EJECT 10 /* Eject media */ 69 | 70 | /* MMC/SDC specific command (Not used by FatFs) */ 71 | #define MMC_GET_TYPE 50 /* Get card type */ 72 | #define MMC_GET_CSD 51 /* Get CSD */ 73 | #define MMC_GET_CID 52 /* Get CID */ 74 | #define MMC_GET_OCR 53 /* Get OCR */ 75 | #define MMC_GET_SDSTAT 54 /* Get SD status */ 76 | 77 | /* ATA/CF specific command (Not used by FatFs) */ 78 | #define ATA_GET_REV 60 /* Get F/W revision */ 79 | #define ATA_GET_MODEL 61 /* Get model name */ 80 | #define ATA_GET_SN 62 /* Get serial number */ 81 | 82 | 83 | /* MMC card type flags (MMC_GET_TYPE) */ 84 | #define CT_MMC 0x01 /* MMC ver 3 */ 85 | #define CT_SD1 0x02 /* SD ver 1 */ 86 | #define CT_SD2 0x04 /* SD ver 2 */ 87 | #define CT_SDC (CT_SD1|CT_SD2) /* SD */ 88 | #define CT_BLOCK 0x08 /* Block addressing */ 89 | 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /hw/drivers/sdcard/sdcard.c: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 sdcard driver 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | /** 25 | * Responsible for SDRAM. 26 | */ 27 | 28 | #include "sdcard.h" 29 | #include "config.h" 30 | 31 | SD_HandleTypeDef g_sd_handle; 32 | static HAL_SD_CardInfoTypedef g_hal_sd_card_info; 33 | 34 | void sdcard_init() 35 | { 36 | g_sd_handle.Instance = SDMMC1; 37 | g_sd_handle.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING; 38 | g_sd_handle.Init.ClockBypass = SDMMC_CLOCK_BYPASS_DISABLE; 39 | g_sd_handle.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE; 40 | g_sd_handle.Init.BusWide = SDMMC_BUS_WIDE_1B; 41 | g_sd_handle.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_ENABLE; 42 | g_sd_handle.Init.ClockDiv = 0; 43 | HAL_SD_Init(&g_sd_handle, &g_hal_sd_card_info); 44 | } 45 | 46 | uint8_t sdcard_inserted() 47 | { 48 | if((SDCARD_CD_PORT->IDR & SDCARD_CD_PIN) != (uint32_t)GPIO_PIN_RESET) 49 | { 50 | return 0; 51 | } 52 | else 53 | { 54 | return 1; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /hw/drivers/sdcard/sdcard.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 sdcard driver 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | #ifndef _SDCARD_H 25 | #define _SDCARD_H 26 | 27 | #include "stm32f7xx_hal_dma.h" 28 | #include "stm32f7xx_hal_sd.h" 29 | #include "stm32f7xx_hal_hcd.h" 30 | #include "stm32f7xx_hal_i2c.h" 31 | #include "stm32f7xx_hal_sdram.h" 32 | #include "main.h" 33 | 34 | void sdcard_init(); 35 | uint8_t sdcard_inserted(); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /hw/drivers/sdram/sdram.c: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 sdram driver 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | /** 25 | * Responsible for extended SDRAM. 26 | */ 27 | 28 | #include "sdram.h" 29 | #include "config.h" 30 | 31 | #define SDRAM_MODEREG_BURST_LENGTH_1 ((uint16_t)0x0000) 32 | #define SDRAM_MODEREG_BURST_LENGTH_2 ((uint16_t)0x0001) 33 | #define SDRAM_MODEREG_BURST_LENGTH_4 ((uint16_t)0x0002) 34 | #define SDRAM_MODEREG_BURST_LENGTH_8 ((uint16_t)0x0003) 35 | #define SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL ((uint16_t)0x0000) 36 | #define SDRAM_MODEREG_BURST_TYPE_INTERLEAVED ((uint16_t)0x0008) 37 | #define SDRAM_MODEREG_CAS_LATENCY_2 ((uint16_t)0x0020) 38 | #define SDRAM_MODEREG_CAS_LATENCY_3 ((uint16_t)0x0030) 39 | #define SDRAM_MODEREG_OPERATING_MODE_STANDARD ((uint16_t)0x0000) 40 | #define SDRAM_MODEREG_WRITEBURST_MODE_PROGRAMMED ((uint16_t)0x0000) 41 | #define SDRAM_MODEREG_WRITEBURST_MODE_SINGLE ((uint16_t)0x0200) 42 | 43 | #define SDRAM_CMD_TIMEOUT 0x1000 44 | 45 | static SDRAM_HandleTypeDef g_sdram_handle; 46 | static FMC_SDRAM_TimingTypeDef g_fmc_sdram_timing; 47 | 48 | static void sdram_start_sequence() 49 | { 50 | FMC_SDRAM_CommandTypeDef FMC_SDRAM_Command; 51 | __IO uint32_t tmpmrd = 0; 52 | 53 | /* Step 1: Configure a clock configuration enable command */ 54 | FMC_SDRAM_Command.CommandMode = FMC_SDRAM_CMD_CLK_ENABLE; 55 | FMC_SDRAM_Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; 56 | FMC_SDRAM_Command.AutoRefreshNumber = 1; 57 | FMC_SDRAM_Command.ModeRegisterDefinition = 0; 58 | 59 | /* Send the command */ 60 | HAL_SDRAM_SendCommand(&g_sdram_handle, &FMC_SDRAM_Command, SDRAM_CMD_TIMEOUT); 61 | 62 | /* Step 2: Insert 100 us minimum delay */ 63 | /* Inserted delay is equal to 1 ms due to systick time base unit (ms) */ 64 | HAL_Delay(1); 65 | 66 | /* Step 3: Configure a PALL (precharge all) command */ 67 | FMC_SDRAM_Command.CommandMode = FMC_SDRAM_CMD_PALL; 68 | FMC_SDRAM_Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; 69 | FMC_SDRAM_Command.AutoRefreshNumber = 1; 70 | FMC_SDRAM_Command.ModeRegisterDefinition = 0; 71 | 72 | /* Send the command */ 73 | HAL_SDRAM_SendCommand(&g_sdram_handle, &FMC_SDRAM_Command, SDRAM_CMD_TIMEOUT); 74 | 75 | /* Step 4 : Configure a Auto-Refresh command */ 76 | FMC_SDRAM_Command.CommandMode = FMC_SDRAM_CMD_AUTOREFRESH_MODE; 77 | FMC_SDRAM_Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; 78 | FMC_SDRAM_Command.AutoRefreshNumber = 8; 79 | FMC_SDRAM_Command.ModeRegisterDefinition = 0; 80 | 81 | /* Send the command */ 82 | HAL_SDRAM_SendCommand(&g_sdram_handle, &FMC_SDRAM_Command, SDRAM_CMD_TIMEOUT); 83 | 84 | /* Step 5: Program the external memory mode register */ 85 | tmpmrd = (uint32_t)SDRAM_MODEREG_BURST_LENGTH_1 | 86 | SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL | 87 | SDRAM_MODEREG_CAS_LATENCY_3 | 88 | SDRAM_MODEREG_OPERATING_MODE_STANDARD | 89 | SDRAM_MODEREG_WRITEBURST_MODE_SINGLE; 90 | 91 | FMC_SDRAM_Command.CommandMode = FMC_SDRAM_CMD_LOAD_MODE; 92 | FMC_SDRAM_Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; 93 | FMC_SDRAM_Command.AutoRefreshNumber = 1; 94 | FMC_SDRAM_Command.ModeRegisterDefinition = tmpmrd; 95 | 96 | /* Send the command */ 97 | HAL_SDRAM_SendCommand(&g_sdram_handle, &FMC_SDRAM_Command, SDRAM_CMD_TIMEOUT); 98 | 99 | /* Step 6: Set the refresh rate counter */ 100 | /* (15.62 us x Freq) - 20 */ 101 | /* Set the device refresh counter */ 102 | g_sdram_handle.Instance->SDRTR |= ((uint32_t)((1292)<< 1)); 103 | } 104 | 105 | void sdram_init() 106 | { 107 | HAL_StatusTypeDef ret = HAL_OK; 108 | 109 | /* SDRAM device configuration */ 110 | g_sdram_handle.Instance = FMC_SDRAM_DEVICE; 111 | 112 | g_fmc_sdram_timing.LoadToActiveDelay = 1; 113 | g_fmc_sdram_timing.ExitSelfRefreshDelay = 1; 114 | g_fmc_sdram_timing.SelfRefreshTime = 1; 115 | g_fmc_sdram_timing.RowCycleDelay = 5; 116 | g_fmc_sdram_timing.WriteRecoveryTime = 1; 117 | g_fmc_sdram_timing.RPDelay = 2; 118 | g_fmc_sdram_timing.RCDDelay = 2; 119 | 120 | g_sdram_handle.Init.SDBank = SDRAM_BANK; 121 | g_sdram_handle.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8; 122 | g_sdram_handle.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_12; 123 | g_sdram_handle.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_16; 124 | g_sdram_handle.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; 125 | g_sdram_handle.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3; 126 | g_sdram_handle.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; 127 | g_sdram_handle.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2; 128 | g_sdram_handle.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; 129 | g_sdram_handle.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0; 130 | 131 | /* Initialize the SDRAM controller */ 132 | ret = HAL_SDRAM_Init(&g_sdram_handle, &g_fmc_sdram_timing); 133 | if(ret != HAL_OK) 134 | { 135 | main_error("Failed to initialize sdram!", __FILE__, __LINE__, ret); 136 | } 137 | 138 | sdram_start_sequence(); 139 | } 140 | -------------------------------------------------------------------------------- /hw/drivers/sdram/sdram.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 sdram driver 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | 25 | #ifndef _SDRAM_H 26 | #define _SDRAM_H 27 | 28 | #include "stm32f7xx_hal.h" 29 | #include "main.h" 30 | 31 | void stats_select_layer(uint8_t layer); 32 | void sdram_init(); 33 | 34 | #endif -------------------------------------------------------------------------------- /hw/drivers/sidbus/sidbus.c: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 sidbus driver 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | 25 | /** 26 | * Responsible for the connection with sid hw. 27 | */ 28 | 29 | #include "sidbus.h" 30 | #include "stm32f7xx_hal_gpio.h" 31 | #include "config.h" 32 | #include "rng.h" 33 | 34 | typedef enum 35 | { 36 | WRITE_LOCKED, 37 | WRITE_UNLOCKED, 38 | } write_lock_t; 39 | 40 | sidbus_state_t g_sidbus_state; 41 | 42 | /* 43 | * Not needed for authentic SID chip, rather for 44 | * replacements such as swinsid since timing is 45 | * slightly different. Performace impact for busy 46 | * wait in this case will be very low. 47 | */ 48 | volatile static write_lock_t g_lock; 49 | 50 | __weak void HAL_SIDBUS_MspInit() 51 | { 52 | ; 53 | } 54 | 55 | void sidbus_irq() 56 | { 57 | switch(g_sidbus_state) 58 | { 59 | case SIDBUS_STATE_ACTIVATE_CHIP: 60 | SID_SET_CS_LOW(); 61 | g_sidbus_state = SIDBUS_STATE_DATA_SENT; 62 | break; 63 | case SIDBUS_STATE_DATA_SENT: 64 | SID_SET_CS_HIGH(); 65 | 66 | /* Disable sidbus IRQ */ 67 | EXTI->FTSR &= ~GPIO_PIN_13; 68 | g_sidbus_state = SIDBUS_STATE_ACTIVATE_CHIP; 69 | g_lock = WRITE_UNLOCKED; 70 | break; 71 | } 72 | } 73 | 74 | void sidbus_init() 75 | { 76 | HAL_SIDBUS_MspInit(); 77 | SID_SET_CS_HIGH(); 78 | 79 | g_sidbus_state = SIDBUS_STATE_ACTIVATE_CHIP; 80 | g_lock = WRITE_UNLOCKED; 81 | } 82 | 83 | void sidbus_write(uint8_t addr, uint8_t value) 84 | { 85 | /* Wait until previous write is complete */ 86 | while(g_lock == WRITE_LOCKED) {;} 87 | 88 | /* Lock write */ 89 | g_lock = WRITE_LOCKED; 90 | SID_ASSERT_WRITE(); 91 | SID_SET_ADDR(addr); 92 | SID_SET_DATA(value); 93 | 94 | /* Enable sidbus IRQ */ 95 | EXTI->FTSR |= GPIO_PIN_13; 96 | } 97 | 98 | uint8_t sidbus_read(uint8_t addr) 99 | { 100 | /* Just return random value for now */ 101 | return rng_get(); 102 | } 103 | -------------------------------------------------------------------------------- /hw/drivers/sidbus/sidbus.h: -------------------------------------------------------------------------------- 1 | #ifndef _SIDBUS_H 2 | #define _SIDBUS_H 3 | 4 | #include "stm32f7xx_hal.h" 5 | #include "main.h" 6 | 7 | typedef enum 8 | { 9 | SIDBUS_STATE_ACTIVATE_CHIP, 10 | SIDBUS_STATE_DATA_SENT 11 | } sidbus_state_t; 12 | 13 | void sidbus_irq(); 14 | void sidbus_init(); 15 | void sidbus_write(uint8_t addr, uint8_t value); 16 | uint8_t sidbus_read(uint8_t addr); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /hw/drivers/timer/timer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 timer driver 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | /** 25 | * Responsible for all timing related stuff. 26 | */ 27 | 28 | #include "timer.h" 29 | #include "if.h" 30 | 31 | extern if_emu_cc_t g_if_cc_emu; 32 | 33 | static TIM_HandleTypeDef g_tim_handle_type; 34 | static uint32_t g_timer_ms; 35 | static uint32_t g_timer3; 36 | static uint8_t g_timer; 37 | 38 | void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim) 39 | { 40 | /* Prevent unused argument(s) compilation warning */ 41 | UNUSED(htim); 42 | 43 | /* NOTE : This function Should not be modified, when the callback is needed, 44 | the HAL_TIM_Base_MspInit could be implemented in the user file 45 | */ 46 | } 47 | 48 | static void InitTimer3() 49 | { 50 | HAL_StatusTypeDef ret = HAL_OK; 51 | 52 | RCC_ClkInitTypeDef clkconfig; 53 | uint32_t uwTimclock, uwAPB1Prescaler = 0; 54 | uint32_t uwPrescalerValue = 0; 55 | uint32_t pFLatency; 56 | 57 | /*Configure the TIM3 IRQ priority */ 58 | HAL_NVIC_SetPriority(TIM3_IRQn, 2 ,0); 59 | 60 | /* Enable the TIM3 global Interrupt */ 61 | HAL_NVIC_EnableIRQ(TIM3_IRQn); 62 | 63 | /* Enable TIM3 clock */ 64 | __HAL_RCC_TIM3_CLK_ENABLE(); 65 | 66 | /* Get clock configuration */ 67 | HAL_RCC_GetClockConfig(&clkconfig, &pFLatency); 68 | 69 | /* Get APB1 prescaler */ 70 | uwAPB1Prescaler = clkconfig.APB1CLKDivider; 71 | 72 | /* Compute TIM3 clock */ 73 | if(uwAPB1Prescaler == RCC_HCLK_DIV1) 74 | { 75 | uwTimclock = HAL_RCC_GetPCLK1Freq(); 76 | } 77 | else 78 | { 79 | uwTimclock = 2*HAL_RCC_GetPCLK1Freq(); 80 | } 81 | 82 | /* Compute the prescaler value to have TIM3 counter clock equal to 1MHz */ 83 | uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000) - 1); 84 | 85 | /* Initialize TIM3 */ 86 | g_tim_handle_type.Instance = TIM3; 87 | 88 | g_tim_handle_type.Init.Period = (1000000 / 10000) - 1; /* (1/10000) s time base */ 89 | g_tim_handle_type.Init.Prescaler = uwPrescalerValue; 90 | g_tim_handle_type.Init.ClockDivision = 0; 91 | g_tim_handle_type.Init.CounterMode = TIM_COUNTERMODE_DOWN; 92 | 93 | ret = HAL_TIM_Base_Init(&g_tim_handle_type); 94 | if(ret != HAL_OK) 95 | { 96 | main_error("Failed to initialize timer 3!", __FILE__, __LINE__, ret); 97 | } 98 | 99 | ret = HAL_TIM_Base_Start_IT(&g_tim_handle_type); 100 | /* Start the TIM time Base generation in interrupt mode */ 101 | if(ret != HAL_OK) 102 | { 103 | main_error("Failed to initialize timer 3!", __FILE__, __LINE__, ret); 104 | } 105 | } 106 | 107 | void timer_init() 108 | { 109 | InitTimer3(); 110 | } 111 | 112 | void systimer_tick() 113 | { 114 | g_timer++; 115 | g_timer_ms++; 116 | if(g_timer == 100) 117 | { 118 | if(g_if_cc_emu.if_emu_cc_time.time_tenth_second_fp != NULL) 119 | { 120 | g_if_cc_emu.if_emu_cc_time.time_tenth_second_fp(); 121 | } 122 | g_timer = 0; 123 | } 124 | } 125 | 126 | uint32_t timer_get_ms() 127 | { 128 | return g_timer_ms; 129 | } 130 | 131 | void timer3_set(uint32_t value) 132 | { 133 | HAL_StatusTypeDef ret = HAL_OK; 134 | 135 | if(value == 0) 136 | { 137 | return; 138 | } 139 | 140 | g_timer3 = value; 141 | 142 | ret = HAL_TIM_Base_Start_IT(&g_tim_handle_type); 143 | /* Start the TIM time Base generation in interrupt mode */ 144 | if(ret != HAL_OK) 145 | { 146 | main_error("Failed to start timer 3", __FILE__, __LINE__, ret); 147 | } 148 | } 149 | 150 | void timer3_tick() 151 | { 152 | HAL_StatusTypeDef ret = HAL_OK; 153 | 154 | TIM3->SR &= ~((uint32_t)0x01); 155 | 156 | if(g_timer3 == 0) 157 | { 158 | ret = HAL_TIM_Base_Stop_IT(&g_tim_handle_type); 159 | /* Start the TIM time Base generation in interrupt mode */ 160 | if(ret != HAL_OK) 161 | { 162 | main_error("Failed to stop timer 3", __FILE__, __LINE__, ret); 163 | } 164 | } 165 | else 166 | { 167 | g_timer3--; 168 | } 169 | } 170 | 171 | uint32_t timer3_get() 172 | { 173 | return g_timer3; 174 | } 175 | -------------------------------------------------------------------------------- /hw/drivers/timer/timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 timer driver 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | #ifndef _TIMER_H 25 | #define _TIMER_H 26 | 27 | #include "stm32f7xx_hal.h" 28 | #include "main.h" 29 | 30 | void timer_init(); 31 | void systimer_tick(); 32 | uint32_t timer_get_ms(); 33 | void timer3_set(uint32_t value); 34 | void timer3_tick(); 35 | uint32_t timer3_get(); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /hw/drivers/usbd_ll/usbd_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_conf_template.h 4 | * @author MCD Application Team 5 | * @version V2.4.1 6 | * @date 19-June-2015 7 | * @brief Header file for the usbd_conf_template.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USBD_CONF_H 30 | #define __USBD_CONF_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "stm32f7xx.h" /* replace 'stm32xxx' with your HAL driver header filename, ex: stm32f4xx.h */ 38 | #include 39 | #include 40 | #include 41 | 42 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 43 | * @{ 44 | */ 45 | 46 | /** @defgroup USBD_CONF 47 | * @brief USB device low level driver configuration file 48 | * @{ 49 | */ 50 | 51 | /** @defgroup USBD_CONF_Exported_Defines 52 | * @{ 53 | */ 54 | 55 | #define USBD_MAX_NUM_INTERFACES 1 56 | #define USBD_MAX_NUM_CONFIGURATION 1 57 | #define USBD_MAX_STR_DESC_SIZ 0x100 58 | #define USBD_SUPPORT_USER_STRING 0 59 | #define USBD_SELF_POWERED 1 60 | #define USBD_DEBUG_LEVEL 2 61 | 62 | /* MSC Class Config */ 63 | #define MSC_MEDIA_PACKET 8192 64 | 65 | /* CDC Class Config */ 66 | #define USBD_CDC_INTERVAL 2000 67 | 68 | /* DFU Class Config */ 69 | #define USBD_DFU_MAX_ITF_NUM 1 70 | #define USBD_DFU_XFERS_IZE 1024 71 | 72 | /* AUDIO Class Config */ 73 | #define USBD_AUDIO_FREQ 22100 74 | 75 | /** @defgroup USBD_Exported_Macros 76 | * @{ 77 | */ 78 | 79 | /* Memory management macros */ 80 | #define USBD_malloc malloc 81 | #define USBD_free free 82 | #define USBD_memset memset 83 | #define USBD_memcpy memcpy 84 | 85 | /* DEBUG macros */ 86 | 87 | 88 | #if (USBD_DEBUG_LEVEL > 0) 89 | #define USBD_UsrLog(...) printf(__VA_ARGS__);\ 90 | printf("\n"); 91 | #else 92 | #define USBD_UsrLog(...) 93 | #endif 94 | 95 | 96 | #if (USBD_DEBUG_LEVEL > 1) 97 | 98 | #define USBD_ErrLog(...) printf("ERROR: ") ;\ 99 | printf(__VA_ARGS__);\ 100 | printf("\n"); 101 | #else 102 | #define USBD_ErrLog(...) 103 | #endif 104 | 105 | 106 | #if (USBD_DEBUG_LEVEL > 2) 107 | #define USBD_DbgLog(...) printf("DEBUG : ") ;\ 108 | printf(__VA_ARGS__);\ 109 | printf("\n"); 110 | #else 111 | #define USBD_DbgLog(...) 112 | #endif 113 | 114 | /** 115 | * @} 116 | */ 117 | 118 | 119 | 120 | /** 121 | * @} 122 | */ 123 | 124 | 125 | /** @defgroup USBD_CONF_Exported_Types 126 | * @{ 127 | */ 128 | /** 129 | * @} 130 | */ 131 | 132 | 133 | /** @defgroup USBD_CONF_Exported_Macros 134 | * @{ 135 | */ 136 | /** 137 | * @} 138 | */ 139 | 140 | /** @defgroup USBD_CONF_Exported_Variables 141 | * @{ 142 | */ 143 | /** 144 | * @} 145 | */ 146 | 147 | /** @defgroup USBD_CONF_Exported_FunctionsPrototype 148 | * @{ 149 | */ 150 | /** 151 | * @} 152 | */ 153 | 154 | #ifdef __cplusplus 155 | } 156 | #endif 157 | 158 | #endif /* __USBD_CONF_TEMPLATE_H */ 159 | 160 | 161 | /** 162 | * @} 163 | */ 164 | 165 | /** 166 | * @} 167 | */ 168 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 169 | 170 | -------------------------------------------------------------------------------- /hw/drivers/usbh_ll/usbh_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file USB_Host/HID_Standalone/Inc/usbh_conf.h 4 | * @author MCD Application Team 5 | * @version V1.0.2 6 | * @date 18-November-2015 7 | * @brief General low level driver configuration 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USBH_CONF_H 30 | #define __USBH_CONF_H 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "stm32f7xx.h" 34 | #include 35 | #include 36 | #include 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | #define USBH_MAX_NUM_ENDPOINTS 2 40 | #define USBH_MAX_NUM_INTERFACES 2 41 | #define USBH_MAX_NUM_CONFIGURATION 1 42 | #define USBH_MAX_NUM_SUPPORTED_CLASS 1 43 | #define USBH_KEEP_CFG_DESCRIPTOR 0 44 | #define USBH_MAX_SIZE_CONFIGURATION 0x200 45 | #define USBH_MAX_DATA_BUFFER 0x200 46 | #define USBH_DEBUG_LEVEL 3 47 | #define USBH_USE_OS 0 48 | 49 | /* Exported constants --------------------------------------------------------*/ 50 | /* Exported macro ------------------------------------------------------------*/ 51 | /* CMSIS OS macros */ 52 | #if (USBH_USE_OS == 1) 53 | #include "cmsis_os.h" 54 | #define USBH_PROCESS_PRIO osPriorityNormal 55 | #endif 56 | 57 | /* Memory management macros */ 58 | #define USBH_malloc malloc 59 | #define USBH_free free 60 | #define USBH_memset memset 61 | #define USBH_memcpy memcpy 62 | 63 | /* DEBUG macros */ 64 | #if (USBH_DEBUG_LEVEL > 0) 65 | #define USBH_UsrLog(...) printf(__VA_ARGS__);\ 66 | printf("\n"); 67 | #else 68 | #define USBH_UsrLog(...) 69 | #endif 70 | 71 | 72 | #if (USBH_DEBUG_LEVEL > 1) 73 | 74 | #define USBH_ErrLog(...) printf("ERROR: ") ;\ 75 | printf(__VA_ARGS__);\ 76 | printf("\n"); 77 | #else 78 | #define USBH_ErrLog(...) 79 | #endif 80 | 81 | #if (USBH_DEBUG_LEVEL > 2) 82 | #define USBH_DbgLog(...) printf("DEBUG : ") ;\ 83 | printf(__VA_ARGS__);\ 84 | printf("\n"); 85 | #else 86 | #define USBH_DbgLog(...) 87 | #endif 88 | 89 | /* Exported functions ------------------------------------------------------- */ 90 | 91 | #endif /* __USBH_CONF_H */ 92 | 93 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 94 | 95 | -------------------------------------------------------------------------------- /hw/hal/stm32f7xx_hal_ltdc_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f7xx_hal_ltdc_ex.h 4 | * @author MCD Application Team 5 | * @version V1.1.2 6 | * @date 23-September-2016 7 | * @brief Header file of LTDC HAL Extension module. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2016 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ 39 | #ifndef __STM32F7xx_HAL_LTDC_EX_H 40 | #define __STM32F7xx_HAL_LTDC_EX_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #if defined (STM32F769xx) || defined (STM32F779xx) 47 | /* Includes ------------------------------------------------------------------*/ 48 | #include "stm32f7xx_hal_def.h" 49 | #include "stm32f7xx_hal_dsi.h" 50 | 51 | /** @addtogroup STM32F7xx_HAL_Driver 52 | * @{ 53 | */ 54 | 55 | /** @addtogroup LTDCEx 56 | * @{ 57 | */ 58 | 59 | /* Exported types ------------------------------------------------------------*/ 60 | /* Exported constants --------------------------------------------------------*/ 61 | 62 | /** @defgroup LTDCEx_Exported_Constants LTDCEx Exported Constants 63 | * @{ 64 | */ 65 | 66 | /** 67 | * @} 68 | */ 69 | 70 | /* Exported macro ------------------------------------------------------------*/ 71 | /** @defgroup LTDCEx_Exported_Macros LTDC Exported Macros 72 | * @{ 73 | */ 74 | 75 | /** 76 | * @} 77 | */ 78 | 79 | /* Exported functions --------------------------------------------------------*/ 80 | /** @defgroup LTDCEx_Exported_Functions LTDC Extended Exported Functions 81 | * @{ 82 | */ 83 | HAL_StatusTypeDef HAL_LTDC_StructInitFromVideoConfig(LTDC_HandleTypeDef* hltdc, DSI_VidCfgTypeDef *VidCfg); 84 | HAL_StatusTypeDef HAL_LTDC_StructInitFromAdaptedCommandConfig(LTDC_HandleTypeDef* hltdc, DSI_CmdCfgTypeDef *CmdCfg); 85 | /** 86 | * @} 87 | */ 88 | 89 | 90 | /* Private types -------------------------------------------------------------*/ 91 | /** @defgroup LTDCEx_Private_Types LTDCEx Private Types 92 | * @{ 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /* Private variables ---------------------------------------------------------*/ 100 | /** @defgroup LTDCEx_Private_Variables LTDCEx Private Variables 101 | * @{ 102 | */ 103 | 104 | /** 105 | * @} 106 | */ 107 | 108 | /* Private constants ---------------------------------------------------------*/ 109 | /** @defgroup LTDCEx_Private_Constants LTDCEx Private Constants 110 | * @{ 111 | */ 112 | 113 | /** 114 | * @} 115 | */ 116 | 117 | /* Private macros ------------------------------------------------------------*/ 118 | /** @defgroup LTDCEx_Private_Macros LTDCEx Private Macros 119 | * @{ 120 | */ 121 | 122 | /** 123 | * @} 124 | */ 125 | 126 | /* Private functions ---------------------------------------------------------*/ 127 | /** @defgroup LTDCEx_Private_Functions LTDCEx Private Functions 128 | * @{ 129 | */ 130 | 131 | /** 132 | * @} 133 | */ 134 | 135 | /** 136 | * @} 137 | */ 138 | 139 | /** 140 | * @} 141 | */ 142 | 143 | #endif /*STM32F769xx | STM32F779xx */ 144 | 145 | #ifdef __cplusplus 146 | } 147 | #endif 148 | 149 | #endif /* __STM32F7xx_HAL_LTDC_EX_H */ 150 | 151 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 152 | -------------------------------------------------------------------------------- /hw/hal/stm32f7xx_hal_pcd_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f7xx_hal_pcd_ex.h 4 | * @author MCD Application Team 5 | * @version V1.1.2 6 | * @date 23-September-2016 7 | * @brief Header file of PCD HAL module. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2016 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ 39 | #ifndef __STM32F7xx_HAL_PCD_EX_H 40 | #define __STM32F7xx_HAL_PCD_EX_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /* Includes ------------------------------------------------------------------*/ 47 | #include "stm32f7xx_hal_def.h" 48 | 49 | /** @addtogroup STM32F7xx_HAL_Driver 50 | * @{ 51 | */ 52 | 53 | /** @addtogroup PCDEx 54 | * @{ 55 | */ 56 | /* Exported types ------------------------------------------------------------*/ 57 | typedef enum 58 | { 59 | PCD_LPM_L0_ACTIVE = 0x00U, /* on */ 60 | PCD_LPM_L1_ACTIVE = 0x01U, /* LPM L1 sleep */ 61 | }PCD_LPM_MsgTypeDef; 62 | 63 | /* Exported constants --------------------------------------------------------*/ 64 | /* Exported macros -----------------------------------------------------------*/ 65 | /* Exported functions --------------------------------------------------------*/ 66 | /** @addtogroup PCDEx_Exported_Functions PCDEx Exported Functions 67 | * @{ 68 | */ 69 | /** @addtogroup PCDEx_Exported_Functions_Group1 Peripheral Control functions 70 | * @{ 71 | */ 72 | HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size); 73 | HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size); 74 | HAL_StatusTypeDef HAL_PCDEx_ActivateLPM(PCD_HandleTypeDef *hpcd); 75 | HAL_StatusTypeDef HAL_PCDEx_DeActivateLPM(PCD_HandleTypeDef *hpcd); 76 | void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg); 77 | 78 | /** 79 | * @} 80 | */ 81 | 82 | /** 83 | * @} 84 | */ 85 | 86 | /** 87 | * @} 88 | */ 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | #ifdef __cplusplus 95 | } 96 | #endif 97 | 98 | 99 | #endif /* __STM32F7xx_HAL_PCD_EX_H */ 100 | 101 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 102 | -------------------------------------------------------------------------------- /hw/hostif/hostif.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 emulator-host interface 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | #ifndef _HOSTIF_H 25 | #define _HOSTIF_H 26 | 27 | #include "stm32f7xx_hal.h" 28 | #include "main.h" 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /hw/irq/irq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file FatFs/FatFs_uSD/Inc/stm32f7xx_it.h 4 | * @author MCD Application Team 5 | * @version V1.0.2 6 | * @date 18-November-2015 7 | * @brief This file contains the headers of the interrupt handlers. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2015 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ 39 | #ifndef __IRQ_H 40 | #define __IRQ_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /* Includes ------------------------------------------------------------------*/ 47 | #include "stm32f7xx_hal.h" 48 | 49 | /* Exported types ------------------------------------------------------------*/ 50 | /* Exported constants --------------------------------------------------------*/ 51 | /* Exported macro ------------------------------------------------------------*/ 52 | /* Exported functions ------------------------------------------------------- */ 53 | void NMI_Handler(void); 54 | void HardFault_Handler(void); 55 | void MemManage_Handler(void); 56 | void BusFault_Handler(void); 57 | void UsageFault_Handler(void); 58 | void SVC_Handler(void); 59 | void DebugMon_Handler(void); 60 | void PendSV_Handler(void); 61 | void SysTick_Handler(void); 62 | void DMA2_Stream3_IRQHandler(void); 63 | void DMA2_Stream6_IRQHandler(void); 64 | void SDMMC1_IRQHandler(void); 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif /* __STM32F7xx_IT_H */ 70 | 71 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 72 | -------------------------------------------------------------------------------- /hw/main/main.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 main 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | #ifndef _MAIN_H 25 | #define _MAIN_H 26 | 27 | #include "stm32f7xx_hal.h" 28 | #include 29 | 30 | /* This must ALWAYS be uppdated for every release */ 31 | #define FW_REVISION "V1.0.7" 32 | 33 | #define SDRAM_BANK FMC_SDRAM_BANK1 34 | #define SDRAM_ADDR 0x60000000 35 | #define SDRAM_SIZE 0x800000 36 | 37 | #define CC_DISP_BUFFER1_ADDR (SDRAM_ADDR) 38 | #define CC_DISP_BUFFER2_ADDR (CC_DISP_BUFFER1_ADDR + IF_MEMORY_CC_SCREEN_BUFFER1_SIZE) 39 | #define CC_DISP_BUFFER3_ADDR (CC_DISP_BUFFER2_ADDR + IF_MEMORY_CC_SCREEN_BUFFER2_SIZE) 40 | #define CC_SPRITE1_BASE_ADDR (CC_DISP_BUFFER3_ADDR + IF_MEMORY_CC_SCREEN_BUFFER3_SIZE) 41 | #define CC_SPRITE2_BASE_ADDR (CC_SPRITE1_BASE_ADDR + IF_MEMORY_CC_SPRITE1_SIZE) 42 | #define CC_SPRITE3_BASE_ADDR (CC_SPRITE2_BASE_ADDR + IF_MEMORY_CC_SPRITE2_SIZE) 43 | #define CC_RAM_BASE_ADDR (CC_SPRITE3_BASE_ADDR + IF_MEMORY_CC_SPRITE3_SIZE) 44 | 45 | /* These can have same memory space, since they are loaded at different address */ 46 | #define CC_KROM_BASE_ADDR (CC_RAM_BASE_ADDR + IF_MEMORY_CC_RAM_SIZE) 47 | #define CC_BROM_BASE_ADDR (CC_RAM_BASE_ADDR + IF_MEMORY_CC_RAM_SIZE) 48 | #define CC_CROM_BASE_ADDR (CC_RAM_BASE_ADDR + IF_MEMORY_CC_RAM_SIZE) 49 | 50 | /* CC IO address needs to be unique, lets use the fast DTCM for this memory */ 51 | #define CC_IO_BASE_ADDR 0x20000000 52 | #define CC_UTIL1_BASE_ADDR (CC_CROM_BASE_ADDR + IF_MEMORY_CC_CROM_SIZE) 53 | #define CC_UTIL2_BASE_ADDR (CC_UTIL1_BASE_ADDR + IF_MEMORY_CC_UTIL1_SIZE) 54 | #define DD_ALL_BASE_ADDR (CC_UTIL2_BASE_ADDR + IF_MEMORY_CC_UTIL2_SIZE) 55 | #define DD_UTIL1_BASE_ADDR (DD_ALL_BASE_ADDR + IF_MEMORY_DD_ALL_SIZE) 56 | #define DD_UTIL2_BASE_ADDR (DD_UTIL1_BASE_ADDR + IF_MEMORY_DD_UTIL1_SIZE) 57 | 58 | /* 59 | * This can get all the remaining memory to support as 60 | * many filenames as possible. 61 | */ 62 | #define CC_STAGE_FILES_ADDR (DD_UTIL2_BASE_ADDR + IF_MEMORY_DD_UTIL2_SIZE) 63 | 64 | #define CC_BROM_LOAD_ADDR 0x0000A000 65 | #define CC_CROM_LOAD_ADDR 0x0000D000 66 | #define CC_KROM_LOAD_ADDR 0x0000E000 67 | 68 | #define DD_DOS_LOAD_ADDR 0x0000C000 69 | 70 | void main_error(char *string_p, char *file_p, uint32_t line, uint32_t extra); 71 | void main_warning(char *string_p, char *file_p, uint32_t line, uint32_t extra); 72 | char *main_get_fw_revision(); 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /hw/mware/fatfs/integer.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------*/ 2 | /* Integer type definitions for FatFs module */ 3 | /*-------------------------------------------*/ 4 | 5 | #ifndef _FF_INTEGER 6 | #define _FF_INTEGER 7 | 8 | #ifdef _WIN32 /* FatFs development platform */ 9 | 10 | #include 11 | #include 12 | 13 | #else /* Embedded platform */ 14 | 15 | /* This type MUST be 8 bit */ 16 | typedef unsigned char BYTE; 17 | 18 | /* These types MUST be 16 bit */ 19 | typedef short SHORT; 20 | typedef unsigned short WORD; 21 | typedef unsigned short WCHAR; 22 | 23 | /* These types MUST be 16 bit or 32 bit */ 24 | typedef int INT; 25 | typedef unsigned int UINT; 26 | 27 | /* These types MUST be 32 bit */ 28 | typedef long LONG; 29 | typedef unsigned long DWORD; 30 | 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /hw/mware/usb/device/cdc/usbd_cdc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_cdc.h 4 | * @author MCD Application Team 5 | * @version V2.4.1 6 | * @date 19-June-2015 7 | * @brief header file for the usbd_cdc.c file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USB_CDC_H 30 | #define __USB_CDC_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbd_ioreq.h" 38 | 39 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 40 | * @{ 41 | */ 42 | 43 | /** @defgroup usbd_cdc 44 | * @brief This file is the Header file for usbd_cdc.c 45 | * @{ 46 | */ 47 | 48 | 49 | /** @defgroup usbd_cdc_Exported_Defines 50 | * @{ 51 | */ 52 | #define CDC_IN_EP 0x81 /* EP1 for data IN */ 53 | #define CDC_OUT_EP 0x01 /* EP1 for data OUT */ 54 | #define CDC_CMD_EP 0x82 /* EP2 for CDC commands */ 55 | 56 | /* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */ 57 | #define CDC_DATA_HS_MAX_PACKET_SIZE 512 /* Endpoint IN & OUT Packet size */ 58 | #define CDC_DATA_FS_MAX_PACKET_SIZE 64 /* Endpoint IN & OUT Packet size */ 59 | #define CDC_CMD_PACKET_SIZE 8 /* Control Endpoint Packet size */ 60 | 61 | #define USB_CDC_CONFIG_DESC_SIZ 67 62 | #define CDC_DATA_HS_IN_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE 63 | #define CDC_DATA_HS_OUT_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE 64 | 65 | #define CDC_DATA_FS_IN_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE 66 | #define CDC_DATA_FS_OUT_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE 67 | 68 | /*---------------------------------------------------------------------*/ 69 | /* CDC definitions */ 70 | /*---------------------------------------------------------------------*/ 71 | #define CDC_SEND_ENCAPSULATED_COMMAND 0x00 72 | #define CDC_GET_ENCAPSULATED_RESPONSE 0x01 73 | #define CDC_SET_COMM_FEATURE 0x02 74 | #define CDC_GET_COMM_FEATURE 0x03 75 | #define CDC_CLEAR_COMM_FEATURE 0x04 76 | #define CDC_SET_LINE_CODING 0x20 77 | #define CDC_GET_LINE_CODING 0x21 78 | #define CDC_SET_CONTROL_LINE_STATE 0x22 79 | #define CDC_SEND_BREAK 0x23 80 | 81 | /** 82 | * @} 83 | */ 84 | 85 | 86 | /** @defgroup USBD_CORE_Exported_TypesDefinitions 87 | * @{ 88 | */ 89 | 90 | /** 91 | * @} 92 | */ 93 | typedef struct 94 | { 95 | uint32_t bitrate; 96 | uint8_t format; 97 | uint8_t paritytype; 98 | uint8_t datatype; 99 | }USBD_CDC_LineCodingTypeDef; 100 | 101 | typedef struct _USBD_CDC_Itf 102 | { 103 | int8_t (* Init) (void); 104 | int8_t (* DeInit) (void); 105 | int8_t (* Control) (uint8_t, uint8_t * , uint16_t); 106 | int8_t (* Receive) (uint8_t *, uint32_t *); 107 | 108 | }USBD_CDC_ItfTypeDef; 109 | 110 | 111 | typedef struct 112 | { 113 | uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE/4]; /* Force 32bits alignment */ 114 | uint8_t CmdOpCode; 115 | uint8_t CmdLength; 116 | uint8_t *RxBuffer; 117 | uint8_t *TxBuffer; 118 | uint32_t RxLength; 119 | uint32_t TxLength; 120 | 121 | __IO uint32_t TxState; 122 | __IO uint32_t RxState; 123 | } 124 | USBD_CDC_HandleTypeDef; 125 | 126 | 127 | 128 | /** @defgroup USBD_CORE_Exported_Macros 129 | * @{ 130 | */ 131 | 132 | /** 133 | * @} 134 | */ 135 | 136 | /** @defgroup USBD_CORE_Exported_Variables 137 | * @{ 138 | */ 139 | 140 | extern USBD_ClassTypeDef USBD_CDC; 141 | #define USBD_CDC_CLASS &USBD_CDC 142 | /** 143 | * @} 144 | */ 145 | 146 | /** @defgroup USB_CORE_Exported_Functions 147 | * @{ 148 | */ 149 | uint8_t USBD_CDC_RegisterInterface (USBD_HandleTypeDef *pdev, 150 | USBD_CDC_ItfTypeDef *fops); 151 | 152 | uint8_t USBD_CDC_SetTxBuffer (USBD_HandleTypeDef *pdev, 153 | uint8_t *pbuff, 154 | uint16_t length); 155 | 156 | uint8_t USBD_CDC_SetRxBuffer (USBD_HandleTypeDef *pdev, 157 | uint8_t *pbuff); 158 | 159 | uint8_t USBD_CDC_ReceivePacket (USBD_HandleTypeDef *pdev); 160 | 161 | uint8_t USBD_CDC_TransmitPacket (USBD_HandleTypeDef *pdev); 162 | /** 163 | * @} 164 | */ 165 | 166 | #ifdef __cplusplus 167 | } 168 | #endif 169 | 170 | #endif /* __USB_CDC_H */ 171 | /** 172 | * @} 173 | */ 174 | 175 | /** 176 | * @} 177 | */ 178 | 179 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 180 | -------------------------------------------------------------------------------- /hw/mware/usb/device/core/usbd_core.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_core.h 4 | * @author MCD Application Team 5 | * @version V2.4.1 6 | * @date 19-June-2015 7 | * @brief Header file for usbd_core.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USBD_CORE_H 30 | #define __USBD_CORE_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbd_conf.h" 38 | #include "usbd_def.h" 39 | #include "usbd_ioreq.h" 40 | #include "usbd_ctlreq.h" 41 | 42 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 43 | * @{ 44 | */ 45 | 46 | /** @defgroup USBD_CORE 47 | * @brief This file is the Header file for usbd_core.c file 48 | * @{ 49 | */ 50 | 51 | 52 | /** @defgroup USBD_CORE_Exported_Defines 53 | * @{ 54 | */ 55 | 56 | /** 57 | * @} 58 | */ 59 | 60 | 61 | /** @defgroup USBD_CORE_Exported_TypesDefinitions 62 | * @{ 63 | */ 64 | 65 | 66 | /** 67 | * @} 68 | */ 69 | 70 | 71 | 72 | /** @defgroup USBD_CORE_Exported_Macros 73 | * @{ 74 | */ 75 | 76 | /** 77 | * @} 78 | */ 79 | 80 | /** @defgroup USBD_CORE_Exported_Variables 81 | * @{ 82 | */ 83 | #define USBD_SOF USBD_LL_SOF 84 | /** 85 | * @} 86 | */ 87 | 88 | /** @defgroup USBD_CORE_Exported_FunctionsPrototype 89 | * @{ 90 | */ 91 | USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev, USBD_DescriptorsTypeDef *pdesc, uint8_t id); 92 | USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev); 93 | USBD_StatusTypeDef USBD_Start (USBD_HandleTypeDef *pdev); 94 | USBD_StatusTypeDef USBD_Stop (USBD_HandleTypeDef *pdev); 95 | USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass); 96 | 97 | USBD_StatusTypeDef USBD_RunTestMode (USBD_HandleTypeDef *pdev); 98 | USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx); 99 | USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx); 100 | 101 | USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup); 102 | USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev , uint8_t epnum, uint8_t *pdata); 103 | USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev , uint8_t epnum, uint8_t *pdata); 104 | 105 | USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev); 106 | USBD_StatusTypeDef USBD_LL_SetSpeed(USBD_HandleTypeDef *pdev, USBD_SpeedTypeDef speed); 107 | USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev); 108 | USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev); 109 | 110 | USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev); 111 | USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum); 112 | USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum); 113 | 114 | USBD_StatusTypeDef USBD_LL_DevConnected(USBD_HandleTypeDef *pdev); 115 | USBD_StatusTypeDef USBD_LL_DevDisconnected(USBD_HandleTypeDef *pdev); 116 | 117 | /* USBD Low Level Driver */ 118 | USBD_StatusTypeDef USBD_LL_Init (USBD_HandleTypeDef *pdev); 119 | USBD_StatusTypeDef USBD_LL_DeInit (USBD_HandleTypeDef *pdev); 120 | USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev); 121 | USBD_StatusTypeDef USBD_LL_Stop (USBD_HandleTypeDef *pdev); 122 | USBD_StatusTypeDef USBD_LL_OpenEP (USBD_HandleTypeDef *pdev, 123 | uint8_t ep_addr, 124 | uint8_t ep_type, 125 | uint16_t ep_mps); 126 | 127 | USBD_StatusTypeDef USBD_LL_CloseEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr); 128 | USBD_StatusTypeDef USBD_LL_FlushEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr); 129 | USBD_StatusTypeDef USBD_LL_StallEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr); 130 | USBD_StatusTypeDef USBD_LL_ClearStallEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr); 131 | uint8_t USBD_LL_IsStallEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr); 132 | USBD_StatusTypeDef USBD_LL_SetUSBAddress (USBD_HandleTypeDef *pdev, uint8_t dev_addr); 133 | USBD_StatusTypeDef USBD_LL_Transmit (USBD_HandleTypeDef *pdev, 134 | uint8_t ep_addr, 135 | uint8_t *pbuf, 136 | uint16_t size); 137 | 138 | USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, 139 | uint8_t ep_addr, 140 | uint8_t *pbuf, 141 | uint16_t size); 142 | 143 | uint32_t USBD_LL_GetRxDataSize (USBD_HandleTypeDef *pdev, uint8_t ep_addr); 144 | void USBD_LL_Delay (uint32_t Delay); 145 | 146 | /** 147 | * @} 148 | */ 149 | 150 | #ifdef __cplusplus 151 | } 152 | #endif 153 | 154 | #endif /* __USBD_CORE_H */ 155 | 156 | /** 157 | * @} 158 | */ 159 | 160 | /** 161 | * @} 162 | */ 163 | 164 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 165 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /hw/mware/usb/device/core/usbd_ctlreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_req.h 4 | * @author MCD Application Team 5 | * @version V2.4.1 6 | * @date 19-June-2015 7 | * @brief Header file for the usbd_req.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USB_REQUEST_H 30 | #define __USB_REQUEST_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbd_def.h" 38 | 39 | 40 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 41 | * @{ 42 | */ 43 | 44 | /** @defgroup USBD_REQ 45 | * @brief header file for the usbd_req.c file 46 | * @{ 47 | */ 48 | 49 | /** @defgroup USBD_REQ_Exported_Defines 50 | * @{ 51 | */ 52 | /** 53 | * @} 54 | */ 55 | 56 | 57 | /** @defgroup USBD_REQ_Exported_Types 58 | * @{ 59 | */ 60 | /** 61 | * @} 62 | */ 63 | 64 | 65 | 66 | /** @defgroup USBD_REQ_Exported_Macros 67 | * @{ 68 | */ 69 | /** 70 | * @} 71 | */ 72 | 73 | /** @defgroup USBD_REQ_Exported_Variables 74 | * @{ 75 | */ 76 | /** 77 | * @} 78 | */ 79 | 80 | /** @defgroup USBD_REQ_Exported_FunctionsPrototype 81 | * @{ 82 | */ 83 | 84 | USBD_StatusTypeDef USBD_StdDevReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 85 | USBD_StatusTypeDef USBD_StdItfReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 86 | USBD_StatusTypeDef USBD_StdEPReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 87 | 88 | 89 | void USBD_CtlError (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 90 | 91 | void USBD_ParseSetupRequest (USBD_SetupReqTypedef *req, uint8_t *pdata); 92 | 93 | void USBD_GetString (uint8_t *desc, uint8_t *unicode, uint16_t *len); 94 | /** 95 | * @} 96 | */ 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | #endif /* __USB_REQUEST_H */ 103 | 104 | /** 105 | * @} 106 | */ 107 | 108 | /** 109 | * @} 110 | */ 111 | 112 | 113 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 114 | -------------------------------------------------------------------------------- /hw/mware/usb/device/core/usbd_ioreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_ioreq.h 4 | * @author MCD Application Team 5 | * @version V2.4.1 6 | * @date 19-June-2015 7 | * @brief Header file for the usbd_ioreq.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USBD_IOREQ_H 30 | #define __USBD_IOREQ_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbd_def.h" 38 | #include "usbd_core.h" 39 | 40 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 41 | * @{ 42 | */ 43 | 44 | /** @defgroup USBD_IOREQ 45 | * @brief header file for the usbd_ioreq.c file 46 | * @{ 47 | */ 48 | 49 | /** @defgroup USBD_IOREQ_Exported_Defines 50 | * @{ 51 | */ 52 | /** 53 | * @} 54 | */ 55 | 56 | 57 | /** @defgroup USBD_IOREQ_Exported_Types 58 | * @{ 59 | */ 60 | 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | 67 | 68 | /** @defgroup USBD_IOREQ_Exported_Macros 69 | * @{ 70 | */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @defgroup USBD_IOREQ_Exported_Variables 77 | * @{ 78 | */ 79 | 80 | /** 81 | * @} 82 | */ 83 | 84 | /** @defgroup USBD_IOREQ_Exported_FunctionsPrototype 85 | * @{ 86 | */ 87 | 88 | USBD_StatusTypeDef USBD_CtlSendData (USBD_HandleTypeDef *pdev, 89 | uint8_t *buf, 90 | uint16_t len); 91 | 92 | USBD_StatusTypeDef USBD_CtlContinueSendData (USBD_HandleTypeDef *pdev, 93 | uint8_t *pbuf, 94 | uint16_t len); 95 | 96 | USBD_StatusTypeDef USBD_CtlPrepareRx (USBD_HandleTypeDef *pdev, 97 | uint8_t *pbuf, 98 | uint16_t len); 99 | 100 | USBD_StatusTypeDef USBD_CtlContinueRx (USBD_HandleTypeDef *pdev, 101 | uint8_t *pbuf, 102 | uint16_t len); 103 | 104 | USBD_StatusTypeDef USBD_CtlSendStatus (USBD_HandleTypeDef *pdev); 105 | 106 | USBD_StatusTypeDef USBD_CtlReceiveStatus (USBD_HandleTypeDef *pdev); 107 | 108 | uint16_t USBD_GetRxCount (USBD_HandleTypeDef *pdev , 109 | uint8_t epnum); 110 | 111 | /** 112 | * @} 113 | */ 114 | 115 | #ifdef __cplusplus 116 | } 117 | #endif 118 | 119 | #endif /* __USBD_IOREQ_H */ 120 | 121 | /** 122 | * @} 123 | */ 124 | 125 | /** 126 | * @} 127 | */ 128 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 129 | -------------------------------------------------------------------------------- /hw/mware/usb/device/cust/usbd_cdc_if.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file USB_Device/CDC_Standalone/Inc/usbd_cdc_interface.h 4 | * @author MCD Application Team 5 | * @version V1.0.3 6 | * @date 18-November-2015 7 | * @brief Header for usbd_cdc_interface.c file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USBD_CDC_IF_H 30 | #define __USBD_CDC_IF_H 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "usbd_cdc.h" 34 | 35 | /* Exported types ------------------------------------------------------------*/ 36 | /* Exported constants --------------------------------------------------------*/ 37 | /* User can use this section to tailor USARTx/UARTx instance used and associated 38 | resources */ 39 | /* Definition for USARTx clock resources */ 40 | #define USARTx USART1 41 | #define USARTx_CLK_ENABLE() __HAL_RCC_USART1_CLK_ENABLE(); 42 | #define DMAx_CLK_ENABLE() __HAL_RCC_DMA2_CLK_ENABLE() 43 | #define USARTx_RX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() 44 | #define USARTx_TX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() 45 | 46 | #define USARTx_FORCE_RESET() __HAL_RCC_USART1_FORCE_RESET() 47 | #define USARTx_RELEASE_RESET() __HAL_RCC_USART1_RELEASE_RESET() 48 | 49 | /* Definition for USARTx Pins */ 50 | #define USARTx_TX_PIN GPIO_PIN_9 51 | #define USARTx_TX_GPIO_PORT GPIOA 52 | #define USARTx_TX_AF GPIO_AF7_USART1 53 | #define USARTx_RX_PIN GPIO_PIN_10 54 | #define USARTx_RX_GPIO_PORT GPIOA 55 | #define USARTx_RX_AF GPIO_AF7_USART1 56 | 57 | /* Definition for USARTx's NVIC: used for receiving data over Rx pin */ 58 | #define USARTx_IRQn USART1_IRQn 59 | #define USARTx_IRQHandler USART1_IRQHandler 60 | 61 | /* Definition for USARTx's DMA: used for transmitting data over Tx pin */ 62 | #define USARTx_TX_DMA_CHANNEL DMA_CHANNEL_4 63 | #define USARTx_TX_DMA_STREAM DMA2_Stream7 64 | 65 | #define USARTx_DMA_TX_IRQHandler DMA2_Stream7_IRQHandler 66 | #define USARTx_DMA_TX_IRQn DMA2_Stream7_IRQn 67 | 68 | /* Definition for TIMx clock resources */ 69 | #define TIMx TIM3 70 | #define TIMx_CLK_ENABLE __HAL_RCC_TIM3_CLK_ENABLE 71 | #define TIMx_FORCE_RESET() __HAL_RCC_USART1_FORCE_RESET() 72 | #define TIMx_RELEASE_RESET() __HAL_RCC_USART1_RELEASE_RESET() 73 | 74 | /* Definition for TIMx's NVIC */ 75 | #define TIMx_IRQn TIM3_IRQn 76 | #define TIMx_IRQHandler TIM3_IRQHandler 77 | 78 | /* Periodically, the state of the buffer "UserTxBuffer" is checked. 79 | The period depends on CDC_POLLING_INTERVAL */ 80 | #define CDC_POLLING_INTERVAL 5 /* in ms. The max is 65 and the min is 1 */ 81 | 82 | typedef void (ReceiveCb_t)(uint8_t* Buf, uint32_t Len); 83 | /* Exported macro ------------------------------------------------------------*/ 84 | /* Exported functions ------------------------------------------------------- */ 85 | 86 | void CDC_Iif_RegisterReceiveCb(ReceiveCb_t *NewReceiveCb); 87 | void CDC_Itf_Send(uint8_t *Buf, uint32_t Len); 88 | void CDC_Itf_Flush(); 89 | #endif /* __USBD_CDC_IF_H */ 90 | 91 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 92 | -------------------------------------------------------------------------------- /hw/mware/usb/device/cust/usbd_desc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file USB_Device/CDC_Standalone/Inc/usbd_desc.h 4 | * @author MCD Application Team 5 | * @version V1.0.3 6 | * @date 18-November-2015 7 | * @brief Header for usbd_desc.c module 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USBD_DESC_H 30 | #define __USBD_DESC_H 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "usbd_def.h" 34 | 35 | /* Exported types ------------------------------------------------------------*/ 36 | /* Exported constants --------------------------------------------------------*/ 37 | #define DEVICE_ID1 (0x1FFF7A10) 38 | #define DEVICE_ID2 (0x1FFF7A14) 39 | #define DEVICE_ID3 (0x1FFF7A18) 40 | 41 | #define USB_SIZ_STRING_SERIAL 0x1A 42 | /* Exported macro ------------------------------------------------------------*/ 43 | /* Exported functions ------------------------------------------------------- */ 44 | extern USBD_DescriptorsTypeDef VCP_Desc; 45 | 46 | #endif /* __USBD_DESC_H */ 47 | 48 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 49 | -------------------------------------------------------------------------------- /hw/mware/usb/host/core/usbh_core.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbh_core.h 4 | * @author MCD Application Team 5 | * @version V3.2.2 6 | * @date 07-July-2015 7 | * @brief Header file for usbh_core.c 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive ----------------------------------------------*/ 29 | #ifndef __USBH_CORE_H 30 | #define __USBH_CORE_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbh_conf.h" 38 | #include "usbh_def.h" 39 | #include "usbh_ioreq.h" 40 | #include "usbh_pipes.h" 41 | #include "usbh_ctlreq.h" 42 | 43 | /** @addtogroup USBH_LIB 44 | * @{ 45 | */ 46 | 47 | /** @addtogroup USBH_LIB_CORE 48 | * @{ 49 | */ 50 | 51 | /** @defgroup USBH_CORE 52 | * @brief This file is the Header file for usbh_core.c 53 | * @{ 54 | */ 55 | 56 | 57 | /** @defgroup USBH_CORE_Exported_Defines 58 | * @{ 59 | */ 60 | 61 | /** 62 | * @} 63 | */ 64 | #define HOST_USER_SELECT_CONFIGURATION 1 65 | #define HOST_USER_CLASS_ACTIVE 2 66 | #define HOST_USER_CLASS_SELECTED 3 67 | #define HOST_USER_CONNECTION 4 68 | #define HOST_USER_DISCONNECTION 5 69 | #define HOST_USER_UNRECOVERED_ERROR 6 70 | 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | 77 | 78 | /** @defgroup USBH_CORE_Exported_Macros 79 | * @{ 80 | */ 81 | 82 | /** 83 | * @} 84 | */ 85 | 86 | /** @defgroup USBH_CORE_Exported_Variables 87 | * @{ 88 | */ 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | /** @defgroup USBH_CORE_Exported_FunctionsPrototype 95 | * @{ 96 | */ 97 | 98 | 99 | USBH_StatusTypeDef USBH_Init(USBH_HandleTypeDef *phost, void (*pUsrFunc)(USBH_HandleTypeDef *phost, uint8_t ), uint8_t id); 100 | USBH_StatusTypeDef USBH_DeInit(USBH_HandleTypeDef *phost); 101 | USBH_StatusTypeDef USBH_RegisterClass(USBH_HandleTypeDef *phost, USBH_ClassTypeDef *pclass); 102 | USBH_StatusTypeDef USBH_SelectInterface(USBH_HandleTypeDef *phost, uint8_t interface); 103 | uint8_t USBH_FindInterface(USBH_HandleTypeDef *phost, 104 | uint8_t Class, 105 | uint8_t SubClass, 106 | uint8_t Protocol); 107 | uint8_t USBH_GetActiveClass(USBH_HandleTypeDef *phost); 108 | 109 | uint8_t USBH_FindInterfaceIndex(USBH_HandleTypeDef *phost, 110 | uint8_t interface_number, 111 | uint8_t alt_settings); 112 | 113 | USBH_StatusTypeDef USBH_Start (USBH_HandleTypeDef *phost); 114 | USBH_StatusTypeDef USBH_Stop (USBH_HandleTypeDef *phost); 115 | USBH_StatusTypeDef USBH_Process (USBH_HandleTypeDef *phost); 116 | USBH_StatusTypeDef USBH_ReEnumerate (USBH_HandleTypeDef *phost); 117 | 118 | /* USBH Low Level Driver */ 119 | USBH_StatusTypeDef USBH_LL_Init (USBH_HandleTypeDef *phost); 120 | USBH_StatusTypeDef USBH_LL_DeInit (USBH_HandleTypeDef *phost); 121 | USBH_StatusTypeDef USBH_LL_Start (USBH_HandleTypeDef *phost); 122 | USBH_StatusTypeDef USBH_LL_Stop (USBH_HandleTypeDef *phost); 123 | 124 | USBH_StatusTypeDef USBH_LL_Connect (USBH_HandleTypeDef *phost); 125 | USBH_StatusTypeDef USBH_LL_Disconnect (USBH_HandleTypeDef *phost); 126 | USBH_SpeedTypeDef USBH_LL_GetSpeed (USBH_HandleTypeDef *phost); 127 | USBH_StatusTypeDef USBH_LL_ResetPort (USBH_HandleTypeDef *phost); 128 | uint32_t USBH_LL_GetLastXferSize (USBH_HandleTypeDef *phost, uint8_t ); 129 | USBH_StatusTypeDef USBH_LL_DriverVBUS (USBH_HandleTypeDef *phost, uint8_t ); 130 | 131 | USBH_StatusTypeDef USBH_LL_OpenPipe (USBH_HandleTypeDef *phost, uint8_t, uint8_t, uint8_t, uint8_t , uint8_t, uint16_t ); 132 | USBH_StatusTypeDef USBH_LL_ClosePipe (USBH_HandleTypeDef *phost, uint8_t ); 133 | USBH_StatusTypeDef USBH_LL_SubmitURB (USBH_HandleTypeDef *phost, uint8_t, uint8_t,uint8_t, uint8_t, uint8_t*, uint16_t, uint8_t ); 134 | USBH_URBStateTypeDef USBH_LL_GetURBState (USBH_HandleTypeDef *phost, uint8_t ); 135 | #if (USBH_USE_OS == 1) 136 | USBH_StatusTypeDef USBH_LL_NotifyURBChange (USBH_HandleTypeDef *phost); 137 | #endif 138 | USBH_StatusTypeDef USBH_LL_SetToggle (USBH_HandleTypeDef *phost, uint8_t , uint8_t ); 139 | uint8_t USBH_LL_GetToggle (USBH_HandleTypeDef *phost, uint8_t ); 140 | 141 | /* USBH Time base */ 142 | void USBH_Delay (uint32_t Delay); 143 | void USBH_LL_SetTimer (USBH_HandleTypeDef *phost, uint32_t ); 144 | void USBH_LL_IncTimer (USBH_HandleTypeDef *phost); 145 | /** 146 | * @} 147 | */ 148 | 149 | #ifdef __cplusplus 150 | } 151 | #endif 152 | 153 | #endif /* __USBH_CORE_H */ 154 | /** 155 | * @} 156 | */ 157 | 158 | /** 159 | * @} 160 | */ 161 | 162 | /** 163 | * @} 164 | */ 165 | 166 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 167 | 168 | 169 | 170 | -------------------------------------------------------------------------------- /hw/mware/usb/host/core/usbh_ctlreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbh_ctlreq.h 4 | * @author MCD Application Team 5 | * @version V3.2.2 6 | * @date 07-July-2015 7 | * @brief Header file for usbh_ctlreq.c 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive ----------------------------------------------*/ 29 | #ifndef __USBH_CTLREQ_H 30 | #define __USBH_CTLREQ_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbh_core.h" 38 | 39 | /** @addtogroup USBH_LIB 40 | * @{ 41 | */ 42 | 43 | /** @addtogroup USBH_LIB_CORE 44 | * @{ 45 | */ 46 | 47 | /** @defgroup USBH_CTLREQ 48 | * @brief This file is the 49 | * @{ 50 | */ 51 | 52 | 53 | /** @defgroup USBH_CTLREQ_Exported_Defines 54 | * @{ 55 | */ 56 | /*Standard Feature Selector for clear feature command*/ 57 | #define FEATURE_SELECTOR_ENDPOINT 0X00 58 | #define FEATURE_SELECTOR_DEVICE 0X01 59 | 60 | 61 | #define INTERFACE_DESC_TYPE 0x04 62 | #define ENDPOINT_DESC_TYPE 0x05 63 | #define INTERFACE_DESC_SIZE 0x09 64 | 65 | /** 66 | * @} 67 | */ 68 | 69 | 70 | /** @defgroup USBH_CTLREQ_Exported_Types 71 | * @{ 72 | */ 73 | /** 74 | * @} 75 | */ 76 | 77 | 78 | /** @defgroup USBH_CTLREQ_Exported_Macros 79 | * @{ 80 | */ 81 | /** 82 | * @} 83 | */ 84 | 85 | /** @defgroup USBH_CTLREQ_Exported_Variables 86 | * @{ 87 | */ 88 | extern uint8_t USBH_CfgDesc[512]; 89 | /** 90 | * @} 91 | */ 92 | 93 | /** @defgroup USBH_CTLREQ_Exported_FunctionsPrototype 94 | * @{ 95 | */ 96 | USBH_StatusTypeDef USBH_CtlReq (USBH_HandleTypeDef *phost, 97 | uint8_t *buff, 98 | uint16_t length); 99 | 100 | USBH_StatusTypeDef USBH_GetDescriptor(USBH_HandleTypeDef *phost, 101 | uint8_t req_type, 102 | uint16_t value_idx, 103 | uint8_t* buff, 104 | uint16_t length ); 105 | 106 | USBH_StatusTypeDef USBH_Get_DevDesc(USBH_HandleTypeDef *phost, 107 | uint8_t length); 108 | 109 | USBH_StatusTypeDef USBH_Get_StringDesc(USBH_HandleTypeDef *phost, 110 | uint8_t string_index, 111 | uint8_t *buff, 112 | uint16_t length); 113 | 114 | USBH_StatusTypeDef USBH_SetCfg(USBH_HandleTypeDef *phost, 115 | uint16_t configuration_value); 116 | 117 | USBH_StatusTypeDef USBH_Get_CfgDesc(USBH_HandleTypeDef *phost, 118 | uint16_t length); 119 | 120 | USBH_StatusTypeDef USBH_SetAddress(USBH_HandleTypeDef *phost, 121 | uint8_t DeviceAddress); 122 | 123 | USBH_StatusTypeDef USBH_SetInterface(USBH_HandleTypeDef *phost, 124 | uint8_t ep_num, uint8_t altSetting); 125 | 126 | USBH_StatusTypeDef USBH_ClrFeature(USBH_HandleTypeDef *phost, 127 | uint8_t ep_num); 128 | 129 | USBH_DescHeader_t *USBH_GetNextDesc (uint8_t *pbuf, 130 | uint16_t *ptr); 131 | /** 132 | * @} 133 | */ 134 | 135 | #ifdef __cplusplus 136 | } 137 | #endif 138 | 139 | #endif /* __USBH_CTLREQ_H */ 140 | 141 | /** 142 | * @} 143 | */ 144 | 145 | /** 146 | * @} 147 | */ 148 | 149 | /** 150 | * @} 151 | */ 152 | 153 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 154 | 155 | 156 | -------------------------------------------------------------------------------- /hw/mware/usb/host/core/usbh_ioreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbh_ioreq.h 4 | * @author MCD Application Team 5 | * @version V3.2.2 6 | * @date 07-July-2015 7 | * @brief Header file for usbh_ioreq.c 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive ----------------------------------------------*/ 29 | #ifndef __USBH_IOREQ_H 30 | #define __USBH_IOREQ_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbh_conf.h" 38 | #include "usbh_core.h" 39 | 40 | /** @addtogroup USBH_LIB 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup USBH_LIB_CORE 45 | * @{ 46 | */ 47 | 48 | /** @defgroup USBH_IOREQ 49 | * @brief This file is the header file for usbh_ioreq.c 50 | * @{ 51 | */ 52 | 53 | 54 | /** @defgroup USBH_IOREQ_Exported_Defines 55 | * @{ 56 | */ 57 | 58 | #define USBH_PID_SETUP 0 59 | #define USBH_PID_DATA 1 60 | 61 | #define USBH_EP_CONTROL 0 62 | #define USBH_EP_ISO 1 63 | #define USBH_EP_BULK 2 64 | #define USBH_EP_INTERRUPT 3 65 | 66 | #define USBH_SETUP_PKT_SIZE 8 67 | /** 68 | * @} 69 | */ 70 | 71 | 72 | /** @defgroup USBH_IOREQ_Exported_Types 73 | * @{ 74 | */ 75 | /** 76 | * @} 77 | */ 78 | 79 | 80 | /** @defgroup USBH_IOREQ_Exported_Macros 81 | * @{ 82 | */ 83 | /** 84 | * @} 85 | */ 86 | 87 | /** @defgroup USBH_IOREQ_Exported_Variables 88 | * @{ 89 | */ 90 | /** 91 | * @} 92 | */ 93 | 94 | /** @defgroup USBH_IOREQ_Exported_FunctionsPrototype 95 | * @{ 96 | */ 97 | USBH_StatusTypeDef USBH_CtlSendSetup (USBH_HandleTypeDef *phost, 98 | uint8_t *buff, 99 | uint8_t hc_num); 100 | 101 | USBH_StatusTypeDef USBH_CtlSendData (USBH_HandleTypeDef *phost, 102 | uint8_t *buff, 103 | uint16_t length, 104 | uint8_t hc_num, 105 | uint8_t do_ping ); 106 | 107 | USBH_StatusTypeDef USBH_CtlReceiveData(USBH_HandleTypeDef *phost, 108 | uint8_t *buff, 109 | uint16_t length, 110 | uint8_t hc_num); 111 | 112 | USBH_StatusTypeDef USBH_BulkReceiveData(USBH_HandleTypeDef *phost, 113 | uint8_t *buff, 114 | uint16_t length, 115 | uint8_t hc_num); 116 | 117 | USBH_StatusTypeDef USBH_BulkSendData (USBH_HandleTypeDef *phost, 118 | uint8_t *buff, 119 | uint16_t length, 120 | uint8_t hc_num, 121 | uint8_t do_ping ); 122 | 123 | USBH_StatusTypeDef USBH_InterruptReceiveData(USBH_HandleTypeDef *phost, 124 | uint8_t *buff, 125 | uint8_t length, 126 | uint8_t hc_num); 127 | 128 | USBH_StatusTypeDef USBH_InterruptSendData(USBH_HandleTypeDef *phost, 129 | uint8_t *buff, 130 | uint8_t length, 131 | uint8_t hc_num); 132 | 133 | 134 | USBH_StatusTypeDef USBH_IsocReceiveData(USBH_HandleTypeDef *phost, 135 | uint8_t *buff, 136 | uint32_t length, 137 | uint8_t hc_num); 138 | 139 | 140 | USBH_StatusTypeDef USBH_IsocSendData(USBH_HandleTypeDef *phost, 141 | uint8_t *buff, 142 | uint32_t length, 143 | uint8_t hc_num); 144 | /** 145 | * @} 146 | */ 147 | 148 | #ifdef __cplusplus 149 | } 150 | #endif 151 | 152 | #endif /* __USBH_IOREQ_H */ 153 | 154 | /** 155 | * @} 156 | */ 157 | 158 | /** 159 | * @} 160 | */ 161 | 162 | /** 163 | * @} 164 | */ 165 | 166 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 167 | 168 | 169 | -------------------------------------------------------------------------------- /hw/mware/usb/host/core/usbh_pipes.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbh_pipes.c 4 | * @author MCD Application Team 5 | * @version V3.2.2 6 | * @date 07-July-2015 7 | * @brief This file implements functions for opening and closing Pipes 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "usbh_pipes.h" 30 | 31 | /** @addtogroup USBH_LIB 32 | * @{ 33 | */ 34 | 35 | /** @addtogroup USBH_LIB_CORE 36 | * @{ 37 | */ 38 | 39 | /** @defgroup USBH_PIPES 40 | * @brief This file includes opening and closing Pipes 41 | * @{ 42 | */ 43 | 44 | /** @defgroup USBH_PIPES_Private_Defines 45 | * @{ 46 | */ 47 | /** 48 | * @} 49 | */ 50 | 51 | /** @defgroup USBH_PIPES_Private_TypesDefinitions 52 | * @{ 53 | */ 54 | /** 55 | * @} 56 | */ 57 | 58 | 59 | /** @defgroup USBH_PIPES_Private_Macros 60 | * @{ 61 | */ 62 | /** 63 | * @} 64 | */ 65 | 66 | 67 | /** @defgroup USBH_PIPES_Private_Variables 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | 76 | /** @defgroup USBH_PIPES_Private_Functions 77 | * @{ 78 | */ 79 | static uint16_t USBH_GetFreePipe (USBH_HandleTypeDef *phost); 80 | 81 | 82 | /** 83 | * @brief USBH_Open_Pipe 84 | * Open a pipe 85 | * @param phost: Host Handle 86 | * @param pipe_num: Pipe Number 87 | * @param dev_address: USB Device address allocated to attached device 88 | * @param speed : USB device speed (Full/Low) 89 | * @param ep_type: end point type (Bulk/int/ctl) 90 | * @param mps: max pkt size 91 | * @retval USBH Status 92 | */ 93 | USBH_StatusTypeDef USBH_OpenPipe (USBH_HandleTypeDef *phost, 94 | uint8_t pipe_num, 95 | uint8_t epnum, 96 | uint8_t dev_address, 97 | uint8_t speed, 98 | uint8_t ep_type, 99 | uint16_t mps) 100 | { 101 | 102 | USBH_LL_OpenPipe(phost, 103 | pipe_num, 104 | epnum, 105 | dev_address, 106 | speed, 107 | ep_type, 108 | mps); 109 | 110 | return USBH_OK; 111 | 112 | } 113 | 114 | /** 115 | * @brief USBH_ClosePipe 116 | * Close a pipe 117 | * @param phost: Host Handle 118 | * @param pipe_num: Pipe Number 119 | * @retval USBH Status 120 | */ 121 | USBH_StatusTypeDef USBH_ClosePipe (USBH_HandleTypeDef *phost, 122 | uint8_t pipe_num) 123 | { 124 | 125 | USBH_LL_ClosePipe(phost, pipe_num); 126 | 127 | return USBH_OK; 128 | 129 | } 130 | 131 | /** 132 | * @brief USBH_Alloc_Pipe 133 | * Allocate a new Pipe 134 | * @param phost: Host Handle 135 | * @param ep_addr: End point for which the Pipe to be allocated 136 | * @retval Pipe number 137 | */ 138 | uint8_t USBH_AllocPipe (USBH_HandleTypeDef *phost, uint8_t ep_addr) 139 | { 140 | uint16_t pipe; 141 | 142 | pipe = USBH_GetFreePipe(phost); 143 | 144 | if (pipe != 0xFFFF) 145 | { 146 | phost->Pipes[pipe] = 0x8000 | ep_addr; 147 | } 148 | return pipe; 149 | } 150 | 151 | /** 152 | * @brief USBH_Free_Pipe 153 | * Free the USB Pipe 154 | * @param phost: Host Handle 155 | * @param idx: Pipe number to be freed 156 | * @retval USBH Status 157 | */ 158 | USBH_StatusTypeDef USBH_FreePipe (USBH_HandleTypeDef *phost, uint8_t idx) 159 | { 160 | if(idx < 11) 161 | { 162 | phost->Pipes[idx] &= 0x7FFF; 163 | } 164 | return USBH_OK; 165 | } 166 | 167 | /** 168 | * @brief USBH_GetFreePipe 169 | * @param phost: Host Handle 170 | * Get a free Pipe number for allocation to a device endpoint 171 | * @retval idx: Free Pipe number 172 | */ 173 | static uint16_t USBH_GetFreePipe (USBH_HandleTypeDef *phost) 174 | { 175 | uint8_t idx = 0; 176 | 177 | for (idx = 0 ; idx < 11 ; idx++) 178 | { 179 | if ((phost->Pipes[idx] & 0x8000) == 0) 180 | { 181 | return idx; 182 | } 183 | } 184 | return 0xFFFF; 185 | } 186 | /** 187 | * @} 188 | */ 189 | 190 | /** 191 | * @} 192 | */ 193 | 194 | /** 195 | * @} 196 | */ 197 | 198 | /** 199 | * @} 200 | */ 201 | 202 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 203 | 204 | 205 | -------------------------------------------------------------------------------- /hw/mware/usb/host/core/usbh_pipes.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbh_pipes.h 4 | * @author MCD Application Team 5 | * @version V3.2.2 6 | * @date 07-July-2015 7 | * @brief Header file for usbh_pipes.c 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive ----------------------------------------------*/ 29 | #ifndef __USBH_PIPES_H 30 | #define __USBH_PIPES_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbh_core.h" 38 | 39 | /** @addtogroup USBH_LIB 40 | * @{ 41 | */ 42 | 43 | /** @addtogroup USBH_LIB_CORE 44 | * @{ 45 | */ 46 | 47 | /** @defgroup USBH_PIPES 48 | * @brief This file is the header file for usbh_pipes.c 49 | * @{ 50 | */ 51 | 52 | /** @defgroup USBH_PIPES_Exported_Defines 53 | * @{ 54 | */ 55 | /** 56 | * @} 57 | */ 58 | 59 | /** @defgroup USBH_PIPES_Exported_Types 60 | * @{ 61 | */ 62 | /** 63 | * @} 64 | */ 65 | 66 | 67 | /** @defgroup USBH_PIPES_Exported_Macros 68 | * @{ 69 | */ 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @defgroup USBH_PIPES_Exported_Variables 75 | * @{ 76 | */ 77 | /** 78 | * @} 79 | */ 80 | 81 | /** @defgroup USBH_PIPES_Exported_FunctionsPrototype 82 | * @{ 83 | */ 84 | 85 | USBH_StatusTypeDef USBH_OpenPipe (USBH_HandleTypeDef *phost, 86 | uint8_t ch_num, 87 | uint8_t epnum, 88 | uint8_t dev_address, 89 | uint8_t speed, 90 | uint8_t ep_type, 91 | uint16_t mps); 92 | 93 | USBH_StatusTypeDef USBH_ClosePipe (USBH_HandleTypeDef *phost, 94 | uint8_t pipe_num); 95 | 96 | uint8_t USBH_AllocPipe (USBH_HandleTypeDef *phost, 97 | uint8_t ep_addr); 98 | 99 | USBH_StatusTypeDef USBH_FreePipe (USBH_HandleTypeDef *phost, 100 | uint8_t idx); 101 | 102 | 103 | 104 | 105 | /** 106 | * @} 107 | */ 108 | 109 | 110 | #ifdef __cplusplus 111 | } 112 | #endif 113 | 114 | #endif /* __USBH_PIPES_H */ 115 | 116 | 117 | /** 118 | * @} 119 | */ 120 | 121 | /** 122 | * @} 123 | */ 124 | 125 | /** 126 | * @} 127 | */ 128 | 129 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 130 | 131 | 132 | -------------------------------------------------------------------------------- /hw/mware/usb/host/hid/usbh_hid_parser.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbh_hid_parser.c 4 | * @author MCD Application Team 5 | * @version V3.2.2 6 | * @date 07-July-2015 7 | * @brief This file is the HID Layer Handlers for USB Host HID class. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "usbh_hid_parser.h" 29 | 30 | 31 | /** @addtogroup USBH_LIB 32 | * @{ 33 | */ 34 | 35 | /** @addtogroup USBH_CLASS 36 | * @{ 37 | */ 38 | 39 | /** @addtogroup USBH_HID_CLASS 40 | * @{ 41 | */ 42 | 43 | /** @defgroup USBH_HID_PARSER 44 | * @brief This file includes HID parsers for USB Host HID class. 45 | * @{ 46 | */ 47 | 48 | /** @defgroup USBH_HID_PARSER_Private_TypesDefinitions 49 | * @{ 50 | */ 51 | /** 52 | * @} 53 | */ 54 | 55 | 56 | /** @defgroup USBH_HID_PARSER_Private_Defines 57 | * @{ 58 | */ 59 | /** 60 | * @} 61 | */ 62 | 63 | 64 | /** @defgroup USBH_HID_PARSER_Private_Macros 65 | * @{ 66 | */ 67 | /** 68 | * @} 69 | */ 70 | 71 | /** @defgroup USBH_HID_PARSER_Private_FunctionPrototypes 72 | * @{ 73 | */ 74 | 75 | /** 76 | * @} 77 | */ 78 | 79 | 80 | /** @defgroup USBH_HID_PARSER_Private_Variables 81 | * @{ 82 | */ 83 | 84 | /** 85 | * @} 86 | */ 87 | 88 | 89 | /** @defgroup USBH_HID_PARSER_Private_Functions 90 | * @{ 91 | */ 92 | 93 | /** 94 | * @brief HID_ReadItem 95 | * The function read a report item. 96 | * @param ri: report item 97 | * @param ndx: report index 98 | * @retval status (0 : fail / otherwise: item value) 99 | */ 100 | uint32_t HID_ReadItem(HID_Report_ItemTypedef *ri, uint8_t ndx) 101 | { 102 | uint32_t val=0; 103 | uint32_t x=0; 104 | uint32_t bofs; 105 | uint8_t *data=ri->data; 106 | uint8_t shift=ri->shift; 107 | 108 | /* get the logical value of the item */ 109 | 110 | /* if this is an array, wee may need to offset ri->data.*/ 111 | if (ri->count > 0) 112 | { 113 | /* If app tries to read outside of the array. */ 114 | if (ri->count <= ndx) 115 | { 116 | return(0); 117 | } 118 | 119 | /* calculate bit offset */ 120 | bofs = ndx*ri->size; 121 | bofs += shift; 122 | /* calculate byte offset + shift pair from bit offset. */ 123 | data+=bofs/8; 124 | shift=(uint8_t)(bofs%8); 125 | } 126 | /* read data bytes in little endian order */ 127 | for(x=0; x < ((ri->size & 0x7) ? (ri->size/8)+1 : (ri->size/8)); x++) 128 | { 129 | val=(uint32_t)(*data << (x*8)); 130 | } 131 | val=(val >> shift) & ((1<size)-1); 132 | 133 | if (val < ri->logical_min || val > ri->logical_max) 134 | { 135 | return(0); 136 | } 137 | 138 | /* convert logical value to physical value */ 139 | /* See if the number is negative or not. */ 140 | if ((ri->sign) && (val & (1<<(ri->size-1)))) 141 | { 142 | /* yes, so sign extend value to 32 bits. */ 143 | int vs=(int)((-1 & ~((1<<(ri->size))-1)) | val); 144 | 145 | if(ri->resolution == 1) 146 | { 147 | return((uint32_t)vs); 148 | } 149 | return((uint32_t)(vs*ri->resolution)); 150 | } 151 | else 152 | { 153 | if(ri->resolution == 1) 154 | { 155 | return(val); 156 | } 157 | return(val*ri->resolution); 158 | } 159 | } 160 | 161 | /** 162 | * @brief HID_WriteItem 163 | * The function write a report item. 164 | * @param ri: report item 165 | * @param ndx: report index 166 | * @retval status (1: fail/ 0 : Ok) 167 | */ 168 | uint32_t HID_WriteItem(HID_Report_ItemTypedef *ri, uint32_t value, uint8_t ndx) 169 | { 170 | uint32_t x; 171 | uint32_t mask; 172 | uint32_t bofs; 173 | uint8_t *data=ri->data; 174 | uint8_t shift=ri->shift; 175 | 176 | if (value < ri->physical_min || value > ri->physical_max) 177 | { 178 | return(1); 179 | } 180 | 181 | /* if this is an array, wee may need to offset ri->data.*/ 182 | if (ri->count > 0) 183 | { 184 | /* If app tries to read outside of the array. */ 185 | if (ri->count >= ndx) 186 | { 187 | return(0); 188 | } 189 | /* calculate bit offset */ 190 | bofs = ndx*ri->size; 191 | bofs += shift; 192 | /* calculate byte offset + shift pair from bit offset. */ 193 | data+=bofs/8; 194 | shift=(uint8_t)(bofs%8); 195 | 196 | } 197 | 198 | /* Convert physical value to logical value. */ 199 | if (ri->resolution != 1) 200 | { 201 | value=value/ri->resolution; 202 | } 203 | 204 | /* Write logical value to report in little endian order. */ 205 | mask=(uint32_t)((1<size)-1); 206 | value = (value & mask) << shift; 207 | 208 | for(x=0; x < ((ri->size & 0x7) ? (ri->size/8)+1 : (ri->size/8)); x++) 209 | { 210 | *(ri->data+x)=(uint8_t)((*(ri->data+x) & ~(mask>>(x*8))) | ((value>>(x*8)) & (mask>>(x*8)))); 211 | } 212 | return(0); 213 | } 214 | 215 | /** 216 | * @} 217 | */ 218 | 219 | /** 220 | * @} 221 | */ 222 | 223 | /** 224 | * @} 225 | */ 226 | 227 | /** 228 | * @} 229 | */ 230 | 231 | 232 | /** 233 | * @} 234 | */ 235 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 236 | -------------------------------------------------------------------------------- /hw/mware/usb/host/hid/usbh_hid_parser.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbh_hid_parser.c 4 | * @author MCD Application Team 5 | * @version V3.2.2 6 | * @date 07-July-2015 7 | * @brief This file is the header file of the usbh_hid_parser.c 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive -----------------------------------------------*/ 29 | #ifndef __USBH_HID_PARSER_H 30 | #define __USBH_HID_PARSER_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbh_hid.h" 38 | #include "usbh_hid_usage.h" 39 | 40 | /** @addtogroup USBH_LIB 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup USBH_CLASS 45 | * @{ 46 | */ 47 | 48 | /** @addtogroup USBH_HID_CLASS 49 | * @{ 50 | */ 51 | 52 | /** @defgroup USBH_HID_PARSER 53 | * @brief This file is the Header file for usbh_hid_parser.c 54 | * @{ 55 | */ 56 | 57 | 58 | /** @defgroup USBH_HID_PARSER_Exported_Types 59 | * @{ 60 | */ 61 | typedef struct 62 | { 63 | uint8_t *data; 64 | uint32_t size; 65 | uint8_t shift; 66 | uint8_t count; 67 | uint8_t sign; 68 | uint32_t logical_min; /*min value device can return*/ 69 | uint32_t logical_max; /*max value device can return*/ 70 | uint32_t physical_min; /*min vale read can report*/ 71 | uint32_t physical_max; /*max value read can report*/ 72 | uint32_t resolution; 73 | } 74 | HID_Report_ItemTypedef; 75 | 76 | 77 | uint32_t HID_ReadItem (HID_Report_ItemTypedef *ri, uint8_t ndx); 78 | uint32_t HID_WriteItem(HID_Report_ItemTypedef *ri, uint32_t value, uint8_t ndx); 79 | 80 | 81 | /** 82 | * @} 83 | */ 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif /* __USBH_HID_PARSER_H */ 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /** 100 | * @} 101 | */ 102 | 103 | /** 104 | * @} 105 | */ 106 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 107 | -------------------------------------------------------------------------------- /hw/rom/romcc.h: -------------------------------------------------------------------------------- 1 | #ifndef _ROMCC_H 2 | #define _ROMCC_H 3 | 4 | typedef enum 5 | { 6 | ROM_CC_SECTION_KROM, 7 | ROM_CC_SECTION_BROM, 8 | ROM_CC_SECTION_CROM 9 | } rom_cc_section_t; 10 | 11 | unsigned char *rom_cc_get_memory(rom_cc_section_t rom_section); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /hw/rom/romdd.h: -------------------------------------------------------------------------------- 1 | #ifndef _ROMDD_H 2 | #define _ROMDD_H 3 | 4 | typedef enum 5 | { 6 | ROM_DD_SECTION_DOS 7 | } rom_dd_section_t; 8 | 9 | unsigned char *rom_dd_get_memory(rom_dd_section_t rom_section); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /hw/sm/sm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 state machine 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | #ifndef _SM_H 25 | #define _SM_H 26 | 27 | #include "stm32f7xx_hal.h" 28 | #include "main.h" 29 | 30 | typedef enum 31 | { 32 | SM_STATE_MENU, 33 | SM_STATE_FILE_SELECT, 34 | SM_STATE_COLOR_SCREEN, 35 | SM_STATE_EMULATOR, 36 | SM_STATE_ERROR, 37 | } sm_state_t; 38 | 39 | void sm_init(); 40 | void sm_run(); 41 | uint8_t sm_get_disp_stats_flag(); 42 | void sm_error_occured(); 43 | sm_state_t sm_get_state(); 44 | void sm_tape_play(uint8_t play); 45 | 46 | #endif -------------------------------------------------------------------------------- /hw/util/console/console.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 console utility 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | #ifndef _CONSOLE_H 25 | #define _CONSOLE_H 26 | 27 | #include "main.h" 28 | 29 | void console_init(); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /hw/util/keybd/keybd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 keyboard utility 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | #ifndef _KEYBD_H 25 | #define _KEYBD_H 26 | 27 | #include "stm32f7xx_hal.h" 28 | #include "main.h" 29 | #include "if.h" 30 | 31 | typedef enum 32 | { 33 | KEYBD_STATE_RELEASED, 34 | KEYBD_STATE_PRESSED 35 | } keybd_state_t; 36 | 37 | void keybd_init(); 38 | void keybd_poll(); 39 | keybd_state_t keybd_key_state(); 40 | keybd_state_t keybd_get_shift_state(); 41 | keybd_state_t keybd_get_ctrl_state(); 42 | uint8_t keybd_get_active_key(); 43 | uint8_t *keybd_get_active_keys(); 44 | uint8_t keybd_get_active_keys_hash(); 45 | uint8_t keybd_get_active_number_of_keys(); 46 | uint8_t keybd_get_active_ascii_key(); 47 | if_keybd_map_t *keybd_get_default_map(); 48 | void keybd_populate_map(uint8_t *conf_text, if_keybd_map_t *keybd_map_p); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /hw/util/stage/stage.h: -------------------------------------------------------------------------------- 1 | /* 2 | * memwa2 stage utility 3 | * 4 | * Copyright (c) 2016 Mathias Edman 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | 24 | #ifndef _STAGE_H 25 | #define _STAGE_H 26 | 27 | #include "stm32f7xx_hal.h" 28 | #include "main.h" 29 | 30 | typedef enum 31 | { 32 | FILE_LIST_TYPE_CASETTE, 33 | FILE_LIST_TYPE_FLOPPY, 34 | FILE_LIST_TYPE_T64, 35 | FILE_LIST_TYPE_PRG, 36 | FILE_LIST_TYPE_MAX 37 | } file_list_type_t; 38 | 39 | typedef enum 40 | { 41 | STAGE_EMULATION, 42 | STAGE_MENU, 43 | STAGE_FILE_SELECT, 44 | STAGE_COLOR_SCREEN 45 | } stage_t; 46 | 47 | typedef enum 48 | { 49 | INFO_FPS, 50 | INFO_DISK, 51 | INFO_DISK_LED, 52 | INFO_FREQLOCK, 53 | INFO_FRAMERATE, 54 | INFO_TAPE_BUTTON, 55 | INFO_TAPE_MOTOR, 56 | INFO_PRINT 57 | } info_t; 58 | 59 | void stage_init(uint32_t memory); 60 | void stage_prepare(stage_t stage); 61 | void stage_select_layer(uint8_t layer); 62 | void stage_clear_last_messsage(); 63 | void stage_draw_string(char *string_p, uint32_t xpos, uint32_t ypos); 64 | void stage_draw_char(char character, uint32_t xpos, uint32_t ypos); 65 | void stage_draw_selection(stage_t stage); 66 | void stage_draw_fw(); 67 | void stage_input_key(stage_t stage, char keybd_key); 68 | char *stage_get_selected_filename(); 69 | char *stage_get_selected_path(); 70 | file_list_type_t stage_get_selected_file_list_type(); 71 | void stage_draw_info(info_t info, uint8_t value); 72 | void stage_set_message(char *string_p); 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /link.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ***************************************************************************** 3 | ** 4 | 5 | ** File : LinkerScript.ld 6 | ** 7 | ** Abstract : Linker script for STM32F756IGTx Device with 8 | ** 1024KByte FLASH, 320KByte RAM 9 | ** 10 | ** Set heap size, stack size and stack location according 11 | ** to application requirements. 12 | ** 13 | ** Set memory bank area and size if external memory is used. 14 | ** 15 | ** Target : STMicroelectronics STM32 16 | ** 17 | ** 18 | ** Distribution: The file is distributed as is, without any warranty 19 | ** of any kind. 20 | ** 21 | ** (c)Copyright Ac6. 22 | ** You may use this file as-is or modify it according to the needs of your 23 | ** project. Distribution of this file (unmodified or modified) is not 24 | ** permitted. Ac6 permit registered System Workbench for MCU users the 25 | ** rights to distribute the assembled, compiled & linked contents of this 26 | ** file as part of an application binary file, provided that it is built 27 | ** using the System Workbench for MCU toolchain. 28 | ** 29 | ***************************************************************************** 30 | */ 31 | 32 | /* Entry Point */ 33 | ENTRY(Reset_Handler) 34 | 35 | /* Highest address of the user mode stack */ 36 | _estack = 0x2007FFFF; /* end of RAM */ 37 | /* Generate a link error if heap and stack don't fit into RAM */ 38 | _Min_Heap_Size = 0x400;; /* required amount of heap */ 39 | _Min_Stack_Size = 0x800;; /* required amount of stack */ 40 | 41 | /* Specify the memory areas */ 42 | MEMORY 43 | { 44 | FLASH (rx) : ORIGIN = 0x08020000, LENGTH = 1024K 45 | RAM (xrw) : ORIGIN = 0x20010000, LENGTH = 448K 46 | } 47 | 48 | /* Define output sections */ 49 | SECTIONS 50 | { 51 | /* The startup code goes first into FLASH */ 52 | .isr_vector : 53 | { 54 | . = ALIGN(4); 55 | KEEP(*(.isr_vector)) /* Startup code */ 56 | . = ALIGN(4); 57 | } >FLASH 58 | 59 | /* The program code and other data goes into FLASH */ 60 | .text : 61 | { 62 | . = ALIGN(4); 63 | *(.text) /* .text sections (code) */ 64 | *(.text*) /* .text* sections (code) */ 65 | *(.glue_7) /* glue arm to thumb code */ 66 | *(.glue_7t) /* glue thumb to arm code */ 67 | *(.eh_frame) 68 | 69 | KEEP (*(.init)) 70 | KEEP (*(.fini)) 71 | 72 | . = ALIGN(4); 73 | _etext = .; /* define a global symbols at end of code */ 74 | } >FLASH 75 | 76 | /* Constant data goes into FLASH */ 77 | .rodata : 78 | { 79 | . = ALIGN(4); 80 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 81 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 82 | . = ALIGN(4); 83 | } >FLASH 84 | 85 | .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH 86 | .ARM : { 87 | __exidx_start = .; 88 | *(.ARM.exidx*) 89 | __exidx_end = .; 90 | } >FLASH 91 | 92 | .preinit_array : 93 | { 94 | PROVIDE_HIDDEN (__preinit_array_start = .); 95 | KEEP (*(.preinit_array*)) 96 | PROVIDE_HIDDEN (__preinit_array_end = .); 97 | } >FLASH 98 | .init_array : 99 | { 100 | PROVIDE_HIDDEN (__init_array_start = .); 101 | KEEP (*(SORT(.init_array.*))) 102 | KEEP (*(.init_array*)) 103 | PROVIDE_HIDDEN (__init_array_end = .); 104 | } >FLASH 105 | .fini_array : 106 | { 107 | PROVIDE_HIDDEN (__fini_array_start = .); 108 | KEEP (*(SORT(.fini_array.*))) 109 | KEEP (*(.fini_array*)) 110 | PROVIDE_HIDDEN (__fini_array_end = .); 111 | } >FLASH 112 | 113 | /* used by the startup to initialize data */ 114 | _sidata = LOADADDR(.data); 115 | 116 | /* Initialized data sections goes into RAM, load LMA copy after code */ 117 | .data : 118 | { 119 | . = ALIGN(4); 120 | _sdata = .; /* create a global symbol at data start */ 121 | *(.data) /* .data sections */ 122 | *(.data*) /* .data* sections */ 123 | 124 | . = ALIGN(4); 125 | _edata = .; /* define a global symbol at data end */ 126 | } >RAM AT> FLASH 127 | 128 | 129 | /* Uninitialized data section */ 130 | . = ALIGN(4); 131 | .bss : 132 | { 133 | /* This is used by the startup in order to initialize the .bss secion */ 134 | _sbss = .; /* define a global symbol at bss start */ 135 | __bss_start__ = _sbss; 136 | *(.bss) 137 | *(.bss*) 138 | *(COMMON) 139 | 140 | . = ALIGN(4); 141 | _ebss = .; /* define a global symbol at bss end */ 142 | __bss_end__ = _ebss; 143 | } >RAM 144 | 145 | /* User_heap_stack section, used to check that there is enough RAM left */ 146 | ._user_heap_stack : 147 | { 148 | . = ALIGN(4); 149 | PROVIDE ( end = . ); 150 | PROVIDE ( _end = . ); 151 | . = . + _Min_Heap_Size; 152 | . = . + _Min_Stack_Size; 153 | . = ALIGN(4); 154 | } >RAM 155 | 156 | 157 | 158 | /* Remove information from the standard libraries */ 159 | /DISCARD/ : 160 | { 161 | libc.a ( * ) 162 | libm.a ( * ) 163 | libgcc.a ( * ) 164 | } 165 | 166 | .ARM.attributes 0 : { *(.ARM.attributes) } 167 | } 168 | 169 | 170 | -------------------------------------------------------------------------------- /out_target/target.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Staringlizard/memwa2/4eb942e0ed6235af7c8ab64a5269c08a0e9c2924/out_target/target.bin -------------------------------------------------------------------------------- /out_target/target.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Staringlizard/memwa2/4eb942e0ed6235af7c8ab64a5269c08a0e9c2924/out_target/target.elf -------------------------------------------------------------------------------- /pcb/case/memwa2.skp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Staringlizard/memwa2/4eb942e0ed6235af7c8ab64a5269c08a0e9c2924/pcb/case/memwa2.skp -------------------------------------------------------------------------------- /pcb/mk2/gerber.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Staringlizard/memwa2/4eb942e0ed6235af7c8ab64a5269c08a0e9c2924/pcb/mk2/gerber.zip -------------------------------------------------------------------------------- /pcb/mk2/layer_stack.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Staringlizard/memwa2/4eb942e0ed6235af7c8ab64a5269c08a0e9c2924/pcb/mk2/layer_stack.jpg -------------------------------------------------------------------------------- /pcb/mk2/model.3ds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Staringlizard/memwa2/4eb942e0ed6235af7c8ab64a5269c08a0e9c2924/pcb/mk2/model.3ds -------------------------------------------------------------------------------- /pcb/mk2/part_list.txt: -------------------------------------------------------------------------------- 1 | U3, 1 MCU, STM32F756IGK6 (to be changed) 2 | U4, 1 HDMI transmitter, ADV7511WBSWZ 3 | U2, 1 SDRAM, IS42S16400J-5BL 4 | CN1, 1 SDCARD, 104031-0811 5 | P2-P3, 2 D-SUB9, XM3C-0942-112LS 6 | P5, 1 Audio connector, SJ-3523-SMT-TR 7 | P7, 1 DC power connector, PJ-037A 8 | P1, 1 HDMI connector, 10029449-001RLF 9 | P4, 1 USB-A connector, 62900416021 10 | P6, 1 USB micro connector, 47590-0001 11 | U1, 1 IC-sockel, DIL 28 SMD, 114-87-628-41-117101 12 | C10, 1 Tantalum Capacitor, TAJB226M016RNJ 13 | C0-C2, 3 Tantalum Capacitors, TMCMB0J227MTRF 14 | C70, 1 AUDIO capacitor, RFS-50V010ME3#5 15 | U6, 1 Volt regulator (3.3V), NCP5662DS33R4G 16 | U5, 1 Volt regulator (1.8V), NCP5662DS18R4G 17 | G1, 1 1Mhz Oscillator (SID), FXO-HC735-1MHZ 18 | X1, 1 8Mhz Crystal, FQ7050B-8 19 | U7-U9, 3 TPD4S010DQAR 20 | C4-C5, 2 2.2uF (0603) 21 | C21, 1 15pF (0603) 22 | C22-C23, 2 10pF (0603) 23 | C30-C33, 4 10nF (0603) 24 | C40-C46, C47-C48, C80-C88, 14 100nF (0603) 25 | C50-C54, 5 1.0uF (0603) 26 | C60-C61, 2 2.2nF (0603) 27 | R0-R5, 6 10K (0603) 28 | R14, 1 0 (0603) 29 | R15, 1 DNI (0603) 30 | R20, 1 887 (0603) 31 | R30-R34, 5 47K (0603) 32 | R50, 1 1K (0603) 33 | -------------------------------------------------------------------------------- /pcb/mk2/schematics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Staringlizard/memwa2/4eb942e0ed6235af7c8ab64a5269c08a0e9c2924/pcb/mk2/schematics.png -------------------------------------------------------------------------------- /sdcard.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Staringlizard/memwa2/4eb942e0ed6235af7c8ab64a5269c08a0e9c2924/sdcard.zip --------------------------------------------------------------------------------