Browse Source

add more pins

Signed-off-by: zhaijunyuan <1045598574@qq.com>
master
zhaijunyuan 6 years ago
parent
commit
92bd84fe51
  1. 34
      lib/a3k.c
  2. 46
      lib/pins.h

34
lib/a3k.c

@ -6,18 +6,16 @@
#include "gpio.h"
#include "a3k.h"
#define RATE_PINS (6)
struct a3k_tag {
struct serial *uart;
uint32_t rst;
uint32_t rts;
uint32_t rst_rcc;
uint32_t rst_port;
uint32_t rst_pin;
uint32_t rts_rcc;
uint32_t rts_port;
uint32_t rts_pin;
uint32_t rate[RATE_PINS];
uint32_t ec;
uint32_t ns;
uint32_t es;
};
static char *put_next_byte( char *p, short val )
@ -174,6 +172,7 @@ static int packet_reset_a3k(a3k_t a3k)
gpio_set(a3k->rst);
#if 0
char packet[30];
char *p = packet+4;
short cfg = (1<<13); //noise suppressor on
@ -186,6 +185,7 @@ static int packet_reset_a3k(a3k_t a3k)
p = put_next_word( p, 0x0700 );
p = put_next_byte( p, 0 );
put_packet(a3k, packet, p, PKT_CONTROL, 1);
#endif
return (wait_a3k_ready(a3k));
}
@ -420,9 +420,19 @@ static int __attribute__((unused)) stop_a3k_codec(a3k_t interface)
int a3k_setup(a3k_t tag)
{
int i;
gpio_init(tag->rst, GPIO_OUTPUT | GPIO_FLAG_PP | GPIO_FLAG_PU);
gpio_init(tag->rts, GPIO_INPUT | GPIO_FLAG_PP | GPIO_FLAG_PU | GPIO_SPEED_FAST);
gpio_init(tag->ec, GPIO_OUTPUT);
gpio_init(tag->ns, GPIO_OUTPUT);
gpio_init(tag->es, GPIO_OUTPUT);
for (i = 0; i < RATE_PINS; ++i) {
gpio_init(tag->rate[i], GPIO_OUTPUT);
}
serial_setup(tag->uart, UART_BAUDRATE, 8, SERIAL_STOPBITS_1);
if (packet_reset_a3k(tag)) {
@ -456,11 +466,19 @@ struct a3k_tag a3k0 = {
.uart = &serial1,
.rst = PF10,
.rts = PG7,
.rate = {PB0, PC4, PC5, PC3, PC0, PC1},
.ec = PC2,
.ns = PJ15,
.es = PG12,
};
struct a3k_tag a3k1 = {
.uart = &serial2,
.rst = PI14,
.rts = PK2
.rts = PK2,
.rate = {PJ4, PJ13, PJ14, PK3, PG10, PK4},
.ec = PI15,
.ns = PJ12,
.es = PH4,
};

46
lib/pins.h

@ -23,6 +23,15 @@
#define PA14 __pin__('A', 14)
#define PA15 __pin__('A', 15)
#define PB0 __pin__('B', 0)
#define PC0 __pin__('C', 0)
#define PC1 __pin__('C', 1)
#define PC2 __pin__('C', 2)
#define PC3 __pin__('C', 3)
#define PC4 __pin__('C', 4)
#define PC5 __pin__('C', 5)
#define PF9 __pin__('F', 9)
#define PF10 __pin__('F', 10)
#define PF11 __pin__('F', 11)
@ -30,10 +39,47 @@
#define PG5 __pin__('G', 5)
#define PG6 __pin__('G', 6)
#define PG7 __pin__('G', 7)
#define PG10 __pin__('G', 10)
#define PG12 __pin__('G', 12)
#define PH0 __pin__('H', 0)
#define PH1 __pin__('H', 1)
#define PH2 __pin__('H', 2)
#define PH3 __pin__('H', 3)
#define PH4 __pin__('H', 4)
#define PH5 __pin__('H', 5)
#define PH6 __pin__('H', 6)
#define PH7 __pin__('H', 7)
#define PH8 __pin__('H', 8)
#define PH9 __pin__('H', 9)
#define PH10 __pin__('H', 10)
#define PH11 __pin__('H', 11)
#define PH12 __pin__('H', 12)
#define PH13 __pin__('H', 13)
#define PH14 __pin__('H', 14)
#define PH15 __pin__('H', 15)
#define PI12 __pin__('I', 12)
#define PI13 __pin__('I', 13)
#define PI14 __pin__('I', 14)
#define PI15 __pin__('I', 15)
#define PJ0 __pin__('J', 0)
#define PJ1 __pin__('J', 1)
#define PJ2 __pin__('J', 2)
#define PJ3 __pin__('J', 3)
#define PJ4 __pin__('J', 4)
#define PJ5 __pin__('J', 5)
#define PJ6 __pin__('J', 6)
#define PJ7 __pin__('J', 7)
#define PJ8 __pin__('J', 8)
#define PJ9 __pin__('J', 9)
#define PJ10 __pin__('J', 10)
#define PJ11 __pin__('J', 11)
#define PJ12 __pin__('J', 12)
#define PJ13 __pin__('J', 13)
#define PJ14 __pin__('J', 14)
#define PJ15 __pin__('J', 15)
#define PK0 __pin__('K', 0)
#define PK1 __pin__('K', 1)

Loading…
Cancel
Save