2010-10-21 16:03:42 +03:00
|
|
|
/*
|
|
|
|
* f32x/c2.c - Basic C2 messages
|
|
|
|
*
|
|
|
|
* Written 2010 by Werner Almesberger
|
|
|
|
* Copyright 2010 Werner Almesberger
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "c2.h"
|
|
|
|
#include "c2-drv.h"
|
|
|
|
|
|
|
|
|
|
|
|
static struct c2_ops *c2_ops;
|
|
|
|
|
|
|
|
|
|
|
|
/* ----- C2 Register read/write -------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
void c2_addr_write(uint8_t addr)
|
|
|
|
{
|
|
|
|
c2_ops->addr_write(addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t c2_addr_read(void)
|
|
|
|
{
|
|
|
|
return c2_ops->addr_read();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void c2_data_write(uint32_t data, int bytes)
|
|
|
|
{
|
|
|
|
c2_ops->data_write(data, bytes);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t c2_data_read(int bytes)
|
|
|
|
{
|
|
|
|
return c2_ops->data_read(bytes);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----- C2 initialization ------------------------------------------------- */
|
|
|
|
|
|
|
|
|
2010-10-22 20:09:35 +03:00
|
|
|
void c2_init(int power)
|
2010-10-21 16:03:42 +03:00
|
|
|
{
|
|
|
|
extern struct c2_ops DRIVER;
|
|
|
|
|
|
|
|
c2_ops = &DRIVER;
|
|
|
|
if (c2_ops->init)
|
2010-10-22 20:09:35 +03:00
|
|
|
c2_ops->init(power);
|
2010-10-21 16:03:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void c2_reset(void)
|
|
|
|
{
|
|
|
|
c2_ops->reset();
|
|
|
|
}
|