Detab some HAL files

2.0.x
Scott Lahteine 7 years ago
parent 1c41de16d4
commit 3319765034

@ -89,25 +89,25 @@ void HardwareSerial::begin(uint32_t baudrate) {
PINSEL_ConfigPin(&PinCfg); PINSEL_ConfigPin(&PinCfg);
} }
/* Initialize UART Configuration parameter structure to default state: /* Initialize UART Configuration parameter structure to default state:
* Baudrate = 9600bps * Baudrate = 9600bps
* 8 data bit * 8 data bit
* 1 Stop bit * 1 Stop bit
* None parity * None parity
*/ */
UART_ConfigStructInit(&UARTConfigStruct); UART_ConfigStructInit(&UARTConfigStruct);
// Re-configure baudrate // Re-configure baudrate
UARTConfigStruct.Baud_rate = baudrate; UARTConfigStruct.Baud_rate = baudrate;
// Initialize eripheral with given to corresponding parameter // Initialize eripheral with given to corresponding parameter
UART_Init(UARTx, &UARTConfigStruct); UART_Init(UARTx, &UARTConfigStruct);
// Enable and reset the TX and RX FIFOs // Enable and reset the TX and RX FIFOs
UART_FIFOConfigStructInit(&FIFOConfig); UART_FIFOConfigStructInit(&FIFOConfig);
UART_FIFOConfig(UARTx, &FIFOConfig); UART_FIFOConfig(UARTx, &FIFOConfig);
// Enable UART Transmit // Enable UART Transmit
UART_TxCmd(UARTx, ENABLE); UART_TxCmd(UARTx, ENABLE);
// Configure Interrupts // Configure Interrupts
@ -234,9 +234,9 @@ void HardwareSerial::IRQHandler() {
uint8_t LSRValue, byte; uint8_t LSRValue, byte;
IIRValue = UART_GetIntId(UARTx); IIRValue = UART_GetIntId(UARTx);
IIRValue &= UART_IIR_INTID_MASK; /* check bit 1~3, interrupt identification */ IIRValue &= UART_IIR_INTID_MASK; /* check bit 1~3, interrupt identification */
if ( IIRValue == UART_IIR_INTID_RLS ) /* Receive Line Status */ if ( IIRValue == UART_IIR_INTID_RLS ) /* Receive Line Status */
{ {
LSRValue = UART_GetLineStatus(UARTx); LSRValue = UART_GetLineStatus(UARTx);
@ -246,13 +246,13 @@ void HardwareSerial::IRQHandler() {
/* There are errors or break interrupt */ /* There are errors or break interrupt */
/* Read LSR will clear the interrupt */ /* Read LSR will clear the interrupt */
Status = LSRValue; Status = LSRValue;
byte = UART_ReceiveByte(UARTx); /* Dummy read on RX to clear byte = UART_ReceiveByte(UARTx); /* Dummy read on RX to clear
interrupt, then bail out */ interrupt, then bail out */
return; return;
} }
} }
if ( IIRValue == UART_IIR_INTID_RDA ) /* Receive Data Available */ if ( IIRValue == UART_IIR_INTID_RDA ) /* Receive Data Available */
{ {
/* Clear the FIFO */ /* Clear the FIFO */
while ( UART_Receive(UARTx, &byte, 1, NONE_BLOCKING) ) { while ( UART_Receive(UARTx, &byte, 1, NONE_BLOCKING) ) {
@ -265,10 +265,10 @@ void HardwareSerial::IRQHandler() {
break; break;
} }
} }
else if ( IIRValue == UART_IIR_INTID_CTI ) /* Character timeout indicator */ else if ( IIRValue == UART_IIR_INTID_CTI ) /* Character timeout indicator */
{ {
/* Character Time-out indicator */ /* Character Time-out indicator */
Status |= 0x100; /* Bit 9 as the CTI error */ Status |= 0x100; /* Bit 9 as the CTI error */
} }
#if TX_BUFFER_SIZE > 0 #if TX_BUFFER_SIZE > 0
@ -302,12 +302,12 @@ extern "C" {
#endif #endif
/***************************************************************************** /*****************************************************************************
** Function name: UART0_IRQHandler ** Function name: UART0_IRQHandler
** **
** Descriptions: UART0 interrupt handler ** Descriptions: UART0 interrupt handler
** **
** parameters: None ** parameters: None
** Returned value: None ** Returned value: None
** **
*****************************************************************************/ *****************************************************************************/
void UART0_IRQHandler (void) void UART0_IRQHandler (void)
@ -316,12 +316,12 @@ void UART0_IRQHandler (void)
} }
/***************************************************************************** /*****************************************************************************
** Function name: UART1_IRQHandler ** Function name: UART1_IRQHandler
** **
** Descriptions: UART1 interrupt handler ** Descriptions: UART1 interrupt handler
** **
** parameters: None ** parameters: None
** Returned value: None ** Returned value: None
** **
*****************************************************************************/ *****************************************************************************/
void UART1_IRQHandler (void) void UART1_IRQHandler (void)
@ -330,12 +330,12 @@ void UART1_IRQHandler (void)
} }
/***************************************************************************** /*****************************************************************************
** Function name: UART2_IRQHandler ** Function name: UART2_IRQHandler
** **
** Descriptions: UART2 interrupt handler ** Descriptions: UART2 interrupt handler
** **
** parameters: None ** parameters: None
** Returned value: None ** Returned value: None
** **
*****************************************************************************/ *****************************************************************************/
void UART2_IRQHandler (void) void UART2_IRQHandler (void)
@ -344,12 +344,12 @@ void UART2_IRQHandler (void)
} }
/***************************************************************************** /*****************************************************************************
** Function name: UART3_IRQHandler ** Function name: UART3_IRQHandler
** **
** Descriptions: UART3 interrupt handler ** Descriptions: UART3 interrupt handler
** **
** parameters: None ** parameters: None
** Returned value: None ** Returned value: None
** **
*****************************************************************************/ *****************************************************************************/
void UART3_IRQHandler (void) void UART3_IRQHandler (void)

@ -49,45 +49,45 @@ namespace PersistentStore {
char HAL_STM32F1_eeprom_content[HAL_STM32F1_EEPROM_SIZE]; char HAL_STM32F1_eeprom_content[HAL_STM32F1_EEPROM_SIZE];
bool access_start() { bool access_start() {
if (!card.cardOK) return false; if (!card.cardOK) return false;
int16_t bytes_read = 0; int16_t bytes_read = 0;
const char eeprom_zero = 0xFF; const char eeprom_zero = 0xFF;
card.openFile((char *)CONFIG_FILE_NAME,true); card.openFile((char *)CONFIG_FILE_NAME,true);
bytes_read = card.read (HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE); bytes_read = card.read (HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE);
if (bytes_read == -1) return false; if (bytes_read == -1) return false;
for (; bytes_read < HAL_STM32F1_EEPROM_SIZE; bytes_read++) { for (; bytes_read < HAL_STM32F1_EEPROM_SIZE; bytes_read++) {
HAL_STM32F1_eeprom_content[bytes_read] = eeprom_zero; HAL_STM32F1_eeprom_content[bytes_read] = eeprom_zero;
} }
card.closefile(); card.closefile();
return true; return true;
} }
bool access_finish(){ bool access_finish(){
if (!card.cardOK) return false; if (!card.cardOK) return false;
int16_t bytes_written = 0; int16_t bytes_written = 0;
card.openFile((char *)CONFIG_FILE_NAME,true); card.openFile((char *)CONFIG_FILE_NAME,true);
bytes_written = card.write (HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE); bytes_written = card.write (HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE);
card.closefile(); card.closefile();
return (bytes_written == HAL_STM32F1_EEPROM_SIZE); return (bytes_written == HAL_STM32F1_EEPROM_SIZE);
} }
bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) { bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
HAL_STM32F1_eeprom_content [pos + i] = value[i]; HAL_STM32F1_eeprom_content [pos + i] = value[i];
} }
crc16(crc, value, size); crc16(crc, value, size);
pos += size; pos += size;
return false; return false;
} }
bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc) { bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc) {
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
value[i] = HAL_STM32F1_eeprom_content [pos + i]; value[i] = HAL_STM32F1_eeprom_content [pos + i];
} }
crc16(crc, value, size); crc16(crc, value, size);
pos += size; pos += size;
return false; return false;
} }
} // PersistentStore:: } // PersistentStore::

Loading…
Cancel
Save