C8051F32x firmware infrastructure
Sign in or create your account | Project List | Help
C8051F32x firmware infrastructure Git Source Tree
Root/
| 1 | /* |
| 2 | * f32x/c2.c - Basic C2 messages |
| 3 | * |
| 4 | * Written 2010 by Werner Almesberger |
| 5 | * Copyright 2010 Werner Almesberger |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | */ |
| 12 | |
| 13 | |
| 14 | #include <stdint.h> |
| 15 | |
| 16 | #include "c2.h" |
| 17 | #include "c2-drv.h" |
| 18 | |
| 19 | |
| 20 | static struct c2_ops *c2_ops; |
| 21 | |
| 22 | |
| 23 | /* ----- C2 Register read/write -------------------------------------------- */ |
| 24 | |
| 25 | |
| 26 | void c2_addr_write(uint8_t addr) |
| 27 | { |
| 28 | c2_ops->addr_write(addr); |
| 29 | } |
| 30 | |
| 31 | |
| 32 | uint8_t c2_addr_read(void) |
| 33 | { |
| 34 | return c2_ops->addr_read(); |
| 35 | } |
| 36 | |
| 37 | |
| 38 | void c2_data_write(uint32_t data, int bytes) |
| 39 | { |
| 40 | c2_ops->data_write(data, bytes); |
| 41 | } |
| 42 | |
| 43 | |
| 44 | uint32_t c2_data_read(int bytes) |
| 45 | { |
| 46 | return c2_ops->data_read(bytes); |
| 47 | } |
| 48 | |
| 49 | |
| 50 | /* ----- C2 initialization ------------------------------------------------- */ |
| 51 | |
| 52 | |
| 53 | void c2_init(int power) |
| 54 | { |
| 55 | extern struct c2_ops DRIVER; |
| 56 | |
| 57 | c2_ops = &DRIVER; |
| 58 | if (c2_ops->init) |
| 59 | c2_ops->init(power); |
| 60 | } |
| 61 | |
| 62 | |
| 63 | void c2_reset(void) |
| 64 | { |
| 65 | c2_ops->reset(); |
| 66 | } |
| 67 |
Branches:
master
