Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: a0291ceddc19
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0e7557c98e4e
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Sep 22, 2016

  1. phaser: spi tweaks

    jordens committed Sep 22, 2016
    Copy the full SHA
    028a783 View commit details
  2. Copy the full SHA
    0e7557c View commit details
Showing with 896 additions and 12 deletions.
  1. +8 −6 artiq/runtime/ad9154.c
  2. +881 −0 artiq/runtime/ad9154_reg.h
  3. +7 −6 artiq/runtime/ad9516.c
14 changes: 8 additions & 6 deletions artiq/runtime/ad9154.c
Original file line number Diff line number Diff line change
@@ -5,34 +5,35 @@

#include "artiq_personality.h"
#include "ad9154.h"
#include "ad9154_reg.h"

#ifdef CONFIG_AD9154_DAC_CS

void ad9154_spi_config(void)
{
ad9154_spi_offline_write(0);
ad9154_spi_offline_write(1);
ad9154_spi_cs_polarity_write(0);
ad9154_spi_clk_polarity_write(0);
ad9154_spi_clk_phase_write(0);
ad9154_spi_lsb_first_write(0);
ad9154_spi_half_duplex_write(0);
ad9154_spi_clk_div_write_write(7); /* FIXME: test 1 */
ad9154_spi_clk_div_read_write(7);
ad9154_spi_clk_div_write_write(11);
ad9154_spi_clk_div_read_write(11);
ad9154_spi_cs_write(CONFIG_AD9154_DAC_CS);
ad9154_spi_xfer_len_write_write(24);
ad9154_spi_xfer_len_read_write(0);
ad9154_spi_offline_write(0);
}

#define AD9154_READ (1 << 15)
#define AD9154_XFER(w) ((w) << 13)

static uint8_t ad9154_xfer(uint16_t addr, uint8_t data)
static void ad9154_xfer(uint16_t addr, uint8_t data)
{
ad9154_spi_data_write_write(
((AD9154_XFER(0) | addr) << 16) | (data << 8));
while (ad9154_spi_pending_read());
while (ad9154_spi_active_read());
return ad9154_spi_data_read_read() & 0xff;
}

void ad9154_write(uint16_t addr, uint8_t data)
@@ -42,7 +43,8 @@ void ad9154_write(uint16_t addr, uint8_t data)

uint8_t ad9154_read(uint16_t addr)
{
return ad9154_xfer(AD9154_READ | addr, 0);
ad9154_xfer(AD9154_READ | addr, 0);
return ad9154_spi_data_read_read() & 0xff;
}

#endif
Loading