forked from yashwanthsinghm/BH1750_PCF8574_lcd_stm32f411
-
Notifications
You must be signed in to change notification settings - Fork 0
/
memory.x
38 lines (23 loc) · 1.69 KB
/
memory.x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
MEMORY
{
/* NOTE K = KiBi = 1024 bytes */
FLASH : ORIGIN = 0x08000000, LENGTH = 128K
RAM : ORIGIN = 0x20000000, LENGTH = 32K
}
/* This is where the call stack will be allocated. */
/* The stack is of the full descending type. */
/* NOTE Do NOT modify `_stack_start` unless you know what you are doing */
_stack_start = ORIGIN(RAM) + LENGTH(RAM);
About this code:
This is a Rust code for STM32F4xx microcontroller to read light intensity from BH1750 sensor using I2C and print it on USART2.
It uses the cortex_m_rt and stm32f4xx_hal crates. The code is written in Rust programming language. It initializes the I2C and USART2 peripherals,
sets up the BH1750 sensor, reads the light intensity from the sensor, and prints it on USART2. The code is written in a loop so that it keeps reading
and printing the light intensity continuously.
Code Explaination:
#![no_std] and #![no_main] are attributes used in Rust to indicate that no standard library (no_std) and no standard entry point (no_main) are used.
This is common in embedded systems programming where the standard library might not be available or appropriate, and the entry point
is provided by the hardware-specific environment.
core::fmt::{Write, write}: Importing traits related to text formatting and writing.
cortex_m_rt::entry: This attribute marks the entry point of the program. It's used for setting up the initial function that will be executed when the microcontroller starts.
panic_halt as _: This is a panic handler that halts the program in case of a panic.
stm32f4xx_hal: This is a hardware abstraction layer (HAL) for the STM32F4 microcontroller series. It provides a high-level API to interact with the microcontroller peripherals.