Skip to content

Commit

Permalink
Merge pull request #31 from ucb-bar/fix-default
Browse files Browse the repository at this point in the history
FIX: Fix default code behavior
  • Loading branch information
hongyihuang authored Dec 31, 2023
2 parents 7c27293 + aa0f652 commit 7511555
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
8 changes: 4 additions & 4 deletions core/inc/hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ extern "C" {
/**
* System Clock Configuration
*/
#define HXTAL_FREQ 20000000 // Hz
// #define HXTAL_FREQ 100000000 // Hz
#define SYS_CLK_FREQ HXTAL_FREQ / 2 // Hz
#define MTIME_FREQ (SYS_CLK_FREQ / 100000) // tick per milliseconds
#define HXTAL_FREQ 50000000 /** crystal or external clock frequency in Hz */
#define SYS_CLK_FREQ HXTAL_FREQ /** system clock frequency in Hz */
#define MTIME_TIMEBASE 50000 /** tick per milliseconds */
#define MTIME_FREQ (SYS_CLK_FREQ / MTIME_TIMEBASE)

#ifdef __cplusplus
}
Expand Down
11 changes: 4 additions & 7 deletions core/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,6 @@ int main(int argc, char **argv) {
/* Initialize all configured peripherals */
/* USER CODE BEGIN 2 */

// set up GPIO registers
GPIO_InitTypeDef GPIO_init_config;
GPIO_init_config.mode = GPIO_MODE_OUTPUT;
GPIO_init_config.pull = GPIO_PULL_NONE;
GPIO_init_config.drive_strength = GPIO_DS_STRONG;
HAL_GPIO_init(GPIOA, &GPIO_init_config, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);

// set up UART registers
UART_InitTypeDef UART_init_config;
UART_init_config.baudrate = 115200;
Expand All @@ -96,8 +89,12 @@ int main(int argc, char **argv) {
/* USER CODE BEGIN WHILE */
while (1) {
uint64_t mhartid = READ_CSR("mhartid");

printf("Hello world from hart %d: %d\n", mhartid, counter);

counter += 1;

HAL_delay(100);
/* USER CODE END WHILE */
}
/* USER CODE BEGIN 3 */
Expand Down

0 comments on commit 7511555

Please sign in to comment.