Skip to content
Snippets Groups Projects
Commit 215aa909 authored by Leon Bohnwagner's avatar Leon Bohnwagner :crab:
Browse files

fix: add send byte control bits

parent 4812f98d
No related branches found
No related tags found
No related merge requests found
...@@ -76,13 +76,20 @@ static enum hrtimer_restart timer_callback(struct hrtimer *timer) { ...@@ -76,13 +76,20 @@ static enum hrtimer_restart timer_callback(struct hrtimer *timer) {
return HRTIMER_RESTART; return HRTIMER_RESTART;
} }
static void send_bit(uint8_t bit) {
gpio_set_value(GPIO_PIN, bit);
udelay(1);
}
static void send_byte(uint8_t byte) { static void send_byte(uint8_t byte) {
send_bit(0);
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
int bit = (byte >> (7 - i)) & 1; int bit = (byte >> (7 - i)) & 1;
send_bit(bit);
gpio_set_value(GPIO_PIN, bit);
udelay(1);
} }
send_bit(1);
} }
static void send_data(const void *data, size_t length) { static void send_data(const void *data, size_t length) {
...@@ -170,7 +177,7 @@ static int __init lkm_init(void) ...@@ -170,7 +177,7 @@ static int __init lkm_init(void)
printk(KERN_ALERT "Failed to request GPIO pin\n"); printk(KERN_ALERT "Failed to request GPIO pin\n");
return -1; return -1;
} }
gpio_direction_output(GPIO_PIN, 0); gpio_direction_output(GPIO_PIN, 1);
timed_thread = kthread_run(timed_thread_fn, NULL, "timed_thread"); timed_thread = kthread_run(timed_thread_fn, NULL, "timed_thread");
if (IS_ERR(timed_thread)) { if (IS_ERR(timed_thread)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment