Skip to content

Commit 193ccea

Browse files
authored
Merge pull request #17 from SummerGGift/1206
fix compile warning about 'extern inline' in driverlib/ .c .h
2 parents 54eb4d3 + 7138a80 commit 193ccea

File tree

6 files changed

+175
-180
lines changed

6 files changed

+175
-180
lines changed

firmware/Libraries/driverlib/fh_i2c.c

Lines changed: 8 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -202,25 +202,13 @@ static int I2C_SetSpeedCount(struct fh_i2c_obj *i2c_obj)
202202
return 0;
203203
}
204204

205-
inline UINT8 I2C_GetData(struct fh_i2c_obj *i2c_obj)
206-
{
207-
return GET_REG(i2c_obj->base + OFFSET_I2C_DATA_CMD) & 0xff;
208-
}
209205

210-
inline void I2C_SetDataCmd(struct fh_i2c_obj *i2c_obj, UINT32 reg)
211-
{
212-
SET_REG(i2c_obj->base + OFFSET_I2C_DATA_CMD, reg);
213-
}
214206

215-
inline void I2C_SetInterruptMask(struct fh_i2c_obj *i2c_obj, UINT32 mask)
216-
{
217-
SET_REG(i2c_obj->base + OFFSET_I2C_INTR_MASK, mask);
218-
}
219207

220-
inline UINT32 I2C_GetInterruptMask(struct fh_i2c_obj *i2c_obj)
221-
{
222-
return GET_REG(i2c_obj->base + OFFSET_I2C_INTR_MASK);
223-
}
208+
209+
210+
211+
224212

225213
UINT32 I2C_ClearAndGetInterrupts(struct fh_i2c_obj *i2c_obj)
226214
{
@@ -301,56 +289,17 @@ int I2C_HandleTxAbort(struct fh_i2c_obj *i2c_obj)
301289
return 0;
302290
}
303291

304-
inline UINT32 I2C_SetTransmitThreshold(struct fh_i2c_obj *i2c_obj, int txtl)
305-
{
306-
return SET_REG(i2c_obj->base + OFFSET_I2C_TX_TL, txtl);
307-
}
308292

309-
inline UINT32 I2C_GetReceiveFifoLevel(struct fh_i2c_obj *i2c_obj)
310-
{
311-
return GET_REG(i2c_obj->base + OFFSET_I2C_RXFLR);
312-
}
313293

314-
inline UINT32 I2C_GetTransmitFifoLevel(struct fh_i2c_obj *i2c_obj)
315-
{
316-
return GET_REG(i2c_obj->base + OFFSET_I2C_TXFLR);
317-
}
318294

319-
inline void I2C_SetSlaveAddress(struct fh_i2c_obj *i2c_obj, rt_uint16_t addr)
320-
{
321-
UINT32 reg;
322-
reg = GET_REG(i2c_obj->base + OFFSET_I2C_TAR);
323-
reg &= ~(0x3ff);
324-
reg |= addr & 0x3ff;
325-
SET_REG(i2c_obj->base + OFFSET_I2C_TAR, reg);
326-
}
327295

328-
inline int I2C_Abort(struct fh_i2c_obj *i2c_obj)
329-
{
330-
int timeout = 20000; // 20 ms
331-
UINT32 reg;
332-
reg = GET_REG(i2c_obj->base + OFFSET_I2C_ENABLE);
333-
reg |= DW_IC_ENABLE_ABORT;
334-
SET_REG(i2c_obj->base + OFFSET_I2C_ENABLE, reg);
335296

336-
while (GET_REG(i2c_obj->base + OFFSET_I2C_ENABLE) & DW_IC_ENABLE_ABORT)
337-
{
338-
if (timeout < 0)
339-
{
340-
rt_kprintf("ERROR: %s, timeout when aborting transfer\n", __func__);
341-
return -RT_ETIMEOUT;
342-
}
343-
udelay(10);
344-
timeout--;
345-
}
346297

347-
return RT_EOK;
348-
}
349298

350-
inline void I2C_Enable(struct fh_i2c_obj *i2c_obj, int enable)
351-
{
352-
SET_REG(i2c_obj->base + OFFSET_I2C_ENABLE, enable);
353-
}
299+
300+
301+
302+
354303

355304
void I2C_Init(struct fh_i2c_obj *i2c_obj)
356305
{

firmware/Libraries/driverlib/fh_mmc.c

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,7 @@
2929

3030
// *1: card off
3131
// *0: card on
32-
inline rt_uint32_t MMC_GetCardStatus(struct fh_mmc_obj *mmc_obj)
33-
{
34-
rt_uint32_t card_status = GET_REG(mmc_obj->base + OFFSET_SDC_CDETECT);
3532

36-
return card_status & 0x1;
37-
}
38-
39-
inline void MMC_StartDma(struct fh_mmc_obj *mmc_obj)
40-
{
41-
rt_uint32_t reg;
42-
43-
SET_REG(mmc_obj->base + OFFSET_SDC_DBADDR,
44-
(rt_uint32_t)mmc_obj->descriptors);
45-
reg = GET_REG(mmc_obj->base + OFFSET_SDC_BMOD);
46-
reg |= 1 << 7;
47-
SET_REG(mmc_obj->base + OFFSET_SDC_BMOD, reg);
48-
}
49-
50-
inline void MMC_StopDma(struct fh_mmc_obj *mmc_obj)
51-
{
52-
rt_uint32_t reg;
53-
54-
reg = GET_REG(mmc_obj->base + OFFSET_SDC_BMOD);
55-
reg &= ~(1 << 7);
56-
SET_REG(mmc_obj->base + OFFSET_SDC_BMOD, reg);
57-
}
5833

5934
void MMC_InitDescriptors(struct fh_mmc_obj *mmc_obj, rt_uint32_t *buf,
6035
rt_uint32_t size)
@@ -86,67 +61,7 @@ void MMC_InitDescriptors(struct fh_mmc_obj *mmc_obj, rt_uint32_t *buf,
8661
desc[desc_cnt - 1].desc3.bit.buffer_addr1 = 0;
8762
}
8863

89-
inline rt_uint32_t MMC_GetWaterlevel(struct fh_mmc_obj *mmc_obj)
90-
{
91-
return (GET_REG(mmc_obj->base + OFFSET_SDC_STATUS) >> 17) & 0x1fff;
92-
}
93-
94-
inline rt_uint32_t MMC_GetStatus(struct fh_mmc_obj *mmc_obj)
95-
{
96-
return GET_REG(mmc_obj->base + OFFSET_SDC_STATUS);
97-
}
98-
99-
inline rt_uint32_t MMC_GetRawInterrupt(struct fh_mmc_obj *mmc_obj)
100-
{
101-
return GET_REG(mmc_obj->base + OFFSET_SDC_RINTSTS);
102-
}
103-
104-
inline rt_uint32_t MMC_GetUnmaskedInterrupt(struct fh_mmc_obj *mmc_obj)
105-
{
106-
return GET_REG(mmc_obj->base + OFFSET_SDC_MINTSTS);
107-
}
10864

109-
inline rt_uint32_t MMC_ClearRawInterrupt(struct fh_mmc_obj *mmc_obj,
110-
rt_uint32_t interrupts)
111-
{
112-
return SET_REG(mmc_obj->base + OFFSET_SDC_RINTSTS, interrupts);
113-
}
114-
115-
inline rt_uint32_t MMC_GetInterruptMask(struct fh_mmc_obj *mmc_obj)
116-
{
117-
return GET_REG(mmc_obj->base + OFFSET_SDC_INTMASK);
118-
}
119-
120-
inline rt_uint32_t MMC_SetInterruptMask(struct fh_mmc_obj *mmc_obj,
121-
rt_uint32_t mask)
122-
{
123-
return SET_REG(mmc_obj->base + OFFSET_SDC_INTMASK, mask);
124-
}
125-
126-
inline void MMC_SetByteCount(struct fh_mmc_obj *mmc_obj, rt_uint32_t bytes)
127-
{
128-
SET_REG(mmc_obj->base + OFFSET_SDC_BYTCNT, bytes);
129-
}
130-
131-
inline void MMC_SetBlockSize(struct fh_mmc_obj *mmc_obj, rt_uint32_t size)
132-
{
133-
SET_REG(mmc_obj->base + OFFSET_SDC_BLKSIZ, size);
134-
}
135-
136-
inline rt_uint32_t MMC_GetResponse(struct fh_mmc_obj *mmc_obj, int resp_num)
137-
{
138-
return GET_REG(mmc_obj->base + OFFSET_SDC_RESP0 + resp_num * 4);
139-
}
140-
141-
inline rt_uint32_t MMC_IsFifoEmpty(struct fh_mmc_obj *mmc_obj)
142-
{
143-
return (GET_REG(mmc_obj->base + OFFSET_SDC_STATUS) >> 2) & 0x1;
144-
}
145-
146-
inline rt_uint32_t MMC_IsDataStateBusy(struct fh_mmc_obj *mmc_obj)
147-
{
148-
return (GET_REG(mmc_obj->base + OFFSET_SDC_STATUS) >> 10) & 0x1;
149-
}
15065

15166
int MMC_WriteData(struct fh_mmc_obj *mmc_obj, rt_uint32_t *buf,
15267
rt_uint32_t size)

firmware/Libraries/driverlib/fh_wdt.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ void WDT_Enable(struct fh_wdt_obj *wdt_obj, int enable)
3232
SET_REG(wdt_obj->base + WDOG_CONTROL_REG_OFFSET, enable);
3333
}
3434

35-
inline int WDT_IsEnable(struct fh_wdt_obj *wdt_obj)
36-
{
37-
return GET_REG(wdt_obj->base + WDOG_CONTROL_REG_OFFSET) &
38-
WDOG_CONTROL_REG_WDT_EN_MASK;
39-
}
40-
4135
void WDT_SetTopValue(struct fh_wdt_obj *wdt_obj, int top)
4236
{
4337
SET_REG(wdt_obj->base + WDOG_TIMEOUT_RANGE_REG_OFFSET, top);

firmware/Libraries/inc/fh_i2c.h

Lines changed: 72 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#define FH_I2C_H_
3030

3131
#include "fh_def.h"
32+
#include <gcc/delay.h>
3233

3334
#define OFFSET_I2C_CON (0x0000)
3435
#define OFFSET_I2C_TAR (0x0004)
@@ -184,20 +185,81 @@ struct fh_i2c_obj
184185
};
185186

186187
void I2C_Init(struct fh_i2c_obj *i2c_obj);
187-
extern inline void I2C_Enable(struct fh_i2c_obj *i2c_obj, int enable);
188-
extern inline void I2C_SetSlaveAddress(struct fh_i2c_obj *i2c_obj, rt_uint16_t addr);
189-
extern inline UINT32 I2C_GetTransmitFifoLevel(struct fh_i2c_obj *i2c_obj);
190-
extern inline UINT32 I2C_GetReceiveFifoLevel(struct fh_i2c_obj *i2c_obj);
191-
extern inline UINT32 I2C_SetTransmitThreshold(struct fh_i2c_obj *i2c_obj, int txtl);
188+
static inline void I2C_Enable(struct fh_i2c_obj *i2c_obj, int enable)
189+
{
190+
SET_REG(i2c_obj->base + OFFSET_I2C_ENABLE, enable);
191+
}
192+
193+
static inline void I2C_SetSlaveAddress(struct fh_i2c_obj *i2c_obj, rt_uint16_t addr)
194+
{
195+
UINT32 reg;
196+
reg = GET_REG(i2c_obj->base + OFFSET_I2C_TAR);
197+
reg &= ~(0x3ff);
198+
reg |= addr & 0x3ff;
199+
SET_REG(i2c_obj->base + OFFSET_I2C_TAR, reg);
200+
}
201+
202+
static inline UINT32 I2C_GetTransmitFifoLevel(struct fh_i2c_obj *i2c_obj)
203+
{
204+
return GET_REG(i2c_obj->base + OFFSET_I2C_TXFLR);
205+
}
206+
207+
static inline UINT32 I2C_GetReceiveFifoLevel(struct fh_i2c_obj *i2c_obj)
208+
{
209+
return GET_REG(i2c_obj->base + OFFSET_I2C_RXFLR);
210+
}
211+
212+
static inline UINT32 I2C_SetTransmitThreshold(struct fh_i2c_obj *i2c_obj, int txtl)
213+
{
214+
return SET_REG(i2c_obj->base + OFFSET_I2C_TX_TL, txtl);
215+
}
216+
192217
int I2C_HandleTxAbort(struct fh_i2c_obj *i2c_obj);
193218
UINT32 I2C_ClearAndGetInterrupts(struct fh_i2c_obj *i2c_obj);
194-
extern inline void I2C_SetInterruptMask(struct fh_i2c_obj *i2c_obj, UINT32 mask);
195-
extern inline UINT32 I2C_GetInterruptMask(struct fh_i2c_obj *i2c_obj);
196-
extern inline void I2C_SetDataCmd(struct fh_i2c_obj *i2c_obj, UINT32 reg);
197-
extern inline UINT8 I2C_GetData(struct fh_i2c_obj *i2c_obj);
219+
static inline void I2C_SetInterruptMask(struct fh_i2c_obj *i2c_obj, UINT32 mask)
220+
{
221+
SET_REG(i2c_obj->base + OFFSET_I2C_INTR_MASK, mask);
222+
}
223+
224+
static inline UINT32 I2C_GetInterruptMask(struct fh_i2c_obj *i2c_obj)
225+
{
226+
return GET_REG(i2c_obj->base + OFFSET_I2C_INTR_MASK);
227+
}
228+
229+
static inline void I2C_SetDataCmd(struct fh_i2c_obj *i2c_obj, UINT32 reg)
230+
{
231+
SET_REG(i2c_obj->base + OFFSET_I2C_DATA_CMD, reg);
232+
}
233+
234+
static inline UINT8 I2C_GetData(struct fh_i2c_obj *i2c_obj)
235+
{
236+
return GET_REG(i2c_obj->base + OFFSET_I2C_DATA_CMD) & 0xff;
237+
}
238+
198239
int I2C_WaitMasterIdle(struct fh_i2c_obj *i2c_obj);
199240
int I2C_WaitSlaveIdle(struct fh_i2c_obj *i2c_obj);
200241
int I2C_WaitDeviceIdle(struct fh_i2c_obj *i2c_obj);
201-
extern inline int I2C_Abort(struct fh_i2c_obj *i2c_obj);
242+
static inline int I2C_Abort(struct fh_i2c_obj *i2c_obj)
243+
{
244+
int timeout = 20000; // 20 ms
245+
UINT32 reg;
246+
reg = GET_REG(i2c_obj->base + OFFSET_I2C_ENABLE);
247+
reg |= DW_IC_ENABLE_ABORT;
248+
SET_REG(i2c_obj->base + OFFSET_I2C_ENABLE, reg);
249+
250+
while (GET_REG(i2c_obj->base + OFFSET_I2C_ENABLE) & DW_IC_ENABLE_ABORT)
251+
{
252+
if (timeout < 0)
253+
{
254+
rt_kprintf("ERROR: %s, timeout when aborting transfer\n", __func__);
255+
return -RT_ETIMEOUT;
256+
}
257+
udelay(10);
258+
timeout--;
259+
}
260+
261+
return RT_EOK;
262+
}
263+
202264

203265
#endif /* FH_I2C_H_ */

0 commit comments

Comments
 (0)