Compare commits
2 Commits
6706055229
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bee9777a4b | ||
|
|
20dade6168 |
2
basics/.gitignore
vendored
Normal file
2
basics/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.zig-cache/
|
||||
zig-out/
|
||||
@@ -4,15 +4,17 @@ pub fn build(b: *std.Build) void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "HAL-9000",
|
||||
.version = "0.1.0",
|
||||
.debug = true,
|
||||
const root_module = b.createModule(.{
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "HAL-9000",
|
||||
.root_module = root_module,
|
||||
});
|
||||
|
||||
b.installArtifact(exe);
|
||||
|
||||
const run_cmd = b.addRunArtifact(exe);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
zls = pkgs.zls;
|
||||
in {
|
||||
devShells.${system}.default = pkgs.mkShell {
|
||||
buildInputs = [ zig zls ];
|
||||
buildInputs = [ zig zls pkgs.openocd ];
|
||||
shellHook = ''
|
||||
echo "Entering Zig Master Environment"
|
||||
echo "Zig: $(zig version)"
|
||||
|
||||
@@ -20,7 +20,7 @@ pub fn build(b: *std.Build) void {
|
||||
const cmsis_path = "/home/priec/programs/CMSIS";
|
||||
|
||||
// Generic CMSIS Core (for core_cm4.h)
|
||||
tiva_module.addIncludePath(.{ .cwd_relative = cmsis_path ++ "/CMSIS/Include" });
|
||||
tiva_module.addIncludePath(.{ .cwd_relative = cmsis_path ++ "/Include" });
|
||||
// TM4C Device Specific (for TM4C123GH6PM.h)
|
||||
tiva_module.addIncludePath(.{ .cwd_relative = cmsis_path ++ "/Device/TI/TM4C/Include" });
|
||||
|
||||
|
||||
@@ -1,7 +1,31 @@
|
||||
const cmsis = @cImport({
|
||||
@cDefine("TM4C123GH6PM", "");
|
||||
@cInclude("TM4C123GH6PM.h");
|
||||
});
|
||||
|
||||
const GPIO_PORTF_CLK_EN: u32 = 0x20; // Bit 5 (Port F)
|
||||
const GPIO_PORTF_PIN1_EN: u32 = 0x02; // Bit 1
|
||||
|
||||
const LED_ON1: u32 = 0x02;
|
||||
|
||||
export fn _start() noreturn {
|
||||
while (true) {}
|
||||
cmsis.SYSCTL.*.RCGCGPIO |= GPIO_PORTF_CLK_EN;
|
||||
_ = cmsis.SYSCTL.*.RCGCGPIO;
|
||||
|
||||
cmsis.GPIOF.*.DEN |= GPIO_PORTF_PIN1_EN;
|
||||
cmsis.GPIOF.*.DIR |= GPIO_PORTF_PIN1_EN;
|
||||
|
||||
const DELAY_VALUE = 4000000;
|
||||
while (true) {
|
||||
cmsis.GPIOF.*.DATA = LED_ON1; // LED On
|
||||
Delay(DELAY_VALUE);
|
||||
cmsis.GPIOF.*.DATA = 0; // LED On
|
||||
Delay(DELAY_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
fn Delay(delay: usize) void{
|
||||
for(0..delay) |_| {
|
||||
asm volatile ("nop");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user