initial check in based on SVN revision 575
This commit is contained in:
69
source/m95512.c
Normal file
69
source/m95512.c
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* m95512.c
|
||||
*
|
||||
* Created on: Nov 1, 2023
|
||||
* Author: Warner
|
||||
*/
|
||||
|
||||
#include "m95512.h"
|
||||
#include "fsl_spi.h"
|
||||
#include "spi.h"
|
||||
#include "timer.h"
|
||||
|
||||
#define M95512_BUFFER_SIZE (8)
|
||||
|
||||
extern uint8_t Port_State[];
|
||||
extern spi_transfer_t SPI0_xfer;
|
||||
|
||||
|
||||
|
||||
/* BB 11/10/23
|
||||
* m95512.c functions should ONLY be used by eeprom.c functions!
|
||||
* This is because the CTIMER0 interrupt corrupts EEPROM data
|
||||
* eeprom.c functions stop CTIMER0 while accessing the EEPROM
|
||||
*/
|
||||
|
||||
|
||||
status_t M95512_WriteEnable(void){
|
||||
status_t reslut; //not used, because function SPI0_SendBytes() has no return.
|
||||
uint8_t srcBuff[M95512_BUFFER_SIZE];
|
||||
|
||||
srcBuff[0] = WRITE_ENABLE;
|
||||
SPI0_SendBytes(srcBuff, 1, E2PROM);
|
||||
|
||||
return reslut;
|
||||
}
|
||||
|
||||
status_t M95512_WriteDisable(void){
|
||||
status_t reslut;
|
||||
uint8_t srcBuff[M95512_BUFFER_SIZE];
|
||||
|
||||
srcBuff[0] = WRITE_DISABLE;
|
||||
SPI0_SendBytes(srcBuff, 1, E2PROM);
|
||||
|
||||
return reslut;
|
||||
}
|
||||
|
||||
status_t M95512_ReadStatus(uint8_t *pdata){
|
||||
status_t reslut;
|
||||
uint8_t srcBuff[M95512_BUFFER_SIZE];
|
||||
uint8_t destBuff[M95512_BUFFER_SIZE];
|
||||
|
||||
srcBuff[0] = READ_STATUS_REG;
|
||||
SPI0_SendBytes(srcBuff, 2, E2PROM);
|
||||
*pdata = SPI0_xfer.rxData[1];
|
||||
|
||||
return reslut;
|
||||
}
|
||||
|
||||
status_t M95512_WriteStatus(uint8_t *pdata){
|
||||
status_t reslut;
|
||||
uint8_t srcBuff[M95512_BUFFER_SIZE];
|
||||
|
||||
srcBuff[0] = WRITE_STATUS_REG;
|
||||
srcBuff[1] = *pdata;
|
||||
SPI0_SendBytes(srcBuff, 2, E2PROM);
|
||||
|
||||
return reslut;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user