Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NuttX RTOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
f4grx
NuttX RTOS
Commits
eed14e5e
Commit
eed14e5e
authored
7 years ago
by
Gregory Nutt
Browse files
Options
Downloads
Patches
Plain Diff
arch/arm/src/lpc43xx: Add I2C stop logic.
parent
c50b4f55
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arch/arm/src/lpc54xx/lpc54_i2c_master.c
+35
-7
35 additions, 7 deletions
arch/arm/src/lpc54xx/lpc54_i2c_master.c
arch/arm/src/lpc54xx/lpc54_spi_master.c
+26
-2
26 additions, 2 deletions
arch/arm/src/lpc54xx/lpc54_spi_master.c
with
61 additions
and
9 deletions
arch/arm/src/lpc54xx/lpc54_i2c_master.c
+
35
−
7
View file @
eed14e5e
...
...
@@ -166,7 +166,7 @@ static struct lpc54_i2cdev_s g_i2c9_dev;
* Name: lpc54_i2c_putreg
*
* Description:
*
Set the frequency for the next transfer
*
Write a value to a register at the offset from the Flexcomm base.
*
****************************************************************************/
...
...
@@ -177,19 +177,46 @@ static inline void lpc54_i2c_putreg(struct lpc54_i2cdev_s *priv,
}
/****************************************************************************
* Name: lpc54_i2c_get
t
reg
* Name: lpc54_i2c_getreg
*
* Description:
*
Set the frequency for the next transfer
*
Read the content of a register at the offset from the Flexcomm base.
*
****************************************************************************/
static
inline
void
lpc54_i2c_get
t
reg
(
struct
lpc54_i2cdev_s
*
priv
,
unsigned
int
regoffset
)
static
inline
void
lpc54_i2c_getreg
(
struct
lpc54_i2cdev_s
*
priv
,
unsigned
int
regoffset
)
{
return
getreg32
(
priv
->
base
+
regoffset
);
}
/****************************************************************************
* Name: lpc54_wait_pendingstatus
*
* Description:
* Wait for status update to complete and clear the I2C state.
*
****************************************************************************/
static
uint32_t
lpc54_wait_pendingstatus
(
struct
lpc54_i2cdev_s
*
priv
)
{
uint32_t
regval
;
/* Wait until status is no longer pending */
do
{
regval
=
lpc54_i2c_getreg
(
priv
,
LPC54_I2C_STAT_OFFSET
);
}
while
((
regval
&
I2C_INT_MSTPENDING
)
==
0
);
/* Clear controller state and return the last status */
lpc43_i2c_putreg
(
priv
,
LPC54_I2C_STAT_OFFSET
,
(
I2C_STAT_MSTARBLOSS_MASK
|
I2C_STAT_MSTSTSTPERR_MASK
));
return
regval
;
}
/****************************************************************************
* Name: lpc54_i2c_setfrequency
*
...
...
@@ -263,7 +290,7 @@ static void lpc54_i2c_setfrequency(struct lpc54_i2cdev_s *priv,
regval
=
I2C_CLKDIV
(
best_div
);
lpc54_i2c_putreg
(
priv
,
LPC54_I2C_CLKDIV_OFFSET
,
regval
);
regval
=
I2C_MSTTIME_SCLLOW
(
n
)
|
I2C_MSTTIME_SCLHIGH
(
n
);
regval
=
I2C_MSTTIME_SCLLOW
(
best_scl
)
|
I2C_MSTTIME_SCLHIGH
(
best_scl
);
lpc54_i2c_putreg
(
LPC54_I2C_MSTTIME_OFFSET
,
regval
);
priv
->
frequency
=
frequency
;
...
...
@@ -312,7 +339,8 @@ static int lpc54_i2c_start(struct lpc54_i2cdev_s *priv)
static
void
lpc54_i2c_stop
(
struct
lpc54_i2cdev_s
*
priv
)
{
#warning Missing logic
(
void
)
lpc54_wait_pendingstatus
(
priv
);
lpc54_i2c_putreg
(
pric
,
LPC54_I2C_MSTCTL_OFFSET
,
I2C_MSTCTL_MSTSTOP
);
nxsem_post
(
&
priv
->
waitsem
);
}
...
...
This diff is collapsed.
Click to expand it.
arch/arm/src/lpc54xx/lpc54_spi_master.c
+
26
−
2
View file @
eed14e5e
...
...
@@ -182,13 +182,37 @@ static struct lpc54_spidev_s g_spi9_dev;
#endif
/****************************************************************************
* P
ublic Data
* P
rivate Functions
****************************************************************************/
/****************************************************************************
* Private Functions
* Name: lpc54_spi_putreg
*
* Description:
* Write a value to a register at the offset from the Flexcomm base.
*
****************************************************************************/
static
inline
void
lpc54_spi_putreg
(
struct
lpc54_spidev_s
*
priv
,
unsigned
int
regoffset
,
uint32_t
regval
)
{
putreg32
(
value
,
priv
->
base
+
regoffset
);
}
/****************************************************************************
* Name: lpc54_spi_gettreg
*
* Description:
* Read the content of a register at the offset from the Flexcomm base.
*
****************************************************************************/
static
inline
void
lpc54_spi_gettreg
(
struct
lpc54_spidev_s
*
priv
,
unsigned
int
regoffset
)
{
return
getreg32
(
priv
->
base
+
regoffset
);
}
/****************************************************************************
* Name: lpc54_spi_16bitmode
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment