11const std = @import ("std" );
22const microzig = @import ("microzig" );
33
4- const RCC = microzig .chip .peripherals .RCC ;
54const stm32 = microzig .hal ;
5+ const rcc = stm32 .rcc ;
66const gpio = stm32 .gpio ;
77
88const drivers = microzig .drivers ;
@@ -16,9 +16,6 @@ const timer = stm32.timer.GPTimer.init(.TIM2).into_counter_mode();
1616const I2c = stm32 .i2c ;
1717const I2C_Device = stm32 .drivers .I2C_Device ;
1818
19- const uart = stm32 .uart .UART .init (.USART1 );
20- const TX = gpio .Pin .from_port (.A , 9 );
21-
2219const i2c = I2c .I2C .init (.I2C2 );
2320const SCL = gpio .Pin .from_port (.B , 10 );
2421const SDA = gpio .Pin .from_port (.B , 11 );
@@ -28,10 +25,6 @@ const config = I2c.Config{
2825 .mode = .standard ,
2926};
3027
31- pub const microzig_options = microzig.Options {
32- .logFn = stm32 .uart .log ,
33- };
34-
3528var global_counter : stm32.drivers.CounterDevice = undefined ;
3629
3730const i2c_device = I2C_Device .init (i2c , I2c .Address .new (0x27 ), config , null , null );
@@ -40,19 +33,11 @@ pub fn delay_us(time_delay: u32) void {
4033 global_counter .sleep_us (time_delay );
4134}
4235pub fn main () ! void {
43- RCC .APB2ENR .modify (.{
44- .GPIOBEN = 1 ,
45- .GPIOAEN = 1 ,
46- .AFIOEN = 1 ,
47- .USART1EN = 1 ,
48- });
49-
50- RCC .APB1ENR .modify (.{
51- .I2C2EN = 1 ,
52- .TIM2EN = 1 ,
53- });
54-
55- TX .set_output_mode (.alternate_function_push_pull , .max_50MHz );
36+ rcc .enable_clock (.GPIOB );
37+ rcc .enable_clock (.GPIOC );
38+ rcc .enable_clock (.USART1 );
39+ rcc .enable_clock (.I2C2 );
40+ rcc .enable_clock (.TIM2 );
5641
5742 //Set internal Pull-ups (not recommended for real applications)
5843 SCL .set_input_mode (.pull );
@@ -69,12 +54,6 @@ pub fn main() !void {
6954
7055 i2c .apply (config );
7156
72- uart .apply (.{
73- .baud_rate = 115200 ,
74- .clock_speed = 8_000_000 ,
75- });
76-
77- stm32 .uart .init_logger (& uart );
7857 var expander = PCF8574 (.{}).init (i2c_device .datagram_device ());
7958 const pins_config = lcd (.{}).pins_struct {
8059 .high_pins = .{
0 commit comments