Sony's LANC camera control protocol project.

Dependencies:   aconno_LANC aconno_bsp aconno_SEGGER_RTT

Committer:
jurica238814
Date:
Thu Jul 12 16:51:44 2018 +0000
Revision:
11:e5f11b96088e
Parent:
9:978106d4b181
Segger RTT added. Charac. extended on 2B.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jurica238814 9:978106d4b181 1 /*
jurica238814 9:978106d4b181 2 * Made by Jurica Resetar @ aconno
jurica238814 9:978106d4b181 3 * jurica_resetar@yahoo.com
jurica238814 9:978106d4b181 4 * More info @ aconno.de
jurica238814 9:978106d4b181 5 *
jurica238814 9:978106d4b181 6 * All rights reserved
jurica238814 9:978106d4b181 7 *
jurica238814 9:978106d4b181 8 */
jurica238814 9:978106d4b181 9
jurica238814 9:978106d4b181 10 #include "mbed.h"
jurica238814 9:978106d4b181 11 #include "aconno_i2s.h"
jurica238814 9:978106d4b181 12
jurica238814 9:978106d4b181 13 aconno_i2s::aconno_i2s(){
jurica238814 9:978106d4b181 14 // Constructor
jurica238814 9:978106d4b181 15 }
jurica238814 9:978106d4b181 16
jurica238814 9:978106d4b181 17 void aconno_i2s::init(uint8_t dataOutPin, uint8_t LrckPin, uint8_t SckPin, uint16_t bufferSize_B, uint8_t *dataPointer){
jurica238814 9:978106d4b181 18 NRF_I2S->CONFIG.RXEN = 0; // Disable reception
jurica238814 9:978106d4b181 19 NRF_I2S->CONFIG.MCKEN = 1; // Enable MCK generator
jurica238814 9:978106d4b181 20
jurica238814 9:978106d4b181 21 NRF_I2S->CONFIG.MCKFREQ = 0x10000000; // DIV 31
jurica238814 9:978106d4b181 22 NRF_I2S->CONFIG.RATIO = 0; // Ratio = 32x
jurica238814 9:978106d4b181 23
jurica238814 9:978106d4b181 24 NRF_I2S->CONFIG.SWIDTH = 0; // Sample width = 8 bit
jurica238814 9:978106d4b181 25 NRF_I2S->CONFIG.ALIGN = 0; // Alignment = Right
jurica238814 9:978106d4b181 26 NRF_I2S->CONFIG.FORMAT = 0; // Format = I2S
jurica238814 9:978106d4b181 27 NRF_I2S->CONFIG.CHANNELS = 0; // Use stereo
jurica238814 9:978106d4b181 28
jurica238814 9:978106d4b181 29 NRF_I2S->PSEL.LRCK = LrckPin; // LRCK routed to pin 26
jurica238814 9:978106d4b181 30 NRF_I2S->PSEL.SDOUT = dataOutPin; // SDOUT routed to pin 28
jurica238814 9:978106d4b181 31 NRF_I2S->PSEL.SCK = SckPin; // SCK routed to pin 30
jurica238814 9:978106d4b181 32 NRF_I2S->PSEL.MCK = 0x80000000; // MCK disconnected
jurica238814 9:978106d4b181 33 NRF_I2S->PSEL.SDIN = 0x80000000; // SDIN disconnected
jurica238814 9:978106d4b181 34
jurica238814 9:978106d4b181 35 NRF_I2S->TXD.PTR = (uint32_t)dataPointer;
jurica238814 9:978106d4b181 36 NRF_I2S->RXTXD.MAXCNT = bufferSize_B/4; // Div with 4 cuz that's number of 32 bit words
jurica238814 9:978106d4b181 37 }
jurica238814 9:978106d4b181 38
jurica238814 9:978106d4b181 39 void aconno_i2s::sendData(){
jurica238814 9:978106d4b181 40 /*
jurica238814 9:978106d4b181 41 * I2S bits go from MSB to LSB on the bus
jurica238814 9:978106d4b181 42 */
jurica238814 9:978106d4b181 43
jurica238814 9:978106d4b181 44 NRF_I2S->EVENTS_TXPTRUPD = 0;
jurica238814 9:978106d4b181 45 NRF_I2S->ENABLE = 1;
jurica238814 9:978106d4b181 46 NRF_I2S->TASKS_START = 1;
jurica238814 9:978106d4b181 47
jurica238814 9:978106d4b181 48 while(!NRF_I2S->EVENTS_TXPTRUPD); // Wait for the data to be send
jurica238814 9:978106d4b181 49 NRF_I2S->EVENTS_TXPTRUPD = 0;
jurica238814 9:978106d4b181 50 while(!NRF_I2S->EVENTS_TXPTRUPD); // Wait for the data to be send
jurica238814 9:978106d4b181 51 NRF_I2S->EVENTS_TXPTRUPD = 0;
jurica238814 9:978106d4b181 52 NRF_I2S->TASKS_STOP = 1;
jurica238814 9:978106d4b181 53 while(!NRF_I2S->EVENTS_STOPPED);
jurica238814 9:978106d4b181 54 NRF_I2S->ENABLE = 0;
jurica238814 9:978106d4b181 55 }
jurica238814 9:978106d4b181 56
jurica238814 9:978106d4b181 57