Skip to content

Commit f823193

Browse files
committed
move static funcs
1 parent 1fe4de6 commit f823193

8 files changed

Lines changed: 88 additions & 88 deletions

File tree

drivers/block/block_driver.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
11
#include "block_driver.h"
2-
typedef struct BlockDeviceState_s {
3-
HalfWord_t ioDriverUID;
4-
Byte_t protocol;
5-
HalfWord_t blockSize;
6-
Word_t totalBlocks;
7-
Base_t initialized;
8-
Word_t currentBlockNumber;
9-
HalfWord_t currentBlockCount;
10-
Byte_t currentTransferMode;
11-
} BlockDeviceState_t;
122
static BlockDeviceState_t state = {
133
0x0u
144
};
15-
static Return_t __PrepareBlockIORequest__(const Byte_t operation_, BlockIORequest_t **request_, Size_t *configSize_);
16-
static Return_t __BlockDeviceReadBlockRAW__(Byte_t **data_);
17-
static Return_t __BlockDeviceWriteBlockRAW__(const Byte_t *data_);
185
Return_t TO_FUNCTION(DEVICE_NAME, _self_register)(void) {
196
FUNCTION_ENTER;
207
if(OK(__RegisterDevice__(DEVICE_UID,
@@ -150,7 +137,7 @@ Return_t TO_FUNCTION(DEVICE_NAME, _simple_write)(Device_t *device_, Byte_t data_
150137
__AssertOnElse__();
151138
FUNCTION_EXIT;
152139
}
153-
static Return_t __PrepareBlockIORequest__(const Byte_t operation_,
140+
Return_t __PrepareBlockIORequest__(const Byte_t operation_,
154141
BlockIORequest_t **request_,
155142
Size_t *configSize_) {
156143
FUNCTION_ENTER;
@@ -172,7 +159,7 @@ static Return_t __PrepareBlockIORequest__(const Byte_t operation_,
172159
}
173160
FUNCTION_EXIT;
174161
}
175-
static Return_t __BlockDeviceReadBlockRAW__(Byte_t **data_) {
162+
Return_t __BlockDeviceReadBlockRAW__(Byte_t **data_) {
176163
FUNCTION_ENTER;
177164
Size_t totalSize = (Size_t) state.blockSize * state.currentBlockCount;
178165
Byte_t *buffer = null;
@@ -197,7 +184,7 @@ static Return_t __BlockDeviceReadBlockRAW__(Byte_t **data_) {
197184
}
198185
FUNCTION_EXIT;
199186
}
200-
static Return_t __BlockDeviceWriteBlockRAW__(const Byte_t *data_) {
187+
Return_t __BlockDeviceWriteBlockRAW__(const Byte_t *data_) {
201188
FUNCTION_ENTER;
202189
Size_t totalSize = (Size_t) state.blockSize * state.currentBlockCount;
203190
BlockIORequest_t *request = null;

drivers/block/block_driver.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@
3434
#define BLOCK_CMD_WRITE_SINGLE 0x03u
3535
#define BLOCK_CMD_WRITE_MULTIPLE 0x04u
3636
#define BLOCK_DEFAULT_SECTOR_SIZE 0x200u
37+
typedef struct BlockDeviceState_s {
38+
HalfWord_t ioDriverUID;
39+
Byte_t protocol;
40+
HalfWord_t blockSize;
41+
Word_t totalBlocks;
42+
Base_t initialized;
43+
Word_t currentBlockNumber;
44+
HalfWord_t currentBlockCount;
45+
Byte_t currentTransferMode;
46+
} BlockDeviceState_t;
3747
typedef struct BlockDeviceConfig_s {
3848
Byte_t command;
3949
HalfWord_t ioDriverUID;
@@ -60,6 +70,9 @@
6070
Return_t TO_FUNCTION(DEVICE_NAME, _write)(Device_t *device_, Size_t *size_, Addr_t *data_);
6171
Return_t TO_FUNCTION(DEVICE_NAME, _simple_read)(Device_t *device_, Byte_t *data_);
6272
Return_t TO_FUNCTION(DEVICE_NAME, _simple_write)(Device_t *device_, Byte_t data_);
73+
Return_t __PrepareBlockIORequest__(const Byte_t operation_, BlockIORequest_t **request_, Size_t *configSize_);
74+
Return_t __BlockDeviceReadBlockRAW__(Byte_t **data_);
75+
Return_t __BlockDeviceWriteBlockRAW__(const Byte_t *data_);
6376
#if defined(POSIX_ARCH_OTHER)
6477
void __BlockDeviceStateClear__(void);
6578
#endif

drivers/char/char_driver.c

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,7 @@
11
#include "char_driver.h"
2-
typedef struct CharDeviceState_s {
3-
HalfWord_t ioDriverUID;
4-
Byte_t protocol;
5-
Byte_t lineMode;
6-
Word_t baudRate;
7-
Base_t initialized;
8-
HalfWord_t rxBufferSize;
9-
HalfWord_t txBufferSize;
10-
Byte_t *rxBuffer;
11-
Byte_t *txBuffer;
12-
HalfWord_t rxHead;
13-
HalfWord_t rxTail;
14-
HalfWord_t txHead;
15-
HalfWord_t txTail;
16-
HalfWord_t currentByteCount;
17-
Byte_t currentTransferMode;
18-
} CharDeviceState_t;
192
static CharDeviceState_t state = {
203
0x0u
214
};
22-
static Return_t __PrepareCharIORequest__(const Byte_t operation_, CharIORequest_t **request_, Size_t *configSize_);
23-
static Return_t __CharDeviceReadRAW__(Byte_t **data_, Size_t *bytesRead_);
24-
static Return_t __CharDeviceWriteRAW__(const Byte_t *data_);
25-
static HalfWord_t __CircularBufferSpace__(const HalfWord_t head_, const HalfWord_t tail_, const HalfWord_t size_);
26-
static HalfWord_t __CircularBufferAvailable__(const HalfWord_t head_, const HalfWord_t tail_, const HalfWord_t size_);
275
Return_t TO_FUNCTION(DEVICE_NAME, _self_register)(void) {
286
FUNCTION_ENTER;
297
if(OK(__RegisterDevice__(DEVICE_UID,
@@ -226,7 +204,7 @@ Return_t TO_FUNCTION(DEVICE_NAME, _simple_write)(Device_t *device_, Byte_t data_
226204
}
227205
FUNCTION_EXIT;
228206
}
229-
static Return_t __PrepareCharIORequest__(const Byte_t operation_,
207+
Return_t __PrepareCharIORequest__(const Byte_t operation_,
230208
CharIORequest_t **request_,
231209
Size_t *configSize_) {
232210
FUNCTION_ENTER;
@@ -246,7 +224,7 @@ static Return_t __PrepareCharIORequest__(const Byte_t operation_,
246224
}
247225
FUNCTION_EXIT;
248226
}
249-
static Return_t __CharDeviceReadRAW__(Byte_t **data_,
227+
Return_t __CharDeviceReadRAW__(Byte_t **data_,
250228
Size_t *bytesRead_) {
251229
FUNCTION_ENTER;
252230
Size_t requestSize = (Size_t) state.currentByteCount;
@@ -270,7 +248,7 @@ static Return_t __CharDeviceReadRAW__(Byte_t **data_,
270248
}
271249
FUNCTION_EXIT;
272250
}
273-
static Return_t __CharDeviceWriteRAW__(const Byte_t *data_) {
251+
Return_t __CharDeviceWriteRAW__(const Byte_t *data_) {
274252
FUNCTION_ENTER;
275253
Size_t writeSize = (Size_t) state.currentByteCount;
276254
CharIORequest_t *request = null;
@@ -290,7 +268,7 @@ static Return_t __CharDeviceWriteRAW__(const Byte_t *data_) {
290268
}
291269
FUNCTION_EXIT;
292270
}
293-
static HalfWord_t __CircularBufferSpace__(const HalfWord_t head_,
271+
HalfWord_t __CircularBufferSpace__(const HalfWord_t head_,
294272
const HalfWord_t tail_,
295273
const HalfWord_t size_) {
296274
if(head_ >= tail_) {
@@ -299,7 +277,7 @@ static HalfWord_t __CircularBufferSpace__(const HalfWord_t head_,
299277
return (tail_ - head_ - CHAR_SINGLE_BYTE_COUNT);
300278
}
301279
}
302-
static HalfWord_t __CircularBufferAvailable__(const HalfWord_t head_,
280+
HalfWord_t __CircularBufferAvailable__(const HalfWord_t head_,
303281
const HalfWord_t tail_,
304282
const HalfWord_t size_) {
305283
if(head_ >= tail_) {

drivers/char/char_driver.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,23 @@
4949
HalfWord_t byteCount;
5050
Byte_t transferMode;
5151
} CharDeviceCommand_t;
52+
typedef struct CharDeviceState_s {
53+
HalfWord_t ioDriverUID;
54+
Byte_t protocol;
55+
Byte_t lineMode;
56+
Word_t baudRate;
57+
Base_t initialized;
58+
HalfWord_t rxBufferSize;
59+
HalfWord_t txBufferSize;
60+
Byte_t *rxBuffer;
61+
Byte_t *txBuffer;
62+
HalfWord_t rxHead;
63+
HalfWord_t rxTail;
64+
HalfWord_t txHead;
65+
HalfWord_t txTail;
66+
HalfWord_t currentByteCount;
67+
Byte_t currentTransferMode;
68+
} CharDeviceState_t;
5269
typedef struct CharDeviceInfo_s {
5370
Byte_t command;
5471
Byte_t protocol;
@@ -69,6 +86,11 @@
6986
Return_t TO_FUNCTION(DEVICE_NAME, _write)(Device_t *device_, Size_t *size_, Addr_t *data_);
7087
Return_t TO_FUNCTION(DEVICE_NAME, _simple_read)(Device_t *device_, Byte_t *data_);
7188
Return_t TO_FUNCTION(DEVICE_NAME, _simple_write)(Device_t *device_, Byte_t data_);
89+
Return_t __PrepareCharIORequest__(const Byte_t operation_, CharIORequest_t **request_, Size_t *configSize_);
90+
Return_t __CharDeviceReadRAW__(Byte_t **data_, Size_t *bytesRead_);
91+
Return_t __CharDeviceWriteRAW__(const Byte_t *data_);
92+
HalfWord_t __CircularBufferSpace__(const HalfWord_t head_, const HalfWord_t tail_, const HalfWord_t size_);
93+
HalfWord_t __CircularBufferAvailable__(const HalfWord_t head_, const HalfWord_t tail_, const HalfWord_t size_);
7294
#if defined(POSIX_ARCH_OTHER)
7395
void __CharDeviceStateClear__(void);
7496
#endif

drivers/ramdisk/ramdisk_driver.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@
22
static Byte_t ramdisk[RAMDISK_SIZE_BYTES] = {
33
0x0u
44
};
5-
typedef struct RAMDiskState_s {
6-
Word_t currentPosition;
7-
Word_t bytesRead;
8-
Word_t bytesWritten;
9-
Word_t readOperations;
10-
Word_t writeOperations;
11-
Base_t initialized;
12-
} RAMDiskState_t;
135
static RAMDiskState_t state = {
146
0x0u
157
};
@@ -27,7 +19,6 @@ static RAMDiskState_t state = {
2719
} while (0x0u)
2820
#define __ValidateBufferParams__(size_, data_) \
2921
(__PointerIsNotNull__(size_) && __PointerIsNotNull__(data_) && (0x0u < *(size_)))
30-
static Return_t __ValidateAndTruncateSize__(Size_t requested_, Size_t *actual_);
3122
Return_t TO_FUNCTION(DEVICE_NAME, _self_register)(void) {
3223
FUNCTION_ENTER;
3324
if(OK(__RegisterDevice__(DEVICE_UID,
@@ -189,7 +180,7 @@ Return_t TO_FUNCTION(DEVICE_NAME, _simple_write)(Device_t *device_, Byte_t data_
189180
}
190181
FUNCTION_EXIT;
191182
}
192-
static Return_t __ValidateAndTruncateSize__(Size_t requested_, Size_t *actual_) {
183+
Return_t __ValidateAndTruncateSize__(Size_t requested_, Size_t *actual_) {
193184
FUNCTION_ENTER;
194185
if((state.currentPosition + requested_) > RAMDISK_SIZE_BYTES) {
195186
*actual_ = RAMDISK_SIZE_BYTES - state.currentPosition;

drivers/ramdisk/ramdisk_driver.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@
4343
Word_t readOperations;
4444
Word_t writeOperations;
4545
} RAMDiskStats_t;
46+
typedef struct RAMDiskState_s {
47+
Word_t currentPosition;
48+
Word_t bytesRead;
49+
Word_t bytesWritten;
50+
Word_t readOperations;
51+
Word_t writeOperations;
52+
Base_t initialized;
53+
} RAMDiskState_t;
4654
#ifdef __cplusplus
4755
extern "C" {
4856
#endif
@@ -53,6 +61,7 @@
5361
Return_t TO_FUNCTION(DEVICE_NAME, _write)(Device_t *device_, Size_t *size_, Addr_t *data_);
5462
Return_t TO_FUNCTION(DEVICE_NAME, _simple_read)(Device_t *device_, Byte_t *data_);
5563
Return_t TO_FUNCTION(DEVICE_NAME, _simple_write)(Device_t *device_, Byte_t data_);
64+
Return_t __ValidateAndTruncateSize__(Size_t requested_, Size_t *actual_);
5665
#if defined(POSIX_ARCH_OTHER)
5766
void __RAMDiskStateClear__(void);
5867
#endif

drivers/usart_stm32/usart_stm32_driver.c

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,9 @@
22
#if !defined(POSIX_ARCH_OTHER)
33
#include <unistd.h>
44
#endif
5-
typedef struct USARTDriverState_s {
6-
#if !defined(POSIX_ARCH_OTHER)
7-
UART_HandleTypeDef huart;
8-
#else
9-
void *huart;
10-
#endif
11-
Byte_t rxBuffer[USART_RX_BUFFER_SIZE];
12-
Byte_t txBuffer[USART_TX_BUFFER_SIZE];
13-
volatile HalfWord_t rxHead;
14-
volatile HalfWord_t rxTail;
15-
volatile HalfWord_t txHead;
16-
volatile HalfWord_t txTail;
17-
volatile Base_t txBusy;
18-
volatile Base_t rxBusy;
19-
volatile Byte_t errorFlags;
20-
CharIORequest_t currentRequest;
21-
Base_t initialized;
22-
Byte_t rxSingleByte;
23-
} USARTDriverState_t;
245
static USARTDriverState_t state = {
256
0x0u
267
};
27-
static HalfWord_t __CircularBufferSpace__(const HalfWord_t head_, const HalfWord_t tail_, const HalfWord_t size_);
28-
static HalfWord_t __CircularBufferAvailable__(const HalfWord_t head_, const HalfWord_t tail_, const HalfWord_t size_);
29-
static void __CircularBufferPut__(Byte_t *buffer_, HalfWord_t *head_, const HalfWord_t size_, const Byte_t data_);
30-
static Byte_t __CircularBufferGet__(const Byte_t *buffer_, HalfWord_t *tail_, const HalfWord_t size_);
31-
#if !defined(POSIX_ARCH_OTHER)
32-
static Return_t __TranslateHALToParity__(const Byte_t parity_, Word_t *halParity_);
33-
static Return_t __TranslateHALToStopBits__(const Byte_t stopBits_, Word_t *halStopBits_);
34-
static Return_t __TranslateHALToWordLength__(const Byte_t dataBits_, Word_t *halWordLength_);
35-
#endif
368
Return_t TO_FUNCTION(DEVICE_NAME, _self_register)(void) {
379
FUNCTION_ENTER;
3810
if(OK(__RegisterDevice__(DEVICE_UID,
@@ -352,7 +324,7 @@ void USART_TX_IRQHandler(void) {
352324
}
353325
}
354326
#endif
355-
static HalfWord_t __CircularBufferSpace__(const HalfWord_t head_,
327+
HalfWord_t __CircularBufferSpace__(const HalfWord_t head_,
356328
const HalfWord_t tail_,
357329
const HalfWord_t size_) {
358330
if(head_ >= tail_) {
@@ -361,7 +333,7 @@ static HalfWord_t __CircularBufferSpace__(const HalfWord_t head_,
361333
return (tail_ - head_ - USART_SINGLE_BYTE_TRANSFER);
362334
}
363335
}
364-
static HalfWord_t __CircularBufferAvailable__(const HalfWord_t head_,
336+
HalfWord_t __CircularBufferAvailable__(const HalfWord_t head_,
365337
const HalfWord_t tail_,
366338
const HalfWord_t size_) {
367339
if(head_ >= tail_) {
@@ -370,22 +342,22 @@ static HalfWord_t __CircularBufferAvailable__(const HalfWord_t head_,
370342
return (size_ - (tail_ - head_));
371343
}
372344
}
373-
static void __CircularBufferPut__(Byte_t *buffer_,
345+
void __CircularBufferPut__(Byte_t *buffer_,
374346
HalfWord_t *head_,
375347
const HalfWord_t size_,
376348
const Byte_t data_) {
377349
buffer_[*head_] = data_;
378350
*head_ = (*head_ + USART_SINGLE_BYTE_TRANSFER) % size_;
379351
}
380-
static Byte_t __CircularBufferGet__(const Byte_t *buffer_,
352+
Byte_t __CircularBufferGet__(const Byte_t *buffer_,
381353
HalfWord_t *tail_,
382354
const HalfWord_t size_) {
383355
Byte_t data = buffer_[*tail_];
384356
*tail_ = (*tail_ + USART_SINGLE_BYTE_TRANSFER) % size_;
385357
return(data);
386358
}
387359
#if !defined(POSIX_ARCH_OTHER)
388-
static Return_t __TranslateHALToParity__(const Byte_t parity_, Word_t *halParity_) {
360+
Return_t __TranslateHALToParity__(const Byte_t parity_, Word_t *halParity_) {
389361
FUNCTION_ENTER;
390362
switch(parity_) {
391363
case CHAR_IO_PARITY_NONE:
@@ -403,7 +375,7 @@ static Byte_t __CircularBufferGet__(const Byte_t *buffer_,
403375
__ReturnOk__();
404376
FUNCTION_EXIT;
405377
}
406-
static Return_t __TranslateHALToStopBits__(const Byte_t stopBits_, Word_t *halStopBits_) {
378+
Return_t __TranslateHALToStopBits__(const Byte_t stopBits_, Word_t *halStopBits_) {
407379
FUNCTION_ENTER;
408380
switch(stopBits_) {
409381
case CHAR_IO_STOP_BITS_1:
@@ -418,7 +390,7 @@ static Byte_t __CircularBufferGet__(const Byte_t *buffer_,
418390
__ReturnOk__();
419391
FUNCTION_EXIT;
420392
}
421-
static Return_t __TranslateHALToWordLength__(const Byte_t dataBits_, Word_t *halWordLength_) {
393+
Return_t __TranslateHALToWordLength__(const Byte_t dataBits_, Word_t *halWordLength_) {
422394
FUNCTION_ENTER;
423395
switch(dataBits_) {
424396
case CHAR_IO_DATA_BITS_8:

drivers/usart_stm32/usart_stm32_driver.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,25 @@
6969
Byte_t parity;
7070
Byte_t stopBits;
7171
} USARTSTMInitConfig_t;
72+
typedef struct USARTDriverState_s {
73+
#if !defined(POSIX_ARCH_OTHER)
74+
UART_HandleTypeDef huart;
75+
#else
76+
void *huart;
77+
#endif
78+
Byte_t rxBuffer[USART_RX_BUFFER_SIZE];
79+
Byte_t txBuffer[USART_TX_BUFFER_SIZE];
80+
volatile HalfWord_t rxHead;
81+
volatile HalfWord_t rxTail;
82+
volatile HalfWord_t txHead;
83+
volatile HalfWord_t txTail;
84+
volatile Base_t txBusy;
85+
volatile Base_t rxBusy;
86+
volatile Byte_t errorFlags;
87+
CharIORequest_t currentRequest;
88+
Base_t initialized;
89+
Byte_t rxSingleByte;
90+
} USARTDriverState_t;
7291
#ifdef __cplusplus
7392
extern "C" {
7493
#endif
@@ -80,6 +99,15 @@
8099
Return_t TO_FUNCTION(DEVICE_NAME, _simple_read)(Device_t *device_, Byte_t *data_);
81100
Return_t TO_FUNCTION(DEVICE_NAME, _simple_write)(Device_t *device_, Byte_t data_);
82101
void USART_TX_IRQHandler(void);
102+
HalfWord_t __CircularBufferSpace__(const HalfWord_t head_, const HalfWord_t tail_, const HalfWord_t size_);
103+
HalfWord_t __CircularBufferAvailable__(const HalfWord_t head_, const HalfWord_t tail_, const HalfWord_t size_);
104+
void __CircularBufferPut__(Byte_t *buffer_, HalfWord_t *head_, const HalfWord_t size_, const Byte_t data_);
105+
Byte_t __CircularBufferGet__(const Byte_t *buffer_, HalfWord_t *tail_, const HalfWord_t size_);
106+
#if !defined(POSIX_ARCH_OTHER)
107+
Return_t __TranslateHALToParity__(const Byte_t parity_, Word_t *halParity_);
108+
Return_t __TranslateHALToStopBits__(const Byte_t stopBits_, Word_t *halStopBits_);
109+
Return_t __TranslateHALToWordLength__(const Byte_t dataBits_, Word_t *halWordLength_);
110+
#endif
83111
#if defined(POSIX_ARCH_OTHER)
84112
void __USARTSTMStateClear__(void);
85113
#endif

0 commit comments

Comments
 (0)