удалена работа с памятью из программы запускающей CPU2
пины ШИМ инициализируются напрямую, без библиотек
This commit is contained in:
parent
626c5262bd
commit
646d59cf7b
@ -49,7 +49,6 @@
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.INCLUDE_PATH.131753599" name="Add dir to #include search path (--include_path, -I)" superClass="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.INCLUDE_PATH" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="${COM_TI_C2000WARE_SOFTWARE_PACKAGE_INCLUDE_PATH}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/Freemaster}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/ExternalEEPROM}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/Peripherals}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/lib}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src}"/>
|
||||
@ -155,7 +154,6 @@
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/lib}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/CLB}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/Peripherals}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/ExternalEEPROM}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/Freemaster}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/vector}"/>
|
||||
@ -226,7 +224,6 @@
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.INCLUDE_PATH.232403151" name="Add dir to #include search path (--include_path, -I)" superClass="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.INCLUDE_PATH" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/lib}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/Peripherals}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/ExternalEEPROM}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/Freemaster}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/vector}"/>
|
||||
@ -254,7 +251,6 @@
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.INCLUDE_PATH.572238000" name="Add dir to #include search path (--include_path, -I)" superClass="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.INCLUDE_PATH" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/lib}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/Peripherals}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/ExternalEEPROM}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/Freemaster}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/vector}"/>
|
||||
@ -282,7 +278,6 @@
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.INCLUDE_PATH.638189817" name="Add dir to #include search path (--include_path, -I)" superClass="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.INCLUDE_PATH" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/lib}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/Peripherals}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/ExternalEEPROM}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/Freemaster}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/vector}"/>
|
||||
@ -301,34 +296,6 @@
|
||||
<tool id="com.ti.ccstudio.buildDefinitions.C2000_22.6.hex.1567911238" name="C2000 Hex Utility" superClass="com.ti.ccstudio.buildDefinitions.C2000_22.6.hex.1747906040"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<folderInfo id="com.ti.ccstudio.buildDefinitions.C2000.Default.1796646261.1891582305" name="/" resourcePath="src/ExternalEEPROM">
|
||||
<toolChain id="com.ti.ccstudio.buildDefinitions.C2000_22.6.exe.DebugToolchain.1817341729" name="TI Build Tools" superClass="com.ti.ccstudio.buildDefinitions.C2000_22.6.exe.DebugToolchain" unusedChildren="">
|
||||
<option id="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.606629708.1507499021.1969472368" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.606629708.1507499021"/>
|
||||
<option id="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.197899427.1690574508.588294717" name="Compiler version" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.197899427.1690574508"/>
|
||||
<targetPlatform id="com.ti.ccstudio.buildDefinitions.C2000_22.6.exe.targetPlatformDebug" name="Platform" superClass="com.ti.ccstudio.buildDefinitions.C2000_22.6.exe.targetPlatformDebug"/>
|
||||
<tool id="com.ti.ccstudio.buildDefinitions.C2000_22.6.exe.compilerDebug.895877693" name="C2000 Compiler" superClass="com.ti.ccstudio.buildDefinitions.C2000_22.6.exe.compilerDebug.722248393">
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.INCLUDE_PATH.1073182810" name="Add dir to #include search path (--include_path, -I)" superClass="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.INCLUDE_PATH" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/lib}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/Peripherals}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/ExternalEEPROM}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/Freemaster}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/vector}"/>
|
||||
<listOptionValue builtIn="false" value="${COM_TI_C2000WARE_SOFTWARE_PACKAGE_INCLUDE_PATH}"/>
|
||||
<listOptionValue builtIn="false" value="${PROJECT_ROOT}"/>
|
||||
<listOptionValue builtIn="false" value="${C2000WARE_COMMON_INCLUDE}"/>
|
||||
<listOptionValue builtIn="false" value="${C2000WARE_HEADERS_INCLUDE}"/>
|
||||
<listOptionValue builtIn="false" value="${CG_TOOL_ROOT}/include"/>
|
||||
</option>
|
||||
<inputType id="com.ti.ccstudio.buildDefinitions.C2000_22.6.compiler.inputType__C_SRCS.1185358984" name="C Sources" superClass="com.ti.ccstudio.buildDefinitions.C2000_22.6.compiler.inputType__C_SRCS"/>
|
||||
<inputType id="com.ti.ccstudio.buildDefinitions.C2000_22.6.compiler.inputType__CPP_SRCS.1458428746" name="C++ Sources" superClass="com.ti.ccstudio.buildDefinitions.C2000_22.6.compiler.inputType__CPP_SRCS"/>
|
||||
<inputType id="com.ti.ccstudio.buildDefinitions.C2000_22.6.compiler.inputType__ASM_SRCS.829693974" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.C2000_22.6.compiler.inputType__ASM_SRCS"/>
|
||||
<inputType id="com.ti.ccstudio.buildDefinitions.C2000_22.6.compiler.inputType__ASM2_SRCS.1022490459" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.C2000_22.6.compiler.inputType__ASM2_SRCS"/>
|
||||
</tool>
|
||||
<tool id="com.ti.ccstudio.buildDefinitions.C2000_22.6.exe.linkerDebug.1072660240" name="C2000 Linker" superClass="com.ti.ccstudio.buildDefinitions.C2000_22.6.exe.linkerDebug.535799121"/>
|
||||
<tool id="com.ti.ccstudio.buildDefinitions.C2000_22.6.hex.638169967" name="C2000 Hex Utility" superClass="com.ti.ccstudio.buildDefinitions.C2000_22.6.hex.1567911238"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<folderInfo id="com.ti.ccstudio.buildDefinitions.C2000.Default.1796646261.980395002" name="/" resourcePath="src/vector">
|
||||
<toolChain id="com.ti.ccstudio.buildDefinitions.C2000_22.6.exe.DebugToolchain.1090262320" name="TI Build Tools" superClass="com.ti.ccstudio.buildDefinitions.C2000_22.6.exe.DebugToolchain" unusedChildren="">
|
||||
<option id="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.606629708.1507499021.1886355966" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.606629708.1507499021"/>
|
||||
@ -338,7 +305,6 @@
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.INCLUDE_PATH.395133003" name="Add dir to #include search path (--include_path, -I)" superClass="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.INCLUDE_PATH" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/lib}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/Peripherals}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/ExternalEEPROM}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/Freemaster}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/vector}"/>
|
||||
@ -366,7 +332,6 @@
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.INCLUDE_PATH.1754087693" name="Add dir to #include search path (--include_path, -I)" superClass="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.INCLUDE_PATH" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/lib}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/Peripherals}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/ExternalEEPROM}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/Freemaster}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/vector}"/>
|
||||
@ -394,7 +359,6 @@
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.INCLUDE_PATH.445028314" name="Add dir to #include search path (--include_path, -I)" superClass="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.INCLUDE_PATH" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/lib}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/Peripherals}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/ExternalEEPROM}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/Freemaster}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src}"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/src/vector}"/>
|
||||
|
||||
@ -8,8 +8,6 @@ encoding//CPU1_FLASH/objects.mk=UTF-8
|
||||
encoding//CPU1_FLASH/sources.mk=UTF-8
|
||||
encoding//CPU1_FLASH/src/CLB/subdir_rules.mk=UTF-8
|
||||
encoding//CPU1_FLASH/src/CLB/subdir_vars.mk=UTF-8
|
||||
encoding//CPU1_FLASH/src/ExternalEEPROM/subdir_rules.mk=UTF-8
|
||||
encoding//CPU1_FLASH/src/ExternalEEPROM/subdir_vars.mk=UTF-8
|
||||
encoding//CPU1_FLASH/src/Peripherals/subdir_rules.mk=UTF-8
|
||||
encoding//CPU1_FLASH/src/Peripherals/subdir_vars.mk=UTF-8
|
||||
encoding//CPU1_FLASH/src/subdir_rules.mk=UTF-8
|
||||
@ -27,8 +25,6 @@ encoding//CPU1_RAM/objects.mk=UTF-8
|
||||
encoding//CPU1_RAM/sources.mk=UTF-8
|
||||
encoding//CPU1_RAM/src/CLB/subdir_rules.mk=UTF-8
|
||||
encoding//CPU1_RAM/src/CLB/subdir_vars.mk=UTF-8
|
||||
encoding//CPU1_RAM/src/ExternalEEPROM/subdir_rules.mk=UTF-8
|
||||
encoding//CPU1_RAM/src/ExternalEEPROM/subdir_vars.mk=UTF-8
|
||||
encoding//CPU1_RAM/src/Peripherals/subdir_rules.mk=UTF-8
|
||||
encoding//CPU1_RAM/src/Peripherals/subdir_vars.mk=UTF-8
|
||||
encoding//CPU1_RAM/src/subdir_rules.mk=UTF-8
|
||||
|
||||
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Arr.c
|
||||
*
|
||||
* Created on: 21 íîÿá. 2023 ã.
|
||||
* Author: seklyuts
|
||||
*/
|
||||
|
||||
#include "f28x_project.h"
|
||||
|
||||
uint16_t quant16bitWords(uint16_t bytes)
|
||||
{
|
||||
if((bytes) & 1) return (bytes + 1)/2; //åñëè îñòàëîñü íå÷¸òíîå ÷èñëî áàéò, òî ÷òîáû ðàññ÷èòàòü êîë-âî 16-áèòíûõ ñëîâ íàäî +1
|
||||
else return (bytes)/2;
|
||||
}
|
||||
|
||||
void copy16_to_8(uint16_t *Arr16, uint16_t *Arr8, uint16_t N)
|
||||
{
|
||||
uint16_t j=0;
|
||||
for(j = 0; j < N; j+=1) {Arr8[2*j] = 0xFF & Arr16[j]; Arr8[2*j+1] = (Arr16[j]>>8);}
|
||||
}
|
||||
|
||||
|
||||
void copy8_to_16(uint16_t *Arr8, uint16_t *Arr16, uint16_t N)
|
||||
{
|
||||
uint16_t j=0;
|
||||
for(j = 0; j < N; j+=1) Arr16[j] = (0xFF & Arr8[2*j]) + (Arr8[2*j+1]<<8);
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
/*
|
||||
* Arr.h
|
||||
*
|
||||
* Created on: 21 íîÿá. 2023 ã.
|
||||
* Author: seklyuts
|
||||
*/
|
||||
|
||||
#ifndef SRC_EXTERNALEEPROM_ARR_H_
|
||||
#define SRC_EXTERNALEEPROM_ARR_H_
|
||||
|
||||
void copy16_to_8(uint16_t *Arr16, uint16_t *Arr8, uint16_t N);
|
||||
void copy8_to_16(uint16_t *Arr8, uint16_t *Arr16, uint16_t N);
|
||||
uint16_t quant16bitWords(uint16_t bytes);
|
||||
|
||||
|
||||
#endif /* SRC_EXTERNALEEPROM_ARR_H_ */
|
||||
@ -1,242 +0,0 @@
|
||||
/*
|
||||
* BL25CM1A.c
|
||||
*
|
||||
* Created on: 7 ñåíò. 2023 ã.
|
||||
* Author: seklyuts
|
||||
*/
|
||||
#include "f28x_project.h"
|
||||
#include "spi_init.h"
|
||||
|
||||
#include "BL25CM1A.h"
|
||||
#include "Arr.h"
|
||||
|
||||
#define WREN 0b00000110 //Enable Write Operations
|
||||
#define WRDI 0b00000100 //Disable Write Operations
|
||||
#define RDSR 0b00000101 //Read Status Register
|
||||
#define WRSR 0b00000001 //Write Status Register
|
||||
#define READ 0b00000011 //Read Data from Memory
|
||||
#define WRITE 0b00000010 //Write Data to Memory
|
||||
#define RDID 0b10000011 //Read identification page
|
||||
#define WRID 0b10000010 //Write identification page
|
||||
#define RDLS 0b10000011 //Reads the identification page lock status
|
||||
#define LID 0b10000010 //Locks the identification page in read-only mode
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Bl25cm1a_en(void)
|
||||
{
|
||||
volatile uint16_t empty;
|
||||
Gpio_SPI_CS_BL25CM1A(0);
|
||||
transmitData(WREN);
|
||||
while(SpiRegs.SPIFFRX.bit.RXFFST != 1)
|
||||
{
|
||||
|
||||
}
|
||||
Gpio_SPI_CS_BL25CM1A(1);
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
}
|
||||
|
||||
uint16_t Bl25cm1a_ReadStatus(void)
|
||||
{
|
||||
volatile uint16_t empty;
|
||||
Gpio_SPI_CS_BL25CM1A(0);
|
||||
transmitData(RDSR);
|
||||
transmitData(0xFF);
|
||||
while(SpiRegs.SPIFFRX.bit.RXFFST != 2)
|
||||
{
|
||||
|
||||
}
|
||||
Gpio_SPI_CS_BL25CM1A(1);
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
return empty;
|
||||
}
|
||||
|
||||
void Bl25cm1a_read_8_bytes(uint32_t Addr, uint16_t * read_data, uint16_t num_byte)//num_byte <=8
|
||||
{
|
||||
volatile uint16_t empty, i, j;
|
||||
uint16_t Stat = 1;
|
||||
|
||||
Stat = Bl25cm1a_ReadStatus();
|
||||
while((Stat&0x1) != 0 )
|
||||
{
|
||||
Stat = Bl25cm1a_ReadStatus();
|
||||
}
|
||||
Gpio_SPI_CS_BL25CM1A(0);
|
||||
transmitData(READ);
|
||||
transmitData(Addr>>16);
|
||||
transmitData(Addr>>8);
|
||||
transmitData(Addr);
|
||||
for(i = 0; i<num_byte; i++) transmitData(0xFF);
|
||||
while(SpiRegs.SPIFFRX.bit.RXFFST != (num_byte+4))
|
||||
{
|
||||
|
||||
}
|
||||
Gpio_SPI_CS_BL25CM1A(1);
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
for(j = 0; j<num_byte; j++)
|
||||
{
|
||||
read_data[j] = SpiRegs.SPIRXBUF;
|
||||
}
|
||||
}
|
||||
|
||||
void Bl25cm1a_write_8_bytes(uint32_t Addr, uint16_t * write_data, uint16_t num_byte)//num_byte <=8
|
||||
{
|
||||
volatile uint16_t empty, i, j;
|
||||
uint16_t Stat = 1;
|
||||
|
||||
Stat = Bl25cm1a_ReadStatus();
|
||||
while((Stat&0x1) != 0 )
|
||||
{
|
||||
Stat = Bl25cm1a_ReadStatus();
|
||||
}
|
||||
|
||||
Bl25cm1a_en();
|
||||
Gpio_SPI_CS_BL25CM1A(0);
|
||||
transmitData(WRITE);
|
||||
transmitData(Addr>>16);
|
||||
transmitData(Addr>>8);
|
||||
transmitData(Addr);
|
||||
for(i = 0; i<num_byte; i++) transmitData(write_data[i]);
|
||||
while(SpiRegs.SPIFFRX.bit.RXFFST != (num_byte+4))
|
||||
{
|
||||
|
||||
}
|
||||
Gpio_SPI_CS_BL25CM1A(1);
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
for(j = 0; j<num_byte; j++)
|
||||
{
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t Bl25cm1a_verify_8_bytes(uint32_t Addr, uint16_t * verify_data, uint16_t num_byte)//num_byte <=8
|
||||
{
|
||||
volatile uint16_t empty, i, j;
|
||||
uint16_t Stat = 1;
|
||||
uint16_t Err = 0;
|
||||
|
||||
Stat = Bl25cm1a_ReadStatus();
|
||||
while((Stat&0x1) != 0 )
|
||||
{
|
||||
Stat = Bl25cm1a_ReadStatus();
|
||||
}
|
||||
Gpio_SPI_CS_BL25CM1A(0);
|
||||
transmitData(READ);
|
||||
transmitData(Addr>>16);
|
||||
transmitData(Addr>>8);
|
||||
transmitData(Addr);
|
||||
for(i = 0; i<num_byte; i++) transmitData(0xFF);
|
||||
while(SpiRegs.SPIFFRX.bit.RXFFST != (num_byte+4))
|
||||
{
|
||||
|
||||
}
|
||||
Gpio_SPI_CS_BL25CM1A(1);
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
for(j = 0; j<num_byte; j++)
|
||||
{
|
||||
if(verify_data[j] != SpiRegs.SPIRXBUF) Err++;
|
||||
}
|
||||
return Err;
|
||||
}
|
||||
|
||||
void Bl25cm1a_read_data(uint32_t Addr, uint16_t quant8, uint16_t * read_data)
|
||||
{
|
||||
uint32_t i=0;
|
||||
uint16_t addr_read_data[8];
|
||||
|
||||
if(quant8 > 8)
|
||||
{
|
||||
for(i = 0; i < (quant8-8); i += 8)
|
||||
{ //â ýòîì öèêëå òîëüêî ïîëíûå ïîñûëêè ïî 8 áàéò
|
||||
Bl25cm1a_read_8_bytes(Addr+i, addr_read_data, 8);
|
||||
copy8_to_16(addr_read_data, read_data, 4);
|
||||
read_data+=4;
|
||||
}
|
||||
}
|
||||
if(i < quant8)
|
||||
{ //òóò ì.á. îò 1 äî 8 áàéò
|
||||
Bl25cm1a_read_8_bytes(Addr+i, addr_read_data, (quant8 - i)); //÷èòàåì îñòàâøèåñÿ áàéòû
|
||||
if((quant8 - i) & 1) {addr_read_data[quant8] = 0; quant8++; } //åñëè áàéò íå÷¸òíîå ÷èñëî, òî äîïîëíÿåì äî ÷¸òíîãî íóë¸ì ÷òîáû çàïèñàòü 16-áèòíûìè ñëîâàìè â áóôåð
|
||||
copy8_to_16(addr_read_data, read_data, (quant8 - i)/2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t Bl25cm1a_verify_data(uint32_t Addr, uint16_t quant8, uint16_t * verify_data)
|
||||
{
|
||||
uint32_t i=0;
|
||||
uint16_t addr_vfy_data[8];
|
||||
uint16_t quant16;
|
||||
|
||||
if(quant8 > 8)
|
||||
{
|
||||
for(i = 0; i < (quant8-8); i += 8)
|
||||
{ //â ýòîì öèêëå òîëüêî ïîëíûå ïîñûëêè ïî 8 áàéò
|
||||
copy16_to_8(verify_data, addr_vfy_data, 4);
|
||||
if(Bl25cm1a_verify_8_bytes(Addr+i, addr_vfy_data, 8)) return 1;
|
||||
verify_data+=4;
|
||||
}
|
||||
}
|
||||
if(i < quant8)
|
||||
{ //òóò ì.á. îò 1 äî 8 áàéò
|
||||
quant16 = quant16bitWords(quant8-i);
|
||||
copy16_to_8(verify_data, addr_vfy_data, quant16);
|
||||
if(Bl25cm1a_verify_8_bytes(Addr+i, addr_vfy_data, (quant8 - i))) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Bl25cm1a_write_1_page(uint32_t Addr, uint16_t quant8, uint16_t * write_data)
|
||||
{
|
||||
uint32_t i=0;
|
||||
uint16_t addr_write_data[8];
|
||||
uint16_t quant16;
|
||||
|
||||
if(quant8 > 8)
|
||||
{
|
||||
for(i = 0; i < (quant8-8); i += 8)
|
||||
{ //â ýòîì öèêëå òîëüêî ïîëíûå ïîñûëêè ïî 8 áàéò
|
||||
copy16_to_8(write_data, addr_write_data, 4);
|
||||
Bl25cm1a_write_8_bytes(Addr+i, addr_write_data, 8);
|
||||
write_data += 4;
|
||||
}
|
||||
}
|
||||
if(i < quant8)
|
||||
{ //òóò ì.á. îò 1 äî 8 áàéò
|
||||
quant16 = quant16bitWords(quant8-i);
|
||||
copy16_to_8(write_data, addr_write_data, quant16);
|
||||
Bl25cm1a_write_8_bytes(Addr+i, addr_write_data, (quant8 - i));
|
||||
}
|
||||
}
|
||||
|
||||
void Bl25cm1a_write_data(uint32_t Addr_8bit, uint16_t quant_8bit, uint16_t * write_data)
|
||||
{
|
||||
uint16_t * addr_write_data = write_data;
|
||||
uint16_t page_quant_8bit = 0;
|
||||
|
||||
while( (Addr_8bit&0xFF)+(quant_8bit) > BL25CM1A0_PAGE) //åñëè äàííûå âûõîäÿò çà ãðàíèöó òåêóùåé ñòðàíèöû
|
||||
{
|
||||
page_quant_8bit = BL25CM1A0_PAGE - (Addr_8bit&0xFF); //âû÷èñëÿåì êîë-âî áàéò äàííûõ äî êîíöà òåêóùåé ñòðàíèöû
|
||||
Bl25cm1a_write_1_page(Addr_8bit, page_quant_8bit/2, addr_write_data); //çàïèñûâàåì ýòè äàííûå íà òåêóùóþ ñòðàíèöó
|
||||
Addr_8bit += page_quant_8bit; //ïåðåëèñòûâàåì ñòðàíèöó âíåøíåé ïàìÿòè
|
||||
addr_write_data += page_quant_8bit/2; //øàãàåì íà ñëåäóþùèå íåçàïèñàííûå äàííûå â áóôåðå
|
||||
quant_8bit -= page_quant_8bit; //óìåíüøàåì êîë-âî äàííûõ íà âåëè÷èíó êîòîðóþ óæå çàïèñàëè
|
||||
}
|
||||
if(quant_8bit > 0)
|
||||
{
|
||||
Bl25cm1a_write_1_page(Addr_8bit, quant_8bit, addr_write_data); //åñëè äàííûå äëÿ çàïèñè îñòàëèñü, òî çàïèñûâàåì èõ
|
||||
}
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
/*
|
||||
* BL25CM1A.h
|
||||
*
|
||||
* Created on: 7 ñåíò. 2023 ã.
|
||||
* Author: seklyuts
|
||||
*/
|
||||
|
||||
#ifndef SRC_BL25CM1A_H_
|
||||
#define SRC_BL25CM1A_H_
|
||||
|
||||
#define BL25CM1A0_SIZE 0x10000 //16 bit lenght
|
||||
#define BL25CM1A0_PAGE 0x100
|
||||
|
||||
void Bl25cm1a_en(void);
|
||||
|
||||
void Bl25cm1a_write_data(uint32_t Addr, uint16_t quant, uint16_t * write_data);
|
||||
void Bl25cm1a_read_data(uint32_t Addr, uint16_t quant, uint16_t * read_data);
|
||||
uint16_t Bl25cm1a_verify_data(uint32_t Addr, uint16_t quant, uint16_t * verify_data);
|
||||
#endif /* SRC_BL25CM1A_H_ */
|
||||
@ -1,77 +0,0 @@
|
||||
/*
|
||||
* ExtEEPROM.c
|
||||
*
|
||||
* Created on: 14 ńĺíň. 2023 ă.
|
||||
* Author: seklyuts
|
||||
*/
|
||||
#include "f28x_project.h"
|
||||
#include "i2c_init.h"
|
||||
#include "BL25CM1A.h"
|
||||
#include "GD25Q16ETIGR.h"
|
||||
#include "ZD24C02A.h"
|
||||
|
||||
#define MAX_BUFFER_SIZE 0x10
|
||||
|
||||
|
||||
uint16_t sendNowI2C = 0, sendNowSPIGD25 = 0, sendNowSPIBL25 = 0;
|
||||
uint16_t TestADR = 0;
|
||||
uint16_t NByte = 16;
|
||||
uint16_t WriteI2C = 0;
|
||||
uint16_t Adr = 0x0;
|
||||
uint32_t SpiAdr = 0;
|
||||
|
||||
uint16_t ArrayForTests[MAX_BUFFER_SIZE+1] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0x51, 0x52};
|
||||
uint16_t ArrayMax[256];
|
||||
|
||||
void ExtEEPROM_run(void)
|
||||
{
|
||||
if(sendNowI2C==1)
|
||||
{
|
||||
if(WriteI2C)
|
||||
{
|
||||
ZD24C02A_write(Adr, NByte, ArrayForTests);
|
||||
}
|
||||
else
|
||||
{
|
||||
ZD24C02A_read(Adr, NByte, ArrayMax);
|
||||
}
|
||||
sendNowI2C = 0;
|
||||
}
|
||||
else if(sendNowI2C==2)
|
||||
{
|
||||
I2CWriteRes();
|
||||
sendNowI2C = 0;
|
||||
}
|
||||
|
||||
switch(sendNowSPIGD25)
|
||||
{
|
||||
case 1:
|
||||
GD25Q16ETIGR_write_data(Adr, NByte, ArrayForTests);
|
||||
sendNowSPIGD25 = 0;
|
||||
break;
|
||||
case 2:
|
||||
GD25Q16ETIGR_read_data(Adr, NByte, ArrayMax);
|
||||
sendNowSPIGD25 = 0;
|
||||
break;
|
||||
case 3:
|
||||
GD25Q16ETIGR_ReadManufacturerDeviceID();
|
||||
sendNowSPIGD25 = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
switch(sendNowSPIBL25)
|
||||
{
|
||||
case 1:
|
||||
ZD24C02A_write(Adr, NByte, ArrayForTests);
|
||||
sendNowSPIBL25 = 0;
|
||||
break;
|
||||
case 2:
|
||||
ZD24C02A_read(Adr, NByte, ArrayMax);
|
||||
sendNowSPIBL25 = 0;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
/*
|
||||
* ExtEEPROM.h
|
||||
*
|
||||
* Created on: 14 ñåíò. 2023 ã.
|
||||
* Author: seklyuts
|
||||
*/
|
||||
|
||||
#ifndef SRC_EXTEEPROM_H_
|
||||
#define SRC_EXTEEPROM_H_
|
||||
|
||||
void ExtEEPROM_run(void);
|
||||
|
||||
#endif /* SRC_EXTEEPROM_H_ */
|
||||
@ -1,315 +0,0 @@
|
||||
/*
|
||||
* GD25Q16ETIGR.c
|
||||
*
|
||||
* Created on: 7 ñåíò. 2023 ã.
|
||||
* Author: seklyuts
|
||||
*/
|
||||
#include "f28x_project.h"
|
||||
#include "spi_init.h"
|
||||
|
||||
#include "GD25Q16ETIGR.h"
|
||||
#include "Arr.h"
|
||||
|
||||
//max adr 0x1FFFFF (2097152 bytes = 2048 Kbytes = 2 Mbyte)
|
||||
#define WriteEnable 0x06
|
||||
#define WriteDisable 0x04
|
||||
#define ReadStatusRegister1 0x05 //(S7-S0) (cont.)
|
||||
#define ReadStatusRegister2 0x35 //(S15-S8) (cont.)
|
||||
#define WriteStatusRegister12 0x01 //S7-S0 S15-S8
|
||||
#define VolatileSRwriteEnable 0x50
|
||||
#define ReadData 0x03 //A23-A16 A15-A8 A7-A0 (D7-D0) (cont.)
|
||||
#define FastRead 0x0B //A23-A16 A15-A8 A7-A0 dummy (D7-D0) (cont.)
|
||||
#define ReadManufacturerDeviceID 0x90
|
||||
#define PageProgram 0x02 //A23-A16 A15-A8 A7-A0 D7-D0
|
||||
#define SectorErase 0x20 //A23-A16 A15-A8 A7-A0
|
||||
#define ChipErase 0xC7 //0x60
|
||||
|
||||
uint16_t sdata1 = ReadStatusRegister1; // sent data
|
||||
uint16_t GD25Q16ETIGR_buffer8bytes[8];
|
||||
|
||||
uint16_t SectorWasErraised[512];
|
||||
|
||||
|
||||
uint16_t GD25Q16ETIGR_Sektor_Addr(uint32_t Addr)
|
||||
{
|
||||
uint16_t sektor;
|
||||
for (sektor=1; sektor <= 512; sektor++ )
|
||||
{
|
||||
if(Addr < (0x1000*sektor)) return sektor-1;
|
||||
}
|
||||
return 511;
|
||||
}
|
||||
|
||||
|
||||
void GD25Q16ETIGR_clean_SectorWasErraised(void)
|
||||
{
|
||||
uint16_t i;
|
||||
for(i=0; i<512; i++)
|
||||
{
|
||||
SectorWasErraised[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GD25Q16ETIGR_en(void)
|
||||
{
|
||||
volatile uint16_t empty;
|
||||
transmitData(WriteEnable);
|
||||
while(SpiRegs.SPIFFRX.bit.RXFFST != 1)
|
||||
{
|
||||
|
||||
}
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
}
|
||||
|
||||
uint16_t GD25Q16ETIGR_ReadStatus(void)
|
||||
{
|
||||
volatile uint16_t empty;
|
||||
transmitData(ReadStatusRegister1);
|
||||
transmitData(0xFF);
|
||||
while(SpiRegs.SPIFFRX.bit.RXFFST != 2)
|
||||
{
|
||||
|
||||
}
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
return empty;
|
||||
}
|
||||
|
||||
void GD25Q16ETIGR_sector_erase(uint32_t Addr)
|
||||
{
|
||||
volatile uint16_t empty;
|
||||
uint16_t Stat = 1;
|
||||
|
||||
Stat = GD25Q16ETIGR_ReadStatus();
|
||||
while((Stat&0x1) != 0 )
|
||||
{
|
||||
Stat = GD25Q16ETIGR_ReadStatus();
|
||||
}
|
||||
|
||||
GD25Q16ETIGR_en();
|
||||
transmitData(SectorErase);
|
||||
transmitData(Addr>>16);
|
||||
transmitData(Addr>>8);
|
||||
transmitData(Addr);
|
||||
while(SpiRegs.SPIFFRX.bit.RXFFST != 4)
|
||||
{
|
||||
|
||||
}
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
}
|
||||
|
||||
void GD25Q16ETIGR_read_8_bytes(uint32_t Addr, uint16_t * read_data, uint16_t num_byte)//÷òåíèå äî 8 áàéò
|
||||
{
|
||||
volatile uint16_t empty, i, j;
|
||||
uint16_t Stat = 1;
|
||||
|
||||
Stat = GD25Q16ETIGR_ReadStatus();
|
||||
while((Stat&0x1) != 0 )
|
||||
{
|
||||
Stat = GD25Q16ETIGR_ReadStatus();
|
||||
}
|
||||
|
||||
transmitData(ReadData);
|
||||
transmitData(Addr>>16);
|
||||
transmitData(Addr>>8);
|
||||
transmitData(Addr);
|
||||
for(i = 0; i<num_byte; i++) transmitData(0xFF);
|
||||
while(SpiRegs.SPIFFRX.bit.RXFFST != (num_byte+4))
|
||||
{
|
||||
|
||||
}
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
for(j = 0; j<num_byte; j++)
|
||||
{
|
||||
read_data[j] = SpiRegs.SPIRXBUF;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t GD25Q16ETIGR_verify_8_bytes(uint32_t Addr, uint16_t * verify_data, uint16_t num_byte)//÷òåíèå è ïðîâåðêà äî 8 áàéò
|
||||
{
|
||||
volatile uint16_t empty, i, j;
|
||||
uint16_t Stat = 1;
|
||||
|
||||
Stat = GD25Q16ETIGR_ReadStatus();
|
||||
while((Stat&0x1) != 0 )
|
||||
{
|
||||
Stat = GD25Q16ETIGR_ReadStatus();
|
||||
}
|
||||
|
||||
transmitData(ReadData);
|
||||
transmitData(Addr>>16);
|
||||
transmitData(Addr>>8);
|
||||
transmitData(Addr);
|
||||
for(i = 0; i<num_byte; i++) transmitData(0xFF);
|
||||
while(SpiRegs.SPIFFRX.bit.RXFFST != (num_byte+4))
|
||||
{
|
||||
|
||||
}
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
for(j = 0; j<num_byte; j++)
|
||||
{
|
||||
if(verify_data[j] != SpiRegs.SPIRXBUF) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GD25Q16ETIGR_write_8_bytes(uint32_t Addr, uint16_t * write_data, uint16_t num_byte)//çàïèñü äî 8 áàéò
|
||||
{
|
||||
volatile uint16_t empty, i, j;
|
||||
uint16_t Stat = 1;
|
||||
|
||||
Stat = GD25Q16ETIGR_ReadStatus();
|
||||
while((Stat&0x1) != 0 )
|
||||
{
|
||||
Stat = GD25Q16ETIGR_ReadStatus();
|
||||
}
|
||||
|
||||
GD25Q16ETIGR_en();
|
||||
transmitData(PageProgram);
|
||||
transmitData(Addr>>16);
|
||||
transmitData(Addr>>8);
|
||||
transmitData(Addr);
|
||||
for(i = 0; i<num_byte; i++) transmitData(write_data[i]);
|
||||
while(SpiRegs.SPIFFRX.bit.RXFFST != (num_byte+4))
|
||||
{
|
||||
|
||||
}
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
for(j = 0; j<num_byte; j++)
|
||||
{
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
}
|
||||
}
|
||||
|
||||
void GD25Q16ETIGR_read_data(uint32_t Addr, uint16_t quant8, uint16_t * read_data)
|
||||
{
|
||||
uint32_t i=0;
|
||||
uint16_t addr_read_data[8];
|
||||
|
||||
if(quant8 > 8)
|
||||
{
|
||||
for(i = 0; i < (quant8-8); i += 8)
|
||||
{//â ýòîì öèêëå òîëüêî ïîëíûå ïîñûëêè ïî 8 áàéò
|
||||
GD25Q16ETIGR_read_8_bytes(Addr+i, addr_read_data, 8);
|
||||
copy8_to_16(addr_read_data, read_data, 4);
|
||||
read_data+=4;
|
||||
}
|
||||
}
|
||||
if(i < quant8)
|
||||
{//òóò ì.á. îò 1 äî 8 áàéò
|
||||
GD25Q16ETIGR_read_8_bytes(Addr+i, addr_read_data, (quant8 - i));
|
||||
if((quant8 - i) & 1) {addr_read_data[quant8] = 0; quant8++; }//åñëè áàéò íå÷¸òíîå ÷èñëî, òî äîïîëíÿåì äî ÷¸òíîãî íóë¸ì
|
||||
copy8_to_16(addr_read_data, read_data, (quant8 - i)/2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint16_t GD25Q16ETIGR_verify_data(uint32_t Addr, uint16_t quant8, uint16_t * verify_data)
|
||||
{
|
||||
uint32_t i=0;
|
||||
uint16_t addr_vfy_data[8];
|
||||
uint16_t quant16;
|
||||
|
||||
if(quant8 > 8)
|
||||
{
|
||||
for(i = 0; i < (quant8-8); i += 8)
|
||||
{//â ýòîì öèêëå òîëüêî ïîëíûå ïîñûëêè ïî 8 áàéò
|
||||
copy16_to_8(verify_data, addr_vfy_data, 4);
|
||||
if(GD25Q16ETIGR_verify_8_bytes(Addr+i, addr_vfy_data, 8)) return 1;
|
||||
verify_data+=4;
|
||||
}
|
||||
}
|
||||
if(i < quant8)
|
||||
{//òóò ì.á. îò 1 äî 8 áàéò
|
||||
quant16 = quant16bitWords(quant8-i);
|
||||
copy16_to_8(verify_data, addr_vfy_data, quant16);
|
||||
if(GD25Q16ETIGR_verify_8_bytes(Addr+i, addr_vfy_data, (quant8 - i))) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GD25Q16ETIGR_write_1_page(uint32_t Addr, uint16_t quant8, uint16_t * write_data) // çàïèñü âíóòðè îäíîé ñòðàíèöû
|
||||
{
|
||||
uint32_t i=0;
|
||||
uint16_t addr_write_data[8];
|
||||
uint16_t quant16;
|
||||
|
||||
if(quant8 > 8)
|
||||
{
|
||||
for(i = 0; i < (quant8-8); i += 8)
|
||||
{ //â ýòîì öèêëå òîëüêî ïîëíûå ïîñûëêè ïî 8 áàéò
|
||||
copy16_to_8(write_data, addr_write_data, 4);
|
||||
GD25Q16ETIGR_write_8_bytes(Addr+i, addr_write_data, 8);
|
||||
write_data += 4;
|
||||
}
|
||||
}
|
||||
if(i < quant8)
|
||||
{//òóò ì.á. îò 1 äî 8 áàéò
|
||||
quant16 = quant16bitWords(quant8-i);
|
||||
copy16_to_8(write_data, addr_write_data, quant16);
|
||||
GD25Q16ETIGR_write_8_bytes(Addr+i, addr_write_data, (quant8 - i));
|
||||
}
|
||||
}
|
||||
|
||||
void GD25Q16ETIGR_write_data(uint32_t Addr_8bit, uint16_t quant_8bit, uint16_t * write_data)
|
||||
{
|
||||
uint16_t * addr_write_data = write_data;
|
||||
uint16_t page_quant_8bit = 0;
|
||||
uint16_t FlashSektorStart = 0;
|
||||
uint16_t FlashSektorEnd = 0;
|
||||
uint16_t i=0;
|
||||
|
||||
FlashSektorStart = GD25Q16ETIGR_Sektor_Addr(Addr_8bit); //ñåêòîð ñ êîòîðîãî íà÷èíàåòñÿ çàïèñü
|
||||
FlashSektorEnd = GD25Q16ETIGR_Sektor_Addr(Addr_8bit + quant_8bit - 1); //ñåêòîð â êîòîðîì êîíåö çàïèñè
|
||||
|
||||
for(i = FlashSektorStart; i <= FlashSektorEnd; i++)
|
||||
{
|
||||
if(!SectorWasErraised[i]) {SectorWasErraised[i] = 1; GD25Q16ETIGR_sector_erase(i*0x1000);}
|
||||
}
|
||||
|
||||
while( (Addr_8bit&0xFF)+(quant_8bit) > GD25Q16E_PAGE) //åñëè äàííûå âûõîäÿò çà ãðàíèöó òåêóùåé ñòðàíèöû
|
||||
{
|
||||
page_quant_8bit = GD25Q16E_PAGE - (Addr_8bit&0xFF); //âû÷èñëÿåì êîë-âî áàéò äàííûõ äî êîíöà òåêóùåé ñòðàíèöû
|
||||
GD25Q16ETIGR_write_1_page(Addr_8bit, page_quant_8bit/2, addr_write_data); //çàïèñûâàåì ýòè äàííûå íà òåêóùóþ ñòðàíèöó
|
||||
Addr_8bit += page_quant_8bit; //ïåðåëèñòûâàåì ñòðàíèöó âíåøíåé ïàìÿòè
|
||||
addr_write_data += page_quant_8bit/2; //øàãàåì íà ñëåäóþùèå íåçàïèñàííûå äàííûå â áóôåðå (îíè ó íàñ 16-áèòíûìè ñëîâàìè)
|
||||
quant_8bit -= page_quant_8bit; //óìåíüøàåì êîë-âî äàííûõ íà âåëè÷èíó êîòîðóþ óæå çàïèñàëè
|
||||
}
|
||||
if(quant_8bit > 0)
|
||||
{
|
||||
GD25Q16ETIGR_write_1_page(Addr_8bit, quant_8bit, addr_write_data); //åñëè äàííûå äëÿ çàïèñè îñòàëèñü, òî çàïèñûâàåì èõ
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
uint16_t GD25Q16ETIGR_ReadManufacturerDeviceID(void)
|
||||
{
|
||||
volatile uint16_t empty, i, j;
|
||||
transmitData(ReadManufacturerDeviceID);
|
||||
|
||||
for(i = 0; i<5; i++) transmitData(0xFF);
|
||||
while(SpiRegs.SPIFFRX.bit.RXFFST != (6))
|
||||
{
|
||||
|
||||
}
|
||||
for(j = 0; j<6; j++)
|
||||
{
|
||||
empty = SpiRegs.SPIRXBUF;
|
||||
}
|
||||
return empty;
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
/*
|
||||
* GD25Q16ETIGR.h
|
||||
*
|
||||
* Created on: 7 ñåíò. 2023 ã.
|
||||
* Author: seklyuts
|
||||
*/
|
||||
|
||||
#ifndef SRC_GD25Q16ETIGR_H_
|
||||
#define SRC_GD25Q16ETIGR_H_
|
||||
|
||||
#define GD25Q16E_SIZE 0x100000 // 16 bit lenght
|
||||
#define GD25Q16E_PAGE 0x100
|
||||
|
||||
void GD25Q16ETIGR_en(void);
|
||||
void GD25Q16ETIGR_write(void);
|
||||
void GD25Q16ETIGR_write_data(uint32_t Addr, uint16_t quant, uint16_t * write_data);
|
||||
void GD25Q16ETIGR_read_data(uint32_t Addr, uint16_t quant, uint16_t * read_data);
|
||||
uint16_t GD25Q16ETIGR_verify_data(uint32_t Addr, uint16_t quant, uint16_t * verify_data);
|
||||
uint16_t GD25Q16ETIGR_ReadManufacturerDeviceID(void);
|
||||
void GD25Q16ETIGR_clean_SectorWasErraised(void);
|
||||
|
||||
#endif /* SRC_GD25Q16ETIGR_H_ */
|
||||
@ -1,137 +0,0 @@
|
||||
/*
|
||||
* ZD24C02A.c
|
||||
*
|
||||
* Created on: 8 ñåíò. 2023 ã.
|
||||
* Author: seklyuts
|
||||
*/
|
||||
#include "f28x_project.h"
|
||||
#include "i2c_init.h"
|
||||
#include "ZD24C02A.h"
|
||||
#include "Arr.h"
|
||||
|
||||
//Íóæäàåòñÿ â ïðîâåðêå è îòëàäêå, òàê êàê ñ ýòîé ìèêðîñõåìîé íå óäàëîñü äîáèòüñÿ ñòàáèëüíîé ðàáîòû, îíà òî ðàáîòàåò, òî íåò
|
||||
|
||||
volatile uint16_t SlaveAdr = I2C_SLAVE_ADDRESS;
|
||||
uint16_t BufferZD24C02A[17];
|
||||
|
||||
uint16_t ZD24C02A_write_8(uint16_t Addr, uint16_t * Array, uint16_t quant)// ìîæåò ïèñàòü î÷åðåäÿìè ïî 16 áàéò
|
||||
{
|
||||
if(I2CWrite(SlaveAdr, Addr, quant, true, Array)) return 1;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
uint16_t ZD24C02A_read_8(uint16_t Addr, uint16_t * Array, uint16_t quant)
|
||||
{
|
||||
|
||||
if(I2CWrite(SlaveAdr, Addr, 0, false, Array)) return 1;
|
||||
if(I2CRead(SlaveAdr, quant, true, Array)) return 1;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
|
||||
uint16_t ZD24C02A_verify_8(uint16_t Addr, uint16_t * Array, uint16_t quant)
|
||||
{
|
||||
uint16_t VerifyErr = 0;
|
||||
|
||||
if(I2CWrite(SlaveAdr, Addr, 0, false, BufferZD24C02A)) return 1;
|
||||
VerifyErr = I2CVerify(SlaveAdr, quant, true, Array);
|
||||
return VerifyErr;
|
||||
}
|
||||
|
||||
uint16_t ZD24C02A_write(uint32_t Addr, uint16_t quant8, uint16_t * write_data)
|
||||
{
|
||||
uint32_t i=0;
|
||||
uint16_t addr_write_data[8];
|
||||
uint16_t quant16;
|
||||
|
||||
if(quant8 > 8)
|
||||
{
|
||||
for(i = 0; i < (quant8-8); i += 8)
|
||||
{//â ýòîì öèêëå òîëüêî ïîëíûå ïîñûëêè ïî 8 áàéò
|
||||
copy16_to_8(write_data, addr_write_data, 4);
|
||||
if( ZD24C02A_write_8(Addr+i, addr_write_data, 8)) return 1;
|
||||
write_data += 4;
|
||||
}
|
||||
}
|
||||
if(i < quant8)
|
||||
{//òóò ì.á. îò 1 äî 8 áàéò
|
||||
quant16 = quant16bitWords(quant8-i);
|
||||
copy16_to_8(write_data, addr_write_data, quant16);
|
||||
if( ZD24C02A_write_8(Addr+i, addr_write_data, (quant8 - i))) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t ZD24C02A_read(uint32_t Addr, uint16_t quant8, uint16_t * read_data)
|
||||
{
|
||||
uint32_t i=0;
|
||||
uint16_t addr_read_data[8];
|
||||
|
||||
if(quant8 > 8)
|
||||
{
|
||||
for(i = 0; i < (quant8-8); i += 8)
|
||||
{//â ýòîì öèêëå òîëüêî ïîëíûå ïîñûëêè ïî 8 áàéò
|
||||
if( ZD24C02A_read_8(Addr+i, addr_read_data, 8)) return 1;
|
||||
copy8_to_16(addr_read_data, read_data, 4);
|
||||
read_data+=4;
|
||||
}
|
||||
}
|
||||
if(i < quant8)
|
||||
{//òóò ì.á. îò 1 äî 8 áàéò
|
||||
if( ZD24C02A_read_8(Addr+i, addr_read_data, (quant8 - i))) return 1;
|
||||
if((quant8 - i) & 1) {addr_read_data[quant8] = 0; quant8++; }//åñëè áàéò íå÷¸òíîå ÷èñëî, òî äîïîëíÿåì äî ÷¸òíîãî íóë¸ì
|
||||
copy8_to_16(addr_read_data, read_data, (quant8 - i)/2);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t ZD24C02A_verify(uint32_t Addr, uint16_t quant8, uint16_t * verify_data)
|
||||
{
|
||||
uint32_t i=0;
|
||||
uint16_t addr_vfy_data[8];
|
||||
uint16_t Err_read = 0;
|
||||
uint16_t quant16;
|
||||
|
||||
if(quant8 > 8)
|
||||
{
|
||||
for(i = 0; i < (quant8-8); i += 8)
|
||||
{//â ýòîì öèêëå òîëüêî ïîëíûå ïîñûëêè ïî 8 áàéò
|
||||
copy16_to_8(verify_data, addr_vfy_data, 4);
|
||||
Err_read = ZD24C02A_verify_8(Addr+i, addr_vfy_data, 8);
|
||||
if(Err_read) return Err_read;
|
||||
verify_data+=4;
|
||||
}
|
||||
}
|
||||
if(i < quant8)
|
||||
{//òóò ì.á. îò 1 äî 8 áàéò
|
||||
quant16 = quant16bitWords(quant8-i);
|
||||
copy16_to_8(verify_data, addr_vfy_data, quant16);
|
||||
Err_read = ZD24C02A_verify_8(Addr+i, addr_vfy_data, (quant8 - i));
|
||||
if(Err_read) return Err_read;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ZD24C02A_read_all(uint16_t byteCount, uint16_t * Array)
|
||||
{
|
||||
I2CRead(SlaveAdr, byteCount, true, Array);
|
||||
// I2CWriteRead(I2C_SLAVE_ADDRESS, byteCount, true, Array);
|
||||
// I2CWriteReadOnes(I2C_SLAVE_ADDRESS);
|
||||
}
|
||||
|
||||
|
||||
void ZD24C02A_test(uint16_t * Array)
|
||||
{
|
||||
uint16_t i=0;
|
||||
for(i=0;i<=255;i+=15)
|
||||
{
|
||||
// I2CWrite(SlaveAdr, 1, true, Array);
|
||||
}
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* ZD24C02A.h
|
||||
*
|
||||
* Created on: 8 ñåíò. 2023 ã.
|
||||
* Author: seklyuts
|
||||
*/
|
||||
|
||||
#ifndef SRC_ZD24C02A_H_
|
||||
#define SRC_ZD24C02A_H_
|
||||
|
||||
#define I2C_SLAVE_ADDRESS 0x51U
|
||||
#define I2C_OWN_ADDRESS 0x30U
|
||||
|
||||
#define ZD24C02A_SIZE 0x80
|
||||
|
||||
|
||||
uint16_t ZD24C02A_write(uint32_t Addr, uint16_t quant, uint16_t * write_data);
|
||||
uint16_t ZD24C02A_read(uint32_t Addr, uint16_t quant, uint16_t * read_data);
|
||||
void ZD24C02A_test(uint16_t * Array);
|
||||
void ZD24C02A_read_all(uint16_t byteCount, uint16_t * Array);
|
||||
uint16_t ZD24C02A_verify(uint32_t Addr, uint16_t quant, uint16_t * verify_data);
|
||||
|
||||
#endif /* SRC_ZD24C02A_H_ */
|
||||
@ -102,13 +102,41 @@ void PWMAllInit(void)
|
||||
|
||||
void PWMGpioInit(void)//<2F><><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
InitEPwm2Gpio();
|
||||
InitEPwm5Gpio();
|
||||
InitEPwm7Gpio();
|
||||
InitEPwm8Gpio();
|
||||
InitEPwm3Gpio();
|
||||
EALLOW;
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO2 = 1; // Disable pull-up on GPIO2 (EPWM2A)
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO3 = 1; // Disable pull-up on GPIO3 (EPWM2B)
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 1; // Configure GPIO2 as EPWM2A
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 1; // Configure GPIO3 as EPWM2B
|
||||
GpioCtrlRegs.GPACSEL1.bit.GPIO2 = 2;//to cpu2
|
||||
GpioCtrlRegs.GPACSEL1.bit.GPIO3 = 2;
|
||||
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO8 = 1; // Disable pull-up on GPIO8 (EPWM5A)
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO9 = 1; // Disable pull-up on GPIO9 (EPWM5B)
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO8 = 1; // Configure GPIO8 as EPWM5A
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO9 = 1; // Configure GPIO9 as EPWM5B
|
||||
GpioCtrlRegs.GPACSEL2.bit.GPIO8 = 2;//to cpu2
|
||||
GpioCtrlRegs.GPACSEL2.bit.GPIO9 = 2;
|
||||
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO12 = 1; // Disable pull-up on GPIO12 (EPWM7A)
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO13 = 1; // Disable pull-up on GPIO13 (EPWM7B)
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO12 = 1; // Configure GPIO12 as EPWM7A
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO13 = 1; // Configure GPIO13 as EPWM7B
|
||||
GpioCtrlRegs.GPACSEL2.bit.GPIO12 = 2;//to cpu2
|
||||
GpioCtrlRegs.GPACSEL2.bit.GPIO13 = 2;
|
||||
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO14 = 1; // Disable pull-up on GPIO14 (EPWM8A)
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO14 = 1; // Configure GPIO14 as EPWM8A
|
||||
GpioCtrlRegs.GPACSEL2.bit.GPIO14 = 2;//to cpu2
|
||||
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO4 = 1; // Disable pull-up on GPIO4 (EPWM3A)
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO5 = 1; // Disable pull-up on GPIO5 (EPWM3B)
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO4 = 1; // Configure GPIO4 as EPWM3A
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO5 = 1; // Configure GPIO5 as EPWM3B
|
||||
GpioCtrlRegs.GPACSEL1.bit.GPIO4 = 2;//to cpu2
|
||||
GpioCtrlRegs.GPACSEL1.bit.GPIO5 = 2;
|
||||
|
||||
EDIS;
|
||||
|
||||
// InitEPwm11Gpio();
|
||||
}
|
||||
|
||||
void PWMInitEnable(void)
|
||||
|
||||
@ -13,15 +13,8 @@
|
||||
#include "sdfm.h"
|
||||
#include "f2838x_sdfm_drivers.h"
|
||||
#include "gpio_init.h"
|
||||
#include "spi_init.h"
|
||||
#include "i2c_init.h"
|
||||
#include "frm_uart.h"
|
||||
#include "BL25CM1A.h"
|
||||
#include "GD25Q16ETIGR.h"
|
||||
#include "ZD24C02A.h"
|
||||
#include "vector.h"
|
||||
#include "adc_init.h"
|
||||
#include "biss.h"
|
||||
|
||||
|
||||
#define TO_CPU1 0
|
||||
#define TO_CPU2 1
|
||||
@ -97,38 +90,12 @@ void InitPerif(void)
|
||||
|
||||
// InitPieVectTable();
|
||||
|
||||
|
||||
|
||||
GpioInit();
|
||||
|
||||
|
||||
GpioDiodInit();
|
||||
|
||||
//GpioSetGreen();
|
||||
//GpioSetBlue();
|
||||
|
||||
SdfmGpioInit();
|
||||
SdfmTypeInit();
|
||||
// SdfmInitEnable();
|
||||
// SdfmInit();
|
||||
// SdfmInitInterruptEn();
|
||||
|
||||
PWMGpioInit();
|
||||
// PWMInitEnable();
|
||||
// PWMAllInit();
|
||||
// PWMInitInterruptEn();
|
||||
|
||||
// vectorInitCurrLoop();
|
||||
|
||||
|
||||
// SpiCGpioInit();
|
||||
// SpiCInit();
|
||||
// BissGpioInit();
|
||||
// BissInit();
|
||||
|
||||
FRMGPIOInit();
|
||||
// FRMUartInit();
|
||||
|
||||
|
||||
// ConfigureADC();
|
||||
CONNECT_SD1(TO_CPU2);
|
||||
@ -142,23 +109,16 @@ void InitPerif(void)
|
||||
CONNECT_PWM11(TO_CPU2);
|
||||
CONNECT_PWM12(TO_CPU2);
|
||||
CONNECT_SCIA(TO_CPU2);
|
||||
//
|
||||
// Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
|
||||
Cpu1toCpu2IpcRegs.CPU1TOCPU2IPCBOOTMODE = 0x5A00C803; //str 716
|
||||
Cpu1toCpu2IpcRegs.CPU1TOCPU2IPCSET.bit.IPC0 = 1;
|
||||
|
||||
|
||||
EALLOW;
|
||||
DevCfgRegs.CPU2RESCTL.all = 0xA5A50000;
|
||||
EDIS;
|
||||
|
||||
while(DevCfgRegs.RSTSTAT.bit.CPU2RES == 0);
|
||||
|
||||
// SysCtl_controlCPU2Reset(SYSCTL_CORE_DEACTIVE);
|
||||
// while(SysCtl_isCPU2Reset() == 0x1U);
|
||||
|
||||
//Device_bootCPU2(BOOTMODE_BOOT_TO_FLASH_SECTOR0);
|
||||
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<configurations XML_version="1.2" id="configurations_0">
|
||||
|
||||
<configuration XML_version="1.2" id="Texas Instruments XDS2xx USB Debug Probe_0">
|
||||
<instance XML_version="1.2" desc="Texas Instruments XDS2xx USB Debug Probe_0" href="connections/TIXDS2XXUSB_Connection.xml" id="Texas Instruments XDS2xx USB Debug Probe_0" xml="TIXDS2XXUSB_Connection.xml" xmlpath="connections"/>
|
||||
<connection XML_version="1.2" id="Texas Instruments XDS2xx USB Debug Probe_0">
|
||||
<instance XML_version="1.2" href="drivers/tixds560icepick_c.xml" id="drivers" xml="tixds560icepick_c.xml" xmlpath="drivers"/>
|
||||
<instance XML_version="1.2" href="drivers/tixds560c28x.xml" id="drivers" xml="tixds560c28x.xml" xmlpath="drivers"/>
|
||||
<instance XML_version="1.2" href="drivers/tixds560cla2.xml" id="drivers" xml="tixds560cla2.xml" xmlpath="drivers"/>
|
||||
<instance XML_version="1.2" href="drivers/tixds560cs_child.xml" id="drivers" xml="tixds560cs_child.xml" xmlpath="drivers"/>
|
||||
<instance XML_version="1.2" href="drivers/tixds560cs_dap.xml" id="drivers" xml="tixds560cs_dap.xml" xmlpath="drivers"/>
|
||||
<instance XML_version="1.2" href="drivers/tixds560cortexM.xml" id="drivers" xml="tixds560cortexM.xml" xmlpath="drivers"/>
|
||||
<instance XML_version="1.2" href="drivers/tixds560ajsm.xml" id="drivers" xml="tixds560ajsm.xml" xmlpath="drivers"/>
|
||||
<configuration XML_version="1.2" id="Texas Instruments XDS100v2 USB Debug Probe_0">
|
||||
<instance XML_version="1.2" desc="Texas Instruments XDS100v2 USB Debug Probe_0" href="connections/TIXDS100v2_Connection.xml" id="Texas Instruments XDS100v2 USB Debug Probe_0" xml="TIXDS100v2_Connection.xml" xmlpath="connections"/>
|
||||
<connection XML_version="1.2" id="Texas Instruments XDS100v2 USB Debug Probe_0">
|
||||
<instance XML_version="1.2" href="drivers/tixds100v2icepick_c.xml" id="drivers" xml="tixds100v2icepick_c.xml" xmlpath="drivers"/>
|
||||
<instance XML_version="1.2" href="drivers/tixds100v2c28x.xml" id="drivers" xml="tixds100v2c28x.xml" xmlpath="drivers"/>
|
||||
<instance XML_version="1.2" href="drivers/tixds100v2cla2.xml" id="drivers" xml="tixds100v2cla2.xml" xmlpath="drivers"/>
|
||||
<instance XML_version="1.2" href="drivers/tixds100v2cs_child.xml" id="drivers" xml="tixds100v2cs_child.xml" xmlpath="drivers"/>
|
||||
<instance XML_version="1.2" href="drivers/tixds100v2cs_dap.xml" id="drivers" xml="tixds100v2cs_dap.xml" xmlpath="drivers"/>
|
||||
<instance XML_version="1.2" href="drivers/tixds100v2cortexM.xml" id="drivers" xml="tixds100v2cortexM.xml" xmlpath="drivers"/>
|
||||
<instance XML_version="1.2" href="drivers/tixds510ajsm.xml" id="drivers" xml="tixds510ajsm.xml" xmlpath="drivers"/>
|
||||
<platform XML_version="1.2" id="platform_0">
|
||||
<instance XML_version="1.2" desc="TMS320F28388D_0" href="devices/f28388d.xml" id="TMS320F28388D_0" xml="f28388d.xml" xmlpath="devices"/>
|
||||
<device HW_revision="1" XML_version="1.2" description="" id="TMS320F28388D_0" partnum="TMS320F28388D">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user