xmos / fwk_io

I/O Framework
Other
2 stars 11 forks source link

Add 4b-port support to I2S #30

Closed ACascarino closed 1 year ago

ACascarino commented 2 years ago

Resolves #3

ACascarino commented 2 years ago

@xmos-jmccarthy I've not finished implementing yet but can I just check you're happy with the layout and function API here?

xmos-jmccarthy commented 2 years ago

So far it looks good.

When you get to updating the drivers, I2S does something interesting. At the API level there is only 1 I2S context, rtos_i2s_t instead of a master and slave, as only the init is different. The main difference in the drivers is master/slave port setup. Adding 4b variant should be done by replacing the port calls with a single port description object. This way we could potentially add 8b 16b, etc in the future without breaking the 4b port API.

typedef enum {
    rtos_i2s_port_config_none = -1,
    rtos_i2s_port_config_master_1b,
    rtos_i2s_port_config_master_1b,
    rtos_i2s_port_config_slave_4b,
    rtos_i2s_port_config_slave_4b,
   RTOS_I2S_TOTAL_PORT_CONFIGS_CNT
} rtos_i2s_port_type_t;

typedef struct rtos_i2s_port_config_struct rtos_i2s_port_config_t;

struct rtos_i2s_port_config_struct{
    rtos_i2s_port_type_t port_typeg;
    i2s_mode_t mode;
    port_t p_dout[I2S_MAX_DATALINES];
    size_t num_out;
    port_t p_din[I2S_MAX_DATALINES];
    size_t num_in;
    port_t p_bclk;
    port_t p_lrclk;
    port_t p_mclk;
    xclock_t bclk;
}

void rtos_i2s_init(
        rtos_i2s_t *i2s_ctx,
        uint32_t io_core_mask,
        rtos_i2s_port_config_t *config);

The above would be similar for the slave.

Feel free to ask any questions when you get here.

keithm-xmos commented 1 year ago

Closing this PR as this feature was experimental.