{ ' This file is a skeleton file that can be used to add XMM support for a ' completely new Propeller platform, or for a memory add-on board to be ' used with multiple Propeller platforms. ' ' The first step is to decide on the Platform or Board name, and the Catalina ' symbol that will be used to specify it on the command line (using the -C ' command line option). In this file We will assume the platform is to be ' called "New_Board", and we will use the symbol NEW_BOARD. ' ' 1. The first step is to rename this file to be "New_Board_XMM.inc". ' ' 2. The next step is to update XMM.inc. There are two options - select (a) ' for new platforms with XMM hardware "built-in", or (b) for new "add-on" ' XMM boards (but not both!): ' ' a. If this represents a completely new platform, add the following lines ' to the file END of the list in XMM.inc, just before the line that says ' "#elseifdef CUSTOM": ' ' #elseifdef NEW_BOARD ' #include "New_Board_XMM.inc" ' ' Note that for new platforms, you will also need to update CFG.inc, DEF.inc ' and HMI.inc in a similar manner. ' ' b. If this is an add-on board that can be used on other platforms, add the ' above lines to the START of the list in XMM.inc, just above the first ' platform - i.e. just before the line that says "#elseifdef HYDRA": ' ' #elseifdef NEW_BOARD ' #include "New_Board_XMM.inc" ' ' 3. The final step is to add the required code to the API functions below. ' ' Note that if you only intend to use this board in conjunction with the ' Cache, you only need to implement the "MINIMAL API FUNCTIONS". ' ' If you want to use this board WITHOUT the cache, you also need to ' implement the "DIRECT API FUNCTIONS". Also, delete the CACHE CHECK ' code below. ' ' If your board implelements FLASH RAM, you will also need to implement ' the "FLASH API FUNCTIONS". Also, delete the FLASH CHECK code below. } '=============================================================================== { ' The XMM functions included are controlled via Catalina symbols defined ' internally as required within various Catalina files: ' ' CACHED : defined if CACHE in use (any size) ' ' NEED_FLASH : defined if FLASH support required ' ' NEED_XMM_READLONG : defined if XMM_ReadLong (and XMM_ReadMult) required ' ' NEED_XMM_WRITELONG : defined if XMM_WriteLong (and XMM_WriteMult) required ' ' NEED_XMM_READPAGE : defined if XMM_ReadPage required ' ' NEED_XMM_WRITEPAGE : defined if XMM_WritePage required } '=============================== CACHE CHECK =================================== ' ' If this platform does not need the cache enabled, delete the following: ' '#ifndef CACHED '#error : PLATFORM REQUIRES CACHE OPTION (CACHED_1K .. CACHED_8K or CACHED) '#endif ' '=============================== FLASH CHECK =================================== ' ' If this platform has FLASH RAM, delete the following: ' #ifdef NEED_FLASH #error : FLASH NOT SUPPORTED ON THIS PLATFORM #endif ' CON Mem_Clk_Pin = 6 Ram_Cs_Pin = 5 Rom_Cs_Pin = 4 Quad_Data_D3 = 3 Quad_Data_D2 = 2 Quad_Data_D1 = 1 Quad_Data_D0 = 0 Mem_Clk_High = (|< Mem_Clk_Pin) Mem_Clk_Low = !Mem_Clk_High Ram_Cs_High = (|< Ram_Cs_Pin) Ram_Cs_Low = !Ram_Cs_High Quad_Bus_Out = (|< Quad_Data_D3) | (|< Quad_Data_D2) | (|< Quad_Data_D1) | (|< Quad_Data_D0) Quad_Bus_In = !Quad_Bus_Out Clear_Quad_Bus = !(Quad_Bus_Out | Mem_Clk_High) SPI_Hi = (|< Quad_Data_D0) | (|< Quad_Data_D3) SPI_Lo = !(|< Quad_Data_D0) & Mem_Clk_Low Ctrl_Sigs_Enable = Mem_Clk_High | Ram_Cs_High | SPI_Hi WMR = 1 'Write Mode Register WDR = 2 'Write Data Register RDR = 3 'Read Data Register RMR = 5 'Read Mode Register WSDI = $3B 'Write SDI Mode WSQI = $38 'Write SQI Mode WRST = $FF 'Write RESET Cmd WSEQ = $0140 'Write SEQ Mode Access DAT '=========================== MINIMAL API FUNCTIONS ============================= '-----------------------------------Activate SRAM Chip---------------------------------------- XMM_Activate or dira,CtrlSigsEnable 'Enable RamCsPin,MemClkPin,D0,D3 or outa,CtrlSigsEnable 'Set RamCsHigh,MemClkHigh,D0=1,D3=1 call #MakeQuadMode 'Force QuadMode ' call #MakeSeqMode 'Force Sequential Access XMM_Activate_ret ret '--------------------------------------TriState Memory---------------------------------------- XMM_Tristate XMM_Tristate_ret ret #ifdef NEED_XMM_WRITEPAGE '-----------------------------------XMM_WritePage (HubRam -> XMM)-------------------------- XMM_WritePage and outa,RamCsLow 'Set RamCsLow (SRAM Active) mov MemData,#WDR 'Write Command call #SendDirCmd 'Send The Command :WritePageLoop rdbyte MemData,Hub_Addr 'Get Byte From HubRam mov NibsUsed,#02 'Send 2 Nibbles (1 Byte) call #SendDirData 'Write The Data add Hub_Addr,#01 'Increment HubRam Address add XMM_Addr,#01 'Increment XMM_Addr djnz XMM_Len,#:WritePageLoop 'Loop Until Done or outa,RamCsHigh 'Set RamCsHigh (SRAM Inactive) XMM_WritePage_ret ret #endif #ifdef NEED_XMM_READPAGE '----------------------------------- XMM_ReadPage (XMM -> HubRam)------------------------ XMM_ReadPage and outa,RamCsLow 'Set RamCsLow (SRAM Active) mov MemData,#RDR 'Read Command call #SendDirCmd 'Send The Command call #ClkDirect 'First Dummy Clock and dira,QuadBusIn 'Set QuadBus for Input call #ClkDirect 'Second Dummy Clock :ReadPageLoop xor MemData,MemData 'Clear MemData mov NibsUsed,#02 'Grab 2 Nibbles,1 Byte :NextNibble mov MemTemp,ina 'INA -> MemTemp call #ClkDirect 'Ack Receipt Of Data shr MemTemp,PinJustify 'Move To Nibble0 and MemTemp,#$0F 'Keep Nibble0 Only shl MemData,#04 'Nibble0 -> Nibble1 or MemData,MemTemp 'MemData=MemData | MemTemp djnz NibsUsed,#:NextNibble 'Loop Until Byte Received wrbyte MemData,Hub_Addr 'MemData -> HubRam add Hub_Addr,#01 'Increment Hub_Addr add XMM_Addr,#01 'Increment XMM_Addr djnz XMM_Len,#:ReadPageLoop 'Loop Until Done or outa,RamCsHigh 'Set RamCsHigh (SRAM Inactive) XMM_ReadPage_ret ret #endif '============================ DIRECT API FUNCTIONS ============================= #ifdef NEED_XMM_READLONG XMM_ReadLong mov XMM_Len,#04 'Get 1 Long,2 Words,4 Bytes,8 Nibbles XMM_ReadMult and outa,RamCsLow 'Set RamCsLow (SRAM Active) mov MemData,#RDR 'Read Command call #SendDirCmd 'Send The Command call #ClkDirect 'First Dummy Clock and dira,QuadBusIn 'Set QuadBus For Input call #ClkDirect 'Second Dummy Clock add XMM_Addr,XMM_Len 'Increment XMM_Addr shl XMM_Len,#01 'Bytes -> Nibbles xor MemData,MemData 'Clear MemData :GetDirect mov MemTemp,ina 'INA -> MemTemp call #ClkDirect 'Ack Receipt Of Data shr MemTemp,PinJustify 'Move To Nibble0 and MemTemp,#$0F 'Keep Nibble0 shl MemData,#04 'N0>>N1>>N2>>N3>>N4>>N5>>N6>>N7 or MemData,MemTemp 'MemData=MemData | MemTemp djnz XMM_Len,#:GetDirect 'Loop Until Done XMM_Dst mov XMM_Temp,MemData 'MemData -> XMM_Temp = Cog XMM_Dst or outa,RamCsHigh 'Set RamCsHigh (SRAM Inactive) XMM_ReadMult_ret XMM_ReadLong_ret ret #endif #ifdef NEED_XMM_WRITELONG XMM_WriteLong mov XMM_Len,#04 'Send 1 Long,2 Words,4 Bytes,8 Nibbles XMM_WriteMult and outa,RamCsLow 'Set RamCsLow (SRAM Active) mov MemData,#WDR 'Write Command call #SendDirCmd 'Send Command add XMM_Addr,XMM_Len 'Increment XMM_Addr shl XMM_Len,#01 'Bytes -> Nibbles XMM_Src mov MemData,XMM_Temp 'Cog XMM_Src = XMM_Temp -> MemData mov NibsUsed,XMM_Len 'Data Nibbles call #SendDirData 'Send Data or outa,RamCsHigh 'Set RamCsHigh (SRAM Inactive) XMM_WriteMult_ret XMM_WriteLong_ret ret #endif '=====================Common Required Functions For SRAM Read/Write=========================== '----------------------------------Send Commands And/Or Data To SRAM-------------------------- SendDirCmd and XMM_Addr,HighMask 'Clear Upper Address Byte shl MemData,#24 'Move To Upper Byte or MemData,XMM_Addr 'Combine Command & Address mov NibsUsed,#08 '8 Command Nibbles SendDirData mov MemSlide,NibsUsed 'NibsUsed -> MemSlide sub MemSlide,#01 'MemSlide = NibsUsed - 1 shl MemSlide,#02 'MemSlide = 4 * (NibsUsed - 1) or dira,QuadBusOut 'Set QuadBus For Output :SendLoop and outa,QuadBusIn 'Clear Quad Bus mov MemTemp,MemData 'MemData -> MemTemp shr MemTemp,MemSlide 'NibbleX -> Nibble0 sub MemSlide,#04 'Move To Next Lower Nibble and MemTemp,#$0F 'Leave Nibble0 Only shl MemTemp,PinJustify 'Position To Output Bus or outa,MemTemp 'Output The Data call #ClkDirect 'Latch The Data djnz NibsUsed,#:SendLoop 'Loop Until Done SendDirData_ret SendDirCmd_ret ret '----------------------------------Force SRAM Into Quad Mode Operation------------------------ MakeQuadMode and outa,RamCsLow 'Set RamCsLow (SRAM Active) mov MemSlide,#$80 'MemSlide=0b10000000 :QuadLoop and outa,SPILo 'Quad_Data0 = 0 mov MemData,#WSQI 'MemData = 0x38 (QuadCmd) and MemData,MemSlide 'Mask Out MemData Bits tjz MemData,#:QuadSkip 'if(MemData == 0) Output=SPILo or outa,SPIHi 'else Output=SPIHi :QuadSkip call #ClkDirect 'Latch The Data shr MemSlide,#01 'MemSlide=MemSlide >> 1 tjnz MemSlide,#:QuadLoop 'Loop Until Done or outa,RamCsHigh 'Set RamCsHigh (SRAM Inactive) MakeQuadMode_ret ret '---------------------------Force SRAM Into Sequential Access Mode---------------------------- 'MakeSeqMode and outa,RamCsLow 'Set RamCsLow (SRAM Active) ' mov MemData,SeqModeAccess 'Set For Seq Access ' mov NibsUsed,#04 'Send 4 Nibbles,2 Bytes ' call #SendDirData 'Send The command ' or outa,RamCsHigh 'Set RamCsHigh (SRAM Inactive) 'MakeSeqMode_ret ret '-------------------------------Direct Clock Strobe------------------------------------------- ClkDirect or outa,MemClkHigh 'Set MemClkHigh and outa,MemClkLow 'Set MemClkLow ClkDirect_ret ret '============================= FLASH API FUNCTIONS ============================= DAT #ifdef NEED_FLASH XMM_FlashActivate nop ' <== INSERT CODE HERE XMM_FlashActivate_ret ret XMM_FlashTristate nop ' <== INSERT CODE HERE XMM_FlashTristate_ret ret XMM_FlashWritePage nop ' <== INSERT CODE HERE XMM_FlashWritePage_ret ret XMM_FlashReadPage nop ' <== INSERT CODE HERE XMM_FlashReadPage_ret ret XMM_FlashCheckEmpty nop ' <== INSERT CODE HERE XMM_FlashCheckEmpty_ret ret XMM_FlashComparePage nop ' <== INSERT CODE HERE XMM_FlashComparePage_ret ret XMM_FlashEraseChip nop ' <== INSERT CODE HERE XMM_FlashEraseChip_ret ret XMM_FlashEraseBlock nop ' <== INSERT CODE HERE XMM_FlashEraseBlock_ret ret XMM_FlashUnprotect nop ' <== INSERT CODE HERE XMM_FlashUnprotect_ret ret XMM_FlashWriteEnable nop ' <== INSERT CODE HERE XMM_FlashWriteEnable_ret ret XMM_FlashWaitUntilDone nop ' <== INSERT CODE HERE XMM_FlashWaitUntilDone_ret ret #endif '===========================Required Variables For SRAM Read/Write===================== RamCsHigh long Ram_Cs_High RamCsLow long Ram_Cs_Low MemClkHigh long Mem_Clk_High MemClkLow long Mem_Clk_Low QuadBusOut long Quad_Bus_Out QuadBusIn long Quad_Bus_In SPIHi long SPI_Hi SPILo long SPI_Lo CtrlSigsEnable long Ctrl_Sigs_Enable SeqModeAccess long WSEQ PinJustify long Quad_Data_D0 HighMask long $FFFFFF MemData long 0 MemTemp long 0 MemSlide long 0 NibsUsed long 0 XMM_Temp long 0 'outx long 0 '--------------------------------External Variables---------------------------- 'XMM_Len long 0 'XMM_Addr long 0 'Hub_Addr long 0 '===============================================================================