Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed mbed-MapleMini USBDevice_STM32F103 USBJoystick
main.cpp
00001 #include "MapleMini.h" 00002 #include "mbed.h" 00003 #include "USBJoystick.h" 00004 00005 #include "nintendo.h" 00006 #include "sega.h" 00007 00008 DigitalInOut USB2(PB_12); 00009 DigitalInOut USB3(PB_13); 00010 DigitalInOut USB4(PB_14); 00011 DigitalInOut USB5(PB_15); 00012 DigitalInOut USB6(PA_8); 00013 DigitalInOut USB7(PA_9); 00014 DigitalInOut USB8(PA_10); 00015 DigitalInOut USB9(PA_15); 00016 00017 int main() { 00018 00019 DigitalOut myled(LED1); 00020 00021 confSysClock(); 00022 USBJoystick joystick; 00023 Serial pc(USBTX, USBRX); 00024 00025 int controller = 0; 00026 00027 while(1) { 00028 00029 int idLow = 0; 00030 int idHigh = 0; 00031 00032 USB5.input(); 00033 USB6.input(); 00034 USB7.input(); 00035 USB8.output(); 00036 USB9.input(); 00037 00038 USB5.mode(PullUp); 00039 USB6.mode(PullUp); 00040 USB7.mode(PullUp); 00041 USB9.mode(PullUp); 00042 00043 if(!USB9) { 00044 USB8 = 0; 00045 wait_us(1); 00046 if(!USB7) { 00047 idLow = idLow + 1; 00048 } 00049 if(!USB6) { 00050 idLow = idLow + 2; 00051 } 00052 if(!USB5) { 00053 idLow = idLow + 4; 00054 } 00055 00056 USB8 = 1; 00057 wait_us(1); 00058 if(USB7) { 00059 idHigh = idHigh + 1; 00060 } 00061 if(USB6) { 00062 idHigh = idHigh + 2; 00063 } 00064 if(USB5) { 00065 idHigh = idHigh + 4; 00066 } 00067 00068 if(idHigh == 7) { 00069 controller = idLow; 00070 //pc.printf("idLow : %i idHigh : %i\r\n",idLow,idHigh); 00071 } else { 00072 // pc.printf("Error idLow : %i idHigh : %i\r\n",idLow,idHigh); 00073 //wait_ms(100); 00074 } 00075 switch(controller) { 00076 case 0: 00077 int *sega = SegaMasterGenesisSaturn(); 00078 joystick.update(sega[0],sega[1],sega[2],sega[3],sega[4],sega[5]); // Envoi des position des noutton au pc 00079 // pc.printf("Sega ou Saturn \r\n"); 00080 //pc.printf("X : %i - Y : %i \r\n", sega[2], sega[3]); 00081 break; 00082 case 3: 00083 // pc.printf("PS1\r\n"); 00084 break; 00085 case 4: 00086 int *nes = NintendoNes(); 00087 joystick.update(nes[0],nes[1],nes[2],nes[3],nes[4],nes[5]); // Envoi des position des noutton au pc 00088 // pc.printf("NES\r\n"); 00089 break; 00090 case 5: 00091 int *snes = NintendoSnes(); 00092 joystick.update(snes[0],snes[1],snes[2],snes[3],snes[4],snes[5]); // Envoi des position des noutton au pc 00093 // pc.printf("SNES\r\n"); 00094 break; 00095 case 6: 00096 // pc.printf("Dreamcast\r\n"); 00097 break; 00098 case 7: 00099 // pc.printf("N64\r\n"); 00100 break; 00101 } 00102 } else { 00103 pc.printf("Pas d'adaptateur\r\n"); 00104 wait_ms(100); 00105 } 00106 myled = !myled; 00107 } 00108 }
Generated on Sat Jul 30 2022 03:21:19 by
1.7.2