Skip to content

Commit

Permalink
update fw
Browse files Browse the repository at this point in the history
  • Loading branch information
NouranAbdelaziz committed May 12, 2024
1 parent 15448bb commit 4598c0e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 98 deletions.
60 changes: 11 additions & 49 deletions fw/EF_UART.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,57 +185,29 @@ void EF_UART_setRxFIFOThreshold(uint32_t uart_base, int value){

EF_UART_TYPE* uart = (EF_UART_TYPE*)uart_base;

// Clear the field bits in the register using the defined mask
uart->FIFOCTRL &= ~EF_UART_FIFOCTRL_REG_RXLT_MASK;

// Set the bits with the given value at the defined offset
uart->FIFOCTRL |= ((value << EF_UART_FIFOCTRL_REG_RXLT_BIT) & EF_UART_FIFOCTRL_REG_RXLT_MASK);
uart->RX_FIFO_THRESHOLD = value;
}

int EF_UART_getRxFIFOThreshold(uint32_t uart_base){

EF_UART_TYPE* uart = (EF_UART_TYPE*)uart_base;

int rx_level_th = (uart->FIFOCTRL & EF_UART_FIFOCTRL_REG_RXLT_MASK) >> EF_UART_FIFOCTRL_REG_RXLT_BIT;

return (rx_level_th);
return (uart->RX_FIFO_THRESHOLD);

}

void EF_UART_setTxFIFOThreshold(uint32_t uart_base, int value){

EF_UART_TYPE* uart = (EF_UART_TYPE*)uart_base;

// Clear the field bits in the register using the defined mask
uart->FIFOCTRL &= ~EF_UART_FIFOCTRL_REG_TXLT_MASK;

// Set the bits with the given value at the defined offset
uart->FIFOCTRL |= ((value << EF_UART_FIFOCTRL_REG_TXLT_BIT) & EF_UART_FIFOCTRL_REG_TXLT_MASK);
uart->TX_FIFO_THRESHOLD=value;
}

int EF_UART_getTxFIFOThreshold(uint32_t uart_base){

EF_UART_TYPE* uart = (EF_UART_TYPE*)uart_base;

int tx_level_th = (uart->FIFOCTRL & EF_UART_FIFOCTRL_REG_TXLT_MASK) >> EF_UART_FIFOCTRL_REG_TXLT_BIT;

return (tx_level_th);

}

void EF_UART_setFIFOControl (uint32_t uart_base, int value){

EF_UART_TYPE* uart = (EF_UART_TYPE*)uart_base;

uart->FIFOCTRL = value;

}

int EF_UART_getFIFOControl (uint32_t uart_base){

EF_UART_TYPE* uart = (EF_UART_TYPE*)uart_base;

return (uart->FIFOCTRL) ;
return (uart->TX_FIFO_THRESHOLD);

}

Expand All @@ -244,26 +216,16 @@ int EF_UART_getTxCount(uint32_t uart_base){

EF_UART_TYPE* uart = (EF_UART_TYPE*)uart_base;

int tx_level = (uart->FIFOS & EF_UART_FIFOS_REG_TXL_MASK) >> EF_UART_FIFOS_REG_TXL_BIT;

return (tx_level);
return(uart->TX_FIFO_LEVEL);
}

int EF_UART_getRxCount(uint32_t uart_base){

EF_UART_TYPE* uart = (EF_UART_TYPE*)uart_base;

int rx_level = (uart->FIFOS & EF_UART_FIFOS_REG_RXL_MASK) >> EF_UART_FIFOS_REG_RXL_BIT;

return (rx_level);
return(uart->RX_FIFO_LEVEL);
}

int EF_UART_getFIFOStatus(uint32_t uart_base){

EF_UART_TYPE* uart = (EF_UART_TYPE*)uart_base;

return (uart->FIFOS);
}

void EF_UART_setMatchData(uint32_t uart_base, int matchData){

Expand Down Expand Up @@ -293,31 +255,31 @@ int EF_UART_getMatchData(uint32_t uart_base){
int EF_UART_getRIS(uint32_t uart_base){

EF_UART_TYPE* uart = (EF_UART_TYPE*)uart_base;
return (uart->ris);
return (uart->RIS);
}

int EF_UART_getMIS(uint32_t uart_base){

EF_UART_TYPE* uart = (EF_UART_TYPE*)uart_base;
return (uart->mis);
return (uart->MIS);
}

void EF_UART_setIM(uint32_t uart_base, int mask){

EF_UART_TYPE* uart = (EF_UART_TYPE*)uart_base;
uart->im |= mask;
uart->IM |= mask;
}

int EF_UART_getIM(uint32_t uart_base){

EF_UART_TYPE* uart = (EF_UART_TYPE*)uart_base;
return (uart->im);
return (uart->IM);
}

void EF_UART_setICR(uint32_t uart_base, int mask){

EF_UART_TYPE* uart = (EF_UART_TYPE*)uart_base;
(uart->icr) |= mask;
(uart->IC) |= mask;
}


Expand Down
28 changes: 0 additions & 28 deletions fw/EF_UART.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,34 +197,6 @@ void EF_UART_setTxFIFOThreshold(uint32_t uart_base, int threshold);
int EF_UART_getTxFIFOThreshold(uint32_t uart_base);


//! sets the FIFO control register to a certain value where
//! * bit 0-3: Transmit FIFO Level Threshold
//! * bit 8-11: Receive FIFO Level Threshold
/*!
\param uart_base The base memory address of UART registers.
\param config The value of the FIFO control register
*/
void EF_UART_setFIFOControl (uint32_t uart_base, int value);


//! returns the value of the FIFO control register
/*!
\param uart_base The base memory address of UART registers.
\return FIFO control register value
*/
int EF_UART_getFIFOControl (uint32_t uart_base);


//! returns the value of the FIFO status register where
//! * bit 0-3: Receive FIFO Level
//! * bit 8-11: Transmit FIFO Level
/*!
\param uart_base The base memory address of UART registers.
\return FIFO status register value
*/
int EF_UART_getFIFOStatus(uint32_t uart_base);


//! sets the matchData to a certain value at which "MATCH" interrupt will be raised
/*!
Expand Down
48 changes: 27 additions & 21 deletions fw/EF_UART_regs.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Copyright 2024 Efabless Corp.
Author: Mohamed Shalan (mshalan@aucegypt.edu)
Author: Mohamed Shalan (mshalan@efabless.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -17,11 +17,6 @@
*/

/*! \file EF_UART_regs.h
\brief C header file which contains UART registers definition
*/

#ifndef EF_UARTREGS_H
#define EF_UARTREGS_H

Expand Down Expand Up @@ -50,14 +45,18 @@
#define EF_UART_CFG_REG_PARITY_MASK 0xe0
#define EF_UART_CFG_REG_TIMEOUT_BIT 8
#define EF_UART_CFG_REG_TIMEOUT_MASK 0x3f00
#define EF_UART_FIFOCTRL_REG_TXLT_BIT 0
#define EF_UART_FIFOCTRL_REG_TXLT_MASK 0xf
#define EF_UART_FIFOCTRL_REG_RXLT_BIT 8
#define EF_UART_FIFOCTRL_REG_RXLT_MASK 0xf00
#define EF_UART_FIFOS_REG_RXL_BIT 0
#define EF_UART_FIFOS_REG_RXL_MASK 0xf
#define EF_UART_FIFOS_REG_TXL_BIT 8
#define EF_UART_FIFOS_REG_TXL_MASK 0xf00
#define EF_UART_RX_FIFO_LEVEL_REG_LEVEL_BIT 0
#define EF_UART_RX_FIFO_LEVEL_REG_LEVEL_MASK 0xf
#define EF_UART_RX_FIFO_THRESHOLD_REG_THRESHOLD_BIT 0
#define EF_UART_RX_FIFO_THRESHOLD_REG_THRESHOLD_MASK 0xf
#define EF_UART_RX_FIFO_FLUSH_REG_FLUSH_BIT 0
#define EF_UART_RX_FIFO_FLUSH_REG_FLUSH_MASK 0x1
#define EF_UART_TX_FIFO_LEVEL_REG_LEVEL_BIT 0
#define EF_UART_TX_FIFO_LEVEL_REG_LEVEL_MASK 0xf
#define EF_UART_TX_FIFO_THRESHOLD_REG_THRESHOLD_BIT 0
#define EF_UART_TX_FIFO_THRESHOLD_REG_THRESHOLD_MASK 0xf
#define EF_UART_TX_FIFO_FLUSH_REG_FLUSH_BIT 0
#define EF_UART_TX_FIFO_FLUSH_REG_FLUSH_MASK 0x1

#define EF_UART_TXE_FLAG 0x1
#define EF_UART_RXF_FLAG 0x2
Expand All @@ -76,14 +75,21 @@ typedef struct _EF_UART_TYPE_ {
__W PR;
__W CTRL;
__W CFG;
__W FIFOCTRL;
__R FIFOS;
__R reserved_0[2];
__W MATCH;
__R reserved[952];
__RW im;
__R mis;
__R ris;
__W icr;
__R reserved_1[16248];
__R RX_FIFO_LEVEL;
__W RX_FIFO_THRESHOLD;
__W RX_FIFO_FLUSH;
__R reserved_2[1];
__R TX_FIFO_LEVEL;
__W TX_FIFO_THRESHOLD;
__W TX_FIFO_FLUSH;
__R reserved_3[57];
__RW IM;
__R MIS;
__R RIS;
__W IC;
} EF_UART_TYPE;

#endif
Expand Down

0 comments on commit 4598c0e

Please sign in to comment.