Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offer my new and modified usr/app modifications and enhancements. #159

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
03e2b81
Modifications to build environment files to achieve successful build …
ab1aw Feb 7, 2019
25d9f28
Trying to resolve the memory fault - see https://github.com/f9micro/f…
ab1aw Feb 18, 2019
542f618
Revert the modifications for the failed attempt to build and run usin…
ab1aw Feb 18, 2019
2caf08a
Add repeating printf() to ping-pong test to show activity.
ab1aw Feb 18, 2019
ccdb8d9
User app to blink LEDs on the STM32F407 Discovery board. Code taken f…
ab1aw Feb 19, 2019
739cfe1
Modified ping-pong usr app to send incrementing message counter from …
ab1aw Feb 21, 2019
bf8951b
Disable gpioer usr app. Enable ping pong usr app.
ab1aw Feb 21, 2019
5a163fe
Add debug statements to understand logic flow and debug LED functiona…
ab1aw Feb 21, 2019
3b911e5
L4 User Manual
ab1aw Feb 21, 2019
1fbd795
L4 Programming Introduction slideware from The University of New Sout…
ab1aw Feb 21, 2019
e42f337
Experimenting with user app examples demonstrating IPC among three (3…
ab1aw Feb 24, 2019
c185431
Move initiation (trigger) of thread IPC sequencing from ping thread t…
ab1aw Feb 24, 2019
714439f
Converting to using thread info structure and moving to generic threa…
ab1aw Feb 24, 2019
8011d5b
Create a user app demonstration of a mechanism to work around the mis…
ab1aw Feb 25, 2019
dfe5fec
Modifications to pingpong user app to successfully flash the GPIO LEDs.
ab1aw Feb 25, 2019
aec66b1
More interesting sequencing of the GPIO LEDs.
ab1aw Feb 25, 2019
5cd9cd1
Modified the usr/app/gpioer/main.c to properly compile and execute wi…
ab1aw Feb 26, 2019
205d913
More interesting LED blinking sequence for usr/app/gpioer.
ab1aw Feb 26, 2019
4023e62
Attempting to understand why the following line does not execute prop…
ab1aw Feb 26, 2019
68f4b99
Resolved problem w/ user button detection. Problem was due to button …
ab1aw Feb 26, 2019
01b22b9
More diddling with the button thread and LED sequencing.
ab1aw Feb 26, 2019
08ba6c8
Issue #157 - Demonstration of possible implementation to resolve this…
ab1aw Feb 26, 2019
17aee1e
First cut at adding I2C support for platform STM32F407G-DISC1. Copied…
ab1aw Feb 28, 2019
d68a2ea
Re-implementation of user/apps/generic_thread to use the thread funct…
ab1aw Mar 4, 2019
3eb4c6d
Use L4_Receive_Timeout() instead of L4_Receive() to demonstrate the I…
ab1aw Mar 4, 2019
8483e17
Cannot call L4_MsgStore(tag, &msg) or L4_MsgWord(&msg, 0) in the even…
ab1aw Mar 4, 2019
8f3676e
NOTE: Includes enhancements and modifications.
ab1aw Mar 7, 2019
754dc82
Add commentary to identify LED colors relative to LED pins.
Jun 6, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Documentation/L4-programming-intro.pdf
Binary file not shown.
Binary file added Documentation/l4uman-n1.pdf
Binary file not shown.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ communications) for ARM Cortex-M series microprocessors with efficiency
(performance + power consumption) and security (memory protection + isolated
execution) in mind.

Includes enhancements and modifications from master branch.


Characteristics of F9 Microkernel
=================================
Expand Down
3 changes: 2 additions & 1 deletion mk/rules/symmap.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ cmd_elf_to_symmap = $(NM) $< | sort | cut -d' ' -f1,3 | \
{ \
SYM = SYM "{ (void*) (0x"$$1"), "STRCOUNT" },\n"; \
STRCOUNT += length($$2) + 1;\
STRNAME = STRNAME "\"" $$2 "\\0" "\"" "\n"; \
MPOLIA = substr($$2, 1, length($$2)-1); \
STRNAME = STRNAME "\"" MPOLIA "\\0" "\"" "\n"; \
COUNT++; \
} \
END { \
Expand Down
3 changes: 2 additions & 1 deletion platform/stm32f4/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

chip-y =
chip-y = \
i2c.o \

loader-chip-y = \
gpio.loader.o \
Expand Down
181 changes: 181 additions & 0 deletions platform/stm32f4/i2c.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
#include <platform/stm32f429/i2c.h>
#include <platform/stm32f429/rcc.h>

/* I2C register mask */
#define CR1_CLEAR_MASK ((uint16_t)0xFBF5)
/* Flag mask */
#define FLAG_MASK ((uint32_t)0x00FFFFFF)

void __USER_TEXT i2c_reset(uint32_t i2cx)
{
/* TODO: assertion */

if (i2cx == I2C1_BASE) {
RCC_APB1PeriphResetCmd(RCC_APB1RSTR_I2C1RST, 1);
RCC_APB1PeriphResetCmd(RCC_APB1RSTR_I2C1RST, 0);
} else if (i2cx == I2C2_BASE) {
RCC_APB1PeriphResetCmd(RCC_APB1RSTR_I2C2RST, 1);
RCC_APB1PeriphResetCmd(RCC_APB1RSTR_I2C2RST, 0);
} else if (i2cx == I2C3_BASE) {
RCC_APB1PeriphResetCmd(RCC_APB1RSTR_I2C2RST, 1);
RCC_APB1PeriphResetCmd(RCC_APB1RSTR_I2C2RST, 0);
}
}

void __USER_TEXT i2c_config(uint32_t i2cx, struct i2c_cfg* cfg)
{
uint16_t tmpreg = 0, freqrange = 0;
uint16_t result = 0x04;
uint32_t pclk1 = 8000000;
struct rcc_clocks clocks;
/* TODO: assertion */

tmpreg = *I2C_CR2(i2cx);
tmpreg &= (uint16_t)~((uint16_t)I2C_CR2_FREQ_ALL);

RCC_GetClocksFreq(&clocks);
pclk1 = clocks.pclk1_freq;

freqrange = (uint16_t)(pclk1 / 1000000);
tmpreg |= freqrange;

*I2C_CR2(i2cx) = tmpreg;

*I2C_CR1(i2cx) &= (uint16_t)~((uint16_t)I2C_CR1_PE);
tmpreg = 0;

if (cfg->clock_speed <= 100000) {
result = (uint16_t)(pclk1 / (cfg->clock_speed << 1));

if (result < 0x04)
result = 0x04;

tmpreg |= result;
*I2C_TRISE(i2cx) = freqrange + 1;
} else {
if (cfg->duty_cycle == I2C_DutyCycle_2) {
result = (uint16_t)(pclk1 / (cfg->clock_speed * 3));
} else {
result = (uint16_t)(pclk1 / (cfg->clock_speed * 25));
result |= I2C_DutyCycle_16_9;
}

if ((I2C_CCR_CCR(result)) == 0)
result |= (uint16_t)0x0001;

tmpreg |= (uint16_t)(result | I2C_CCR_FS);
*I2C_TRISE(i2cx) = (uint16_t)(((freqrange * (uint16_t)300) / (uint16_t)1000) + (uint16_t)1);
}
*I2C_CCR(i2cx) = tmpreg;
*I2C_CR1(i2cx) |= I2C_CR1_PE;

tmpreg = *I2C_CR1(i2cx);
tmpreg &= CR1_CLEAR_MASK;

tmpreg |= (uint16_t)((uint32_t)cfg->mode | cfg->ack);
*I2C_CR1(i2cx) = tmpreg;

*I2C_OAR1(i2cx) = (cfg->acknowledged_address | cfg->own_address);
}

void __USER_TEXT i2c_cmd(uint32_t i2cx, uint8_t enable)
{
/* TODO: assertion */

if (enable != 0)
*I2C_CR1(i2cx) |= I2C_CR1_PE;
else
*I2C_CR1(i2cx) &= (uint16_t)~((uint16_t)I2C_CR1_PE);
}

void __USER_TEXT i2c_generate_start(uint32_t i2cx, uint8_t enable)
{
/* TODO: assertion */

if (enable != 0)
*I2C_CR1(i2cx) |= I2C_CR1_START;
else
*I2C_CR1(i2cx) &= (uint16_t)~((uint16_t)I2C_CR1_START);
}

uint8_t __USER_TEXT i2c_get_flag(uint32_t i2cx, uint32_t flag)
{
uint8_t bitstatus = 0;
volatile uint32_t i2creg = 0, i2cxbase = 0;

/* TODO: assertion */

i2cxbase = (uint32_t)i2cx;
i2creg = flag >> 28;

flag &= FLAG_MASK;

if (i2creg != 0) {
i2cxbase += 0x14;
} else {
flag = (uint32_t)(flag >> 16);
i2cxbase += 0x18;
}

if (((*(volatile uint32_t *)i2cxbase) & flag) != (uint32_t)0)
bitstatus = 1;
else
bitstatus = 0;

return bitstatus;
}

void __USER_TEXT i2c_acknowledge_config(uint32_t i2cx, uint8_t enable)
{
/* TODO: assertion */
if (enable != 0)
*I2C_CR1(i2cx) |= I2C_CR1_ACK;
else
*I2C_CR1(i2cx) &= (uint16_t)~((uint16_t)I2C_CR1_ACK);
}

void __USER_TEXT i2c_send_7bit_address(uint32_t i2cx, uint8_t address, uint8_t direction)
{
/* TODO: assertion */

if (direction != I2C_Direction_Transmitter)
address |= I2C_OAR1_ADD(0);
else
address &= (uint8_t)~((uint8_t)I2C_OAR1_ADD(0));

*I2C_DR(i2cx) = address;
}

void __USER_TEXT i2c_generate_stop(uint32_t i2cx, uint8_t enable)
{
/* TODO: assertion */

if (enable != 0)
*I2C_CR1(i2cx) |= I2C_CR1_STOP;
else
*I2C_CR1(i2cx) &= (uint16_t)~((uint16_t)I2C_CR1_STOP);
}

void __USER_TEXT i2c_software_reset_cmd(uint32_t i2cx, uint8_t enable)
{
/* TODO: assertion */

if (enable != 0)
*I2C_CR1(i2cx) |= I2C_CR1_SWRST;
else
*I2C_CR1(i2cx) &= (uint16_t)~((uint16_t)I2C_CR1_SWRST);
}

void __USER_TEXT i2c_send(uint32_t i2cx, uint8_t data)
{
/* TODO: assertion */

*I2C_DR(i2cx) = data;
}

uint8_t __USER_TEXT i2c_receive(uint32_t i2cx)
{
/* TODO: assertion */

return (uint8_t)(*I2C_DR(i2cx));
}
6 changes: 6 additions & 0 deletions user/apps/3ping/build.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (c) 2013 The F9 Microkernel Project. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

user-apps-3ping-y = \
main.o
Loading