Add test
This commit is contained in:
parent
d9fc1f2062
commit
4336994571
3 changed files with 45 additions and 0 deletions
BIN
tests/test-upstream.out
Executable file
BIN
tests/test-upstream.out
Executable file
Binary file not shown.
31
tests/test.c
Normal file
31
tests/test.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
#define GPIO_BASE (0x48000000U) // Base address for GPIO port (e.g., GPIOA on STM32)
|
||||
#define RCC_BASE (0x40021000U) // Base address for RCC (Reset and Clock Control)
|
||||
|
||||
#define RCC_AHB2ENR (*(volatile unsigned int *)(RCC_BASE + 0x4C))
|
||||
#define GPIOA_MODER (*(volatile unsigned int *)(GPIO_BASE + 0x00))
|
||||
#define GPIOA_ODR (*(volatile unsigned int *)(GPIO_BASE + 0x14))
|
||||
|
||||
#define LED_PIN 5 // Assume the LED is connected to GPIO pin 5
|
||||
|
||||
void delay(volatile unsigned int count) {
|
||||
while (count--);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
// Enable the clock for GPIOA
|
||||
RCC_AHB2ENR |= (1 << 0); // Enable GPIOA clock
|
||||
|
||||
// Set GPIOA pin 5 to output mode (01)
|
||||
GPIOA_MODER &= ~(3 << (LED_PIN * 2)); // Clear mode bits for pin 5
|
||||
GPIOA_MODER |= (1 << (LED_PIN * 2)); // Set mode to 01 (output)
|
||||
|
||||
while (1) {
|
||||
// Toggle the LED
|
||||
GPIOA_ODR ^= (1 << LED_PIN);
|
||||
|
||||
// Delay
|
||||
delay(100000);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue