Funções Solidtec
Embed:
(wiki syntax)
Show/hide line numbers
dados.cpp
00001 #include "dados.h" 00002 00003 QSPI_DISCO_F746NG _qspi; 00004 Serial _pc(USBTX, USBRX); 00005 00006 void lerMemoria(uint32_t ADDR, uint8_t ReadBuffer[], uint32_t tamanho){ 00007 if (_qspi.Read(ReadBuffer, ADDR, tamanho) != QSPI_OK) 00008 { 00009 _pc.printf("Erro de leitura\n"); 00010 } 00011 else 00012 { 00013 ReadBuffer[11] = '\0'; 00014 _pc.printf("Read PASSED\n"); 00015 _pc.printf("Buffer read [%s]\n", ReadBuffer); 00016 } 00017 } 00018 00019 bool escreverMemoria(uint32_t ADDR, uint8_t WriteBuffer[],uint32_t tamanho){ 00020 _pc.printf("Gravando o Endereco"); 00021 // Erase memory 00022 if (_qspi.Erase_Block(ADDR) != QSPI_OK) 00023 { 00024 _pc.printf("# Erro ao limpar memoria #"); 00025 } 00026 else 00027 { 00028 _pc.printf("# Limpeza de memoria Ok #"); 00029 } 00030 _pc.printf("Limpou a memoria"); 00031 // Write memory 00032 if (_qspi.Write(WriteBuffer, ADDR, tamanho) != QSPI_OK) 00033 { 00034 _pc.printf("# Erro ao escrever valores #"); 00035 return false; 00036 } 00037 else 00038 { 00039 _pc.printf("# Escrita Ok #"); 00040 return true; 00041 } 00042 } 00043 00044 int lerValoresInteiros(uint32_t enderecoMemoria){ 00045 uint8_t txtLer[BUFFER_SIZE]; 00046 lerMemoria(enderecoMemoria, txtLer, 5); 00047 return atoi((char*)txtLer); 00048 } 00049 00050 bool salvarValoresInteiros(int valorLocal, uint32_t enderecoMemoria){ 00051 uint8_t txtGravar[5]; 00052 sprintf((char*)txtGravar, "%d", valorLocal); 00053 return escreverMemoria(enderecoMemoria, txtGravar, 5); 00054 }
Generated on Tue Jul 12 2022 17:15:52 by 1.7.2