@@ -146,11 +146,11 @@ static void flowControlUpdate(void) {
146146 // ISR
147147 if (rx_num_elements < RX_BUFFER_ALMOST_FULL) {
148148 // Space for more data, assert RTS line (active low)
149- RTS_PORT. OUTCLR |= RTS_PIN_bm;
149+ VPORTC. OUT &= (~ RTS_PIN_bm) ;
150150 } else {
151151 // Buffer is filling up, tell the target to stop sending data
152152 // for now by de-asserting RTS
153- RTS_PORT. OUTSET |= RTS_PIN_bm;
153+ VPORTC. OUT |= RTS_PIN_bm;
154154 }
155155}
156156
@@ -168,15 +168,17 @@ ISR(PORTC_PORT_vect) {
168168 // before we enable interrupt
169169 HWSERIALAT.CTRLA |= USART_DREIE_bm;
170170 }
171+
172+ VPORTC.INTFLAGS = CTS_INT_bm;
171173 } else if (VPORTC.INTFLAGS & RING_INT_bm) {
172174 if (VPORTC.IN & RING_PIN) {
173175 if (ring_line_callback != NULL ) {
174176 ring_line_callback ();
175177 }
176178 }
177- }
178179
179- VPORTC.INTFLAGS = 0xff ;
180+ VPORTC.INTFLAGS = RING_INT_bm;
181+ }
180182}
181183
182184// RX complete
@@ -189,11 +191,11 @@ ISR(USART1_RXC_vect) {
189191 rx_buffer[rx_head_index] = data;
190192 rx_num_elements++;
191193
192- // Here we keep track of the length of the URC when it starts and compare it
193- // against the look up table of lengths of the strings we are looking for.
194- // We compare against them first in order to save some cycles in the ISR and
195- // if the lengths match, we compare the string for the URC and against the
196- // buffer. If they match, call the callback
194+ // Here we keep track of the length of the URC when it starts and
195+ // compare it against the look up table of lengths of the strings we are
196+ // looking for. We compare against them first in order to save some
197+ // cycles in the ISR and if the lengths match, we compare the string for
198+ // the URC and against the buffer. If they match, call the callback
197199 switch (urc_parse_state) {
198200
199201 case URC_NOT_PARSING:
@@ -207,8 +209,8 @@ ISR(USART1_RXC_vect) {
207209 case URC_PARSING_IDENTIFIER:
208210
209211 if (data == URC_IDENTIFIER_END_CHARACTER) {
210- // We set this as the initial condition and if we find a match for
211- // the URC we go on parsing the data
212+ // We set this as the initial condition and if we find a match
213+ // for the URC we go on parsing the data
212214 urc_parse_state = URC_NOT_PARSING;
213215
214216 for (uint8_t i = 0 ; i < MAX_URC_CALLBACKS; i++) {
@@ -224,8 +226,8 @@ ISR(USART1_RXC_vect) {
224226 urc_current_callback = urc_callbacks[i];
225227 urc_parse_state = URC_PARSING_DATA;
226228
227- // Reset the index in order to prepare the URC buffer
228- // for data
229+ // Reset the index in order to prepare the URC
230+ // buffer for data
229231 urc_data_buffer_length = 0 ;
230232 break ;
231233 }
@@ -276,9 +278,9 @@ ISR(USART1_RXC_vect) {
276278}
277279
278280/* *
279- * @brief Data register empty. Allows us to keep track of when the data has been
280- * transmitted on the line and set up new data to be transmitted from the ring
281- * buffer.
281+ * @brief Data register empty. Allows us to keep track of when the data has
282+ * been transmitted on the line and set up new data to be transmitted from
283+ * the ring buffer.
282284 */
283285ISR (USART1_DRE_vect) {
284286 if (tx_num_elements != 0 ) {
@@ -303,10 +305,10 @@ void SequansControllerClass::begin(void) {
303305
304306 // Request to send (RTS) and clear to send (CTS) are the control lines
305307 // on the UART line. From the configuration the MCU and the LTE modem is
306- // in, we control the RTS line from the MCU to signalize if we can process
307- // more data or not from the LTE modem. The CTS line is controlled from
308- // the LTE modem and gives us the ability to know whether the LTE modem
309- // can receive more data or if we have to wait.
308+ // in, we control the RTS line from the MCU to signalize if we can
309+ // process more data or not from the LTE modem. The CTS line is
310+ // controlled from the LTE modem and gives us the ability to know
311+ // whether the LTE modem can receive more data or if we have to wait.
310312 //
311313 // Both pins are active low.
312314
@@ -488,7 +490,8 @@ ResponseResult SequansControllerClass::readResponse(char *out_buffer,
488490 }
489491
490492 // For AT command responses from the LTE module, "\r\nOK\r\n" or
491- // "\r\nERROR\r\n" signifies the end of a response, so we look "\r\n".
493+ // "\r\nERROR\r\n" signifies the end of a response, so we look
494+ // "\r\n".
492495 if (out_buffer[i - 1 ] == CARRIAGE_RETURN &&
493496 out_buffer[i] == LINE_FEED) {
494497
@@ -566,11 +569,12 @@ bool SequansControllerClass::extractValueFromCommandResponse(
566569 return false ;
567570 }
568571
569- // Increment pointer to skip the data start character (and the following
570- // space in the start sequence of the data if it is there)
572+ // Increment pointer to skip the data start character (and the
573+ // following space in the start sequence of the data if it is there)
571574 while (*data == start_character || *data == SPACE_CHARACTER) { data++; }
572575 } else {
573- // If no start character is given, just set data start to string start
576+ // If no start character is given, just set data start to string
577+ // start
574578 data = response_copy;
575579 }
576580
@@ -585,9 +589,9 @@ bool SequansControllerClass::extractValueFromCommandResponse(
585589 char *start_value_ptr = data;
586590 char *end_value_ptr = strchr (data, RESPONSE_DELIMITER);
587591
588- // We did not find the delimiter at all, abort if the index we request is >
589- // 0. If it is 0, the command might only consist of one entry and not have a
590- // delimiter
592+ // We did not find the delimiter at all, abort if the index we request
593+ // is > 0. If it is 0, the command might only consist of one entry and
594+ // not have a delimiter
591595 if (end_value_ptr == NULL && index > 0 ) {
592596 return false ;
593597 }
@@ -601,8 +605,8 @@ bool SequansControllerClass::extractValueFromCommandResponse(
601605 value_index++;
602606 }
603607
604- // If we got all the way to the end, set the end_value_ptr to the end of the
605- // data ptr
608+ // If we got all the way to the end, set the end_value_ptr to the end of
609+ // the data ptr
606610 if (end_value_ptr == NULL ) {
607611 end_value_ptr = data + strlen (data);
608612 }
@@ -666,9 +670,9 @@ void SequansControllerClass::unregisterCallback(const char *urc_identifier) {
666670 (const void *)urc_lookup_table[i],
667671 urc_identifier_length) == 0 ) {
668672 // No need to fill the look up table identifier table, as we
669- // override it if a new registration is issued, but the length is
670- // used to check if the slot is active or not, so we set that to 0
671- // and reset the callback pointer for house keeping
673+ // override it if a new registration is issued, but the length
674+ // is used to check if the slot is active or not, so we set that
675+ // to 0 and reset the callback pointer for house keeping
672676 urc_lookup_table_length[i] = 0 ;
673677 urc_callbacks[i] = NULL ;
674678 break ;
@@ -696,8 +700,8 @@ void SequansControllerClass::setPowerSaveMode(const uint8_t mode,
696700
697701 // We have interrupt on change here since there is sometimes
698702 // a too small interval for the sensing to sense a rising edge.
699- // This is fine as any change will yield that we are out of power
700- // save mode.
703+ // This is fine as any change will yield that we are out of
704+ // power save mode.
701705 pinConfigure (RING_PIN, PIN_DIR_INPUT | PIN_INT_CHANGE);
702706 }
703707
0 commit comments