Anonymous user
Create an object at a given address: Difference between revisions
m
→{{header|C}}
m (omit swift) |
m (→{{header|C}}) |
||
Line 154:
A more typical embedded way of doing this is below. Note that the OS will probably not allow this due to memory protections. Embedded systems often do not have memory managers.
<lang c>#include <stdint.h>
#include <stddef.h>
// This is a port variable located at address 0x100
#define PORT_A (*(volatile uint32_t*)0x100)
{
uint32_t dat;
size_t addr;
PORT_A ^= 0x01; // Toggle bit 0 of PORT_A
Line 167 ⟶ 169:
addr = &PORT_A; // addr = 0x100
}</lang>
|